Interactive setup for SQL LSP development environment
Sets up SQL development environment with sql-language-server for LSP features and sqlfluff for linting/formatting. Use this when you need intelligent SQL autocomplete, error checking, and consistent code formatting in your project.
/plugin marketplace add zircote/sql-lsp/plugin install sql-lsp@zircote-lspThis command will configure your SQL development environment with sql-language-server LSP and sqlfluff for linting and formatting.
Verify you have Node.js and Python installed:
node --version
python --version || python3 --version
npm install -g sql-language-server
Verify installation:
sql-language-server --version
pip install sqlfluff
Or with pipx for isolated installation:
pipx install sqlfluff
Verify installation:
sqlfluff --version
Create a .sqlfluff configuration file in your project root:
cat > .sqlfluff << 'EOF'
[sqlfluff]
# Set your SQL dialect
dialect = postgres
# Options: postgres, mysql, sqlite, bigquery, redshift, snowflake, tsql, etc.
[sqlfluff:rules]
max_line_length = 120
indent_unit = space
tab_space_size = 4
[sqlfluff:rules:L010]
# Keywords should be upper case
capitalisation_policy = upper
[sqlfluff:rules:L030]
# Function names should be upper case
capitalisation_policy = upper
[sqlfluff:rules:L014]
# Unquoted identifiers should be lower case
capitalisation_policy = lower
EOF
Check that .lsp.json exists and is properly configured:
cat .lsp.json
Expected configuration:
{
"sql": {
"command": "sql-language-server",
"args": ["up", "--method", "stdio"],
"extensionToLanguage": {
".sql": "sql"
},
"transport": "stdio"
}
}
Test sqlfluff on a sample SQL file:
# Create test file
cat > test.sql << 'EOF'
select * from users where id = 1;
EOF
# Lint the file
sqlfluff lint test.sql
# Format the file
sqlfluff format test.sql
# Clean up
rm test.sql
sqlfluff supports multiple SQL dialects. Configure in .sqlfluff:
postgres - PostgreSQLmysql - MySQL/MariaDBsqlite - SQLitebigquery - Google BigQueryredshift - Amazon Redshiftsnowflake - Snowflaketsql - Microsoft SQL Server / T-SQLoracle - Oracle SQLdb2 - IBM DB2sparksql - Apache Spark SQLhive - Apache Hiveclickhouse - ClickHouseathena - AWS Athena# Install both tools
npm install -g sql-language-server
pip install sqlfluff
node --versionnpm config get prefixpython --versionpip show sqlfluffpython -m pip install sqlfluff.sql files exist in your project.sqlfluff matches your SQL flavorsqlfluff lint yourfile.sqlAfter setup, verify everything works:
# Check installations
sql-language-server --version
sqlfluff --version
# Verify LSP config
cat .lsp.json
# Test sqlfluff
echo "SELECT * FROM users;" | sqlfluff lint -
All commands should complete successfully without errors.