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

bug: `Trouble lsp_definitions` do not work with the `pbkit` language server while `vim.lsp.buf.definition` does.

Open xulongwu4 opened this issue 2 years ago • 1 comments

Did you check docs and existing issues?

  • [X] I have read all the trouble.nvim docs
  • [X] I have searched the existing issues of trouble.nvim
  • [X] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

v0.10.0-dev-ac1c234

Operating system/version

Linux

Describe the bug

pbkit is a language server for google's protobuf message. With this commit merged to pbkit's main branch, we can use easily integrate this lsp with nvim-lspconfig and work on .proto files (see steps to reproduce below).

I found most features supported by pbkit works out of the box except for goto definitions. When I use the :Trouble lsp_definitions command, it does not do anything. However, when I use vim.lsp.buf.definition, it correctly jumps to the definition of a message.

Steps To Reproduce

  1. Install pbkit at the commit bfbb45b:
git clone https://github.com/pbkit/pbkit.git
cd pbkit
git checkout bfbb45b
./scripts/build-binary.sh x86_64-unknown-linux-gnu # or x86_64-apple-darwin, aarch64-apple-darwin, etc. depending on your platform
# Move the generated `pb` binary file into some directory that is on your PATH
mv tmp/dist/pbkit-x86_64-unknown-linux-gnu/pb ~/.local/bin/`
  1. Add a config for pbkit:

First create a fold named lspconfig/server_configurations/pbkit.lua with the following content:

return {
  default_config = {
    cmd = { "pb", "lsp" },
    filetypes = { "proto" },
    single_file_support = true,
    root_dir = require("lspconfig.util").root_pattern("buf.work.yml", "buf.work.yaml", ".git"),
  },
}

Then in the init.lua file, setup the pbkit server: `require("lspconfig").pbkit.setup()

  1. Test its functionality in a protobuf file.

Create a protobuf file with the following content:

// content of test.proto
message A { int32 f = 1; }

message B { A b = 1; }

Let the cursor sit on the letter A on line 4 (the line that defines message B), and run command :Trouble lsp_definitions. Notice how the cursor stays there while it should have jumped to the definition of A on line 2. Now still with the cursor on the letter A on line 4, run command :lua vim.lsp.buf.definition(). Notice now the cursor jumps to the definition of A on line 2 correctly.

Expected Behavior

Trouble lsp_definitions should jump to the definition in a proto file if the pbkit supports it and vim.lsp.buf.definitino works correctly.

Repro

See the `Steps to reproduce` part.

xulongwu4 avatar Nov 22 '23 17:11 xulongwu4

Hi, I'm not sure whether it is worth opening a new issue for this, but I get the exact same behaviour with the lsp server of zk through zk-nvim.

:Trouble lsp_definitions doesn't do anything (except for letting my status bar disappear until I press another key), while vim.lsp.buf.definition works as expected.

kluen avatar Dec 22 '23 10:12 kluen

Development on the main branch is EOL.

Trouble has been rewritten and will be merged in main soon.

This issue/feature either no longer exists or has been implemented on dev.

For more info, see https://github.com/folke/trouble.nvim/tree/dev

folke avatar Mar 29 '24 07:03 folke