plugins/nvim-tree: fix onAttach option (#364)

This commit is contained in:
Gaétan Lepage 2023-05-14 11:44:06 +02:00 committed by GitHub
parent 8a8efebda2
commit c1a46a8360
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -356,20 +356,28 @@ in {
''; '';
}; };
onAttach = helpers.defaultNullOpts.mkStr "disable" '' onAttach =
helpers.defaultNullOpts.mkNullable
(with types; either (enum ["default"]) helpers.rawType)
"default"
''
Function ran when creating the nvim-tree buffer. Function ran when creating the nvim-tree buffer.
This can be used to attach keybindings to the tree buffer. This can be used to attach keybindings to the tree buffer.
When onAttach is "disabled", it will use the older mapping strategy, otherwise it When onAttach is "default", it will use the older mapping strategy, otherwise it
will use the newer one. will use the newer one.
Type: `function(bufnr)`, Default: `"disable"`
e.g. > Example:
{
__raw = \'\'
function(bufnr)
local api = require("nvim-tree.api") local api = require("nvim-tree.api")
local function on_attach(bufnr)
vim.keymap.set("n", "<C-P>", function() vim.keymap.set("n", "<C-P>", function()
local node = api.tree.get_node_under_cursor() local node = api.tree.get_node_under_cursor()
print(node.absolute_path) print(node.absolute_path)
end, { buffer = bufnr, noremap = true, silent = true, nowait = true, desc = "print the node's absolute path" }) end, { buffer = bufnr, noremap = true, silent = true, nowait = true, desc = "print the node's absolute path" })
end end
\'\';
}
''; '';
removeKeymaps = helpers.defaultNullOpts.mkNullable (types.either types.bool (types.listOf types.str)) "false" '' removeKeymaps = helpers.defaultNullOpts.mkNullable (types.either types.bool (types.listOf types.str)) "false" ''