File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -1494,6 +1494,23 @@ api.config.mappings.default() *nvim-tree.api.config.mappings.default()*
14941494 Return: ~
14951495 (table) as per | nvim-tree.view.mappings.list |
14961496
1497+ *nvim-tree.api.config.mappings.get_keymap()*
1498+ api.config.mappings.get_keymap()
1499+ Retrieves all buffer local mappings for nvim-tree.
1500+ These are the mappings that are applied by | nvim-tree.on_attach | , which
1501+ may include default mappings.
1502+
1503+ Return: ~
1504+ (table) as per | nvim_buf_get_keymap() |
1505+
1506+ *nvim-tree.api.config.mappings.get_keymap()*
1507+ api.config.mappings.get_keymap_default()
1508+ Retrieves the buffer local mappings for nvim-tree that are applied by
1509+ | nvim-tree.api.config.mappings.default_on_attach() |
1510+
1511+ Return: ~
1512+ (table) as per | nvim_buf_get_keymap() |
1513+
14971514==============================================================================
14981515 6. MAPPINGS *nvim-tree-mappings*
14991516
Original file line number Diff line number Diff line change @@ -182,4 +182,11 @@ Api.config.mappings.default = function()
182182 return require (" nvim-tree.keymap-legacy" ).default_mappings_clone ()
183183end
184184
185+ Api .config .mappings .get_keymap = function ()
186+ return require (" nvim-tree.keymap" ).get_keymap ()
187+ end
188+ Api .config .mappings .get_keymap_default = function ()
189+ return require (" nvim-tree.keymap" ).get_keymap_default ()
190+ end
191+
185192return Api
Original file line number Diff line number Diff line change 11local M = {}
22
3+ --- Apply mappings to a scratch buffer and return buffer local mappings
4+ --- @param fn function (bufnr ) on_attach or default_on_attach
5+ --- @return table as per vim.api.nvim_buf_get_keymap
6+ local function generate_keymap (fn )
7+ -- create an unlisted scratch buffer
8+ local scratch_bufnr = vim .api .nvim_create_buf (false , true )
9+
10+ -- apply mappings
11+ fn (scratch_bufnr )
12+
13+ -- retrieve all
14+ local keymap = vim .api .nvim_buf_get_keymap (scratch_bufnr , " " )
15+
16+ -- delete the scratch buffer
17+ vim .api .nvim_buf_delete (scratch_bufnr , { force = true })
18+
19+ return keymap
20+ end
21+
322-- stylua: ignore start
423function M .default_on_attach (bufnr )
524 local api = require (' nvim-tree.api' )
@@ -65,6 +84,14 @@ function M.default_on_attach(bufnr)
6584end
6685-- stylua: ignore end
6786
87+ function M .get_keymap ()
88+ return generate_keymap (M .on_attach )
89+ end
90+
91+ function M .get_keymap_default ()
92+ return generate_keymap (M .default_on_attach )
93+ end
94+
6895function M .setup (opts )
6996 if type (opts .on_attach ) ~= " function" then
7097 M .on_attach = M .default_on_attach
You can’t perform that action at this time.
0 commit comments