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
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
}
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<ret> %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
map global user -docstring 'buffer mode' b ': enter-user-mode buffermode<ret>'
map global user -docstring 'git mode' g ': enter-user-mode gitmode<ret>'
map global user -docstring 'selection mode' s ': enter-user-mode selmode<ret>'
-map global user -docstring 'LSP mode' l ': enter-user-mode lsp<ret>'
+# map global user -docstring 'LSP mode' l ': enter-user-mode lsp<ret>'
map global user -docstring 'Table mode' t ': enter-user-mode table<ret>'
map global user -docstring 'Table mode (locked)' T ': enter-user-mode -lock table<ret>'
map global user -docstring ':::::::::::::::::::::::::::::::: ::' : ': <esc>'
# kak-lsp keys
# ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
-map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
-map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
-map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
-map global object f '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method'
-map global object t '<a-semicolon>lsp-object Class Interface Struct<ret>' -docstring 'LSP class interface or struct'
-map global object d '<a-semicolon>lsp-diagnostic-object --include-warnings<ret>' -docstring 'LSP errors and warnings'
-map global object D '<a-semicolon>lsp-diagnostic-object<ret>' -docstring 'LSP errors'
+# map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
+# map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
+# map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
+# map global object f '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method'
+# map global object t '<a-semicolon>lsp-object Class Interface Struct<ret>' -docstring 'LSP class interface or struct'
+# map global object d '<a-semicolon>lsp-diagnostic-object --include-warnings<ret>' -docstring 'LSP errors and warnings'
+# map global object D '<a-semicolon>lsp-diagnostic-object<ret>' -docstring 'LSP errors'
# buffer user mode
# ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
map global buffermode -docstring 'enable autocomplete' a ': set-option -add buffer autocomplete insert<ret>'
map global buffermode -docstring 'disable Autocomplete' A ': set-option -remove buffer autocomplete insert<ret>'
map global buffermode -docstring 'clean tabs and trailing whitespaces' c ': clean-buffer<ret>'
-map global buffermode -docstring 'delete buffer' d ': delete-buffer<ret>'
+map global buffermode -docstring 'Debug output buffer' d ': buffer *debug*<ret>'
+map global buffermode -docstring 'delete buffer' D ': delete-buffer<ret>'
+map global buffermode -docstring 'format buffer' f ': format-buffer<ret>'
map global buffermode -docstring 'show file info' i ': info "file saved at %sh{date}"<ret>'
-map global buffermode -docstring 'list buffers' l ': kks-connect terminal-popup kks-buffers<ret>'
-map global buffermode -docstring 'Lint buffer' L ': buffer *lint-output*<ret>'
+map global buffermode -docstring 'run linter' l ': lint-buffer<ret>'
+map global buffermode -docstring 'Lint output buffer' L ': buffer *lint-output*<ret>'
map global buffermode -docstring 'next buffer' n ': buffer-next<ret>'
map global buffermode -docstring 'previous buffer' p ': buffer-previous<ret>'
map global buffermode -docstring 'Word-wrap enable' w ': add-highlighter buffer/wordwrap wrap -word -indent<ret>'
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 -'
}
### 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 <ret>```<ret> <ret>```<ret>
- 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 <ret>```<ret> <ret>```<ret>
+ # 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}'
}
}
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}'
+}