aboutsummaryrefslogtreecommitdiff
path: root/lua/pml68/plugins/guard.lua
blob: 7bdc7a7f731f79fb6aea4fed503a267ff708db64 (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
return {
  "nvimdev/guard.nvim",
  dependencies = {
    "nvimdev/guard-collection"
  },
  event = { "BufReadPost", "BufNewFile" },
  config = function()
    local ft = require("guard.filetype")

    ft("c,cpp,h"):fmt("clang-format")
    ft("rust"):fmt("rustfmt")
    ft("json"):fmt({
      cmd = "jq",
      stdin = true
    })
    ft("go"):fmt({
      cmd = "golines",
      args = { "--max-len=80", "--base-formatter=gofumpt" },
      stdin = true,
    })
    vim.g.guard_config = {
      fmt_on_save = true,
      lsp_as_default_formatter = true
    }
  end
}