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 informationsymbols
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!
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,
},
}