conform.nvim icon indicating copy to clipboard operation
conform.nvim copied to clipboard

help: configure sqlfluff for dbt

Open Velrok opened this issue 9 months ago • 1 comments

Hi. I've tried to configure sqlfluff with DBT support but I keep getting this error:

2025-05-13 15:35:53[ERROR] Formatter 'sqlfluff' error: 
User Error: The dbt templater does not support stdin input, provide a path instead

Here is my config:

return {
  "stevearc/conform.nvim",
  config = function()
    local opts = {
      format_on_save = {
        lsp_format = "prefer",
        timeout_ms = 500,
      },
      default_format_opts = {
        lsp_format = "prefer",
      },
      formatters = {
        sqlfluff = { stdin = false } -- not sure this is getting picked up
      },
      formatters_by_ft = {
        javascript = { "prettier" },
        typescript = { "prettier" },
        sql = { "sqlfluff" },
      },
    }

    require("conform").setup(opts)
  end,
}

This is not really a bug or feature request.

I could not find anything on the internet so at least having an answer here might others find a resolution.

Velrok avatar May 13 '25 14:05 Velrok

You'll also have to change the arguments passed in to sqlfluff. Try this:

sqlfluff = {
  stdin = false,
  args = { "fix", "$FILENAME" }
}

stevearc avatar May 14 '25 00:05 stevearc