mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 17:28:39 +02:00
plugins/nvim-tree: fix onAttach option (#364)
This commit is contained in:
parent
8a8efebda2
commit
c1a46a8360
1 changed files with 18 additions and 10 deletions
|
@ -356,21 +356,29 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
onAttach = helpers.defaultNullOpts.mkStr "disable" ''
|
onAttach =
|
||||||
Function ran when creating the nvim-tree buffer.
|
helpers.defaultNullOpts.mkNullable
|
||||||
This can be used to attach keybindings to the tree buffer.
|
(with types; either (enum ["default"]) helpers.rawType)
|
||||||
When onAttach is "disabled", it will use the older mapping strategy, otherwise it
|
"default"
|
||||||
will use the newer one.
|
''
|
||||||
Type: `function(bufnr)`, Default: `"disable"`
|
Function ran when creating the nvim-tree buffer.
|
||||||
e.g. >
|
This can be used to attach keybindings to the tree buffer.
|
||||||
local api = require("nvim-tree.api")
|
When onAttach is "default", it will use the older mapping strategy, otherwise it
|
||||||
local function on_attach(bufnr)
|
will use the newer one.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
{
|
||||||
|
__raw = \'\'
|
||||||
|
function(bufnr)
|
||||||
|
local api = require("nvim-tree.api")
|
||||||
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" ''
|
||||||
This can be used to remove the default mappings in the tree.
|
This can be used to remove the default mappings in the tree.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue