From d4724b4dc335b91da5c7ae0345df4637f8f85a3c Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Thu, 23 Oct 2025 23:44:40 +0200 Subject: [PATCH] Disable kak-lsp for the time being, update formaters/linkers and clean-up keybinds --- kakrc | 161 +++++++++++++++++++----------------------------- languagecmd.kak | 75 ++++++++++++++-------- starship.toml | 10 +-- 3 files changed, 120 insertions(+), 126 deletions(-) diff --git a/kakrc b/kakrc index e77cb71..05d2256 100644 --- a/kakrc +++ b/kakrc @@ -51,6 +51,7 @@ evaluate-commands %sh{ kks init } define-command -override kks-connect -params 1.. -command-completion %{ %arg{1} sh -c %{ export EDITOR='kks edit' + export VISUAL='kks edit' export KKS_SESSION=$1 export KKS_CLIENT=$2 shift 3 @@ -73,6 +74,7 @@ bundle kakoune-find https://github.com/occivink/kakoune-find bundle kakoune-expand https://github.com/occivink/kakoune-expand bundle foot.kak https://github.com/kkga/foot.kak bundle kakoune-surround https://github.com/h-youhei/kakoune-surround +bundle shadow.kak https://github.com/ftonneau/shadow.kak bundle kakship https://github.com/eburghar/kakship %{ kakship-enable } @@ -91,96 +93,61 @@ bundle-noload dabruin.kak https://git.sr.ht/~nasmevka/dabruin.kak rm -f "${kak_config}/colors/dabruin-light.kak" } bundle kakoune-table https://gitlab.com/listentolist/kakoune-table -bundle kakoune-lsp https://github.com/kakoune-lsp/kakoune-lsp %{ - bundle-install-hook kakoune-lsp %{ - cargo build --release --locked - cargo install --locked --force --path . - } - set global lsp_diagnostic_line_error_sign '║' - set global lsp_diagnostic_line_warning_sign '┊' - define-command ne -docstring 'go to next error/warning from lsp' %{ lsp-find-error --include-warnings } - define-command pe -docstring 'go to previous error/warning from lsp' %{ lsp-find-error --previous --include-warnings } - define-command ee -docstring 'go to current error/warning from lsp' %{ lsp-find-error --include-warnings; lsp-find-error --previous --include-warnings } - # define-command lsp-restart -docstring 'restart lsp server' %{ lsp-stop; lsp-start } - # hook global WinSetOption filetype=(c|cpp|cc|rust|javascript|typescript) %{ - # set-option window lsp_auto_highlight_references true - # set-option window lsp_hover_anchor false - # lsp-auto-hover-enable - # echo -debug "Enabling LSP for filtetype %opt{filetype}" - # lsp-enable-window - # } - # hook global WinSetOption filetype=(rust) %{ - # set window lsp_server_configuration rust.clippy_preference="on" - # } - # hook global WinSetOption filetype=rust %{ - # hook window BufWritePre .* %{ - # evaluate-commands %sh{ - # test -f rustfmt.toml && printf lsp-formatting-sync - # } - # } - # } - evaluate-commands %sh{ kak-lsp } - lsp-enable - hook global KakEnd .* lsp-exit -} - - -# Enable some linting and formating -# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +#bundle kakoune-lsp https://github.com/kakoune-lsp/kakoune-lsp %{ +# bundle-install-hook kakoune-lsp %{ +# cargo build --release --locked +# cargo install --locked --force --path . +# } +# set global lsp_diagnostic_line_error_sign '║' +# set global lsp_diagnostic_line_warning_sign '┊' +# define-command ne -docstring 'go to next error/warning from lsp' %{ lsp-find-error --include-warnings } +# define-command pe -docstring 'go to previous error/warning from lsp' %{ lsp-find-error --previous --include-warnings } +# define-command ee -docstring 'go to current error/warning from lsp' %{ lsp-find-error --include-warnings; lsp-find-error --previous --include-warnings } +# # define-command lsp-restart -docstring 'restart lsp server' %{ lsp-stop; lsp-start } +# # hook global WinSetOption filetype=(c|cpp|cc|rust|javascript|typescript) %{ +# # set-option window lsp_auto_highlight_references true +# # set-option window lsp_hover_anchor false +# # lsp-auto-hover-enable +# # echo -debug "Enabling LSP for filtetype %opt{filetype}" +# # lsp-enable-window +# # } +# # hook global WinSetOption filetype=(rust) %{ +# # set window lsp_server_configuration rust.clippy_preference="on" +# # } +# # hook global WinSetOption filetype=rust %{ +# # hook windoformat-buffer# # } +# # evaluate-commands %slint-buffer{ +# # test -f rustfmt.toml && printf lsp-formatting-sync +# # } +# # } +# # } +# evaluate-commands %sh{ kak-lsp } +# lsp-enable +# # hook global KakEnd .* lsp-exit +# #} + + +# # Enable linting and formating +# # ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── source %sh{ - echo ${kak_config}/languagecmd.kak # borrowed from https://git.sr.ht/~nasmevka + echo ${kak_config}/languagecmd.kak # boilerplate from https://git.sr.ht/~nasmevka } -# Enable some code formaters -# ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── -hook global BufSetOption filetype=(js|javascript) %{ - set-option buffer formatcmd "prettier --stdin-filepath=%val{buffile}" -} -hook global WinSetOption filetype=scss %{ - set-option buffer formatcmd 'npx prettier --parser scss --stdin-filepath=%val{buffile}' -} -hook global WinSetOption filetype=less %{ - set-option buffer formatcmd 'npx prettier --parser less --stdin-filepath=%val{buffile}' -} -hook global WinSetOption filetype=html %{ - set-option buffer formatcmd 'npx prettier --parser html --stdin-filepath=%val{buffile}' -} -hook global WinSetOption filetype=md %{ - set-option buffer formatcmd 'npx prettier --parser md --stdin-filepath=%val{buffile}' -} -hook global WinSetOption filetype=sh %{ - # needs shfmt: $ go install mvdan.cc/sh/v3/cmd/shfmt@latest - set-option buffer formatcmd "shfmt -i 4 -ci -sr -" -} -hook global WinSetOption filetype=yaml %{ - set-option buffer formatcmd "npx prettier --parser yaml --stdin-filepath=%val{buffile}" -} -hook global WinSetOption filetype=(json|jsonc) %{ - set-option buffer formatcmd "jq --indent %opt{tabstop} ." -} -# Enable some code linters +# Shadow.kak config # ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── -hook global WinSetOption filetype=(c|h) %{ - set-option window lintcmd "cppcheck --language=c --enable=warning,style,information --template='{file}:{line}:{column}: {severity}: {message}' --suppress='*:*.h' 2>&1" -} -hook global WinSetOption filetype=css %{ - set-option window lintcmd "npx stylelint --formatter unix --stdin-filename='%val{buffile}'" -} -hook global WinSetOption filetype=(json|jsonc) %{ - set-option window lintcmd %{ run() { cat -- "$1" | jq 2>&1 | awk -v filename="$1" '/ at line [0-9]+, column [0-9]+$/ { line=$(NF - 2); column=$NF; sub(/ at line [0-9]+, column [0-9]+$/, ""); printf "%s:%d:%d: error: %s", filename, line, column, $0; }'; } && run } -} -hook global WinSetOption filetype=sh %{ - # needs shfmt: $ go install mvdan.cc/sh/v3/cmd/shfmt@latest - set-option window lintcmd "shellcheck -fgcc -Cnever" -} -hook global WinSetOption filetype=yaml %{ - set-option window lintcmd %{ - run() { - # change [message-type] to message-type: - yamllint -f parsable "$1" | sed 's/ \[\(.*\)\] / \1: /' - } && run } -} +# markdown +shadow-set markdown \ +code ^\h*``` \n\h*``` nofirst nolast default,rgb:c9c9c9 \ +note ^Note \n\n first nolast default,rgb:ddddc5 +shadow-decorate markdown \ +border ^\h*``` default,rgb:c9afaf + +# kak +shadow-set kak \ +comment ^# ^# nofirst nolast default +shadow-decorate kak \ +border ^# default,rgb:222222 # Look and Feel @@ -338,7 +305,7 @@ map global normal -docstring 'help' ': map global user -docstring 'buffer mode' b ': enter-user-mode buffermode' map global user -docstring 'git mode' g ': enter-user-mode gitmode' map global user -docstring 'selection mode' s ': enter-user-mode selmode' -map global user -docstring 'LSP mode' l ': enter-user-mode lsp' +# map global user -docstring 'LSP mode' l ': enter-user-mode lsp' map global user -docstring 'Table mode' t ': enter-user-mode table' map global user -docstring 'Table mode (locked)' T ': enter-user-mode -lock table' map global user -docstring ':::::::::::::::::::::::::::::::: ::' : ': ' @@ -364,13 +331,13 @@ map global user -docstring 'case insensitive backward extend-search' '' ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' -map global object a 'lsp-object' -docstring 'LSP any symbol' -map global object 'lsp-object' -docstring 'LSP any symbol' -map global object f 'lsp-object Function Method' -docstring 'LSP function or method' -map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' -map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' -map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' +# map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' +# map global object a 'lsp-object' -docstring 'LSP any symbol' +# map global object 'lsp-object' -docstring 'LSP any symbol' +# map global object f 'lsp-object Function Method' -docstring 'LSP function or method' +# map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' +# map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' +# map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' # buffer user mode # ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── @@ -378,10 +345,12 @@ declare-user-mode buffermode map global buffermode -docstring 'enable autocomplete' a ': set-option -add buffer autocomplete insert' map global buffermode -docstring 'disable Autocomplete' A ': set-option -remove buffer autocomplete insert' map global buffermode -docstring 'clean tabs and trailing whitespaces' c ': clean-buffer' -map global buffermode -docstring 'delete buffer' d ': delete-buffer' +map global buffermode -docstring 'Debug output buffer' d ': buffer *debug*' +map global buffermode -docstring 'delete buffer' D ': delete-buffer' +map global buffermode -docstring 'format buffer' f ': format-buffer' map global buffermode -docstring 'show file info' i ': info "file saved at %sh{date}"' -map global buffermode -docstring 'list buffers' l ': kks-connect terminal-popup kks-buffers' -map global buffermode -docstring 'Lint buffer' L ': buffer *lint-output*' +map global buffermode -docstring 'run linter' l ': lint-buffer' +map global buffermode -docstring 'Lint output buffer' L ': buffer *lint-output*' map global buffermode -docstring 'next buffer' n ': buffer-next' map global buffermode -docstring 'previous buffer' p ': buffer-previous' map global buffermode -docstring 'Word-wrap enable' w ': add-highlighter buffer/wordwrap wrap -word -indent' diff --git a/languagecmd.kak b/languagecmd.kak index e582773..ce15ee5 100644 --- a/languagecmd.kak +++ b/languagecmd.kak @@ -7,6 +7,12 @@ hook -group languagecmd global WinSetOption filetype=go %{ set-option buffer lintcmd "golangci-lint run --out-format=line-number --uniq-by-line=true --allow-parallel-runners | grep %val{bufname} #" } +### json +hook -group languagecmd global WinSetOption filetype=(json|jsonc) %{ + set-option buffer formatcmd 'set-option buffer formatcmd "jq --indent %opt{tabstop} ."' + set-option window lintcmd %{ run() { cat -- "$1" | jq 2>&1 | awk -v filename="$1" '/ at line [0-9]+, column [0-9]+$/ { line=$(NF - 2); column=$NF; sub(/ at line [0-9]+, column [0-9]+$/, ""); printf "%s:%d:%d: error: %s", filename, line, column, $0; }'; } && run } +} + ### python hook -group languagecmd global WinSetOption filetype=python %{ set-option buffer formatcmd 'black --line-length 150 -' @@ -24,35 +30,25 @@ hook -group languagecmd global WinSetOption filetype=sh %{ } ### C -hook -group languagecmd global WinSetOption filetype=c %{ +hook -group languagecmd global WinSetOption filetype=(c|h) %{ set-option buffer formatcmd 'clang-format -' set-option buffer lintcmd "clang-check --analyze %val{buffile} 2>&1 | sed '/^[^/]/d' #" } -### scheme (CHICKEN) -hook -group languagecmd global WinSetOption filetype=scheme %{ - set-option buffer formatcmd '' - set-option buffer lintcmd '' - # spaces for indent, using only two since scheme can have a lot of indentation - set-option buffer tabstop 2 - set-option buffer indentwidth 2 - - enter-spacemode - enable-replkak-bindings - # launch parinfer last since we want the tabulation->space transformation before - parinfer-enable-window -indent -} - -hook -group languagecmd global WinSetOption filetype=markdown %{ - try %{ - declare-surrounding-pair 'surround selection with italic syntax' ital * * - declare-surrounding-pair 'surround selection with bold syntax' bold ** ** - declare-surrounding-pair 'surround selection with inline code syntax' icode ` ` - declare-surrounding-pair 'surround selection with bloc code syntax' bcode ``` ``` - alias buffer italic surround-with-ital - alias buffer bold surround-with-bold - alias buffer inline surround-with-icode - alias buffer bloc surround-with-bcode +### Markdown +hook -group languagecmd global WinSetOption filetype=(md|markdown) %{ + # try %{ + # declare-surrounding-pair 'surround selection with italic syntax' ital * * + # declare-surrounding-pair 'surround selection with bold syntax' bold ** ** + # declare-surrounding-pair 'surround selection with inline code syntax' icode ` ` + # declare-surrounding-pair 'surround selection with bloc code syntax' bcode ``` ``` + # alias buffer italic surround-with-ital + # alias buffer bold surround-with-bold + # alias buffer inline surround-with-icode + # alias buffer bloc surround-with-bcode + # } + hook global WinSetOption filetype=md %{ + set-option buffer formatcmd 'npx prettier --parser md --stdin-filepath=%val{buffile}' } } @@ -74,4 +70,33 @@ hook -group languagecmd global WinSetOption filetype=hare %{ set-option buffer indentwidth 8 } +### CSS +hook global WinSetOption filetype=css %{ + set-option buffer formatcmd "yarn dlx stylelint --fix --stdin-filename='%val{buffile}'" + set-option window lintcmd "yarn dlx stylelint --formatter unix --stdin-filename='%val{buffile}'" +} + +### YAML +hook global WinSetOption filetype=yaml %{ + set-option window lintcmd %{ + run() { + # change [message-type] to message-type: + yamllint -f parsable "$1" | sed 's/ \[\(.*\)\] / \1: /' + } && run } + set-option buffer formatcmd "npx prettier --parser yaml --stdin-filepath=%val{buffile}" + +} +### TODO: add corresponding linter +hook global BufSetOption filetype=(js|javascript) %{ + set-option buffer formatcmd "prettier --stdin-filepath=%val{buffile}" +} +hook global WinSetOption filetype=scss %{ + set-option buffer formatcmd 'npx prettier --parser scss --stdin-filepath=%val{buffile}' +} +hook global WinSetOption filetype=less %{ + set-option buffer formatcmd 'npx prettier --parser less --stdin-filepath=%val{buffile}' +} +hook global WinSetOption filetype=html %{ + set-option buffer formatcmd 'npx prettier --parser html --stdin-filepath=%val{buffile}' +} diff --git a/starship.toml b/starship.toml index 1345bb4..053e072 100644 --- a/starship.toml +++ b/starship.toml @@ -34,7 +34,7 @@ format = "[ %opt{lsp_diagnostic_error_count}]($style)" style = "fg:red bold bg:default" when = '[ -n "$kak_opt_lsp_diagnostic_error_count" -a "$kak_opt_lsp_diagnostic_error_count" -ne 0 ]' shell = ['sh'] -disabled = false +disabled = true [custom.kaklsp_warn] description = "Show warnings number from kak-lsp if any" @@ -42,7 +42,7 @@ format = "[  %opt{lsp_diagnostic_warning_count}]($style)" style = "fg:yellow bold bg:default" when = '[ -n "$kak_opt_lsp_diagnostic_warning_count" -a "$kak_opt_lsp_diagnostic_warning_count" -ne 0 ]' shell = ['sh'] -disabled = false +disabled = true [custom.kaklsp_hint] description = "Show hints number from kak-lsp if any" @@ -50,7 +50,7 @@ format = "[ ﯦ %opt{lsp_diagnostic_hint_count}]($style)" style = "fg:white bold bg:default" when = '[ -n "$kak_opt_lsp_diagnostic_hint_count" -a "$kak_opt_lsp_diagnostic_hint_count" -ne 0 ]' shell = ['sh'] -disabled = false +disabled = true [custom.kaklsp_code_actions] description = "Show lsp code actions if any" @@ -58,7 +58,7 @@ format = "[ %opt{lsp_modeline_code_actions} ]($style)" style = "fg:yellow bold bg:default" when = '[ -n "$kak_opt_lsp_modeline_code_actions" ]' shell = ['sh'] -disabled = false +disabled = true [custom.kaklsp_progress] description = "Show activity of kak-lsp if any" @@ -66,7 +66,7 @@ format = " [ ]($style)" style = "fg:bright-white bold bg:default" when = '[ -n "$kak_opt_lsp_modeline_progress" ]' shell = ['sh'] -disabled = false +disabled = true [git_branch] symbol = "" -- 2.51.2