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

[Feature Request] lsp actions preview #944

Closed
jqhr opened this issue Dec 4, 2023 · 12 comments
Closed

[Feature Request] lsp actions preview #944

jqhr opened this issue Dec 4, 2023 · 12 comments
Labels
feature request New feature

Comments

@jqhr
Copy link

jqhr commented Dec 4, 2023

Like actions-preview.nvim,
But this plugin only support telescope.
FzfLua has its own lsp code action provider.
Why not provide preview for code action?

@ibhagwan ibhagwan added the wontfix This will not be worked on label Dec 4, 2023
@ibhagwan
Copy link
Owner

ibhagwan commented Dec 4, 2023

FzfLua has its own lsp code action provider.

It’s a legacy provider that currently only calls the lsp.buf.code_actions while making sure fzf-lua is registered for vim.ui.select as its interface.

Why not provide preview for code action?

IMHO the beneift here is pretty minimal and based on my previous work with code actions the maintenance overhead is bigger than just implementing this, every LSP has its own quirks (jdtls, etc) which can complicate things so I opted against implementing this myself.

If you wish to implement this yourself and submit a PR I’ll gladly accept it.

@ibhagwan
Copy link
Owner

ibhagwan commented Dec 4, 2023

If you decide to submit a PR take a look at #717 and #755 to understand how to create a custom previewer for ui.select.

@jqhr
Copy link
Author

jqhr commented Dec 4, 2023

I could submit a pr, but obviously it may bring many break changes. You know, I just want a simple point. So I submit an issue rather than pr

@ibhagwan
Copy link
Owner

ibhagwan commented Dec 4, 2023

I could submit a pr, but obviously it may bring many break changes. You know, I just want a simple point. So I submit an issue rather than pr

It won’t bring breaking changes, a previewer is an addition which can always be disabled/hidden by default, if you wish to PR this we can work on it together.

@ibhagwan ibhagwan added feature request New feature and removed wontfix This will not be worked on labels Dec 5, 2023
@ibhagwan
Copy link
Owner

ibhagwan commented Dec 5, 2023

@jqhr, don’t worry about if if you don’t feel Ike submitting a PR, I’ll do it myself when I get some free time.

ibhagwan added a commit that referenced this issue Dec 7, 2023
2 new previewers for code actions of type `edit` (diff):
- "codeaction" is the default which displays the diff in the
  "builtin" neovim previewer
- "codeaction_native" uses fzf's native preview ability and is
  recommended when git-delta is installed, by default will
  auto-detect the `delta` binary and set as the preview pager
  Try with `:FzfLua lsp_code_actions previewer=codeaction_native`

Special thanks to @aznhe21 for the diff generation code which
I borrowed from `actions-preview.nvim` plugin:
https://github.com/aznhe21/actions-preview.nvim
@ibhagwan
Copy link
Owner

ibhagwan commented Dec 7, 2023

b3b05f9

@jqhr, this commits adds 2 new previewers, the default is codeaction:
image

If you have git-delta installed I recommend changing the default to codeaction_native for a highly pleasing diff display:

:FzfLua lsp_code_actions previewer=codeaction_native
image

@ibhagwan
Copy link
Owner

ibhagwan commented Dec 8, 2023

For anyone reading this issue, side-by-side can also be achieved with:

require("fzf-lua").setup({
  lsp = {
   code_actions = {
      previewer = "codeaction_native",
      preview_pager = "delta --side-by-side --width=$FZF_PREVIEW_COLUMNS",
    },
  }, ...
})

The result:
image

@jqhr
Copy link
Author

jqhr commented Dec 8, 2023

Great!
Ty

@MariaSolOs
Copy link
Contributor

This is very nice indeed! I just tweaked my config and I'm quite happy with the result :)
Screenshot 2023-12-10 at 2 15 56 PM

In case anyone wants to use it as inspiration, here is the commit where I added this to my dotfiles!

@ibhagwan
Copy link
Owner

ibhagwan commented Dec 10, 2023

This is very nice indeed! I just tweaked my config and I'm quite happy with the result :)

Looks great @MariaSolOs!

wookayin added a commit to wookayin/dotfiles that referenced this issue Dec 11, 2023
- Configure fzf-lua's lsp_code_actions previewer (ibhagwan/fzf-lua#944)
  with some reasonable default settings (uses git-delta native previewer
  and the vertical layout for previewing diff)

- LSP keymap `<leader>ca` and buffer-local command `:CodeActions` now
  execute `fzf-lua.lsp_code_actions()`
@mikesmithgh
Copy link
Contributor

Awesome work @ibhagwan ! and thanks for the inpsiration @MariaSolOs :)

fzf-lua-code-action

@ibhagwan
Copy link
Owner

Very cool color scheme / setup @mikesmithgh :)

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

No branches or pull requests

4 participants