helix icon indicating copy to clipboard operation
helix copied to clipboard

Feature Request: 💡 Light bulb on code actions 💡

Open David-Else opened this issue 3 years ago • 7 comments

At the moment there is no way to discover if a code action exists other than moving around pressing space a. In Neovim this simple plugin https://github.com/kosayoda/nvim-lightbulb shows a little lightbulb when there is a code action available on your cursor position.

It would be great to have this in Helix!

David-Else avatar Apr 07 '22 19:04 David-Else

We can probably do this in the idle timeout that's also used for completion. Would also be a good place to trigger documentHighlights https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentHighlight

archseer avatar Apr 08 '22 00:04 archseer

While i like the feature itself, it can also be distracting depending on the scope of code actions sent by the server. rust-analyzer for example has code actions for flipping a binary comparison when the cursor is on a ==, which I wouldn't want be reminded about since it's pretty trivial.

sudormrfbin avatar Apr 08 '22 05:04 sudormrfbin

How about a space + t for toggle and place any options that wants toggling there? Something like:

space + t + a toggle lightbulb on code action space + t + l toggle line numbers space + t + d toggle lsp diagnostics

David-Else avatar Apr 08 '22 10:04 David-Else

While i like the feature itself, it can also be distracting depending on the scope of code actions sent by the server. rust-analyzer for example has code actions for flipping a binary comparison when the cursor is on a ==, which I wouldn't want be reminded about since it's pretty trivial.

Yeah, that's the main UX problem with :bulb: in the limit, there's an infinite amount of assists for all imaginable cases, and it's hard to teach the user what's available.

One idea I had a while back, is to create a tutorial-like experience, with the editor maintaining the set of code actions which the user invoked at least once. That way, a :bulb: is shown only for "new" assists. This allows to both:

  • teach new users about all existing assists
  • incrementally teach old users about new assists as they get implemented by the language server

matklad avatar Dec 20 '22 17:12 matklad

UI-wise, a less noisy option is to show :bulb: in the modline.

matklad avatar Dec 20 '22 17:12 matklad

@matklad A long time has passed since this thread was created, now we have an event system would it be easier to implement the lightbulb, are you still using Helix and is this something you might consider doing a PR for at some point? Just a simple lightbulb with the ability to turn it on and off in the config would be amazing :)

David-Else avatar Jul 06 '24 13:07 David-Else

No, I am not planning to do any actual work in this area :)

matklad avatar Jul 06 '24 14:07 matklad