-
Notifications
You must be signed in to change notification settings - Fork 150
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
proposal: git_files()
which considers cwd
#459
Comments
Tysm for your kind words @acro5piano!
This is great functionality indeed, but given this can be so easily achieved with a simple customization and also very subjective (some users might like it, some probably won't), it would require yet another configuration option to control (which we have too many already) so we can just keep it documented in this thread. If it turns out there's lots of demand to add this to the defaults (or as a new provider) we can reconsider. In the meantime allow me to offer a slight improvement to your code reusing already exisitng code within fzf-lua: -- The reason I added 'opts' as a paraameter is so you can
-- call this function with your own parameters / customizations
-- for example: 'git_files_cwd_aware({ cwd = <another git repo> })'
function M.git_files_cwd_aware(opts)
opts = opts or {}
local fzf_lua = require('fzf-lua')
-- git_root() will warn us if we're not inside a git repo
-- so we don't have to add another warning here, if
-- you want to avoid the error message change it to:
-- local git_root = fzf_lua.path.git_root(opts, true)
local git_root = fzf_lua.path.git_root(opts)
if not git_root then return end
local relative = fzf_lua.path.relative(vim.loop.cwd(), git_root)
opts.fzf_opts = { ['--query'] = git_root ~= relative and relative or nil }
return fzf_lua.git_files(opts)
end |
Thank you for sharing your thoughts and improved code! Yes the functionality can be here to keep the library maintainable. I'll use the improved code. |
@acro5piano Awesome idea! Thanks for your sharing! and thanks @ibhagwan for helping with the simplification and future-proof comments! Let me put a link to this thread on the Wiki. update: Done. Link to the page. (btw, I forgot to add the change summary...) |
I just realized that this Would it be better to change the update: OK, I just realized that what i need is simply |
Ty @nyngwang for updating the wiki :) |
Hi, thank you for the great library. Your work changed my Neovim life.
Description
I love the feature
git_files()
. My proposal is to consider current working directory. This is especially useful for those who are working on a large monorepo project.I've wrote code something like this and it's working - If it's useful to other people I'm happy to create a PR for this. so my question is that it's okay to create a PR?
Best regards,
Kay
The text was updated successfully, but these errors were encountered: