helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.5k stars 2.48k forks source link

Support a "conceal" feature #5798

Open omentic opened 1 year ago

omentic commented 1 year ago

Vim has a wonderfully helpful "conceal" feature that allows the replacement of arbitrary text with arbitrary other text on lines that are not currently being manipulated. This is exceedingly helpful for editing LaTeX - see the vim-conceal plugin - but it's also helpful for certain other programming languages.

This may perhaps be dependent on a plugin system.

pascalkuthe commented 1 year ago

This heavily factors into the recent work I did in #5420 as conceal is technically a superset of the overlay virtual text implemted there.

Extending the work there to also render a conceal like feature would be easy. However any conceal like feature requires running treesitter. The positioning code is called very often (much more often the the highlight queries) and I strongly believe should not call TS everytime.

Currently virtual text is intended to ne stored on the document. However implementing conceal that way would require running TS for the entire document (not just the visible screen) on every keypress which is also not ok from a performance standpoint.

The only way I see this feature being added is by calcuting conceal om idle timeout if the document has changed and smoothing over conceal ranges apply_impl similar to what we do with diagnostics. As there should.never be conceal at the cursor.to begin with that should work.quite well (but can cause noticeable delay in updating conceal when a syntaxnide changes). Getting all this right will be quite tricky and probably a fairly labor intensive (although not time intensive feature). This feature needs to core support most likely as I don't see us creating APIs for such internal capabilities.

It"s a fairly nieche feature tough so I think it's important that any solution does not slow down the editor when not used or significantly complicates the core positioning code.

ghost commented 1 year ago

Conceal is great when editing or composing any markup, e.g. JSON. Would be a great feature to have out of the box in helix.

rockboynton commented 6 months ago

Would this be able to be built upon the overlay rendering similar to how the Amp-like jump-to-label (gw) feature is rendered?

nkitsaini commented 5 months ago

feature that allows the replacement of arbitrary text with arbitrary other text on lines that are not currently being manipulated

This can be taken a step further to conceal characters even on the current line as long as the cursor is not adjacent to or above those characters. I have seen this behavior in Obsidian note taking app, and personally I prefer this approach.

I assume this might be comparatively harder to implement but since we are starting from scratch, it might be worth considering.

glyh commented 5 months ago

I want to mention that neovim has a long-standing issue where concealer doesn't combo well with line wrap. This can't be resolved as the architecture is not desigend well in the first place. I hope the design of helix's conceal feature is still in early stages so this can be addressed in the design.

pascalkuthe commented 5 months ago

That's not a problem our text positioning and linne wrapping works fundamentally differently and has no issues with things like that