lspsaga.nvim icon indicating copy to clipboard operation
lspsaga.nvim copied to clipboard

Code action improvements

Open smjonas opened this issue 2 years ago • 4 comments

There are a few things that I think can be improved for :Lspsaga code_action:

  1. the lightbulb will always be shown, regardless of where the cursor position is within a line: Current behavior:

image

Expected behavior:

The code action for [1] Add import:: "io" should only be shown when above the io identifier. This is how VSCode behaves.


  1. add option to filter code action items based on their kind
  • Current behavior:

All code actions are shown when using :Lspsaga code_action regardless of the kind (both quickfix and source.organizeImports).

  • Expected behavior: It would be nice to be able to filter them, e.g. only show quickfix and not global code actions such as organizeImports.

  1. E.g. the Golang LSP server can send additional diagnostics for an error. It would be nice to show them in Lspsaga's window. Example response:
 diagnostics = {
  {
    code = "UndeclaredName",
    codeDescription = {
      href = "https://pkg.go.dev/golang.org/x/tools/internal/typesinternal?utm_source=gopls#UndeclaredName",
    },
    message = "undeclared name: io",
    range = {
      ["end"] = {
        character = 14,
        line = 92,
      },
      start = {
        character = 12,
        line = 92,
      },
    },
    severity = 1,
    source = "compiler",
  },
}                 

This is how VSCode shows this info: image


Do you think these are improvements that you want to include in your plugin?

smjonas avatar Sep 13 '22 11:09 smjonas

I will accept any suggestion for improvement. My aim is to make lspsaga have a great ui. Have you used lspsaga's diagnostic yet. I also looked at vscode for this behavior. I think it is showing the behavior of the diagnosis and not the codeaction right? I implement it in jump diagnostic. image

about lightbulb .seems like jump to floatwindow it's disappear. if not it always in. I will fix it later.

add option to filter code action items based on their kind

why not !! good catch.

glepnir avatar Sep 13 '22 11:09 glepnir

there will have a new ui because I am implement title in border in upstream now . It's done right away. Need to write some test code. image

glepnir avatar Sep 13 '22 11:09 glepnir

Have you used lspsaga's diagnostic yet

I haven't, thank you - that looks really nice!

I think it is showing the behavior of the diagnosis and not the codeaction right? I implement it in jump diagnostic.

Yes, I think it would be nice to show the code action and diagnostic information combined so users can fix it immediately. (for me the QuickFixKey: ga text is not shown so I can't run the code action directly)

smjonas avatar Sep 13 '22 11:09 smjonas

right if there has diagnostic when jump it we can show diagnostic and codeaction. then quick fix not press another shortcut.

glepnir avatar Sep 13 '22 11:09 glepnir

just a draft. ui not complete. diagnostic jump with code action . any suggest

images

glepnir avatar Nov 27 '22 12:11 glepnir