SQL LSP
A high-performance, multi-dialect SQL Language Server Protocol (LSP) implementation in Rust.
Features • Quick Start • Documentation • Contributing
✨ Features
Core Capabilities
- 🎯 Multi-Dialect Support - MySQL, PostgreSQL, Hive, ClickHouse, Elasticsearch (EQL/DSL), Redis
- 🔍 Intelligent Completion - Context-aware suggestions for keywords, tables, columns, and functions
- 📍 Code Navigation - Go-to-definition with source location tracking
- 🔎 Find References - Locate all usages of tables and columns
- ⚡ Real-Time Diagnostics - Instant syntax error detection as you type
- 🎨 SQL Formatting - Professional formatting with customizable options
- 📊 Rich Hover Information - Detailed schema information in Markdown format
Advanced Features
- � Runtime Configuration - Update schemas without restarting the server
- 📝 Incremental Sync - Efficient text synchronization for large files
- 🌳 AST-Based Analysis - Tree-sitter powered parsing for accuracy
- 🧵 Thread-Safe - Concurrent request handling
- 📦 Schema Management - Auto-inference with priority-based matching
- 📋 Structured Logging - Observable with
tracingframework
🚀 Quick Start
Installation
Option 1: Build from Source
# Binary location: target/release/sql-lsp
Option 2: Install via Cargo
Basic Usage
# Start the LSP server
# With debug logging
RUST_LOG=debug
Editor Integration
Choose your editor for detailed setup instructions:
- VS Code - Extension or manual setup
- Neovim - nvim-lspconfig integration
- Vim - vim-lsp configuration
- Emacs - lsp-mode setup
- Sublime Text - LSP package
📖 Documentation
User Guides
- Configuration Guide - Schema and dialect configuration
- Editor Integration - Step-by-step editor setup
- Troubleshooting - Common issues and solutions
Developer Resources
- Architecture - System design and components
- Contributing Guide - How to contribute
- Error Handling - Error handling strategies
🎯 Example
Configure a Database Schema
Features in Action
Hover Information:
**Table**: `users`
User accounts
**Columns** (10)
- --
Intelligent Completion:
- Keywords based on context (SELECT, FROM, WHERE, etc.)
- Tables from your schema
- Columns context-aware (knows which table you're querying)
- Functions with parameter hints
🛠 Development
Prerequisites
- Rust 1.70 or later
- Cargo
Build
# Development build
# Release build with optimizations
# Run tests
# Run linter
Project Structure
lsp_sqls/
├── src/
│ ├── main.rs # Entry point
│ ├── server.rs # LSP server
│ ├── dialect.rs # Dialect trait
│ ├── dialects/ # SQL dialect implementations
│ ├── parser/ # SQL parsers (tree-sitter)
│ ├── schema.rs # Schema management
│ └── token.rs # Token definitions
├── docs/ # Documentation
├── tests/ # Integration tests
└── scripts/ # Helper scripts
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Quick Contribution Guide
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Run tests:
cargo test - Commit:
git commit -m 'feat: add amazing feature' - Push:
git push origin feature/amazing-feature - Open a Pull Request
� Supported SQL Dialects
| Dialect | Status | Notes |
|---|---|---|
| MySQL | ✅ Full support | MySQL 5.7+ syntax |
| PostgreSQL | ✅ Full support | PostgreSQL 12+ syntax |
| Hive | ✅ Full support | HiveQL syntax |
| ClickHouse | ✅ Full support | ClickHouse SQL |
| Elasticsearch EQL | ✅ Full support | Event Query Language |
| Elasticsearch DSL | ✅ Full support | Query DSL (JSON) |
| Redis | ✅ Basic support | Redis commands |
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built with tower-lsp - LSP framework
- Powered by tree-sitter - Parser generator
- Formatted with sqlformat - SQL formatter
📬 Contact
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with ❤️ by the SQL LSP community