Created
March 13, 2023 04:04
-
-
Save alex-courtis/de9f5cdda08129e3da9127817d7ffe28 to your computer and use it in GitHub Desktop.
nvim-tree: proactively retrieve mappings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim.keymap.set("n", "gb", function() | |
local api = require "nvim-tree.api" | |
local scratch_bufnr = vim.api.nvim_create_buf(true, true) | |
print("scratch_bufnr " .. scratch_bufnr) | |
-- substitute with user's on_attach as needed | |
api.config.mappings.default_on_attach(scratch_bufnr) | |
local keymaps = vim.api.nvim_buf_get_keymap(scratch_bufnr, "") | |
for i = 1, 4, 1 do | |
print(vim.inspect(keymaps[i])) | |
end | |
vim.api.nvim_buf_delete(scratch_bufnr, {}) | |
end, opts) | |
-- output | |
scratch_bufnr 2 | |
{ | |
buffer = 2, | |
callback = <function 1>, | |
desc = "nvim-tree: Open Preview", | |
expr = 0, | |
lhs = "<Tab>", | |
lhsraw = "\t", | |
lnum = 0, | |
mode = "n", | |
noremap = 1, | |
nowait = 1, | |
script = 0, | |
sid = -8, | |
silent = 1 | |
} | |
{ | |
buffer = 2, | |
callback = <function 1>, | |
desc = "nvim-tree: Open", | |
expr = 0, | |
lhs = "<CR>", | |
lhsraw = "\r", | |
lnum = 0, | |
mode = "n", | |
noremap = 1, | |
nowait = 1, | |
script = 0, | |
sid = -8, | |
silent = 1 | |
} | |
{ | |
buffer = 2, | |
callback = <function 1>, | |
desc = "nvim-tree: Up", | |
expr = 0, | |
lhs = "-", | |
lhsraw = "-", | |
lnum = 0, | |
mode = "n", | |
noremap = 1, | |
nowait = 1, | |
script = 0, | |
sid = -8, | |
silent = 1 | |
} | |
{ | |
buffer = 2, | |
callback = <function 1>, | |
desc = "nvim-tree: Run Command", | |
expr = 0, | |
lhs = ".", | |
lhsraw = ".", | |
lnum = 0, | |
mode = "n", | |
noremap = 1, | |
nowait = 1, | |
script = 0, | |
sid = -8, | |
silent = 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment