Open files in new tab

This commit is contained in:
ekzyis 2024-04-22 20:47:03 +02:00
parent 9abc1b12be
commit 1bcf68ac25
1 changed files with 28 additions and 3 deletions

View File

@ -8,10 +8,35 @@ return {
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
require('nvim-tree').setup()
require('nvim-tree').setup({
tab = {
sync = {
open = true,
close = true
}
},
on_attach = function(bufnr)
local api = require('nvim-tree.api')
local lib = require('nvim-tree.lib')
api.config.mappings.default_on_attach(bufnr)
local function opts(desc)
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
vim.keymap.set('n', '<CR>', function()
local node = lib.get_node_at_cursor()
api.node.open.tab()
if node.type == 'file' then
vim.cmd('wincmd l')
vim.cmd('tabprevious')
end
api.tree.focus()
end, opts('Open: New Tab (unfocused)'))
end
})
local api = require('nvim-tree.api')
vim.keymap.set('n', '<leader>e', api.tree.open, { desc = "Open file explorer" })
vim.keymap.set('n', '<leader>E', api.tree.close, { desc = "Close file explorer" })
vim.keymap.set('n', '<leader>e', api.tree.toggle, { desc = "Toggle file explorer" })
end
}