Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SirWrexes opened this issue Jul 25, 2023 · 1 comment
Open

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

SirWrexes opened this issue Jul 25, 2023 · 1 comment

Comments

@SirWrexes
Copy link

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:

  • Show code actions for what was under the cursor if there was any
  • Show code actions for the whole document if nothing under cursor had actions available

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. 🤔

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

@aznhe21
Copy link
Owner

aznhe21 commented Jul 25, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants