From 51c4020b3f2e6396ee1569d4b749238e943ad64c Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Mon, 10 Jun 2024 23:54:21 +0200 Subject: [PATCH] kak: update config --- config/kak/kakrc | 86 +++++++++++++++++-------------- config/kak/plugins/powerline.kak | 1 - config/kak/plugins/shellcheck.kak | 1 - 3 files changed, 46 insertions(+), 42 deletions(-) delete mode 160000 config/kak/plugins/powerline.kak delete mode 160000 config/kak/plugins/shellcheck.kak diff --git a/config/kak/kakrc b/config/kak/kakrc index 2c725d1b..1612caf6 100644 --- a/config/kak/kakrc +++ b/config/kak/kakrc @@ -15,7 +15,6 @@ hook global NormalKey y %{ nop %sh{ # ────────────────────────────────────────────────────────────────────────────── hook global BufOpenFile .* %{ modeline-parse - editorconfig-load } hook global BufCreate [^*].* %{ @@ -61,7 +60,6 @@ plug "andreyorst/plug.kak" noload hook global WinSetOption filetype=(makefile|gas) noexpandtab hook global WinSetOption filetype=(c|cpp) smarttab } - plug "whereswaldon/shellcheck.kak" plug "occivink/kakoune-sudo-write" plug "occivink/kakoune-find" plug "foot.kak" @@ -77,6 +75,44 @@ plug "andreyorst/plug.kak" noload } +# Enable some linting and formatting +# ────────────────────────────────────────────────────────────────────────────── + hook global WinSetOption filetype=js %{ + set window formatcmd 'npx prettier --stdin-filepath $kak_buffile;' + } + hook global WinSetOption filetype=css %{ + set window formatcmd 'npx prettier --parser css' + } + hook global WinSetOption filetype=scss %{ + set window formatcmd 'npx prettier --parser scss' + } + hook global WinSetOption filetype=less %{ + set window formatcmd 'npx prettier --parser less' + } + hook global WinSetOption filetype=html %{ + set window formatcmd 'npx prettier --parser html' + } + hook global WinSetOption filetype=json %{ + set window formatcmd 'npx prettier --parser json' + } + hook global WinSetOption filetype=md %{ + set window formatcmd 'npx prettier --parser md' + } + hook global WinSetOption filetype=sh %{ + # needs shfmt: $ go install mvdan.cc/sh/v3/cmd/shfmt@latest + set-option buffer formatcmd "shfmt" + set-option window lintcmd "shellcheck -fgcc -Cnever" + } + hook global WinSetOption filetype=yaml %{ + set window formatcmd 'npx prettier --parser yaml' + set-option window lintcmd %{ + run() { + # change [message-type] to message-type: + yamllint -f parsable "$1" | sed 's/ \[\(.*\)\] / \1: /' + } && run } + } + + # Look and Feel # ────────────────────────────────────────────────────────────────────────────── add-highlighter global/trailing-whitespace regex '\h+$' 0:Error # trailing whitespaces in red @@ -113,14 +149,14 @@ define-command clean-buffer -docstring 'Replace tabs with spaces and trim traili execute-keys -draft \%@s\h+$d } } # Bring back and from Vim to increment/decrement the number under the cursor -define-command -hidden -params 2 inc %{ try %{ - evaluate-commands %sh{ - [ "$1" = 0 ] && count=1 || count="$1" - printf '%s%s' 'exec h"_/\dna' "$2($count)|{catecho}|bc" - } -} catch %{ - execute-keys l -}} +# define-command -hidden -params 2 inc %{ try %{ +# evaluate-commands %sh{ +# [ "$1" = 0 ] && count=1 || count="$1" +# printf '%s%s' 'exec h"_/\dna' "$2($count)|{catecho}|bc" +# } +# } catch %{ +# execute-keys l +# }} # Various mappings @@ -190,33 +226,3 @@ set-option global foot_panel_cmd 'foot' # ────────────────────────────────────────────────────────────────────────────── import languagecmd -# Reload kakrc and .kak when saving. -# ────────────────────────────────────────────────────────────────────────────── -# Adds -override to definitions (unless they seem to be python defs!) -# Evals provide module directly - -def resource -params 1 %{ - eval %sh{ - file=$(dirname "$1")/.reload.kak - cat "$1" | - sed 's/^def \([^:]*\)$/def -override \1/' | - sed 's/^define-command /def -override /' | - sed 's/^addhl /addhl -override/' | - sed 's/^add-highlighter /addhl -override /' | - sed 's/^provide-module \w\+ /eval /' | - cat > "$file" - printf %s " - source $file - nop %sh{ - rm $file - } - " - } - echo Reloaded %arg{1} -} - -rmhooks global reload-kak -hook -group reload-kak global BufWritePost (.*kakrc|.*\.kak) %{ - resource %val{hook_param} -} - diff --git a/config/kak/plugins/powerline.kak b/config/kak/plugins/powerline.kak deleted file mode 160000 index e5e9a0e5..00000000 --- a/config/kak/plugins/powerline.kak +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e5e9a0e5734da8f7338ead7f55f9ed04f88adfc6 diff --git a/config/kak/plugins/shellcheck.kak b/config/kak/plugins/shellcheck.kak deleted file mode 160000 index 4e633978..00000000 --- a/config/kak/plugins/shellcheck.kak +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4e633978c119bbb71f215828f7b59cea71a2c5a4 -- 2.51.2