Since protols is a language server, debugging it directly via standard I/O can
be challenging. Furthermore, attaching a debugger to a running process inside a
Dev Container is often restricted by security policies.
The recommended way to debug is to start the server in TCP mode and connect to it with your LSP client.
The project includes a pre-configured launch.json for VS Code that automates
the debugging setup.
In VS Code, go to the Run and Debug view and select "Debug protols via TCP".
This will:
- Build the project in debug mode.
- Start the server listening on a TCP port (default:
7301). - Automatically open a new terminal with Neovim inside the Dev Container.
The Neovim instance in the Dev Container is pre-configured to detect the
LSP_DEBUG_PORT environment variable.
- Wait for the message in the VS Code Debug Console:
LSP server listening on TCP: 127.0.0.1:7301. - In the opened Neovim terminal, open any
.protofile (e.g.,:e sample/simple.proto). - Neovim will automatically connect to the debugged server instance via the specified port.
To ensure the debugger is working and the server is responding:
- Set a breakpoint in the Rust code (e.g., in
src/parser/docsymbol.rs). - In Neovim, trigger an LSP request, such as fetching document symbols:
:lua vim.lsp.buf.document_symbol()
- The debugger should hit your breakpoint in VS Code.
If you prefer to run the components manually:
- Start the server:
cargo run -- --port 7301
- Start Neovim:
LSP_DEBUG_PORT=7301 nvim your_file.proto