diff options
| author | Thomas Schmucker <ts@its1.de> | 2026-09-07 12:00:01 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2026-09-07 12:00:01 +0200 |
| commit | 63f4955bec52f7f12a612d10ee3712796ef76ec6 (patch) | |
| tree | 7d6189db47b848750c84c5a2de07f90571c2c16d /nvim/lua/plugins/format.lua | |
| parent | 58ccb30bb172c7e42728fbe12be69c7505ee297f (diff) | |
| download | dotfiles-63f4955bec52f7f12a612d10ee3712796ef76ec6.tar.gz dotfiles-63f4955bec52f7f12a612d10ee3712796ef76ec6.tar.bz2 dotfiles-63f4955bec52f7f12a612d10ee3712796ef76ec6.zip | |
Unterstützung für jsonc
Diffstat (limited to 'nvim/lua/plugins/format.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 | }, |
