Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git_files with fallback to find_files when not in git repo picker #1338

Closed
marekdedic opened this issue Oct 12, 2021 · 4 comments
Closed

git_files with fallback to find_files when not in git repo picker #1338

marekdedic opened this issue Oct 12, 2021 · 4 comments
Labels
enhancement Enhancement to performance, inner workings or existent features wontfix This will not be worked on

Comments

@marekdedic
Copy link

Is your feature request related to a problem? Please describe.
Hi, I would like to use git_files for most of my work. However, I am not always running vim inside a git repo

Describe the solution you'd like
I'd like to see a picker that behaves like git_files when I'm inside a git repo and like find_files otherwise

@marekdedic marekdedic added the enhancement Enhancement to performance, inner workings or existent features label Oct 12, 2021
@marekdedic
Copy link
Author

@fdschmidt93
Copy link
Member

fdschmidt93 commented Oct 12, 2021

I don't see what a dedicated picker would over the recipe apart from technical debt. Maybe telescope build in a fallback option into builtin.git_files but that's a kind of precedent I'd personally want to avoid.

What would a dedicated picker really offer here?

@marekdedic
Copy link
Author

Hi, honestly, the reason is just ease-of-use. When I opened the issue, I didn't know about the recipe and Googling didn't show anything either. Only later while looking at what else can telescope do I found the recipe accidentally...

@fdschmidt93
Copy link
Member

I agree that customization is something we should further try to improve. However, I'd close this for the time being for tidyness as wontfix as I'm presuming any core member would make a PR for that. Any team member would be free to reopen this though :)

You'd be welcome to make a PR to include this in builtin.git_files here:

git.files = function(opts)
local show_untracked = utils.get_default(opts.show_untracked, true)
local recurse_submodules = utils.get_default(opts.recurse_submodules, false)
if show_untracked and recurse_submodules then
error "Git does not support both --others and --recurse-submodules"
end
-- By creating the entry maker after the cwd options,
-- we ensure the maker uses the cwd options when being created.
opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
pickers.new(opts, {
prompt_title = "Git Files",
finder = finders.new_oneshot_job(
vim.tbl_flatten {
"git",
"ls-files",
"--exclude-standard",
"--cached",
show_untracked and "--others" or nil,
recurse_submodules and "--recurse-submodules" or nil,
},
opts
),
previewer = conf.file_previewer(opts),
sorter = conf.file_sorter(opts),
}):find()
end

Then we can revisit as to whether to include such a fallback. I'd be OK with as I guess it wouldn't increase the maintenance burden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to performance, inner workings or existent features wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants