Closed morgsmccauley closed 1 year ago
Hi, I doubt that is possible, since code actions are position dependant on the LSP server side, and the server will not return a code action for let's say, swapping function parameters if I ask for a code action for the entire line.
A workaround would be to ask the server for possible code actions for every single column on the line, but I feel that it would be very resource intensive and not worthwhile.
I also want this future
@kosayoda how do other IDEs handle this, as they seem to be able to "query" the language server for a list of available code actions
@RaafatTurki Do you have an example of this? As far as I am aware this isn't a feature of any LSP based IDEs.
can't you use tree sitter to only query for relevant information? Like find all arguments, functions and so and ask for their columns? But now that I think about it, that's not how tree sitter works? it doesn't allow you to ask what is in this line? or does it?
can't you use tree sitter to only query for relevant information? Like find all arguments, functions and so and ask for their columns? But now that I think about it, that's not how tree sitter works? it doesn't allow you to ask what is in this line? or does it?
Interesting suggestion. On first thought that might work (making a codeAction
call on every node in the triggered line). Some thoughts:
If a lightbulb shows up whenever there is a an action on the current line, the user would still have to hunt for the relevant node/position in order to actually get the list of code actions, partially defeating the purpose. That being said, writing this out gave me the idea of having different indicators for when an action is available anywhere on a line vs at the current cursor position.
A line may still have enough nodes to degrade performance. Apart from LSP overhead, we also need to run/parse treesitter queries to get a list of nodes on the current line. Admittedly this is not an issue until such a feature exists and benchmarks are ran (I don't have enough knowledge to perform such a benchmark).
It introduces a dependency on treesitter. This may not be a problem if we can make it optional.
TLDR: The suggestion sounds interesting and I will be playing around with the idea when I have time. I'm still not sure the feature is worth the implementation, so I'd be happy to review a proof-of-concept version of this feature if anyone is interested.
@kosayoda A max limit per line can be set, and have that configurable per language server.
Also caching the code action results so the user wouldn't have to ask for them again is a good idea, this opens so many doors regarding displaying them for instance we could have them all show in one vim.ui.select
call with separators between them.
Is it possible to show a 💡when a code action is available on the current line? And then list all available code actions for the line? It can be easy to miss a potential code action if my cursor needs to be in specific position.