I am unable to find out how to get the fixes for a particular diagnostic based errors/warnings in neovim built-in lsp?
For example, let’s say I didn’t import a function name in TypeScript or any other language, quickfix helped me get the potential fixes using the LSP.
I believe you are referring to “Code Actions”.
Here is an example of a library that implements the client side portion for LSPs that provide them GitHub - kosayoda/nvim-lightbulb: VSCode 💡 for neovim's built-in LSP.
The client side portion is implemented in core, that just shows a lightbulb when a core provided code action is available.
Is there something in core for listing the available code actions? Or are those included in the line diagnostics that come back? The functions in core seem to be about performing the code actions and not listing them/displaying them.
All that nvim-lightbulb does, is call ‘textDocument/codeAction’ with a cursor hold autocommand to get the code action at the current point. You can call this yourself with vim.lsp.buf.code_action()
or across a range with ‘vim.lsp.buf.range_code_action()’ (these are core provided helper functions). The difference is nvim-lightbulb swallows the returned code action and just displays the notification.
I understand now. I didn’t realize that that function opened up a prompt for user input, I was thinking the docs were saying it would execute the code action under the cursor.
Thanks for clearing that up!
This is exactly what I needed. I just didn’t know the name of the feature to search. Thanks.