diff options
Diffstat (limited to 'nvim/lua/plugins/format.lua')
| -rw-r--r-- | nvim/lua/plugins/format.lua | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/nvim/lua/plugins/format.lua b/nvim/lua/plugins/format.lua index 714e887..476e513 100644 --- a/nvim/lua/plugins/format.lua +++ b/nvim/lua/plugins/format.lua | |||
| @@ -5,21 +5,13 @@ local djlint = { "djlint" } -- pipx install djlint (macOS & FreeBSD); unter Wind | |||
| 5 | local gawk = { "gawk" } -- brew install gawk, pkg install gawk | 5 | local gawk = { "gawk" } -- brew install gawk, pkg install gawk |
| 6 | local jq = { "jq" } -- brew install jq, pkg install jq | 6 | local jq = { "jq" } -- brew install jq, pkg install jq |
| 7 | local prettier = { "prettier" } -- npm install -g prettier | 7 | local prettier = { "prettier" } -- npm install -g prettier |
| 8 | local prettier_jsonc = { "prettier_jsonc" } -- prettier-Variante, konfiguriert unter opts.formatters | ||
| 8 | local ruff = { "ruff_format" } -- brew install ruff, pkg install ruff | 9 | local ruff = { "ruff_format" } -- brew install ruff, pkg install ruff |
| 9 | local shfmt = { "shfmt" } -- brew install shfmt, pkg install shfmt | 10 | local shfmt = { "shfmt" } -- brew install shfmt, pkg install shfmt |
| 10 | local stylua = { "stylua" } -- brew install stylua, pkg install stylua | 11 | 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) | 12 | 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 | 13 | local yamlfmt = { "yamlfmt" } -- brew install yamlfmt, pkg install yamlfmt |
| 13 | 14 | ||
| 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 | |||
| 23 | return { | 15 | return { |
| 24 | "stevearc/conform.nvim", | 16 | "stevearc/conform.nvim", |
| 25 | event = { "BufReadPre", "BufNewFile" }, | 17 | event = { "BufReadPre", "BufNewFile" }, |
| @@ -42,7 +34,7 @@ return { | |||
| 42 | javascript = prettier, | 34 | javascript = prettier, |
| 43 | jinja = djlint, | 35 | jinja = djlint, |
| 44 | json = jq, | 36 | json = jq, |
| 45 | jsonc = prettier, | 37 | jsonc = prettier_jsonc, |
| 46 | lua = stylua, | 38 | lua = stylua, |
| 47 | python = ruff, | 39 | python = ruff, |
| 48 | sh = shfmt, | 40 | sh = shfmt, |
| @@ -52,8 +44,9 @@ return { | |||
| 52 | yaml = yamlfmt, | 44 | yaml = yamlfmt, |
| 53 | }, | 45 | }, |
| 54 | formatters = { | 46 | formatters = { |
| 55 | prettier = { | 47 | prettier_jsonc = { |
| 56 | prepend_args = prettier_parser_args, | 48 | inherit = "prettier", |
| 49 | prepend_args = { "--parser", "jsonc" }, | ||
| 57 | }, | 50 | }, |
| 58 | }, | 51 | }, |
| 59 | default_format_opts = { | 52 | default_format_opts = { |
