gptme-lsp

LSP (Language Server Protocol) integration plugin for gptme, providing code intelligence features like diagnostics, definitions, and references. plugins/gptme-lsp View on GitHub

gptme-lsp

LSP (Language Server Protocol) integration plugin for gptme, providing code intelligence features like diagnostics, definitions, and references.

Features

Phase 1: Diagnostics ✅

Phase 2.1: Navigation ✅

Phase 2.2: Refactoring Tools ✅

Phase 2.3: User Experience ✅

Phase 3: Advanced Features ✅

Phase 4: Formatting & Assistance ✅

Phase 5: Inlay Hints & Call Hierarchy ✅

Phase 6: Advanced Analysis ✅ (NEW)

Configuration

Custom Language Servers

Configure custom servers in gptme.toml (project root) or ~/.config/gptme/config.toml (user-level).

Uses the [plugin.lsp] namespace to integrate with gptme's existing config system:

[plugin.lsp.servers]
# Override default server
python = ["pyright-langserver", "--stdio"]

# Use alternative server
python = ["pylsp"]

# Custom path
go = ["/custom/path/to/gopls", "serve"]

# Add new language
ocaml = ["ocamllsp"]

Project config (gptme.toml) overrides user config (~/.config/gptme/config.toml), which overrides built-in defaults.

Lazy Initialization

By default, language servers start only when first needed:

# Server starts on first command, not at LSPManager creation
manager = LSPManager(workspace)  # No servers started yet
manager.get_diagnostics(file)    # Python server starts now
manager.get_definition(file2)    # Server already running, reused

# Force eager initialization (previous behavior)
manager = LSPManager(workspace, lazy=False)  # All detected servers start

Supported Languages

Language Server Install
Python pyright npm i -g pyright or pipx install pyright
TypeScript/JavaScript typescript-language-server npm i -g typescript-language-server typescript
Go gopls go install golang.org/x/tools/gopls@latest
Rust rust-analyzer rustup component add rust-analyzer
C/C++ clangd System package manager

Installation

pip install gptme-lsp

Or install from source:

cd plugins/gptme-lsp
pip install -e .

Usage

The LSP tool is automatically registered when the plugin is installed. Use the lsp command prefix:

# Check diagnostics for current file
gptme "lsp diagnostics src/main.py"

# Jump to definition
gptme "lsp definition src/main.py:42:5"

# Find all references
gptme "lsp references src/utils.py:15:10"

# Get hover information
gptme "lsp hover src/config.py:8:12"

# Rename a symbol across project
gptme "lsp rename src/utils.py:15:5 new_function_name"

Development

# Run tests
cd plugins/gptme-lsp
make test

# Type check
make typecheck

Roadmap