Editors
sqlsift ships a language server, sqlsift-lsp, that shows diagnostics as you type. It reads sqlsift.toml from the workspace root, so the editor reports the same problems as the CLI, and files matched by ignore get no diagnostics.
Besides .sql files, the server checks:
- TypeScript and JavaScript (
typescript,typescriptreact,javascript,javascriptreactdocuments, or.ts,.tsx,.js,.jsx,.mts,.ctsfiles): the SQL in tagged template literals whose tag is inembedded_sql_tags(default["sql"]), assqlsift checkdoes. Files without such a template get no diagnostics, and hover and completion are only offered in SQL documents. - Rust (
rustdocuments, or.rsfiles): the SQL passed to sqlx's query macros andsqlx::query functions named inembedded_sql_macros, assqlsift checkdoes (see SQL in Rust (sqlx)). Files without such a query get no diagnostics. - Python (
pythondocuments, or.pyfiles): the SQL passed as a string literal to the calls named inembedded_sql_functions(cur.execute("..."),text("..."), ...), assqlsift checkdoes (see SQL in Python). Files without such a call get no diagnostics. - Go (
godocuments, or.gofiles): the SQL passed as a string literal to thedatabase/sql, sqlx and pgx calls named inembedded_sql_go_functions(db.QueryContext(ctx, "..."), ...), assqlsift checkdoes (see SQL in Go). Files without such a call get no diagnostics. - dbt models: Jinja templates are masked in
jinja-sqldocuments (the language the "dbt Power User" extension sets) and in any document with adbt_project.ymlin one of its parent directories, so a dbt project in a subdirectory of the workspace works too. An explicittemplatinginsqlsift.tomlapplies to every document.
VS Code
Install the sqlsift extension (sqlsift.sqlsift) from the Marketplace. Platform builds bundle the language server, so no extra setup is required. See editors/vscode for settings. It activates on SQL, jinja-sql, Jinja .sql files and, unless sqlsift.embeddedSql.enable is false, TypeScript, JavaScript, Rust, Python and Go files.
The extension provides commands in the command palette (Ctrl+Shift+P / Cmd+Shift+P):
- sqlsift: Restart Language Server (
sqlsift.restartServer): Restarts the language server. - sqlsift: Show Output (
sqlsift.showOutput): Opens the language server output channel.
Other editors
Install the server:
cargo install --git https://github.com/yukikotani231/sqlsift sqlsift-lsp
Then register sqlsift-lsp (it talks LSP over stdin/stdout, with no arguments) as a language server for SQL files (and, to check embedded SQL, for TypeScript and JavaScript files).
Neovim (nvim-lspconfig)
vim.lsp.config('sqlsift', {
cmd = { 'sqlsift-lsp' },
filetypes = { 'sql' },
root_markers = { 'sqlsift.toml', '.git' },
})
vim.lsp.enable('sqlsift')
Helix
# ~/.config/helix/languages.toml
[language-server.sqlsift]
command = "sqlsift-lsp"
[[language]]
name = "sql"
language-servers = ["sqlsift"]
Quick fixes
When your editor supports LSP code actions (e.g. VS Code's lightbulb, Neovim's vim.lsp.buf.code_action()), sqlsift-lsp offers quick fixes for diagnostics in .sql files:
- Disable
<RULE>for this line: inserts-- sqlsift:disable <RULE>above the diagnostic, indented to match the line. - Disable
<RULE>for this file: inserts-- sqlsift:disable-file <RULE>as the first line of the file.