-
-
Notifications
You must be signed in to change notification settings - Fork 623
[WIP] allow passing a custom function as a window picker #1782
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
[WIP] allow passing a custom function as a window picker #1782
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! That is clean!
Please add :help and update as per https://github.com/nvim-tree/nvim-tree.lua/blob/master/CONTRIBUTING.md I'm happy to assist with the :help
Please provide an example so that I may test this out and we can add to the :help
If `M.window_picker.custom_function()` returns `nil` then `pick_win_id()` will run (the or part). We don't want that. More verbose, but better.
Thanks, will do! |
This function uses function()
local window_id
local window_list = {}
for _, win in ipairs(vim.api.nvim_list_wins()) do
if vim.api.nvim_win_get_config(win).relative == '' then
table.insert(window_list, win)
end
end
vim.ui.select(window_list, {
prompt = 'Select window:',
}, function(choice)
window_id = choice
end)
return window_id
end This one uses s1n7ax/nvim-window-picker: require('window-picker').setup()
function()
return require('window-picker').pick_window()
end |
Fantastic. I'm out of time and will review next weekend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works beautifully, and allows full control for the user i.e. ability to pick the nvim-tree window itself.
Please:
- add to :help (I'll help out with this)
- use the
s1n7ax/nvim-window-picker
example in the help
d7e5731
to
0770c9a
Compare
…nvim-tree.lua into feat/custom-window-picker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for your contribution.
Your complete example #1782 (comment) would be a fantastic addition to the wiki Recipes
Hi! According to [WIP] allow using the winbar instead of statusbar as a window picker by davidsierradz · Pull Request #1767 · nvim-tree/nvim-tree.lua, this replaces that PR.
With something like:
Let me know what you think, thanks!