summaryrefslogtreecommitdiff
path: root/fnl/plugins/editor/conform.fnl
blob: fa344dcef9bf473147d8be1e05cdc0a47c4190d5 (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
;; Formatting

(fn init []
  (vim.keymap.set [:n :v] :<leader>e
                  (lambda []
                    (let [conform (require :conform)]
                      (conform.format {:lsp_fallback true :async true})))
                  {:desc :Format}))

(fn config []
  (let [conform (require :conform)]
    (conform.setup {:formatters {:fnlfmt {:command :fnlfmt
                                          :args [:--fix :$FILENAME]
                                          :stdin false}}
                    :formatters_by_ft {:* [:codespell]
                                       :_ [:trim_whitespace :trim_newlines]
                                       :css [:stylelint]
                                       :fennel [:fnlfmt]
                                       :haskell [:fourmolu]
                                       :html [:djlint]
                                       :json [:jq]
                                       :lua [:stylua]
                                       :markdown [:cbfmt]
                                       :ocaml [:ocamlformat]
                                       :org [:cbfmt]
                                       :python [:ruff_format]
                                       :rust [:rustfmt]
                                       :sh [:shfmt :shellharden]
                                       :sql [:pg_format :sqlfluff]
                                       :toml [:taplo]
                                       :yaml [:yamlfmt]}})))

{1 :stevearc/conform.nvim : init : config :event [:BufReadPost :BufNewFile]}