coc-sql
Heyward FannSQL extension for coc.nvim
A practical first workflow
Choose coc-sql for formatting SQL text and checking whether its syntax can be parsed. Its formatter and parser do not connect to your database. A clean diagnostic list does not prove that a table exists, that a query has the right permissions, or that running it is safe.
Format a small query, then check syntax
Install with :CocInstall coc-sql. Save the following as example.sql and confirm :set filetype? reports sql:
| 1 | select name, age from users where age >= 18 order by name; |
Run :CocCommand sql.Format. The query should be laid out across clauses with indentation; exact keyword casing depends on your format options. No database or users table is required for this text-only operation. Review the edit before saving.
For a separate parser check, temporarily remove users after from and inspect :CocDiagnostics, then restore the original query. If the project uses dialect-specific syntax, set sql.database to the appropriate supported dialect before treating a parser message as a database error.
If formatting works but syntax messages do not update, inspect sql.lintOnOpen, sql.lintOnChange and sql.lintOnSave. If your save action produces competing edits, choose one formatting provider. A project .sql-formatter.json takes precedence over sql.formatOptions; sql.database selects the lint dialect. Check the formatter’s own language option when the formatting dialect also needs to change.
Checked against the 0.15.0 configuration and upstream implementation. Expected formatting and parser results are example checks, not a recorded database execution.
Site-authored guidance reviewed on 2026-09-11. Content sources and maintainers · Choose extension responsibilities
Published Package Summary
coc-sql
SQL extension for coc.nvim
Features
- Format by sql-formatter
- Lint by node-sql-parser
Install
:CocInstall coc-sql
Usage
Format document
:call CocAction('format'):CocCommand sql.Format
Format selected content
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
License
MIT
- SQL extension for coc.nvim
- onLanguage:sql
Want to build, test, or contribute to coc.nvim extensions? Explore our official SDK and testing toolkits.
Open Developer GuideVersion History
This published npm package does not include a history.md or changelog.md file. Browse its npm versions or repository releases for available release information.
Contributed Commands
All contributes.commands entries from the published package manifest for coc-sql@0.15.0.
| Command (:CocCommand) | Description |
|---|---|
| sql.Format | Format sql file by sql-formatter |
Configuration Schema
All contributes.configuration entries from the published package manifest, including each raw property schema for coc-settings.json.
Raw JSON Schema
{
"enum": [
"athena",
"bigquery",
"db2",
"flinksql",
"hive",
"mysql",
"mariadb",
"postgresql",
"redshift",
"snowflake",
"sqlite",
"transactsql"
],
"type": "string",
"default": "guess",
"description": "Define the database to lint"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Lint sql file on opening"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Lint sql file on save"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Lint sql file on change"
}Raw JSON Schema
{
"type": "object",
"default": {},
"description": "Format options passed to sql-formatter, check https://github.com/sql-formatter-org/sql-formatter#configuration-options"
}