From 3201478b5ed74340820c66a05eb34ae39d0c9fa0 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 1 Jun 2024 01:33:01 +0200 Subject: make NERDTree have own background color --- lua/autocommands/NERDTree.lua | 2 +- lua/functions.lua | 10 ++++++++++ lua/maps/NERDtree.lua | 2 +- lua/style.lua | 3 ++- 4 files changed, 14 insertions(+), 3 deletions(-) (limited to 'lua') diff --git a/lua/autocommands/NERDTree.lua b/lua/autocommands/NERDTree.lua index 38213e2..9e0acab 100644 --- a/lua/autocommands/NERDTree.lua +++ b/lua/autocommands/NERDTree.lua @@ -1 +1 @@ -autocmd("VimEnter", "*", "NERDTree") +autocmd("VimEnter", "*", "lua toggle_nerdtree()") diff --git a/lua/functions.lua b/lua/functions.lua index 7d95ac3..0030b6c 100644 --- a/lua/functions.lua +++ b/lua/functions.lua @@ -81,6 +81,16 @@ function _G.toggle_terminal() end end +function _G.toggle_nerdtree() + vim.cmd("NERDTreeToggle") + + vim.api.nvim_win_set_option( + vim.fn.win_getid(), + "winhighlight", + "Normal:NERDTreeWindow" + ) +end + function _G.get_current_file() return vim.fn.expand("%") end diff --git a/lua/maps/NERDtree.lua b/lua/maps/NERDtree.lua index 15c933d..c89623c 100644 --- a/lua/maps/NERDtree.lua +++ b/lua/maps/NERDtree.lua @@ -1,2 +1,2 @@ -vim.api.nvim_set_keymap("n", "", ":NERDTreeToggle", +vim.api.nvim_set_keymap("n", "", ":lua toggle_nerdtree()", {silent = true, noremap = true}) diff --git a/lua/style.lua b/lua/style.lua index 7e329b5..d13ecaa 100644 --- a/lua/style.lua +++ b/lua/style.lua @@ -4,7 +4,8 @@ ayu_colors.generate() -- Pass `true` to enable mirage require('ayu').setup({ overrides = { - WinSeparator = { fg = ayu_colors.bg, bg = ayu_colors.bg } + WinSeparator = { fg = ayu_colors.bg, bg = ayu_colors.bg }, + NERDTreeWindow = { fg = ayu_colors.fg, bg = ayu_colors.panel_bg } } }) -- cgit v1.2.3-18-g5258