feat(picker): allow custom function actions.open_file.window_picker.picker (#1782)

* feat: allow passing a custom function as a window picker

WIP

* fix: move logic expression to if statement

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.

* feat(open): add window_picker.picker

* feat(open): add window_picker.picker

* style nit

* feat(open): add window_picker.picker

* docs: add window_picker.picker documentation

* docs: add window_picker.picker documentation

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
David Sierra DiazGranados
2022-12-15 23:14:33 -05:00
committed by GitHub
parent 18272f8df3
commit d85b6718ce
3 changed files with 18 additions and 1 deletions

View File

@@ -348,6 +348,7 @@ Subsequent calls to setup will replace the previous configuration.
resize_window = true,
window_picker = {
enable = true,
picker = "default",
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
@@ -999,6 +1000,16 @@ Configuration for various actions.
from which you last opened the tree.
Type: `boolean`, Default: `true`
*nvim-tree.actions.open_file.window_picker.picker*
Change the default window picker, can be a string `"default"` or a function.
The function should return the window id that will open the node,
or `nil` if an invalid window is picked or user cancelled the action.
Type: `string` | `function`, Default: `"default"`
e.g. s1n7ax/nvim-window-picker plugin: >
window_picker = {
enable = true,
picker = require('window-picker').pick_window,
<
*nvim-tree.actions.open_file.window_picker.chars*
A string of chars used as identifiers by the window picker.
Type: `string`, Default: `"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"`