From dfd598f0669417500f7d12e88a23c591f1fca4f1 Mon Sep 17 00:00:00 2001 From: "Chris @ Web" Date: Sat, 30 Mar 2024 06:41:30 +0100 Subject: [PATCH] .config/nvim/lua/kamu/plugins/tree.lua aktualisiert --- .config/nvim/lua/kamu/plugins/tree.lua | 80 ++++++++++++++++---------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/.config/nvim/lua/kamu/plugins/tree.lua b/.config/nvim/lua/kamu/plugins/tree.lua index d181bff..f1a3611 100644 --- a/.config/nvim/lua/kamu/plugins/tree.lua +++ b/.config/nvim/lua/kamu/plugins/tree.lua @@ -1,30 +1,50 @@ -return { - 'nvim-tree/nvim-tree.lua', - config = 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 - - -- default mappings - api.config.mappings.default_on_attach(bufnr) - - -- custom mappings - vim.keymap.set("n", "ee", ":NvimTreeToggle") -- toggle file explorer - vim.keymap.set("n", "er", ":NvimTreeFocus") -- toggle focus to file explorer - vim.keymap.set("n", "ef", ":NvimTreeFindFile") -- find file in file explorer - - vim.keymap.set('n', '', 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, - --- - } - end -} +return { + 'nvim-tree/nvim-tree.lua', + dependencies = { + { 'nvim-tree/nvim-web-devicons' } + }, + opts = { + view = { width = 40 }, + }, + config = function() + local function my_on_attach(bufnr) + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + + local api = require("nvim-tree.api") + local function opts(desc) + 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", "ee", ":NvimTreeToggle") -- toggle file explorer + vim.keymap.set("n", "er", ":NvimTreeFocus") -- toggle focus to file explorer + vim.keymap.set("n", "ef", ":NvimTreeFindFile") -- find file in file explorer + vim.keymap.set('n', '', api.tree.change_root_to_parent, opts('Up')) + vim.keymap.set('n', '', api.tree.change_root_to_node, opts('CD')) + 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, + --- + } + end +} +-- Currently this will not load the keymaps if the plugin is not loaded. You have to manually open the tree to load the keymaps. +-- I am also thinking about switching to neo-tree: +-- { +-- "nvim-neo-tree/neo-tree.nvim", +-- branch = "v3.x", +-- dependencies = { +-- "nvim-lua/plenary.nvim", +-- "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended +-- "MunifTanjim/nui.nvim", +-- -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information +-- } +-- }