docs: reformat quickstart readme example (#2258)
This commit is contained in:
parent
63061404f4
commit
f5d970d450
36
README.md
36
README.md
@ -79,27 +79,27 @@ require("nvim-tree").setup({
|
|||||||
Optionally customise your mappings, see [:help nvim-tree-mappings](doc/nvim-tree-lua.txt)
|
Optionally customise your mappings, see [:help nvim-tree-mappings](doc/nvim-tree-lua.txt)
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local function my_on_attach(bufnr)
|
local function my_on_attach(bufnr)
|
||||||
local api = require "nvim-tree.api"
|
local api = require "nvim-tree.api"
|
||||||
|
|
||||||
local function opts(desc)
|
local function opts(desc)
|
||||||
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
||||||
end
|
|
||||||
|
|
||||||
-- default mappings
|
|
||||||
api.config.mappings.default_on_attach(bufnr)
|
|
||||||
|
|
||||||
-- custom mappings
|
|
||||||
vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts('Up'))
|
|
||||||
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- pass to setup along with your other options
|
-- default mappings
|
||||||
require("nvim-tree").setup {
|
api.config.mappings.default_on_attach(bufnr)
|
||||||
---
|
|
||||||
on_attach = my_on_attach,
|
-- custom mappings
|
||||||
---
|
vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts('Up'))
|
||||||
}
|
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- pass to setup along with your other options
|
||||||
|
require("nvim-tree").setup {
|
||||||
|
---
|
||||||
|
on_attach = my_on_attach,
|
||||||
|
---
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Open the tree: `:NvimTreeOpen`
|
Open the tree: `:NvimTreeOpen`
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user