diff options
Diffstat (limited to 'nvim/lua')
| -rw-r--r-- | nvim/lua/plugins/format.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/nvim/lua/plugins/format.lua b/nvim/lua/plugins/format.lua index ce3f4e7..714e887 100644 --- a/nvim/lua/plugins/format.lua +++ b/nvim/lua/plugins/format.lua | |||
| @@ -11,6 +11,15 @@ local stylua = { "stylua" } -- brew install stylua, pkg install stylua | |||
| 11 | local xmllint = { "xmllint" } -- xmllint ist Teil von libxml2 (standardmäßig installiert unter MacOS; pkg install libxml2) | 11 | local xmllint = { "xmllint" } -- xmllint ist Teil von libxml2 (standardmäßig installiert unter MacOS; pkg install libxml2) |
| 12 | local yamlfmt = { "yamlfmt" } -- brew install yamlfmt, pkg install yamlfmt | 12 | local yamlfmt = { "yamlfmt" } -- brew install yamlfmt, pkg install yamlfmt |
| 13 | 13 | ||
| 14 | -- prettier leitet den Parser aus dem Dateinamen ab: .json landet beim strikten | ||
| 15 | -- json-Parser, der Kommentare ablehnt. Im Filetype jsonc erzwingen wir deshalb | ||
| 16 | -- den kommentartoleranten jsonc-Parser (prettier >= 3.0). | ||
| 17 | local function prettier_parser_args(_, ctx) | ||
| 18 | if vim.bo[ctx.buf].filetype == "jsonc" then return { "--parser", "jsonc" } end | ||
| 19 | |||
| 20 | return {} | ||
| 21 | end | ||
| 22 | |||
| 14 | return { | 23 | return { |
| 15 | "stevearc/conform.nvim", | 24 | "stevearc/conform.nvim", |
| 16 | event = { "BufReadPre", "BufNewFile" }, | 25 | event = { "BufReadPre", "BufNewFile" }, |
| @@ -42,6 +51,11 @@ return { | |||
| 42 | xsd = xmllint, | 51 | xsd = xmllint, |
| 43 | yaml = yamlfmt, | 52 | yaml = yamlfmt, |
| 44 | }, | 53 | }, |
| 54 | formatters = { | ||
| 55 | prettier = { | ||
| 56 | prepend_args = prettier_parser_args, | ||
| 57 | }, | ||
| 58 | }, | ||
| 45 | default_format_opts = { | 59 | default_format_opts = { |
| 46 | lsp_format = "fallback", | 60 | lsp_format = "fallback", |
| 47 | }, | 61 | }, |
