aboutsummaryrefslogtreecommitdiff
path: root/autoload/formatter.kak
blob: 741e9e8b9fc2fe087996865507059deb4bb73691 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# TODO: Use a single hook?
hook global BufSetOption filetype=json %{ set-option buffer formatcmd "jq" }
hook global BufSetOption filetype=fennel %{ set-option buffer formatcmd "fnlfmt -" }
hook global BufSetOption filetype=nix %{ set-option buffer formatcmd "nixfmt -" }
hook global BufSetOption filetype=(?:javascript|typescript) %{
  evaluate-commands %sh{
    if [ -f "$PWD/biome.json" ]; then
      echo "set-option buffer formatcmd %{npx biome check --fix --stdin-file-path=$kak_buffile 2>/dev/null}"
    fi
  }
}
hook global BufSetOption filetype=(?:ruby) %{
  evaluate-commands %sh{
    if [ -f "$PWD/.rubocop.yml" ]; then
      echo "set-option buffer formatcmd %{rubocop -x --stderr -s '$kak_buffile'}"
    fi
  }
}