1

I'm trying to to have a visible mark depicting the "state" the buffer is at.

A "state" is nothing more but a function that sets or unsets some keymapings that should be easily arbitrarily turned on or of on a per buffer basis.

I'm looking for a way to show some visual mark for every buffer that has that state set. Something like this (with ASCII graphics):

enter image description here

For example, pressing F4 draw that little rectangle in the top, and repressing it clears it.

It doesn't have to be that exact visual mark, am open to suggestions that are simpler to implement but clearly show a visual difference in the buffer.

Any suggestions on how to do this?

  • Maybe add something to the status line. See :help 'statusline'. – Ralf Jan 25 '19 at 14:03
  • Or you could keep it really simple and make a subtle change to the background color or something. The other extreme would be to do something like what vim-airline does with it's "buffers" label in the top right corner when it's in buffer mode (not tab mode). – B Layer Jan 26 '19 at 2:27
2

draw that little rectangle in the top

This will be possible when Neovim's "floating windows" PR is merged.

Meanwhile you might be interested in :help nvim_buf_set_virtual_text(), it could be used to simulate a one-line floating status, but will require some logic to re-position the text when you scroll.

Try this:

:call nvim_buf_set_virtual_text(bufnr('%'), 0, line('w0')-1, [[repeat(' ',max([4,80-strdisplaywidth(getline(line('w0')))])).'Fancy Status', 'Error']],{})
  • Re-execute the command (@:) whenever you move the viewport.
  • Of course, a full solution will need to respond to cursor motion and remove the previous virtual text. Read :help nvim_buf_set_virtual_text().
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.