aznhe21 / actions-preview.nvim

Fully customizable previewer for LSP code actions.
GNU General Public License v3.0
365 stars 9 forks source link

Opening a preview of ALL code actions for current buffer #6

Open SirWrexes opened 1 year ago

SirWrexes commented 1 year ago

Hey, thanks for the plugin, works like a charm !

However, before switching to the builtin LSP, I used CoC with a bunch of plugins (mostly TypeScript oriented stuff) and I had a handy shortcut that would either:

There would be actions that save a lot of time like "Delete all unused imports" in TS, instead of having to go through a list of all of them and deleting them one by one.

Currently, when trying to open actions-preview on a random part of the document with no quickfix simply yields "No code action available".

I tried going Visual mode and selecting the whole document then opening the actions menu, but sadly it didn't have the expected results, most likely because the LSP is trying to find something to do with that whole bunch of text instead of proposing a list of all individual quickfixes. :thinking:

So, would there be a way to display all actions including the ones that are not specific to a specific symbol under cursor ?

aznhe21 commented 1 year ago

Hi! Glad to hear the plugin is working like a charm for you!

To show code actions for the whole document, you can use the following Lua code:

require("actions-preview").code_actions({ context = { only = { "source" } } })

However, currently, the plugin doesn't support flexible branching like "if nothing under cursor had actions available". I'll look into whether it's possible to achieve this functionality.