Skip to content

Commit aac6dc5

Browse files
committed
Add fd_opts option to list command
By passing various options, it is possible to accommodate a wider variety of needs and configurations. An example is given in the corresponding documentation in the README.
1 parent 894400f commit aac6dc5

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ use {
9595

9696
### list
9797

98-
`:Telescope repo list`
98+
`:Telescope repo list` or `lua require'telescope'.extensions.repo.list{}`
9999

100100
Running `repo list` and list repositories' paths.
101101

@@ -126,6 +126,28 @@ Transform the result paths into relative ones with this value as the base dir.
126126

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

129+
#### `fd_opts`
130+
131+
**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**
132+
133+
This passes additional options to the command `fd` that generates the repository list. It is inserted like so:
134+
135+
```
136+
fd [set of default options] [fd_opts] --exec [some default command] [pattern] …
137+
```
138+
139+
##### Example
140+
141+
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).
142+
143+
To avoid taking into account the `.gitignore`, we need to pass `--no-ignore-vcs` to `fd`, like so (in NeoVim):
144+
145+
```
146+
:lua require'telescope'.extensions.repo.list{fd_opts={'--no-ignore-vcs'}}
147+
```
148+
149+
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.
150+
129151
##### `tail_path`
130152

131153
Show only basename of the path.

lua/telescope/_extensions/repo_builtin.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ M.list = function(opts)
9191

9292
-- Don’t filter only on directories with fd as git worktrees actually have a
9393
-- .git file in them.
94-
local find_repo_opts = {'--hidden', '--case-sensitive', '--absolute-path', '--exec', 'echo', [[{//}]], ';', repo_pattern}
94+
local find_repo_opts = {'--hidden', '--case-sensitive', '--absolute-path'}
95+
local find_user_opts = opts.fd_opts or {}
96+
local find_exec_opts = {'--exec', 'echo', [[{//}]], ';'}
97+
local find_pattern_opts = {repo_pattern}
9598

9699
table.insert(fd_command, find_repo_opts)
100+
table.insert(fd_command, find_user_opts)
101+
table.insert(fd_command, find_exec_opts)
102+
table.insert(fd_command, find_pattern_opts)
97103
fd_command = vim.tbl_flatten(fd_command)
98104

99105
pickers.new(opts, {

0 commit comments

Comments
 (0)