Skip to content

Commit

Permalink
Add an option to easily support PowerShell
Browse files Browse the repository at this point in the history
Co-authored-by: Clément Joly <7347374+cljoly@users.noreply.github.com>
  • Loading branch information
hinogi and cljoly committed Dec 18, 2022
1 parent 2b4ad95 commit f0e50ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,17 @@ Transform the result paths into relative ones with this value as the base dir.

Default value: `vim.fn.getcwd()`

##### `fd_opts`
##### `fd_opts` & `find_exec_opts`

**This is a relatively advanced option that you should use with caution. There is no guarantee that a particular set of options would work the same across multiple versions**
**These are relatively advanced options that you should use with caution. There is no guarantee that a particular set of options would work the same across multiple versions of the plugin**

This passes additional options to the command `fd` that generates the repository list. It is inserted like so:
This passes additional exec options to the command `fd` that generates the repository list. It is inserted like so:

```
fd [set of default options] [fd_opts] --exec [some default command] [pattern] …
fd [set of default options] [fd_opts] --exec [find_exec_opts] [pattern] …
```

##### Example
###### `fd_opts` Example

Let’s say you have a git repository `S` inside another git repository `M` (for instance because of [#5](https://github.com/cljoly/telescope-repo.nvim/issues/5)), but `S` is in a directory that’s ignored in the `.gitignore` in `M`. `S` wouldn’t appear in the Telescope list of this extension by default, because it is ignored (`.gitignore` are taken into account by default).

Expand All @@ -207,7 +207,23 @@ To avoid taking into account the `.gitignore`, we need to pass `--no-ignore-vcs`
:lua require'telescope'.extensions.repo.list{fd_opts={'--no-ignore-vcs'}}
```

This will list `M` and `S` in the Telescope output! The downside is that listing repositories will be a little longer, as we don’t skip the git-ignored files anymore.
This will list `M` and `S` in the Telescope output. The downside is that listing repositories will be a little longer, as we don’t skip the git-ignored files anymore.

###### `fd_exec_opts` Example

This is mainly to accommodate different OS shells like PowerShell on windows.

Let’s say you try to use telescope repo in windows powershell, then the command could be something like this to make it work

```
fd --exec powershell /C "echo {//}" ; ^\.git$
```

To use an equivalent command with the plugin, run:

```
:lua require'telescope'.extensions.repo.list{fd_exec_opts={'powershell /C "echo {//}"'}}
```

##### `search_dirs`

Expand Down Expand Up @@ -294,7 +310,7 @@ if you encounter any problems. If it’s not the case by default, you should aut

Options are the similar to `repo list`, bearing in mind that we use `locate` instead of `fd`. Note that the following `list` options are not supported in `cached_list`:

* `fd_opts`, as we don’t use `fd` with `cached_list`,
* `fd_opts` and `fd_exec_opts`, as we don’t use `fd` with `cached_list`,
* `search_dirs`, as `locate` does not accept a directory to search in.

#### Examples
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/_extensions/repo/list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ M.prepare_command = function(opts)
-- .git file in them.
local find_repo_opts = { "--hidden", "--case-sensitive", "--absolute-path" }
local find_user_opts = opts.fd_opts or {}
local find_exec_opts = { "--exec", "echo", [[{//}]], ";" }
local find_exec_opts = opts.fd_exec_opts or { "--exec", "echo", [[{//}]], ";" }

-- Expand '~'
local search_dirs = {}
Expand Down

0 comments on commit f0e50ad

Please sign in to comment.