close nvim-tree when open file

This commit is contained in:
Lorenz Hohermuth 2024-02-27 10:14:58 +01:00
parent 0144cf18ed
commit 6c0050c423
2 changed files with 11 additions and 4 deletions

View File

@ -275,9 +275,6 @@ require('lazy').setup({
"nvim-tree/nvim-web-devicons", "nvim-tree/nvim-web-devicons",
}, },
config = function() config = function()
require("nvim-tree").setup {
on_attach = My_on_attach,
}
end, end,
}, },

View File

@ -1,4 +1,4 @@
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)
@ -12,3 +12,13 @@
vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts('Up')) 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', '?', api.tree.toggle_help, opts('Help'))
end end
require("nvim-tree").setup {
on_attach = my_on_attach,
actions = {
open_file = {
quit_on_open = true,
},
},
}