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

128
Alleyria•

Probably something like a bufenter autocmd that also creates a bufleave autocmd to clean up after itself

1
hellfiniterOP•

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

2
Spiritual_Guide202•

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

3
hellfiniterOP•

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.

1
Spiritual_Guide202•

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.

1
justinmkNeovim core•

:help 'winhighlight'

1
vim-help-bot•

Help pages for:


^`:(h|help) <query>` | ^(about) ^(|) ^(mistake?) ^(|) ^(donate) ^(|) ^Reply 'rescan' to check the comment again ^(|) ^Reply 'stop' to stop getting replies to your comments

1
hellfiniterOP•

i saw that one, I just dont understand how those 3 viml commands work together, I realize i could create highlight for that win only. I just have too many things i dont understand here and I dont see how to get those answers ...I decided to not bother, it isnt really big deal and as I see how complicated it is, its probably for the best.

1