From ccb36c150f43e86fa5fa43f74da61c8745ac717a Mon Sep 17 00:00:00 2001 From: Kutsan Kaplan Date: Wed, 2 Oct 2024 19:48:08 +0300 Subject: [PATCH] refactor(nvim): move nvim tree autocmd inside nvim configs --- .config/nvim/lua/specs/nvim_tree.lua | 12 ++++++++++++ .config/nvim/plugin/autocmds.lua | 8 -------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.config/nvim/lua/specs/nvim_tree.lua b/.config/nvim/lua/specs/nvim_tree.lua index 38b17e0d..d923283e 100644 --- a/.config/nvim/lua/specs/nvim_tree.lua +++ b/.config/nvim/lua/specs/nvim_tree.lua @@ -20,6 +20,18 @@ Plugin.config = function() } end + vim.api.nvim_create_autocmd('BufEnter', { + group = vim.api.nvim_create_augroup( + 'NvimTreeWinFixBuf', + { clear = true } + ), + callback = function() + if vim.list_contains({ 'NvimTree' }, vim.bo.filetype) then + vim.opt_local.winfixbuf = true + end + end, + }) + keymap.set('n', 'l', nvim_tree_api.node.open.edit, opts('Open')) keymap.set('n', '', nvim_tree_api.node.open.edit, opts('Open')) keymap.set('n', '<2-LeftMouse>', nvim_tree_api.node.open.edit, opts('Open')) diff --git a/.config/nvim/plugin/autocmds.lua b/.config/nvim/plugin/autocmds.lua index ca0419c9..a1054af3 100644 --- a/.config/nvim/plugin/autocmds.lua +++ b/.config/nvim/plugin/autocmds.lua @@ -88,11 +88,3 @@ api.nvim_create_autocmd('BufWritePre', { buffer.trim_trailing_spaces() end, }) - -vim.api.nvim_create_autocmd('BufEnter', { - callback = function() - if vim.list_contains({ 'NvimTree' }, vim.bo.filetype) then - vim.opt_local.winfixbuf = true - end - end, -})