.config/nvim/lua/kamu/plugins/tree.lua aktualisiert

This commit is contained in:
2024-03-30 06:41:30 +01:00
parent cf766273b7
commit dfd598f066

View File

@@ -1,9 +1,17 @@
return {
'nvim-tree/nvim-tree.lua',
dependencies = {
{ 'nvim-tree/nvim-web-devicons' }
},
opts = {
view = { width = 40 },
},
config = function()
local function my_on_attach(bufnr)
local api = require "nvim-tree.api"
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
@@ -12,12 +20,12 @@ return {
api.config.mappings.default_on_attach(bufnr)
-- custom mappings
vim.keymap.set("n", "<leader>ee", ":NvimTreeToggle<CR>") -- toggle file explorer
vim.keymap.set("n", "<leader>er", ":NvimTreeFocus<CR>") -- toggle focus to file explorer
vim.keymap.set("n", "<leader>ee", ":NvimTreeToggle<CR>") -- toggle file explorer
vim.keymap.set("n", "<leader>er", ":NvimTreeFocus<CR>") -- toggle focus to file explorer
vim.keymap.set("n", "<leader>ef", ":NvimTreeFindFile<CR>") -- find file in file explorer
vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts('Up'))
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts('Up'))
vim.keymap.set('n', '<leader><Enter>', 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
@@ -28,3 +36,15 @@ return {
}
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
-- }
-- }