From 5c224976d84f72ef3468a6685590a3e50671de05 Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Mon, 9 Mar 2026 01:12:03 -0400 Subject: [PATCH] Improved neotree navigation UX --- lua/plugins/neotree.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lua/plugins/neotree.lua b/lua/plugins/neotree.lua index de0b8d4..fd8efea 100644 --- a/lua/plugins/neotree.lua +++ b/lua/plugins/neotree.lua @@ -20,11 +20,39 @@ return { local win = vim.api.nvim_get_current_win() vim.wo[win].winfixwidth = true vim.wo[win].winfixbuf = true + vim.wo[win].cursorline = true end }, }, }) + -- Set up cursorline highlight for neo-tree (green text on dark bg) + vim.api.nvim_set_hl(0, "NeoTreeCursorLine", { bg = "#313244", fg = "#a6e3a1" }) + + -- Apply highlight and re-apply on colorscheme change + vim.api.nvim_create_autocmd({ "FileType", "ColorScheme" }, { + pattern = { "neo-tree", "*" }, + callback = function(ev) + if ev.event == "ColorScheme" then + vim.api.nvim_set_hl(0, "NeoTreeCursorLine", { bg = "#313244", fg = "#a6e3a1" }) + end + if vim.bo.filetype == "neo-tree" then + vim.wo.winhighlight = "CursorLine:NeoTreeCursorLine" + end + end, + }) + + -- Lock cursor to leftmost column in neo-tree + vim.api.nvim_create_autocmd("CursorMoved", { + pattern = "neo-tree*", + callback = function() + local col = vim.api.nvim_win_get_cursor(0)[2] + if col ~= 0 then + vim.api.nvim_win_set_cursor(0, { vim.api.nvim_win_get_cursor(0)[1], 0 }) + end + end, + }) + local function toggle_neotree() local api = vim.api local bufs = api.nvim_list_bufs()