Skip to content

Conversation

bfredl
Copy link
Member

@bfredl bfredl commented Jan 13, 2019

More of TODO than WIP to be honest, but at least "conceptual" preview of something that can become a generalization of virttext, where virtual text also can be placed in the middle of a line an not only at the end. When working on #9492 I finally understood the remaining missing pieces how horizontal cursor movement/tracking works with conceal, and general virttext can be understood as the the inverse of conceal: we shift vcols to the right rather than the left on the screen.

This currently hard codes some virtual text at line 3 column 10. h l etc cursor movement and mouse clicks should be handled properly. Proper implementation would really need tracking of horizontal changes to marks, so further work will be scheduled after the initial extmark merge #5031.

Also an open question is how to deal with extra needed vertical space. Should virttext be truncated, or should the line be allowed to grow vertically due to virtual text? The later sounds more ideal, though this will differ with conceal behaviour, and might break some invariants.

One could even go so far and allow vcols to change, though that could be a larger and more risky endeavour. But on the other hand flexible vcols might be something we want anyway, so the text rendering of an external UI can affect what gj and gk does, and not only vim's hard coded calculation for how much space text should take on screen.

@bfredl bfredl changed the title WIP: anticonceal (generalized virttext) [WIP] anticonceal (generalized virttext) Jan 13, 2019
@bfredl bfredl added api libnvim, Nvim RPC API display redraw, layout, presentation labels Jan 13, 2019
@justinmk
Copy link
Member

general virttext can be understood as the the inverse of conceal: we shift vcols to the right rather than the left on the screen.

👍

Should virttext be truncated, or should the line be allowed to grow vertically due to virtual text?

Would "grow vertically" be a similar effect as diff "filler lines"?

@marvim marvim added the WIP label Jan 13, 2019
@bfredl
Copy link
Member Author

bfredl commented Jan 13, 2019

Would "grow vertically" be a similar effect as diff "filler lines"?

Ah that's true. So there already is logic for managing vertical space from changes outside the buffer itself, we should follow that then.

@alok
Copy link

alok commented Apr 15, 2019

Would it be feasible to generalize conceal to full strings rather than single characters from these changes?

@bfredl
Copy link
Member Author

bfredl commented Apr 15, 2019

Yes. It would be feasible to replace any character range with any string (within a line). The question is what we do with cursor positions within.

@oblitum
Copy link

oblitum commented Apr 30, 2020

Bump and usecase report:

rust-analyzer provides a compelling use case for this, see fannheyward/coc-rust-analyzer#177 (comment).

Currently only chainingHints are provided due to this limitation.

@heapslip
Copy link

Bump, usecase is adding empty virtual lines to draw images.

https://www.reddit.com/r/neovim/comments/ieh7l4/im_building_an_image_plugin_and_need_some_help/
Can we please, please, please get this?

@lehmacdj
Copy link

lehmacdj commented Jan 3, 2021

Bumping this again with another usecase: displaying titles of linked notes inline.
fiatjaf/neuron.vim#23

This would be really useful!

@alok
Copy link

alok commented Apr 4, 2021

Willing to put $200 bounty on this. I know that’s likely not enough, but I want to provide the most incentive I can currently afford and see if others feel alike.

@oblitum

This comment has been minimized.

@oxilumin
Copy link

One more usecase - pull request comments/in-nvim review: #15331

@oblitum

This comment was marked as off-topic.

@Ciel-MC

This comment was marked as off-topic.

@dundargoc
Copy link
Member

@Ciel-MC we accept contributions. Please send a pull request if you'd like to implement this.

@dundargoc dundargoc changed the title [WIP] anticonceal (virtual text occupying horizontal space) anticonceal (virtual text occupying horizontal space) Apr 2, 2023
flatheadmill added a commit to flatheadmill/dotfiles that referenced this pull request Apr 19, 2023
See vim/vim#260. Might be fixed by NeoVIM
soonish with their "anticonceal" project.

Also: nvim-neorg/neorg#292
Also: neovim/neovim#14409
Also: neovim/neovim#9496

Including `gettysburg.md` to check when conceal is working property, if
ever. Note that everyone claims that concel works better in Emacs.
@robclancy

This comment was marked as spam.

@oblitum
Copy link

oblitum commented May 29, 2023

An extreme case would have a zero-length match instead of CD, in which case, the cursor travels through the "discontinuity", it would jump over from either B to E or from E to B, as there's no real text between it, only virtual. It's the use case of inlay hints (and virtual text, at the end of the line).

After #20130 is merged, NeoVim has got Vim's solution for inlay hints. Right after first usages I'm spotting usability issues that relate to the quote above. Movement over a buffer with intermixed virtual text is affected by it, using w to jump over words, for example, often may land at the start of a virtual text that comes before the start of the real text, the text that's going to be changed on cw is far from cursor, after the virtual head. One can't edit virtual text, just the real text, so why the cursor jumps to the virtual text instead of the actual text? It's an implementation detail that's affecting editing in counter-intuitive ways.

Ideally, while editing code, virtual text would be passed-through, popping in and out of existence meanwhile real content changes. If that's not attained, then we have what we have now, virtual text confusingly positing as real text.

@bfredl
Copy link
Member Author

bfredl commented May 29, 2023

so why the cursor jumps to the virtual text instead of the actual text?

I don't see this happening at all. Is there a screenshot or perhaps a small video?

@oblitum
Copy link

oblitum commented May 29, 2023

@bfredl (click to expand resolution):

gif-2023-05-29-154540

clangd is in use, by means of coc-clangd.

@bfredl
Copy link
Member Author

bfredl commented May 29, 2023

Hmm this is not the behavior I get. But perhaps it is affected by options, like cpoptions which are not the default here.

@bew

This comment was marked as duplicate.

@ddickstein
Copy link
Contributor

A couple questions on the above discussion:

  • @oblitum drew a distinction between concealing and inlaying. I'm not sure I understand the significance of the distinction or what this means exactly. At a high level, why does it make sense to think about virtual text occupying horizontal space in terms of the conceal feature / as "anti-conceal"? There's some mention of this benefiting from existing features / offering a more consistent experience - what does that look like concretely?

  • Would virtual text occupying horizontal space be allowed to contain newlines? For example, given

def foo(|)

where | is the cursor, one might want to virtually display a completion as

def foo(|
  arg1,
  arg2,
)

where the lines with arg1, and arg2, appear as virtual text but the closing ) does not, and this would all still be only one actual line.

@jakubbortlik

This comment was marked as off-topic.

@clason

This comment was marked as off-topic.

@jakubbortlik

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api libnvim, Nvim RPC API display redraw, layout, presentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.