diff --git a/.config/kak/autoload/filetype.kak b/.config/kak/autoload/filetype.kak index 80db42a6..3818a38b 100644 --- a/.config/kak/autoload/filetype.kak +++ b/.config/kak/autoload/filetype.kak @@ -11,8 +11,64 @@ hook global WinSetOption filetype=python %{ } } +hook global WinSetOption filetype=yaml %{ + set-option window formatcmd %{ + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin yaml + else + dprint fmt --stdin yaml --config "$HOME/.dprint.jsonc" + fi + } +} + +hook global WinSetOption filetype=html %{ + set-option window formatcmd %{ + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin html + else + dprint fmt --stdin html --config "$HOME/.dprint.jsonc" + fi + } +} + +hook global WinSetOption filetype=css %{ + set-option window formatcmd %{ + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin css + else + dprint fmt --stdin css --config "$HOME/.dprint.jsonc" + fi + } +} + +hook global WinSetOption filetype=json %{ + set-option window formatcmd %{ + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin json + else + dprint fmt --stdin json --config "$HOME/.dprint.jsonc" + fi + } +} + +hook global WinSetOption filetype=jsonc %{ + set-option window formatcmd %{ + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin jsonc + else + dprint fmt --stdin jsonc --config "$HOME/.dprint.jsonc" + fi + } +} + hook global WinSetOption filetype=toml %{ - set-option window formatcmd "taplo fmt -" + set-option window formatcmd %{ + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin toml + else + dprint fmt --stdin toml --config "$HOME/.dprint.jsonc" + fi + } # hook -group toml-auto-format window BufWritePre .* %{ # try format # } diff --git a/.config/kak/autoload/filetype/markdown.kak b/.config/kak/autoload/filetype/markdown.kak index 9a2d5f53..5a99aefc 100644 --- a/.config/kak/autoload/filetype/markdown.kak +++ b/.config/kak/autoload/filetype/markdown.kak @@ -1,11 +1,14 @@ hook global WinSetOption filetype=markdown %{ # explicitly load to avoid race condition require-module markdown - # set-option window formatcmd "dprint fmt --stdin md" set-option window formatcmd %{ - dprint fmt --stdin md || dprint fmt --stdin md --config '/home/fic/.dprint.jsonc' -L info + if dprint output-resolved-config >/dev/null 2>&1; then + dprint fmt --stdin md + else + dprint fmt --stdin md --config "$HOME/.dprint.jsonc" + fi } - hook -group markdown-auto-format window BufWritePre .* format + hook -group markdown-auto-format window BufWritePre .* { format } # override formatting commands define-command -override -hidden markdown-trim-indent %{ diff --git a/.dprint.jsonc b/.dprint.jsonc index cb4baee0..f8b3750b 100644 --- a/.dprint.jsonc +++ b/.dprint.jsonc @@ -1,22 +1,21 @@ { "markdown": { "lineWidth": 80, - "textWrap": "always" + "textWrap": "always", }, "dockerfile": {}, "markup": {}, "excludes": [ "**/node_modules", - "**/*-lock.json" + "**/*-lock.json", ], "plugins": [ - // "https://plugins.dprint.dev/typescript-0.93.3.wasm", - // "https://plugins.dprint.dev/json-0.19.4.wasm", - "https://plugins.dprint.dev/markdown-0.17.8.wasm", - // "https://plugins.dprint.dev/toml-0.6.4.wasm", - "https://plugins.dprint.dev/dockerfile-0.3.2.wasm", + "https://plugins.dprint.dev/markdown-0.19.0.wasm", + "https://plugins.dprint.dev/dockerfile-0.3.3.wasm", "https://plugins.dprint.dev/g-plane/malva-v0.11.1.wasm", - "https://plugins.dprint.dev/g-plane/markup_fmt-v0.18.0.wasm", - "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm" - ] -} \ No newline at end of file + "https://plugins.dprint.dev/g-plane/markup_fmt-v0.22.0.wasm", + "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm", + "https://plugins.dprint.dev/json-0.20.0.wasm", + "https://plugins.dprint.dev/toml-0.7.0.wasm", + ], +} diff --git a/.editorconfig b/.editorconfig index 50bf2dd3..7e9cfb69 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,6 +8,10 @@ end_of_line = lf # indent_style=space # indent_size=4 +[*.{json,jsonc}] +indent_style = space +indent_size = 2 + [*.py] indent_style = space indent_size = 4