markdown.nvim icon indicating copy to clipboard operation
markdown.nvim copied to clipboard

Anti-conceal virtual text with cursor

Open MeanderingProgrammer opened this issue 1 year ago • 1 comments
trafficstars

Currently the conceal feature is applied to the buffer as a whole. Meaning anything concealed by Neovim / Tree Sitter is able to be hidden in normal mode but shown when the user's cursor enters that line. For example with links the states are:

  • Insert Mode = Show Concealed Text = [link](https://example.com)
  • Normal Mode with cursor not on line = Hide Concealed Text = link
  • Normal Mode with cursor on line = Show Concealed Text = [link](https://example.com)

Ideally we could do something similar with the virtual text added by this plugin, for example headings would have the following states:

  • Insert Mode = No Virtual Text = ### Heading 3
  • Normal Mode with cursor not on line = Show Virtual Text = <symbol> Heading 3
  • Normal Mode with cursor on line = Hide Virtual Text = ### Heading 3

The tricky part here is we essentially want the opposite behavior of a conceal.

  • Conceal = hide text until cursor enters, then show it
  • We need = show text until cursor enters, then hide it

As far as I am aware there is not a builtin feature to support this kind of behavior.

Any solution that involves running an auto command on every cursor movement is IMO not viable.

If a feature gets released that adds support for this or if I am missing something that already exists please let me know!

Pulled from original issue: https://github.com/MeanderingProgrammer/markdown.nvim/issues/14

MeanderingProgrammer avatar Apr 18 '24 18:04 MeanderingProgrammer

Some discussions that may or may not be relevant: https://github.com/neovim/neovim/pull/9496

MeanderingProgrammer avatar Apr 18 '24 18:04 MeanderingProgrammer

This should hopefully work now after merging: https://github.com/MeanderingProgrammer/markdown.nvim/commit/726c85cb9cc6d7d9c85af6ab093e1ee53b5e3c82.

Will keep this open to track any resulting problems.

MeanderingProgrammer avatar Jul 17 '24 00:07 MeanderingProgrammer

A week is probably long enough to catch any glaring issues, no need to keep this around, happy it seems to be working as expected :)

MeanderingProgrammer avatar Jul 25 '24 01:07 MeanderingProgrammer