summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2023-04-18 08:39:40 +0200
committerache <ache@ache.one>2023-04-18 08:40:46 +0200
commit7dcb70467ad973df5d4a1273eaf6115fb53b1349 (patch)
treebee3dfca78cf3cee884398d17f7dbed26a38aa18
parentDisable Vimspector (diff)
Update nvim tree keymap format
-rw-r--r--plugin/init.lua33
1 files changed, 26 insertions, 7 deletions
diff --git a/plugin/init.lua b/plugin/init.lua
index 6685acc..45508a2 100644
--- a/plugin/init.lua
+++ b/plugin/init.lua
@@ -1,19 +1,37 @@
--- examples for your init.lua
+-- Nvim-tree keymap function
+local function my_on_attach(bufnr)
+ local api = require('nvim-tree.api')
+
+ local function opts(desc)
+ return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
+ end
+
+ api.config.mappings.default_on_attach(bufnr)
+
+ vim.keymap.set('n', 'A', api.tree.expand_all, opts('Expand All'))
+ vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
+ vim.keymap.set('n', 'P', function()
+ local node = api.tree.get_node_under_cursor()
+ print(node.absolute_path)
+ end, opts('Print Node Path'))
+
+ vim.keymap.set('n', 'Z', api.node.run.system, opts('Run System'))
+
+ vim.keymap.set('n', 'u', api.tree.change_root_to_parent, opts('Up'))
+end
+
-- disable netrw at the very start of your init.lua (strongly advised)
vim.g.loaded = 1
vim.g.loaded_netrwPlugin = 1
--- OR setup with some options
+
+-- Setup with some options
require("nvim-tree").setup({
sort_by = "case_sensitive",
+ on_attach = my_on_attach,
view = {
adaptive_size = true,
- mappings = {
- list = {
- { key = "u", action = "dir_up" },
- },
- },
},
renderer = {
group_empty = true,
@@ -30,6 +48,7 @@ require("nvim-tree").setup({
},
})
+-- Others setup
require('leap').set_default_keymaps()
require("cscope_maps").setup({})