Setup LSP
Configure language servers for enhanced editing
What is LSP?
The Language Server Protocol (LSP) provides intelligent code features:
- Auto-completion
- Go to Definition
- Find References
- Hover documentation
- Diagnostics
- Code Actions
Automatic Detection
Agentastic automatically detects common language servers when they're installed. Just install the server and it should work.
Common Language Servers
TypeScript/JavaScript
Install typescript-language-server:
npm install -g typescript typescript-language-server
Python
Install pyright:
npm install -g pyright
Or use pylsp:
pip install python-lsp-server
Rust
Install rust-analyzer:
rustup component add rust-analyzer
Or via Homebrew:
brew install rust-analyzer
Go
Install gopls:
go install golang.org/x/tools/gopls@latest
Swift
sourcekit-lsp is included with Xcode. Ensure you have Xcode or Xcode Command Line Tools installed:
xcode-select --install
C/C++
Install clangd:
brew install llvm
Or use the version included with Xcode.
Manual Configuration
For servers not auto-detected, configure them in Settings > LSP:
- Open Settings (Cmd+,)
- Go to LSP
- Click Add Language Server
- Fill in:
- Name: Display name
- Languages: File extensions (e.g.,
.py, .pyw) - Executable: Path to the server binary
- Arguments: Command line arguments
Configuration Example
For a custom Python setup:
| Field | Value |
|---|---|
| Name | Python (pyright) |
| Languages | .py |
| Executable | /usr/local/bin/pyright-langserver |
| Arguments | --stdio |
Initialization Options
Some servers accept initialization options. Add them as JSON in the configuration:
{ "python": { "analysis": { "typeCheckingMode": "basic" } } }
Verifying Setup
Check if LSP is working:
- Open a file of the configured language
- Hover over a symbol - you should see documentation
- Press Cmd+click to go to definition
- Check for error underlines in the editor
Troubleshooting
Server Not Starting
- Verify the executable path is correct
- Check the server is executable:
which server-name - Try running the server manually in terminal
No Completions
- Ensure the file type matches the configured languages
- Some servers need a project file (package.json, Cargo.toml, etc.)
- Wait a moment - servers may need time to index
Performance Issues
- Check if the project is too large for the server
- Add directories to ignore patterns
- Try a different server implementation
Server-Specific Notes
TypeScript
Works best with a tsconfig.json in your project root.
Python
Place a pyrightconfig.json for custom settings or rely on pyproject.toml.
Rust
Requires a Cargo.toml for full functionality.