aboutsummaryrefslogtreecommitdiff
path: root/nvim/custom/configs/conform.lua
blob: 550b65936fa8474994737ae4a913a99c94662fe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--type conform.options
local util = require("conform.util")

local options = {
  lsp_fallback = true,

  formatters_by_ft = {
    lua = { "stylua" },

    javascript = { "prettier", "eslint" },
    javascriptreact = { "prettier", "eslint" },
    css = { "prettier" },
    html = { "prettier" },

    sh = { "shfmt" },
  },

  format_on_save = {
    -- These options will be passed to conform.format()
    timeout_ms = 1000,
    lsp_fallback = true,
  },

  formatters = {
    eslint = {
      command = util.from_node_modules("eslint"),
      args = { "$FILENAME", "--fix" },
      cwd = util.root_file({
        "package.json",
        ".eslintrc.cjs"
      }),
    }
  }
}

require("conform").setup(options)