Improved neotree navigation UX

This commit is contained in:
Bryan Ramos 2026-03-09 01:12:03 -04:00
parent b08b0a9b57
commit 5c224976d8
Signed by: bryan
GPG key ID: 6ABDCD144D6643C8

View file

@ -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()