SQL Language Server

1.7.1 · active · verified Sun Apr 19

sql-language-server is an implementation of the Language Server Protocol (LSP) providing intelligent features for various SQL dialects, including linting, autocompletion, and schema introspection. It is designed to be run as a standalone server process, enabling integration with code editors and IDEs (like VS Code) that support LSP. The current stable version is 1.7.1, with minor releases appearing to follow a monthly or bi-monthly cadence, indicating active development. Key differentiators include its pluggable architecture for different SQL database clients (e.g., PostgreSQL, SQLite, BigQuery) and its focus on robust parsing and error handling, making it a valuable tool for SQL development workflows. It ships with TypeScript types, facilitating its use in TypeScript-based environments.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to install the SQL Language Server globally and run it via standard I/O. Includes a commented example of how an LSP client in a VS Code extension might programmatically start and connect to the server process.

npm install -g sql-language-server

# To run the language server, typically it's invoked by an LSP-enabled editor
# or manually via standard I/O (stdio) for debugging/testing:
sql-language-server --stdio

# Example of how an LSP client (e.g., in a VS Code extension) might start it:
// In a client-side extension's activate() function:
// import * as path from 'path';
// import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient/node';

// let serverModule = context.asAbsolutePath(path.join('node_modules', 'sql-language-server', 'lib', 'main.js'));
// let debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };

// let serverOptions: ServerOptions = {
// 	run: { module: serverModule, transport: TransportKind.stdio },
// 	debug: { module: serverModule, transport: TransportKind.stdio, options: debugOptions }
// };

// let clientOptions: LanguageClientOptions = {
// 	documentSelector: [{ scheme: 'file', language: 'sql' }],
// 	synchronize: { fileEvents: workspace.createFileSystemWatcher('**/.sql') }
// };

// let client = new LanguageClient('sqlLanguageServer', 'SQL Language Server', serverOptions, clientOptions);
// client.start();

view raw JSON →