-
-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Problem
protols crashes with a panic when it receives notifications from other LSP servers running in the same Neovim session. This happens in multi-language projects where multiple LSP servers are active simultaneously (in my case it is a project that uses Scala and Protocol Buffers).
Error
thread 'main' panicked at <REDACTED>.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/protols-0.11.5/src/main.rs:94:46:
called `Result::unwrap()` on an `Err` value: Routing("Unhandled notification: metals/didFocusTextDocument")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Steps to Reproduce
- Open a project containing both
.protoand.scalafiles in Neovim - Configure both
protols(for Protocol Buffers) andmetals(for Scala) LSP servers - Open a
.protofile (protols starts) - Open a
.scalafile (metals starts) - Focus on the Scala file
protolscrashes whenmetalssendsmetals/didFocusTextDocumentnotification
Environment
- protols version: 0.11.5
- I have attached the configuration that I am using for
protolsat the bottom of this description - Of note, I configured
"scalameta/nvim-metals"to only be enabled for Scala files:ft = { "scala", "sbt" },
- I have attached the configuration that I am using for
- Editor: Neovim NVIM v0.11.1 with LazyVim
- Other LSP servers: metals (Scala), but this could happen with any LSP server sending custom notifications
Root Cause
This is a known limitation of the underlying async-lsp library that protols uses. As documented in async-lsp issue #20, their library doesn't gracefully handle unknown notifications and crashes instead.
Suggested Solutions
Based on the async-lsp maintainer's response, protols could implement a no-op handler (link) - if needed manually implement handlers for common foreign notifications that simply ignore them. For foreign methods (not in lsp-types) wrappers could be added. FWIW, maybe you could simply ignore anything that is not of protols?
Impact
This makes protols unusable in polyglot projects where multiple LSP servers need to run simultaneously, which is a common development scenario.
Workaround
Currently, the only workaround is to use separate editor sessions for different file types, which significantly impacts developer workflow.
Current protols configuration:
return {
{
"neovim/nvim-lspconfig",
opts = {
servers = {
-- Configure protols to only handle .proto files
protols = {
filetypes = { "proto" },
},
-- Other server configurations
},
},
-- Ensure the necessary tools are installed through Mason
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, {
"protols", -- Protobuf support
})
end,
},
}- I did use just
require("lspconfig").protols.setup({})for months before today with the same result...