helix-editor / helix

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

Highlighting the word under the main cursor automatically. #3436

Open m-kru opened 2 years ago

m-kru commented 2 years ago

Kakoune allows highlighting the word under the main cursor automatcially.

declare-option -hidden regex cursor_word
add-highlighter global/ dynregex '%opt{cursor_word}' 0:bright-white

The result is as follows:

image

Is it possible with helix?

septemhill commented 2 years ago

Not pretty sure that could we use cursorline to fulfill this requirement

m-kru commented 2 years ago

@septemhill please look at the screenshot one more time. ante is highlighted in 3 lines, not solely in the line with the cursor.

the-mikedavis commented 2 years ago

This is somewhat possible with the Language Server using LSP documentHighlight https://github.com/helix-editor/helix/pull/2738 which creates selections for all occurences of the symbol under the cursor. There isn't a way for those to be highlighted and not selected though and it only works for languages with Language Servers running

m-kru commented 2 years ago

Is helix an editor for coding only? Everything is built around LSP. Sometimes you have a plain text file.

the-mikedavis commented 2 years ago

Development focus so far has been focused on language-aware integrations like LSP, DAP or tree-sitter since that's what contributors are most interested in working on. Fallbacks for when language-aware tools are not available are within scope for the project though. If it's something important to you then it sounds like a nice opportunity to contribute. There are some open issues like https://github.com/helix-editor/helix/issues/1015 although that one has some PRs already

willhansen commented 1 year ago

This looks adjacent to the "semantic highlighting" feature in intellij that I quite like.

Each variable gets its own color.

Would probably use much of the code required for this.

Selection_235

Selection_236

pascalkuthe commented 1 year ago

This looks adjacent to the "semantic highlighting" feature in intellij that I quite like.

Each variable gets its own color.

Would probably use much of the code required for this.

Selection_235

Selection_236

That's unrelated and would be closer to #2857 implementation wire and would have little/nothing to do with this issue