Skip to Content
GuidesLanguage Server Protocol

Language Server Protocol (LSP)

proto integrates with LSP language servers to give the model accurate code intelligence: go-to-definition, find-references, hover info, diagnostics, and code actions.

Enable LSP

Auto-enable — place a .lsp.json in your project root.

CLI flag:

proto --lsp

Settings:

{ "general": { "lsp": true } }

Install a language server

LanguageServerInstall
TypeScript/JavaScripttypescript-language-servernpm i -g typescript-language-server typescript
Pythonpylsppip install python-lsp-server
Gogoplsgo install golang.org/x/tools/gopls@latest
Rustrust-analyzerSee rust-analyzer.github.io 
C/C++clangdInstall LLVM/clangd via your package manager
JavajdtlsInstall JDTLS + JDK

Configure .lsp.json

{ "typescript": { "command": "typescript-language-server", "args": ["--stdio"], "extensionToLanguage": { ".ts": "typescript", ".tsx": "typescriptreact", ".js": "javascript" } } }

Configuration options

OptionTypeDefaultDescription
commandstringLSP server executable (required)
argsstring[][]Command-line arguments
transportstringstdiostdio, tcp, or socket
envobjectEnvironment variables
initializationOptionsobjectLSP initialization options
settingsobjectSent via workspace/didChangeConfiguration
extensionToLanguageobjectMaps file extensions to language IDs
startupTimeoutnumber10000Startup timeout (ms)
restartOnCrashbooleanfalseAuto-restart on crash
maxRestartsnumber3Max restart attempts
trustRequiredbooleantrueRequire trusted workspace

TCP/socket transport

{ "remote-lsp": { "transport": "tcp", "socket": { "host": "127.0.0.1", "port": 9999 }, "extensionToLanguage": { ".custom": "custom" } } }

Available operations (via the lsp tool)

OperationWhat it does
goToDefinitionFind where a symbol is defined
findReferencesFind all references to a symbol
goToImplementationFind implementations of an interface/abstract method
hoverGet documentation and type info
documentSymbolList all symbols in a file
workspaceSymbolSearch for symbols across the workspace
prepareCallHierarchyGet call hierarchy at a position
incomingCallsFunctions that call the given function
outgoingCallsFunctions called by the given function
diagnosticsErrors/warnings for a file
workspaceDiagnosticsAll diagnostics across the workspace
codeActionsQuick fixes and refactorings at a location

All operations take filePath, line (1-based), and character (1-based) parameters.

Security

LSP servers run with your user permissions and can execute code. By default, they only start in trusted workspaces. Override per server:

{ "safe-server": { "command": "my-server", "trustRequired": false, "extensionToLanguage": { ".x": "x" } } }

Trust a workspace with /trust or by configuring trusted folders in settings.

Check server status

/lsp status

Lists all configured servers and whether they are running.

Troubleshooting

SymptomFix
Server not startingVerify binary is in PATH; check workspace is trusted
Slow performanceExclude node_modules; increase startupTimeout
No resultsWait for indexing; save the file first
Multiple servers, no resultsFirst server to return results wins

Debug logging:

DEBUG=lsp* proto --lsp

SDK usage

import { query } from '@protolabsai/sdk'; const conversation = query({ prompt: 'Fix all type errors in the auth module', options: { lsp: true, permissionMode: 'auto-edit' }, });
Last updated on