blob: a3cbcb38bdb5bd9b8343be90b7f76175df2e6303 (
plain) (
blame)
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
|
declare-option str formatlspserver;
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=ruby %{
set-option buffer formatcmd "bundle exec rubocop -a --stderr --stdin '%val{buffile}'"
}
hook global BufSetOption filetype=(?:javascript|typescript|jsx|tsx) %{
set-option buffer formatcmd "biome format --stdin-file-path='%val{buffile}'"
}
hook global BufSetOption filetype=(?:c|cpp) %{
set-option buffer formatcmd "clang-format --assume-filename='%val{buffile}'"
}
define-command apply-formatting -docstring 'Apply formatting with formatcmd or lsp' %{
eval %sh{
if [ -n "$kak_opt_formatcmd" ]; then
echo format-buffer
elif [ -n "$kak_opt_formatlspserver" ]; then
echo "lsp-formatting-sync $kak_opt_formatlspserver"
else
echo lsp-formatting-sync
fi
}
}
define-command biome -params .. -docstring 'Format project using biome' %{
info %sh{ npx biome check --fix "$@" && echo "Success" || echo "Failed" }
}
|