Hide cursor in temporary window
Hello, I m trying to find a way to hide cursor in specific window/buffer.
So far I found out that using these
set termguicolors
hi Cursor blend=100
set guicursor+=a:Cursor/lCursor
you can in fact completely hide cursor, but i cant figure out how to make this just in this window. Or is there better way in vim.api ?
Posted Oct 18, 2022, 6:26 PM UTC
Probably something like a bufenter autocmd that also creates a bufleave autocmd to clean up after itself
i create window using lua so i own that event already, i just dont know how to set those options to just that window, so that when user closes it, cursor appears
There's no way to set it forever to that value only in that window (believe me, I tried), the only method you have is to put it in a WinEnter/WinLeave pair, and change vim.go.guicursor temporarily.
Also, if you do this in lua, you will need to ad reverse = true to your highlight besides blend = 100
I believe you!
Is it guaranteed that using this pair there wont happen situation where i dont set it back after window close? Maybe someone closes using lua api, would it be covered for example?
Could you share your implementation, i m little confused by how to set these settings now, but if i figure it out I ll post it here.
I believe the only way that would happen is if somehow you run into an exception that stops that execution.
https://github.com/gorbit99/codewindow.nvim/blob/08aadc56e665239d33efd762d61fc3672fa260dd/lua/minimap/window.lua#L65
This has an issue if the user switches buffers in that specific window, so might want to use BufEnter and BufLeave instead.