sqlchisel works best with editor integrations that send buffer contents to stdin and read formatted SQL from stdout.
local conform = require("conform")
conform.setup({
formatters_by_ft = { sql = { "sqlchisel" } },
formatters = {
sqlchisel = {
command = "sqlchisel",
args = { "--stdin", "--format" },
stdin = true,
},
},
})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.sql",
callback = function(args)
conform.format({ bufnr = args.buf })
end,
})- Send the current buffer on stdin
- Invoke
sqlchisel --stdin --format - Replace the buffer with stdout on success
- Pass
--dialect dremiofor Dremio SQL files