docs: clarify on_attach example, quick start (#2165)
* doc: more on_attach examples * doc: human readable mappings help * doc: human readable mappings help * doc: more on_attach examples * doc: enhance quick start * doc: enhance quick start * doc: enhance quick start * doc: enhance quick start * doc: enhance quick start * doc: enhance quick start
This commit is contained in:
committed by
GitHub
parent
1f5bbc1efd
commit
74996b8626
@@ -73,7 +73,13 @@ Requirements
|
||||
|
||||
==============================================================================
|
||||
2. QUICK START *nvim-tree-quickstart*
|
||||
>
|
||||
|
||||
Install the plugins via your package manager:
|
||||
`"nvim-tree/nvim-tree.lua"`
|
||||
`"nvim-tree/nvim-web-devicons"`
|
||||
|
||||
Setup the plugin in your `init.lua` >
|
||||
|
||||
-- disable netrw at the very start of your init.lua (strongly advised)
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
@@ -98,6 +104,63 @@ Requirements
|
||||
},
|
||||
})
|
||||
<
|
||||
Open the tree: `:NvimTreeOpen`
|
||||
|
||||
Show the mappings: `g?`
|
||||
|
||||
`<C-]>` CD |nvim-tree-api.tree.change_root_to_node()|
|
||||
`<C-e>` Open: In Place |nvim-tree-api.node.open.replace_tree_buffer()|
|
||||
`<C-k>` Info |nvim-tree-api.node.show_info_popup()|
|
||||
`<C-r>` Rename: Omit Filename |nvim-tree-api.fs.rename_sub()|
|
||||
`<C-t>` Open: New Tab |nvim-tree-api.node.open.tab()|
|
||||
`<C-v>` Open: Vertical Split |nvim-tree-api.node.open.vertical()|
|
||||
`<C-x>` Open: Horizontal Split |nvim-tree-api.node.open.horizontal()|
|
||||
`<BS>` Close Directory |nvim-tree-api.node.navigate.parent_close()|
|
||||
`<CR>` Open |nvim-tree-api.node.open.edit()|
|
||||
`<Tab>` Open Preview |nvim-tree-api.node.open.preview()|
|
||||
`>` Next Sibling |nvim-tree-api.node.navigate.sibling.next()|
|
||||
`<` Previous Sibling |nvim-tree-api.node.navigate.sibling.prev()|
|
||||
`.` Run Command |nvim-tree-api.node.run.cmd()|
|
||||
`-` Up |nvim-tree-api.tree.change_root_to_parent()|
|
||||
`a` Create |nvim-tree-api.fs.create()|
|
||||
`bmv` Move Bookmarked |nvim-tree-api.marks.bulk.move()|
|
||||
`B` Toggle No Buffer |nvim-tree-api.tree.toggle_no_buffer_filter()|
|
||||
`c` Copy |nvim-tree-api.fs.copy.node()|
|
||||
`C` Toggle Git Clean |nvim-tree-api.tree.toggle_git_clean_filter()|
|
||||
`[c` Prev Git |nvim-tree-api.node.navigate.git.prev()|
|
||||
`]c` Next Git |nvim-tree-api.node.navigate.git.next()|
|
||||
`d` Delete |nvim-tree-api.fs.remove()|
|
||||
`D` Trash |nvim-tree-api.fs.trash()|
|
||||
`E` Expand All |nvim-tree-api.tree.expand_all()|
|
||||
`e` Rename: Basename |nvim-tree-api.fs.rename_basename()|
|
||||
`]e` Next Diagnostic |nvim-tree-api.node.navigate.diagnostics.next()|
|
||||
`[e` Prev Diagnostic |nvim-tree-api.node.navigate.diagnostics.prev()|
|
||||
`F` Clean Filter |nvim-tree-api.live_filter.clear()|
|
||||
`f` Filter |nvim-tree-api.live_filter.start()|
|
||||
`g?` Help |nvim-tree-api.tree.toggle_help()|
|
||||
`gy` Copy Absolute Path |nvim-tree-api.fs.copy.absolute_path()|
|
||||
`H` Toggle Dotfiles |nvim-tree-api.tree.toggle_hidden_filter()|
|
||||
`I` Toggle Git Ignore |nvim-tree-api.tree.toggle_gitignore_filter()|
|
||||
`J` Last Sibling |nvim-tree-api.node.navigate.sibling.last()|
|
||||
`K` First Sibling |nvim-tree-api.node.navigate.sibling.first()|
|
||||
`m` Toggle Bookmark |nvim-tree-api.marks.toggle()|
|
||||
`o` Open |nvim-tree-api.node.open.edit()|
|
||||
`O` Open: No Window Picker |nvim-tree-api.node.open.no_window_picker()|
|
||||
`p` Paste |nvim-tree-api.fs.paste()|
|
||||
`P` Parent Directory |nvim-tree-api.node.navigate.parent()|
|
||||
`q` Close |nvim-tree-api.tree.close()|
|
||||
`r` Rename |nvim-tree-api.fs.rename()|
|
||||
`R` Refresh |nvim-tree-api.tree.reload()|
|
||||
`s` Run System |nvim-tree-api.node.run.system()|
|
||||
`S` Search |nvim-tree-api.tree.search_node()|
|
||||
`U` Toggle Hidden |nvim-tree-api.tree.toggle_custom_filter()|
|
||||
`W` Collapse |nvim-tree-api.tree.collapse_all()|
|
||||
`x` Cut |nvim-tree-api.fs.cut()|
|
||||
`y` Copy Name |nvim-tree-api.fs.copy.filename()|
|
||||
`Y` Copy Relative Path |nvim-tree-api.fs.copy.relative_path()|
|
||||
`<2-LeftMouse>` Open |nvim-tree-api.node.open.edit()|
|
||||
`<2-RightMouse>` CD |nvim-tree-api.tree.change_root_to_node()|
|
||||
|
||||
==============================================================================
|
||||
3. COMMANDS *nvim-tree-commands*
|
||||
|
||||
@@ -1745,8 +1808,8 @@ commands.get() *nvim-tree-api.commands.get()*
|
||||
6. MAPPINGS *nvim-tree-mappings*
|
||||
|
||||
Mappings are set via the |nvim-tree.on_attach| function, which is run upon
|
||||
creating the nvim-tree buffer. Mappings may be directly to |nvim-tree-api.
|
||||
functions or your own.
|
||||
creating the nvim-tree buffer. Mappings are usually |nvim-tree-api| functions
|
||||
however may be your own.
|
||||
|
||||
When on_attach is not a function, |nvim-tree-mappings-default| will be used.
|
||||
|
||||
@@ -1763,10 +1826,22 @@ The `on_attach` function is passed the `bufnr` of nvim-tree. Use
|
||||
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
||||
end
|
||||
|
||||
-- put some default mappings here
|
||||
-- copy default mappings here from defaults in next section
|
||||
vim.keymap.set('n', '<C-]>', api.tree.change_root_to_node, opts('CD'))
|
||||
vim.keymap.set('n', '<C-e>', api.node.open.replace_tree_buffer, opts('Open: In Place'))
|
||||
---
|
||||
-- OR use all default mappings
|
||||
api.config.mappings.default_on_attach(bufnr)
|
||||
|
||||
-- user mappings
|
||||
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
|
||||
-- remove a default
|
||||
vim.keymap.del('n', '<C-]>', { buffer = bufnr })
|
||||
|
||||
-- override a default
|
||||
vim.keymap.set('n', '<C-e>', api.tree.reload, opts('Refresh'))
|
||||
|
||||
-- add your mappings
|
||||
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
|
||||
---
|
||||
end
|
||||
|
||||
require("nvim-tree").setup({
|
||||
|
||||
Reference in New Issue
Block a user