DocsConfiguration
View as Markdown

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:

bash
npm install -g typescript typescript-language-server

Python#

Install pyright:

bash
npm install -g pyright

Or use pylsp:

bash
pip install python-lsp-server

Rust#

Install rust-analyzer:

bash
rustup component add rust-analyzer

Or via Homebrew:

bash
brew install rust-analyzer

Go#

Install gopls:

bash
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:

bash
xcode-select --install

C/C++#

Install clangd:

bash
brew install llvm

Or use the version included with Xcode.

Manual Configuration#

For servers not auto-detected, configure them in Settings > LSP:

  1. Open Settings (Cmd+,)
  2. Go to LSP
  3. Click Add Language Server
  4. 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:

FieldValue
NamePython (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:

json
{ "python": { "analysis": { "typeCheckingMode": "basic" } } }

Verifying Setup#

Check if LSP is working:

  1. Open a file of the configured language
  2. Hover over a symbol - you should see documentation
  3. Press Cmd+click to go to definition
  4. Check for error underlines in the editor

Troubleshooting#

Server Not Starting#

  1. Verify the executable path is correct
  2. Check the server is executable: which server-name
  3. Try running the server manually in terminal

No Completions#

  1. Ensure the file type matches the configured languages
  2. Some servers need a project file (package.json, Cargo.toml, etc.)
  3. Wait a moment - servers may need time to index

Performance Issues#

  1. Check if the project is too large for the server
  2. Add directories to ignore patterns
  3. 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.