Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sql): disable sqls formatter and add sqlfluff #1336

Merged
merged 6 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lua/astrocommunity/pack/sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ This plugin pack does the following:

- Adds `sql` Treesitter parser
- Adds `sqls` language server
- `go` must be in your `PATH` and executable.
- `go` must be in your `PATH` and executable.
- formatting is disabled due to https://github.com/sqls-server/sqls/issues/149
- Adds [sqls.nvim](https://github.com/nanotee/sqls.nvim) for language specific tooling
- Adds `sqlfluff` for both formatting and linting (using the ANSI dialect)
59 changes: 57 additions & 2 deletions lua/astrocommunity/pack/sql/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,71 @@ return {
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "sqls" })
end,
},
{
"jay-babu/mason-null-ls.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "sqlfluff" })
opts.handlers = {
sqlfluff = function()
local null_ls = require "null-ls"
null_ls.register(null_ls.builtins.diagnostics.sqlfluff.with {
extra_args = { "--dialect", "ansi" },
})
null_ls.register(null_ls.builtins.formatting.sqlfluff.with {
extra_args = { "--dialect", "ansi" },
})
end,
}
end,
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "sqls" })
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "sqlfluff", "sqls" })
end,
},
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
sql = { "sqlfluff" },
},
formatters = {
sqlfluff = {
args = { "fix", "--dialect=ansi", "-" },
require_cwd = false,
},
},
},
},
{
"mfussenegger/nvim-lint",
optional = true,
opts = {
linters_by_ft = {
sql = { "sqlfluff" },
},
},
},
{
"AstroNvim/astrolsp",
opts = {
config = {
sqls = {
on_attach = function(client)
-- Disable formatting due to bugs: https://github.com/sqls-server/sqls/issues/149
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
},
},
},
},
{
"nanotee/sqls.nvim",
lazy = true,
dependencies = {
"AstroNvim/astrocore",
opts = {
Expand Down