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: Merge results from different LSP sources sharing the same uri and range #423

Closed
1 task done
pidgeon777 opened this issue May 4, 2024 · 1 comment
Closed
1 task done

Comments

@pidgeon777
Copy link

Did you check the docs?

  • I have read all the trouble.nvim docs

Is your feature request related to a problem? Please describe.

When multiple LSP servers are attached to a buffer, they could provide multiple, identical results when querying for the same information (definitions, references...).

For example, let's consider the Trouble lsp results provided by 3 different LSP servers attached to a buffer:

  Definitions  3 
   └╴󰍛  Work\Design\src\TOP.vhd  3 
     ├╴OB  : out   std_ulogic; (lsp_server_1) [426, 8]
     ├╴OB  : out   std_ulogic; (lsp_server_2) [426, 8]
     └╴OB  : out   std_ulogic; (lsp_server_3) [426, 8]
  Implementations  2 
   └╴󰍛  Work\Design\src\TOP.vhd  2 
     ├╴OB  : out   std_ulogic; (lsp_server_2) [426, 8]
     └╴OB  : out   std_ulogic; (lsp_server_1) [426, 8]
  Declarations  1 
   └╴󰍛  Work\Design\src\TOP.vhd  1 
     └╴OB  : out   std_ulogic; (lsp_server_2) [426, 8]

As you can see, the same result is repeated multiple times, with the only difference being the LSP server that provided it.

This redundancy makes the provided results not immediate to read and understand.

Describe the solution you'd like

It would be great to merge the results whose uri and range are the same, for example, this way:

  Definitions  3 
   └╴󰍛  Work\Design\src\TOP.vhd  3 
     ├╴OB  : out   std_ulogic; (lsp_server_1, lsp_server_2, lsp_server_3) [426, 8]
   Implementations  2
    └╴󰍛  Work\Design\src\TOP.vhd  2 
      ├╴OB  : out   std_ulogic; (lsp_server_1, lsp_server_2) [426, 8]
   Declarations  1
    └╴󰍛  Work\Design\src\TOP.vhd  1 
      └╴OB  : out   std_ulogic; (lsp_server_2) [426, 8]

By doing this, the provided information would be far more readable and understandable.

If range is not the same for locations with the same uri, the corresponding results should obviously not be merged.

Describe alternatives you've considered

N/A

Additional context

This merge feature could be added as an option in the settings, named for example merge_results (true/false).

This feature could globally affect all of the result kinds / panels provided by Trouble.

@folke
Copy link
Owner

folke commented May 29, 2024

You could already implement this, by adding a top level filter that removes any dups.

But this is something you'll have to figure out yourself, using the src code and the example below:

https://github.com/folke/trouble.nvim/blob/dev/docs/examples.md#diagnostics-cascade

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants