dots

my dotfiles
git clone https://git.awy.one/dots
Log | Files | Refs | Submodules | README | LICENSE

conform.lua (1331B) - View raw


 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
34
35
36
37
38
39
40
41
42
43
44
return {
  'stevearc/conform.nvim',
  opts = {},
  config = function()
    require("conform").setup({
      formatters_by_ft = {
        lua = { "stylua" },
        -- Conform will run multiple formatters sequentially
        python = { "isort", "black" },
        -- You can customize some of the format options for the filetype (:help conform.format)
        rust = { "rustfmt", lsp_format = "fallback" },
        -- Conform will run the first available formatter
        javascript = { "prettierd", "prettier", stop_after_first = true },
        c = { "clang-format" },
        cpp = { "clang-format" },
        sh = { "shfmt" },
        bash = { "shfmt" },
      },
      formatters = {
        ["clang-format"] = {
          prepend_args = {
            [[--style={
              BasedOnStyle: LLVM,
              BreakBeforeBraces: Custom,
              BraceWrapping: { AfterFunction: true },
            }]],
          },
        },
        ["rustfmt"] = {
          prepend_args = {
            "--config", "tab_spaces=2",
            "--config", "hard_tabs=false",
          },
        },
      },
      default_format_opts = {
        lsp_format = "fallback",
      },
    })
    vim.keymap.set('n', '<leader>lf', function()
      require("conform").format({ async = true })
    end, { desc = "Format buffer" })
  end
}