1

I am trying to configure Protobuf LSP support with nvim (I am using Lazyvim package manager). I've read here that bufls is deprecated and that we should be using buf_ls. Using this snippet, I've configured LSP like such:

-- in ./config/nvim/lua/plugins/lsp-config.lua
return {
  {
    "neovim/nvim-lspconfig",
    ...
        config = function()
      require("lspconfig").buf_ls.setup({
        cmd = { "buf", "beta", "lsp", "--timeout", "0", "--log-format=text" },
        filetypes = { "proto" },
        root_dir = require("lspconfig.util").root_pattern("buf.yaml", ".git"),
      })
    end,

As the result:

  • :LspInfo correctly returns LSP information
  • I have syntax highlighting working
  • But neither symbols nor go to definition work!

For context, similar configuration (just using JSON instead of Lua) yields all LSP features with Zed IDE.

Having run :lua vim.lsp.buf.document_symbol() on a .proto file I got:

Error  15:36:06 notify.error method textDocument/documentSymbol is not supported by any of the servers registered for the current buffer

I think what that means is that buf_ls doesn't have symbol support (yet?): https://github.com/bufbuild/buf#buf ...and that Zed achieves this via a combination of features. Is there a way to achieve the same with nvim? Any hint or help would be appreciated!

2
  • 1
    According to buf code (github.com/bufbuild/buf/blob/main/private/buf/buflsp/nyi.go), "Go to Definition" and "DocumentSymbol" are not yet implemented. Commented Apr 8 at 6:29
  • Thank you for confirming this @Icheylus! Is there a workaround? Using /, *, n takes long for navigating long *.proto files, let alone if those files refer to other imported files. Commented Apr 8 at 13:09

1 Answer 1

3

The solution for me was to switch to protols from buf_ls. It works for the symbols and go to definition functionality as expected!

For LazyVim I enabled it like such:

  -- in plugins/lsp-config.lua
 require("lspconfig").protols.setup({})
 return {
  {
    "neovim/nvim-lspconfig",
      opts = {
        servers = {
           ...
           clangd = {
             filetypes = { "c", "cpp", "objc", "objcpp" }, -- explicitly omitting .proto
       },
       ...
  },{
    "williamboman/mason.nvim",
    opts = function(_, opts)
      opts.ensure_installed = opts.ensure_installed or {}
      vim.list_extend(opts.ensure_installed, {
        ...
        "protols", -- Protobuf support
      })
    end,
  },
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.