Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alex-courtis/984e5b97cc2148778f5353305b911308 to your computer and use it in GitHub Desktop.
Save alex-courtis/984e5b97cc2148778f5353305b911308 to your computer and use it in GitHub Desktop.
nvim-tree: reactively retrieve mappings
local api = require "nvim-tree.api"
local Event = api.events.Event
api.events.subscribe(Event.TreeAttachedPost, function(bufnr)
print(string.format("TreeAttachedPost bufnr=%s", vim.inspect(bufnr)))
local buf_keymaps = vim.api.nvim_buf_get_keymap(bufnr, "")
for i = 1, 4, 1 do
print(vim.inspect(buf_keymaps[i]))
end
end)
-- output
TreeAttachedPost 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