sql-lsp 0.1.2

A high-performance, multi-dialect SQL Language Server Protocol (LSP) implementation in Rust.
Documentation
# SQL LSP

<div align="center">

A **high-performance**, **multi-dialect** SQL Language Server Protocol (LSP) implementation in Rust.

[![Rust](https://img.shields.io/badge/rust-1.70+-orange.svg)](https://www.rust-lang.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![CI](https://github.com/your-org/lsp_sqls/workflows/CI/badge.svg)](https://github.com/your-org/lsp_sqls/actions)

[Features](#-features) โ€ข [Quick Start](#-quick-start) โ€ข [Documentation](#-documentation) โ€ข [Contributing](#-contributing)

</div>

---

## โœจ 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 `tracing` framework

## ๐Ÿš€ Quick Start

### Installation

#### Option 1: Build from Source

```bash
git clone https://github.com/your-org/lsp_sqls.git
cd lsp_sqls
cargo build --release

# Binary location: target/release/sql-lsp
```

#### Option 2: Install via Cargo

```bash
cargo install --path .
```

### Basic Usage

```bash
# Start the LSP server
./target/release/sql-lsp

# With debug logging
RUST_LOG=debug ./target/release/sql-lsp
```

### Editor Integration

Choose your editor for detailed setup instructions:

- **[VS Code]docs/editor-integration.md#vs-code** - Extension or manual setup
- **[Neovim]docs/editor-integration.md#neovim** - nvim-lspconfig integration
- **[Vim]docs/editor-integration.md#vim-vim-lsp** - vim-lsp configuration
- **[Emacs]docs/editor-integration.md#emacs-lsp-mode** - lsp-mode setup
- **[Sublime Text]docs/editor-integration.md#sublime-text-lsp-package** - LSP package

## ๐Ÿ“– Documentation

### User Guides

- **[Configuration Guide]docs/configuration.md** - Schema and dialect configuration
- **[Editor Integration]docs/editor-integration.md** - Step-by-step editor setup
- **[Troubleshooting]docs/configuration.md#troubleshooting** - Common issues and solutions

### Developer Resources

- **[Architecture]ARCHITECTURE.md** - System design and components
- **[Contributing Guide]CONTRIBUTING.md** - How to contribute
- **[Error Handling]docs/error-handling.md** - Error handling strategies

## ๐ŸŽฏ Example

### Configure a Database Schema

```json
{
  "schemas": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "database": "my_app",
      "source_uri": "file:///path/to/schema.sql",
      "tables": [
        {
          "name": "users",
          "source_location": ["file:///path/to/schema.sql", 42],
          "columns": [
            {
              "name": "id",
              "data_type": "INT",
              "nullable": false,
              "comment": "Primary key"
            },
            {
              "name": "email",
              "data_type": "VARCHAR(255)",
              "nullable": false,
              "comment": "User email"
            }
          ],
          "comment": "User accounts"
        }
      ]
    }
  ]
}
```

### Features in Action

**Hover Information:**

```markdown
**Table**: `users`

User accounts

**Columns** (10)

- `id`: INT NOT NULL
- `email`: VARCHAR(255) NOT NULL
- `name`: VARCHAR(255) NOT NULL
  ...
```

**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

```bash
# Development build
cargo build

# Release build with optimizations
cargo build --release

# Run tests
cargo test

# Run linter
cargo clippy
```

### 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](CONTRIBUTING.md) for details.

### Quick Contribution Guide

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Make your changes
4. Run tests: `cargo test`
5. Commit: `git commit -m 'feat: add amazing feature'`
6. Push: `git push origin feature/amazing-feature`
7. 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](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- Built with [tower-lsp]https://github.com/ebkalderon/tower-lsp - LSP framework
- Powered by [tree-sitter]https://tree-sitter.github.io/ - Parser generator
- Formatted with [sqlformat]https://github.com/shssoichiro/sqlformat-rs - SQL formatter

## ๐Ÿ“ฌ Contact

- **Issues**: [GitHub Issues]https://github.com/your-org/lsp_sqls/issues
- **Discussions**: [GitHub Discussions]https://github.com/your-org/lsp_sqls/discussions

---

<div align="center">

Made with โค๏ธ by the SQL LSP community

</div>