aboutsummaryrefslogtreecommitdiff
path: root/nvim/lua/plugins/format.lua
blob: 31533b62b2b2b088946af6b0f9b50bae50887d53 (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
return {
  "stevearc/conform.nvim",
  event = { "BufReadPre", "BufNewFile" },
  keys = {
    {
      "<leader>cf",
      function()
        require("conform").format({ async = true })
      end,
      desc = "Format file",
    },
  },
  opts = {
    formatters_by_ft = {
      awk = { "gawk" }, -- brew install gawk, pkg install gawk
      bash = { "shfmt" }, -- brew install shfmt, pkg install shfmt
      c = {}, -- clangd
      cpp = {}, -- clangd
      javascript = { "prettier" }, -- (siehe "typescript")
      json = { "jq" }, -- brew install jq, pkg install jq
      lua = { "stylua" }, -- brew install stylua, pkg install stylua
      python = { "ruff_format" }, -- brew install ruff, pkg install ruff
      sh = { "shfmt" }, -- brew install, pkg install shfmt
      typescript = { "prettier" }, -- npm install -g prettier
      xml = { "xmllint" }, -- xmllint ist Teil von libxml2 (standardmäßig installiert unter MacOS; pkg install libxml2)
      xsd = { "xmllint" },
      yaml = { "yamlfmt" }, -- brew install yamlfmt, pkg install yamlfmt
    },
    default_format_opts = {
      lsp_format = "fallback",
    },
  },
}