hide the cursor in nvim-tree buffer #3191
|
is it possible to add a new setup option to hide the cursor in nvim-tree buffer? |
Answered by
erikbloodshed
Aug 20, 2025
Replies: 3 comments 1 reply
|
Cursor hiding is possible and working in nvim: neovim/neovim#3688 Unfortunately it's controlled via a global option. I experimented with We can dynamically set the global option, however it's pretty hacky. Please try this POC out for a week and see if it behaves. I think you'll need to tweak things to handle some edge cases. vim.cmd([[
" we have to set some gui attributes for blend to take effect
:hi NvimTreeCursorInvisible guifg=bg guibg=fg blend=100
]])
vim.api.nvim_create_autocmd({ "WinEnter", "BufWinEnter" }, {
callback = function(data)
local api = require("nvim-tree.api")
if api.tree.is_tree_buf(data.buf) then
vim.cmd("set guicursor+=a:NvimTreeCursorInvisible/lNvimTreeCursorInvisible")
else
vim.cmd("set guicursor-=a:NvimTreeCursorInvisible/lNvimTreeCursorInvisible")
end
end,
}) |
0 replies
|
Alternative: change the highlight group instead: vim.cmd("hi NvimTreeCursorInvisible guifg=bg guibg=fg blend=0")
vim.cmd("set guicursor+=a:NvimTreeCursorInvisible/lNvimTreeCursorInvisible")
vim.api.nvim_create_autocmd({ "WinEnter", "BufWinEnter" }, {
callback = function(data)
local api = require("nvim-tree.api")
if api.tree.is_tree_buf(data.buf) then
vim.cmd("hi NvimTreeCursorInvisible blend=100")
else
vim.cmd("hi NvimTreeCursorInvisible blend=0")
end
end,
}) |
0 replies
|
Improving on @alex-courtis answer: |
1 reply
Answer selected by
vivitekk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Improving on @alex-courtis answer: