AI-powered Language Server with intelligent diagnostics
Project description
AI LSP
An AI-powered Language Server that provides intelligent semantic code analysis beyond what traditional LSPs can detect. Built with modern Python tools and designed to integrate seamlessly with any LSP-compatible editor.
What It Does
AI LSP focuses exclusively on semantic issues that require deep understanding:
- Logic errors in algorithms and business logic
- Subtle race conditions and concurrency issues
- Architectural problems and design pattern violations
- Security vulnerabilities requiring context understanding
- Performance anti-patterns needing semantic analysis
- Complex data flow issues
- Domain-specific best practice violations
- Accessibility issues requiring UX understanding
What it doesn't do: Traditional LSP tasks like syntax errors, type errors, undefined variables, or basic formatting - your regular LSP handles those perfectly.
Features
- 🧠 AI-Powered Analysis: Uses advanced language models for semantic code understanding
- ⚡ Debounced Analysis: Smart delays prevent AI spam during rapid typing
- 🔧 Code Actions: Provides automated fixes for detected issues
- 🎯 Multi-Language: Supports Python, JavaScript, TypeScript, Rust, Go, Java, C/C++, and Lua
- ⚖️ Async Architecture: Non-blocking analysis with race condition protection
Installation
From PyPI
uv add ai-lsp
# or
pip install ai-lsp
From Source
git clone https://github.com/benomahony/ai-lsp
cd ai-lsp
uv sync
Setup
Environment Variables
Set your AI provider API key:
# For Google AI (default)
export GOOGLE_API_KEY="your-api-key"
# Or for OpenAI
export OPENAI_API_KEY="your-openai-key"
Configuration
Configure via environment variables or .env file:
AI_LSP_MODEL=google-gla:gemini-2.5-pro # Default model
DEBOUNCE_MS=1000 # Analysis delay (milliseconds)
Supported models:
google-gla:gemini-2.5-pro(default)gpt-4o- Any model supported by
pydantic-ai
Editor Integration
Neovim (LazyVim)
Create ~/.config/nvim/lua/plugins/ai-lsp.lua:
return {
{
"neovim/nvim-lspconfig",
opts = {
servers = {
["ai-lsp"] = {
mason = false,
cmd = { "ai-lsp" },
filetypes = { "python", "javascript", "typescript", "rust", "go", "lua", "java", "cpp", "c" },
},
},
},
},
}
VS Code
Add to your settings.json:
{
"ai-lsp.command": ["uvx", "ai-lsp"],
"ai-lsp.filetypes": ["python", "javascript", "typescript", "rust", "go", "lua", "java", "cpp", "c"]
}
Or if you have it installed in your active environment:
{
"ai-lsp.command": ["ai-lsp"],
"ai-lsp.filetypes": ["python", "javascript", "typescript", "rust", "go", "lua", "java", "cpp", "c"]
}
Other Editors
Any LSP client can use AI LSP with these settings:
{
"command": ["uvx", "ai-lsp"],
"filetypes": ["python", "javascript", "typescript", "rust", "go", "lua", "java", "cpp", "c"],
"rootPatterns": [".git", "pyproject.toml", "package.json", "Cargo.toml", "go.mod"]
}
Example Analysis
Given this Python code:
def authenticate(username, password):
if password == 'admin123': # AI LSP will flag this
print(f'User {username} authenticated') # And suggest logging
return True
else:
print('Authentication failed')
return False
AI LSP might detect:
-
Security Issue: Hardcoded password
'admin123'- Severity: Error
- Suggestion: Use environment variables or secure credential storage
-
Best Practice: Using
printstatements- Severity: Warning
- Code Action: Replace with
logging.info()
Troubleshooting
Common Issues
LSP not starting:
- Verify
ai-lspcommand is in PATH:which ai-lsp - Check log file for errors (default:
ai-lsp.log) - Ensure API keys are set correctly
No diagnostics appearing:
- Check file type is supported
- Verify AI model has API access
- Look for errors in log file
Performance issues:
- Increase
DEBOUNCE_MSto reduce API calls - Use a faster model like
gpt-4o-mini - Check network connectivity to AI provider
Debug Mode
Enable verbose logging:
ai-lsp --log-level DEBUG --log-file debug.log
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_lsp-0.1.0.tar.gz.
File metadata
- Download URL: ai_lsp-0.1.0.tar.gz
- Upload date:
- Size: 101.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ff7283c5d64a03a52b6ccfad4af191af0fc26f944bbb7ca6d06f1cb98b96192
|
|
| MD5 |
c4ca574ff38abceb14f4134143ff0699
|
|
| BLAKE2b-256 |
270f79346326dfc13e2e70fada867c2ca43ea3fb4234a0429a58f96b6a65d216
|
Provenance
The following attestation bundles were made for ai_lsp-0.1.0.tar.gz:
Publisher:
publish.yaml on benomahony/ai-lsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_lsp-0.1.0.tar.gz -
Subject digest:
5ff7283c5d64a03a52b6ccfad4af191af0fc26f944bbb7ca6d06f1cb98b96192 - Sigstore transparency entry: 621508285
- Sigstore integration time:
-
Permalink:
benomahony/ai-lsp@b57ee5efe799b6673f4d4aee256c02e3feb737ce -
Branch / Tag:
refs/heads/main - Owner: https://github.com/benomahony
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@b57ee5efe799b6673f4d4aee256c02e3feb737ce -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ai_lsp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ai_lsp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f34dc978ac1c945112e52bbd5095ccac849bf6c81a140bd666cf00e500101c48
|
|
| MD5 |
100690771efd8cd349a069e59b67363c
|
|
| BLAKE2b-256 |
07a0f853a4034849c528e97367290e9ed856d0be4bb002f4b19baf50d525729b
|
Provenance
The following attestation bundles were made for ai_lsp-0.1.0-py3-none-any.whl:
Publisher:
publish.yaml on benomahony/ai-lsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_lsp-0.1.0-py3-none-any.whl -
Subject digest:
f34dc978ac1c945112e52bbd5095ccac849bf6c81a140bd666cf00e500101c48 - Sigstore transparency entry: 621508287
- Sigstore integration time:
-
Permalink:
benomahony/ai-lsp@b57ee5efe799b6673f4d4aee256c02e3feb737ce -
Branch / Tag:
refs/heads/main - Owner: https://github.com/benomahony
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@b57ee5efe799b6673f4d4aee256c02e3feb737ce -
Trigger Event:
workflow_dispatch
-
Statement type: