aboutsummaryrefslogtreecommitdiffstats
path: root/doc/formatter_options.md
blob: e5c8493ea765408cea19e7a694d0b8853bda6f3b (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Formatter Options

<!-- TOC -->

- [injected](#injected)
- [prettier](#prettier)

<!-- /TOC -->

All formatters can be customized by directly changing the command, args, or other values (see [customizing formatters](../README.md#customizing-formatters)). Some formatters have a bit more advanced logic built in to those functions and expose additional configuration options. You can pass these values in like so:

```lua
-- Customize the "injected" formatter
require("conform").formatters.injected = {
  -- Set the options field
  options = {
    -- Set individual option values
    ignore_errors = true,
    lang_to_formatters = {
      json = { "jq" },
    },
  },
}
```

<!-- OPTIONS -->

## injected

```lua
options = {
  -- Set to true to ignore errors
  ignore_errors = false,
  -- Map of treesitter language to file extension
  -- A temporary file name with this extension will be generated during formatting
  -- because some formatters care about the filename.
  lang_to_ext = {
    bash = "sh",
    c_sharp = "cs",
    elixir = "exs",
    javascript = "js",
    julia = "jl",
    latex = "tex",
    markdown = "md",
    python = "py",
    ruby = "rb",
    rust = "rs",
    teal = "tl",
    typescript = "ts",
  },
  -- Map of treesitter language to formatters to use
  -- (defaults to the value from formatters_by_ft)
  lang_to_formatters = {},
}
```

## prettier

```lua
options = {
  -- Use a specific prettier parser for a filetype
  -- Otherwise, prettier will try to infer the parser from the file name
  ft_parsers = {
    --     javascript = "babel",
    --     javascriptreact = "babel",
    --     typescript = "typescript",
    --     typescriptreact = "typescript",
    --     vue = "vue",
    --     css = "css",
    --     scss = "scss",
    --     less = "less",
    --     html = "html",
    --     json = "json",
    --     jsonc = "json",
    --     yaml = "yaml",
    --     markdown = "markdown",
    --     ["markdown.mdx"] = "mdx",
    --     graphql = "graphql",
    --     handlebars = "glimmer",
  },
  -- Use a specific prettier parser for a file extension
  ext_parsers = {
    -- qmd = "markdown",
  },
}
```

<!-- /OPTIONS -->