diff --git a/README.md b/README.md index 090e1c3..1b50f10 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ use { ### list -`:Telescope repo list` +`:Telescope repo list` or `lua require'telescope'.extensions.repo.list{}` Running `repo list` and list repositories' paths. @@ -112,6 +112,28 @@ Transform the result paths into relative ones with this value as the base dir. Default value: `vim.fn.getcwd()` +#### `fd_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** + +This passes additional 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] … +``` + +##### 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). + +To avoid taking into account the `.gitignore`, we need to pass `--no-ignore-vcs` to `fd`, like so (in NeoVim): + +``` +: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. + ##### `tail_path` Show only basename of the path. diff --git a/lua/telescope/_extensions/repo_builtin.lua b/lua/telescope/_extensions/repo_builtin.lua index edabb70..c16c395 100644 --- a/lua/telescope/_extensions/repo_builtin.lua +++ b/lua/telescope/_extensions/repo_builtin.lua @@ -91,9 +91,15 @@ M.list = function(opts) -- Don’t filter only on directories with fd as git worktrees actually have a -- .git file in them. - local find_repo_opts = {'--hidden', '--case-sensitive', '--absolute-path', '--exec', 'echo', [[{//}]], ';', repo_pattern} + 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_pattern_opts = {repo_pattern} table.insert(fd_command, find_repo_opts) + table.insert(fd_command, find_user_opts) + table.insert(fd_command, find_exec_opts) + table.insert(fd_command, find_pattern_opts) fd_command = vim.tbl_flatten(fd_command) pickers.new(opts, {