diff --git a/.gitignore b/.gitignore index 747463e..2c441d9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ system .*.swo Session.vim dot.config/nnn/.history +dot.config/kak/plugins/ diff --git a/dot.config/kak/autoload/autoload b/dot.config/kak/autoload/autoload new file mode 120000 index 0000000..9decbd0 --- /dev/null +++ b/dot.config/kak/autoload/autoload @@ -0,0 +1 @@ +/usr/share/kak/rc/ \ No newline at end of file diff --git a/dot.config/kak/autoload/buffers.kak b/dot.config/kak/autoload/buffers.kak deleted file mode 100644 index d71d8d6..0000000 --- a/dot.config/kak/autoload/buffers.kak +++ /dev/null @@ -1,234 +0,0 @@ -# buflist++: names AND modified bool -# debug buffers (like *debug*, *lint*…) are excluded -declare-option -hidden str-list buffers_info - -declare-option int buffers_total - -# keys to use for buffer picking -declare-option str buffer_keys "1234567890qwertyuiopasdfghjklzxcvbnm" - -# used to handle [+] (modified) symbol in list -define-command -hidden refresh-buffers-info %{ - set-option global buffers_info - set-option global buffers_total 0 - # iteration over all buffers (except debug ones) - evaluate-commands -no-hooks -buffer * %{ - set-option -add global buffers_info "%val{bufname}_%val{modified}" - } - evaluate-commands %sh{ - total=$(printf '%s\n' "$kak_opt_buffers_info" | tr ' ' '\n' | wc -l) - printf '%s\n' "set-option global buffers_total $total" - } -} - -# used to handle # (alt) symbol in list -declare-option str alt_bufname -declare-option str current_bufname -# adjust this number to display more buffers in info -declare-option int max_list_buffers 42 - -hook global WinDisplay .* %{ - set-option global alt_bufname %opt{current_bufname} - set-option global current_bufname %val{bufname} -} - -define-command info-buffers -docstring 'populate an info box with a numbered buffers list' %{ - refresh-buffers-info - evaluate-commands %sh{ - # info title - printf "info -title '$kak_opt_buffers_total buffers' -- %%^" - - index=0 - eval "set -- $kak_opt_buffers_info" - while [ "$1" ]; do - # limit lists too big - index=$(($index + 1)) - if [ "$index" -gt "$kak_opt_max_list_buffers" ]; then - printf ' …' - break - fi - - name=${1%_*} - if [ "$name" = "$kak_bufname" ]; then - printf "> %s" "$index - $name" - elif [ "$name" = "$kak_opt_alt_bufname" ]; then - printf "# %s" "$index - $name" - else - printf " %s" "$index - $name" - fi - - modified=${1##*_} - if [ "$modified" = true ]; then - printf " [+]" - fi - echo - shift - done - printf ^\\n - } -} - -declare-user-mode pick-buffers -define-command pick-buffers -docstring 'enter buffer pick mode' %{ - refresh-buffers-info - unmap global pick-buffers - evaluate-commands %sh{ - index=0 - keys=" $kak_opt_buffer_keys" - num_keys=$(($(echo "$kak_opt_buffer_keys" | wc -m) - 1)) - eval "set -- $kak_opt_buffers_info" - while [ "$1" ]; do - # limit lists too big - index=$(($index + 1)) - if [ "$index" -gt "$num_keys" ]; then - break - fi - - name=${1%_*} - modified=${1##*_} - if [ "$name" = "$kak_bufname" ]; then - echo "map global pick-buffers ${keys:$index:1} :buffer-by-index$index -docstring \"> $name $(if [ "$modified" = true ]; then echo "[+]"; fi)\"" - elif [ "$name" = "$kak_opt_alt_bufname" ]; then - echo "map global pick-buffers ${keys:$index:1} :buffer-by-index$index -docstring \"# $name $(if [ "$modified" = true ]; then echo "[+]"; fi)\"" - else - echo "map global pick-buffers ${keys:$index:1} :buffer-by-index$index -docstring \" $name $(if [ "$modified" = true ]; then echo "[+]"; fi)\"" - fi - - shift - done - } - enter-user-mode pick-buffers -} - -define-command buffer-first -docstring 'move to the first buffer in the list' 'buffer-by-index 1' - -define-command buffer-last -docstring 'move to the last buffer in the list' %{ - buffer-by-index %opt{buffers_total} -} - -define-command -hidden -params 1 buffer-by-index %{ - refresh-buffers-info - evaluate-commands %sh{ - target=$1 - index=0 - eval "set -- $kak_opt_buffers_info" - while [ "$1" ]; do - index=$(($index+1)) - name=${1%_*} - if [ $index = $target ]; then - echo "buffer $name" - fi - shift - done - } -} - -define-command delete-buffers -docstring 'delete all saved buffers' %{ - evaluate-commands %sh{ - deleted=0 - eval "set -- $kak_buflist" - while [ "$1" ]; do - echo "try 'delete-buffer $1'" - echo "echo -markup '{Information}$deleted buffers deleted'" - deleted=$((deleted+1)) - shift - done - } -} - -define-command buffer-only -docstring 'delete all saved buffers except current one' %{ - evaluate-commands %sh{ - deleted=0 - eval "set -- $kak_buflist" - while [ "$1" ]; do - if [ "$1" != "$kak_bufname" ]; then - echo "try 'delete-buffer $1'" - echo "echo -markup '{Information}$deleted buffers deleted'" - deleted=$((deleted+1)) - fi - shift - done - } -} - -define-command buffer-only-force -docstring 'delete all buffers except current one' %{ - evaluate-commands %sh{ - deleted=0 - eval "set -- $kak_buflist" - while [ "$1" ]; do - if [ "$1" != "$kak_bufname" ]; then - echo "delete-buffer! $1" - echo "echo -markup '{Information}$deleted buffers deleted'" - deleted=$((deleted+1)) - fi - shift - done - } -} - -define-command buffer-only-directory -docstring 'delete all saved buffers except the ones in the same current buffer directory' %{ - evaluate-commands %sh{ - deleted=0 - current_buffer_dir=$(dirname "$kak_bufname") - eval "set -- $kak_buflist" - while [ "$1" ]; do - dir=$(dirname "$1") - if [ $dir != "$current_buffer_dir" ]; then - echo "try 'delete-buffer $1'" - echo "echo -markup '{Information}$deleted buffers deleted'" - deleted=$((deleted+1)) - fi - shift - done - } -} - -define-command edit-kakrc -docstring 'open kakrc in a new buffer' %{ - evaluate-commands %sh{ - printf '%s\n' "edit $kak_config/kakrc" - } -} - -declare-user-mode buffers - -map global buffers a ga -docstring 'alternate' -map global buffers b :info-buffers -docstring 'info' -map global buffers c :edit-kakrc -docstring 'config' -map global buffers d :delete-buffer -docstring 'delete' -map global buffers D :delete-buffers -docstring 'delete all' -map global buffers f :buffer -docstring 'find' -map global buffers h :buffer-first -docstring 'first' -map global buffers l :buffer-last -docstring 'last' -map global buffers n :buffer-next -docstring 'next' -map global buffers o :buffer-only -docstring 'only' -map global buffers p :buffer-previous -docstring 'previous' -map global buffers s ':edit -scratch *scratch*' -docstring '*scratch*' -map global buffers u ':buffer *debug*' -docstring '*debug*' - -# trick to access count, 3b → display third buffer -define-command -hidden enter-buffers-mode %{ - evaluate-commands %sh{ - if [ "$kak_count" -eq 0 ]; then - echo 'enter-user-mode buffers' - else - echo "buffer-by-index $kak_count" - fi - } -} - -# Suggested hook - -#hook global WinDisplay .* info-buffers - -# Suggested mappings - -#map global user b ':enter-buffers-mode' -docstring 'buffers…' -#map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' - -# Suggested aliases - -#alias global bd delete-buffer -#alias global bf buffer-first -#alias global bl buffer-last -#alias global bo buffer-only -#alias global bo! buffer-only-force diff --git a/dot.config/kak/autoload/explore-buffers.kak b/dot.config/kak/autoload/explore-buffers.kak deleted file mode 100644 index 3bccbbd..0000000 --- a/dot.config/kak/autoload/explore-buffers.kak +++ /dev/null @@ -1,58 +0,0 @@ -declare-option -hidden str explore_buffers_current - -set-face global ExploreBuffers 'yellow,default' - -add-highlighter shared/buffers regions -add-highlighter shared/buffers/content default-region group -add-highlighter shared/buffers/content/buffers regex '^.+$' 0:ExploreBuffers - -define-command -hidden explore-buffers -docstring 'Explore buffers' %{ evaluate-commands -save-regs '"/' %{ - set-option current explore_buffers_current %val(bufname) - edit! -scratch *buffers* - set-option buffer filetype buffers - evaluate-commands set-register dquote %val(buflist) - execute-keys ')i' - set-register / "\Q%opt(explore_buffers_current)\E" - execute-keys n -}} - -define-command -hidden explore-buffers-parent -docstring 'Explore the parent directory of the selected buffer' %{ - explore-buffers-validate - explore-files %sh(dirname "$kak_buffile") -} - -define-command -hidden explore-buffers-validate -docstring 'Edit selected buffer' %{ - execute-keys '_' - buffer %reg(.) - delete-buffer *buffers* -} - -define-command -hidden explore-buffers-delete -docstring 'Delete selected buffer' %{ - execute-keys '_' - delete-buffer %reg(.) - explore-buffers -} - -hook global WinSetOption filetype=buffers %{ - add-highlighter window/ ref buffers - map window normal ': explore-buffers-validate' - map window normal ': explore-buffers-parent' - map window normal q ': delete-buffer' - map window normal ': delete-buffer' - map window normal d ': explore-buffers-delete' - hook -always -once window WinSetOption filetype=.* %{ - remove-highlighter window/buffers - } -} - -define-command -hidden explore-buffers-enable %{ - hook window -group explore-buffers RuntimeError '\d+:\d+: ''(buffer|b)'' wrong argument count' %{ - # Hide error message - echo - explore-buffers - } -} - -hook -group explore-buffers global WinCreate .* %{ - explore-buffers-enable -} diff --git a/dot.config/kak/autoload/explore-files.kak b/dot.config/kak/autoload/explore-files.kak deleted file mode 100644 index 6249555..0000000 --- a/dot.config/kak/autoload/explore-files.kak +++ /dev/null @@ -1,136 +0,0 @@ -declare-option -docstring 'Whether to show hidden files' bool explore_files_show_hidden no - -declare-option -hidden str explore_files -declare-option -hidden int explore_files_count - -set-face global ExploreFiles 'magenta,default' -set-face global ExploreDirectories 'cyan,default' - -add-highlighter shared/directory regions -add-highlighter shared/directory/content default-region group -add-highlighter shared/directory/content/files regex '^.+$' 0:ExploreFiles -add-highlighter shared/directory/content/directories regex '^.+/$' 0:ExploreDirectories - -define-command -hidden explore-files-display -params 1..2 %{ evaluate-commands %sh{ - command=$1 - path=$(realpath "${2:-.}") - name=$(basename "$path") - out=$(mktemp --directory) - fifo=$out/fifo - last_buffer_name=$(basename "$kak_bufname") - mkfifo $fifo - cd "$path" - (eval "$command" > $fifo) < /dev/null > /dev/null 2>&1 & - echo " - edit -fifo %($fifo) %($path) - set-option buffer filetype directory - hook -once window NormalIdle '' %{ - evaluate-commands -save-regs / %{ - set-register / %(\b\Q$last_buffer_name\E\b) - try %(execute-keys n) - } - # Information - echo -markup {Information} %(Showing $name/ entries) - } - hook -always -once buffer BufCloseFifo '' %(nop %sh(rm --recursive $out)) - # Information - echo -markup {Information} %(Showing $name/ entries) - " -}} - -define-command -hidden explore-files-smart -params 0..1 %{ evaluate-commands %sh{ - file=${1:-.} - edit=$(test -d "$file" && echo explore-files || echo edit) - echo "$edit %($file)" -}} - -define-command -hidden explore-files -params 0..1 -docstring 'Explore directory entries' %{ - explore-files-display "ls --dereference --group-directories-first --indicator-style=slash %sh(test $kak_opt_explore_files_show_hidden = true && echo --almost-all)" %arg(1) -} - -define-command -hidden explore-files-recursive -params 0..1 -docstring 'Explore directory entries recursively' %{ - explore-files-display "fd %sh(test $kak_opt_explore_files_show_hidden = true && echo --hidden)" %arg(1) -} - -define-command -hidden explore-files-forward -docstring 'Edit selected files' %{ - set-option current explore_files %val(bufname) - execute-keys ';_' - set-option current explore_files_count %sh(count() { echo $#; }; count $kak_selections_desc) - evaluate-commands -draft -itersel -save-regs 'F' %{ - set-register F "%val(bufname)/%reg(.)" - evaluate-commands -client %val(client) %(explore-files-smart %reg(F)) - } - delete-buffer %opt(explore_files) - evaluate-commands %sh{ - count=$kak_opt_explore_files_count - test $count -gt 1 && - echo "echo -markup {Information} %[$count files opened]" - } -} - -define-command -hidden explore-files-back -docstring 'Explore parent directory' %{ - set-option current explore_files %val(bufname) - explore-files "%opt(explore_files)/.." - delete-buffer %opt(explore_files) - echo -markup {Information} "Showing %sh(basename ""$kak_bufname"")/ entries" -} - -define-command -hidden explore-files-change-directory -docstring 'Change directory and quit' %{ - change-directory %val(bufname) - delete-buffer -} - -define-command -hidden explore-files-toggle-hidden -docstring 'Toggle hidden files' %{ - set-option current explore_files_show_hidden %sh{ - if test $kak_opt_explore_files_show_hidden = true; then - echo no - else - echo yes - fi - } - explore-files %val(bufname) -} - -hook global WinSetOption filetype=directory %{ - add-highlighter window/ ref directory - map window normal ': explore-files-forward' - map window normal ': explore-files-back' - map window normal . ': explore-files-toggle-hidden' - map window normal R ': explore-files-recursive %val(bufname)' - map window normal q ': explore-files-change-directory' - map window normal ': delete-buffer' - hook -always -once window WinSetOption filetype=.* %{ - remove-highlighter window/directory - } -} - -define-command -hidden explore-files-enable %{ - hook window -group explore-files RuntimeError '\d+:\d+: ''(?:edit|e)'' wrong argument count' %{ - explore-files %sh(dirname "$kak_buffile") - } - hook window -group explore-files RuntimeError '\d+:\d+: ''(?:edit|e)'' (.+): is a directory' %{ - # Hide error message - echo - explore-files %val(hook_param_capture_1) - } - hook window -group explore-files RuntimeError 'unable to find file ''(.+)''' %{ - # Hide error message - echo - explore-files-smart %val(hook_param_capture_1) - } -} - -hook -group explore-files global WinCreate .* %{ - explore-files-enable -} - -hook -group explore-files global KakBegin .* %{ hook -once global WinCreate .* %{ hook -once global NormalIdle '' %{ - try %{ evaluate-commands -draft -save-regs '/' %{ - buffer *debug* - set-register / 'error while opening file ''(.+?)'':\n\h+(.+?): is a directory' - execute-keys '%1s' - evaluate-commands -draft -itersel %{ - evaluate-commands -client %val(client) explore-files %reg(.) - } - }} -}}} diff --git a/dot.config/kak/autoload/livedown.kak b/dot.config/kak/autoload/livedown.kak deleted file mode 100644 index c9ac60a..0000000 --- a/dot.config/kak/autoload/livedown.kak +++ /dev/null @@ -1,11 +0,0 @@ -decl int livedown_port 8642 - -def livedown-start %{ %sh{ - ( - livedown start --open --port "$kak_opt_livedown_port" "$kak_buffile" - ) >/dev/null 2>&1 \"${reg}pGjo'" - done - - # hide empty registers (lines with less than 4 chars) - echo 'exec \%.{4,}d' - - # make sure all registers are easily visible - echo 'exec gg' - } -} - -# beware, it wipes the content of reg x -def info-registers -docstring 'populate an info box with the content of registers' %{ - list-registers - exec -save-regs \%| '%|cut-c-30%"xyga' - info -title registers -- %reg{x} - set-register x '' -} - diff --git a/dot.config/kak/autoload/replace.kak b/dot.config/kak/autoload/replace.kak deleted file mode 100644 index cf81868..0000000 --- a/dot.config/kak/autoload/replace.kak +++ /dev/null @@ -1,19 +0,0 @@ -define-command -hidden replace-insert -params 1 %{ - try %{ - execute-keys -draft ';\n' - execute-keys '' - } -} - -define-command -hidden replace-delete -params 1 %{ - execute-keys 'H' -} - -define-command replace -docstring 'Enter in replace mode' %{ - hook window InsertChar '[^\n]' -group replace %(replace-insert %val(hook_param)) - hook window InsertDelete '[^\n]' -group replace %(replace-delete %val(hook_param)) - hook -once window ModeChange insert:normal %{ - remove-hooks window replace - } - execute-keys -with-hooks i -} diff --git a/dot.config/kak/autoload/stuff.kak b/dot.config/kak/autoload/stuff.kak index ba6bd6c..df91ab4 100644 --- a/dot.config/kak/autoload/stuff.kak +++ b/dot.config/kak/autoload/stuff.kak @@ -15,45 +15,6 @@ hook global WinSetOption filetype=(?!markdown).* %{ add-highlighter window/ number-lines -hlcursor -separator ' ' } -# map tmux split and window commands in vim style -def -file-completion -params 1 tabe %{ tmux-terminal-window edit %arg{1} } -def -file-completion -params 1 vsplit %{ tmux-terminal-vertical edit %arg{1} } -#map global insert ctrl-n ':new' -#map global normal ctrl-n ':new' - -#def fedit -params 1 -shell-candidates %{ git ls-files } %{ edit %arg{1} } -#alias global fe fedit - -def -docstring 'invoke fzf to open a file' \ - fzf-file %{ %sh{ - if [ -z "$TMUX" ]; then - echo echo only works inside tmux - else - FILE=`fzf-tmux -d 15` - if [ -n "$FILE" ]; then - echo "eval -client '$kak_client' 'edit ${FILE}'" | kak -p ${kak_session} - fi - fi -}} - -def -docstring 'invoke fzf to select a buffer' \ - fzf-buffer %{ %sh{ - if [ -z "$TMUX" ]; then - echo echo only works inside tmux - else - BUFFER=`echo ${kak_buflist} | tr : '\n' | fzf-tmux -d 15` - if [ -n "$BUFFER" ]; then - echo "eval -client '$kak_client' 'buffer ${BUFFER}'" | kak -p ${kak_session} - fi - fi -}} - -alias global ffe fzf-file -alias global ffb fzf-buffer - -set global tabstop 2 -set global indentwidth 2 - hook global WinSetOption filetype=(javascript|ecmascript) %{ set window formatcmd 'prettier-standard' #hook window BufWritePre .* format @@ -69,65 +30,3 @@ hook global WinSetOption filetype=json %{ set window formatcmd 'jq .' hook window BufWritePre .* format } - - -######################################################### -# buffers (https://github.com/Delapouite/kakoune-buffers) -# -# sets former b (word-back) to q and makes b a global key -# for the new buffers command. I don't use macros anyway. -######################################################### - -hook global WinDisplay .* info-buffers - -# ciao macros -map global normal ^ q -map global normal Q -map global normal q b -map global normal Q B -map global normal -map global normal - -map global normal b ':enter-buffers-mode' -docstring 'buffers…' -map global normal B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' - - -############################################# -# lsp support (https://github.com/ul/kak-lsp) -# ...but it's not working yet -############################################# - -# eval %sh{kak-lsp --kakoune -s $kak_session} -# -# set-option global lsp_completion_trigger "execute-keys 'h\S[^\h\n,=;*(){}\[\]]\z'" -# set-option global lsp_diagnostic_line_error_sign "!" -# set-option global lsp_diagnostic_line_warning_sign "?" -# -# hook global WinSetOption filetype=(c|cpp|rust|javascript|html|css|json) %{ -# map window user "l" ": enter-user-mode lsp" -docstring "LSP mode" -# lsp-enable-window -# lsp-auto-hover-enable -# lsp-auto-hover-insert-mode-disable -# set-option window lsp_hover_anchor true -# set-face window DiagnosticError default+u -# set-face window DiagnosticWarning default+u -#} -#hook global WinSetOption filetype=rust %{ -# set-option window lsp_server_configuration rust.clippy_preference="on" -#} -#hook global KakEnd .* lsp-exit - - -########################################################## -# replace mode (https://github.com/alexherbo2/replace.kak) -# that is one thing I missed in Kakoune: writing over text -########################################################## -map global user r -docstring 'Replace' ': replace' - -########################################################### -# explore files (https://github.com/alexherbo2/explore.kak) -# use fd instead of find -########################################################### -define-command -hidden -override explore-files-recursive -params 0..1 %{ - explore-files-display "fd %sh(test $kak_opt_explore_files_show_hidden = true && echo --hidden)" %arg(1) -} diff --git a/dot.config/kak/autoload/todotxt.kak b/dot.config/kak/autoload/todotxt.kak deleted file mode 100644 index eea8975..0000000 --- a/dot.config/kak/autoload/todotxt.kak +++ /dev/null @@ -1,64 +0,0 @@ -# Detection -# ‾‾‾‾‾‾‾‾‾ - -hook global BufCreate .*[.]?(todo\.txt) %{ - set buffer filetype todotxt - - def -hidden todo-done2bottom %{ - try %{ - exec '%^x dge:echo %reg{#} items moved' - } - } - def -hidden todo-a2top %{ - try %{ - exec '%^\(A\) dgg:echo %reg{#} items moved' - } - } - def -hidden todo-b2top %{ - try %{ - exec '%^\(B\) dgg:echo %reg{#} items moved' - } - } - def -hidden todo-c2top %{ - try %{ - exec '%^\(C\) dgg:echo %reg{#} items moved' - } - } - def -docstring 'sort items by priority and state' todo-sort %{ - exec '%:todo-c2top:todo-b2top:todo-a2top:todo-done2bottom' - } - def -docstring 'mark item under cursor as done' todo-mark-done %{ - try %{ - exec 'xs\([ABC]\) cx ' - } catch %{ - exec 'ghix ' - } - } - def -docstring 'mark item under cursor as high priority' -params 1 todo-mark-prio %{ - try %{ - exec "xs^(\([ABC]\)|x) c(%arg{1}) " - } catch %{ - exec "ghi(%arg{1}) " - } - } -} - -face global TodoPrioA red+b -face global TodoPrioB yellow+b -face global TodoPrioC cyan+b -face global TodoDate default+b - - -add-highlighter global/todotxt group -add-highlighter global/todotxt/comment regex "^x ([^\n]+)" 0:comment # done items -add-highlighter global/todotxt/prio-a regex "^\(A\) ([^\n]+)" 0:TodoPrioA # priority (A) -add-highlighter global/todotxt/prio-b regex "^\(B\) ([^\n]+)" 0:TodoPrioB # priority (B) -add-highlighter global/todotxt/prio-c regex "^\(C\) ([^\n]+)" 0:TodoPrioC # priority (C) -add-highlighter global/todotxt/key-value regex "([^:|^ ]+:)([^ |^\n]+)" 0:value 1:type # key:value -add-highlighter global/todotxt/keyword regex "(\+[^\+|^ |^\n]+)" 0:keyword # +project -add-highlighter global/todotxt/meta regex "(@[^\+|^ |^\n]+)" 0:meta # @context -add-highlighter global/todotxt/date regex "(\d{4}-\d{2}-\d{2})" 0:TodoDate # date - -hook -group todotxt-highlight global WinSetOption filetype=todotxt %{ add-highlighter window ref todotxt } -hook -group todotxt-highlight global WinSetOption filetype=(?!todotxt).* %{ remove-highlighter window/todotxt } - diff --git a/dot.config/kak/autoload/vue.kak b/dot.config/kak/autoload/vue.kak deleted file mode 100644 index 6d37385..0000000 --- a/dot.config/kak/autoload/vue.kak +++ /dev/null @@ -1,77 +0,0 @@ -# Vue file -# ‾‾‾‾‾‾‾‾ - -# Detection -# ‾‾‾‾‾‾‾‾‾ - -hook global BufCreate .*\.vue %{ - set-option buffer filetype vue -} - -# Highlighters -# ‾‾‾‾‾‾‾‾‾‾‾‾ - -add-highlighter shared/vue regions -add-highlighter shared/vue/tag region < > regions -add-highlighter shared/vue/pug region \K (?=) ref pug -add-highlighter shared/vue/html region \K (?=) ref html -add-highlighter shared/vue/scss region \K (?=) ref scss -add-highlighter shared/vue/sass region \K (?=) ref sass -add-highlighter shared/vue/less region \K (?=) ref less -add-highlighter shared/vue/css region \K (?=) ref css -add-highlighter shared/vue/ts region \K (?=) ref ts -add-highlighter shared/vue/js region \K (?=) ref javascript - -add-highlighter shared/vue/tag/base default-region group -add-highlighter shared/vue/tag/ region '"' (? s \h+$ d } -} - -define-command -hidden vue-indent-on-greater-than %[ - evaluate-commands -draft -itersel %[ - # align closing tag to opening when alone on a line - try %[ execute-keys -draft s ^\h+/(\w+)$ {c1,/1 s \A|.\z 1 ] - ] -] - -define-command -hidden vue-indent-on-new-line %{ - evaluate-commands -draft -itersel %{ - # preserve previous line indent - try %{ execute-keys -draft \; K } - # filter previous line - try %{ execute-keys -draft k : vue-filter-around-selections } - # indent after lines ending with opening tag - try %{ execute-keys -draft k <[^/][^>]+>$ j } - } -} - -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group vue-highlight global WinSetOption filetype=vue %{ add-highlighter window/vue ref vue } - -hook global WinSetOption filetype=vue %{ - hook window ModeChange insert:.* -group vue-hooks vue-filter-around-selections - hook window InsertChar '>' -group vue-indent vue-indent-on-greater-than - hook window InsertChar \n -group vue-indent vue-indent-on-new-line - set window comment_line '//' - set window comment_block_begin '' -} - -hook -group vue-highlight global WinSetOption filetype=(?!vue).* %{ remove-highlighter window/vue } - -hook global WinSetOption filetype=(?!vue).* %{ - remove-hooks window vue-indent - remove-hooks window vue-hooks -} diff --git a/dot.config/kak/autoload/wiki.kak b/dot.config/kak/autoload/wiki.kak deleted file mode 100644 index 8f90b4e..0000000 --- a/dot.config/kak/autoload/wiki.kak +++ /dev/null @@ -1,116 +0,0 @@ -declare-option -docstring %{ Path to wiki directory } str wiki_path - -# program that outputs relative path given two absolute as params -declare-option -hidden str wiki_relative_path_program %{ perl -e 'use File::Spec; print File::Spec->abs2rel(@ARGV) . "\n"' } - - -define-command -hidden -params 1 wiki_setup %{ - evaluate-commands %sh{ - echo "set-option global wiki_path $1" - echo "hook global BufCreate $1/.+\.md %{ wiki_enable }" - } -} - -define-command wiki -params 1 \ --docstring %{ wiki [file.md]: Edit or create wiki page } \ --shell-script-candidates %{ cd $kak_opt_wiki_path; find . -type f -name '*.md' | sed -e 's/^\.\///' } \ -%{ evaluate-commands %sh{ - if [ ! -e "$kak_opt_wiki_path/$1" ]; then - echo "wiki_new_page %{$1}" - fi - echo "edit %{$kak_opt_wiki_path/$1}" -}} - -define-command wiki_enable %{ - add-highlighter buffer/wiki group - add-highlighter buffer/wiki/tag regex '\B@\S+' 0:link - add-highlighter buffer/wiki/link regex '\[\w+\]' 0:link - hook buffer InsertKey '' -group wiki %{ - evaluate-commands %{ try %{ - execute-keys -draft %{ - \A@!\w+ - :wiki_expand_pic - }} catch %{ - try %{ execute-keys -draft %{ - \A@\w+ - :wiki_expand_tag - } - execute-keys - } - }} - } - hook buffer NormalKey '' -group wiki %{ - try %{ wiki_follow_link } - try %{ wiki_toggle_checkbox } - } -} - -define-command wiki_disable %{ - remove-highlighter buffer/wiki - remove-hooks buffer wiki -} - -define-command wiki_expand_tag \ --docstring %{ Expands tag from @filename form to [filename](filename.md) -Creates empty markdown file in wiki_path if not exist. Selection must be -somewhere on @tag and @tag should not contain extension } %{ - evaluate-commands %sh{ - this="$kak_buffile" - tag=$(echo $kak_selection | sed -e 's/^\@//') - other="$kak_opt_wiki_path/$tag.md" - relative=$(eval "$kak_opt_wiki_relative_path_program" "$other" $(dirname "$this")) - # sanity chceck - echo "execute-keys -draft '\A@[^@]+'" - echo "execute-keys \"c[$tag]($relative)\"" - echo "wiki_new_page \"$tag\"" - } -} - -define-command wiki_expand_pic \ --docstring %{ Expands images from @!filename.png form to ![filename.png](filename.png)} %{ - evaluate-commands %sh{ - this="$kak_buffile" - tag=$(echo $kak_selection | sed -e 's/^\@!//') - other="$kak_opt_wiki_path/$tag" - relative=$(eval "$kak_opt_wiki_relative_path_program" "$other" $(dirname "$this")) - # sanity check - echo execute-keys -draft '^@\+[^@!]+' - echo execute-keys "c![$tag]($relative)" - } -} - -define-command -params 1 -hidden \ --docstring %{ wiki_new_page [name]: create new wiki page in wiki_path if not exists } \ -wiki_new_page %{ - nop %sh{ - file="$kak_opt_wiki_path/${1%.md}" - mkdir -p "$(dirname $file)" - touch "${file}.md" - } -} - -define-command wiki_follow_link \ --docstring %{ Follow markdown link and open file if exists } %{ - evaluate-commands %{ - execute-keys %{ - c\[,\) - b - } - evaluate-commands -try-client %opt{jumpclient} edit -existing %sh{ - echo "${kak_buffile%/*.md}/$kak_selection" - } - try %{ focus %opt{jumpclient} } - } -} - -define-command wiki_toggle_checkbox \ --docstring "Toggle markdown checkbox in current line" %{ - try %{ - try %{ - execute-keys -draft %{ - ;xs-\s\[\s\][rX - }} catch %{ - execute-keys -draft %{ - ;xs-\s\[X\][r - }}} -} diff --git a/dot.config/kak/kakrc b/dot.config/kak/kakrc index 87fc850..97a55d8 100644 --- a/dot.config/kak/kakrc +++ b/dot.config/kak/kakrc @@ -5,8 +5,92 @@ set-option global aligntab true set-option global ui_options ncurses_assistant=dilbert set-option -add global ui_options ncurses_change_colors=true set-option global grepcmd 'rg --column' +set-option global tabstop 2 +set-option global indentwidth 2 -wiki_setup "/home/nk/Wiki" +# plug.kak plugin manager +source "%val{config}/plugins/plug.kak/rc/plug.kak" + + +plug "andreyorst/plug.kak" noload + +plug "lenormf/kakoune-extra" load %{ + autodownload.kak + fzy.kak +} + +############################################### +# lsp support (https://github.com/ul/kak-lsp) # +# ...but it's not working yet # +############################################### +plug "ul/kak-lsp" do %{ + cargo build --release --locked + cargo install --force --path . +} + +plug "TeddyDD/kakoune-wiki" config %{ + wiki_setup "/home/nk/Wiki" +} + +########################################################### +# kakoune-buffers # +# sets former b (word-back) to q and makes b a global key # +# for the new buffers command. I don't use macros anyway. # +########################################################### +plug 'delapouite/kakoune-buffers' config %{ + map global normal ^ q + map global normal Q + map global normal q b + map global normal Q B + map global normal + map global normal + map global normal b ': enter-buffers-mode' -docstring 'buffers' + map global normal B ': enter-user-mode -lock buffers' -docstring 'buffers (lock)' + hook·global·WinDisplay·.*·info-buffers +} + +plug "ABuffSeagull/kakoune-vue" +plug "ABuffSeagull/kakoune-wiki" + +############################################################ +# replace mode # +# that is one thing I missed in Kakoune: writing over text # +############################################################ +plug "alexherbo2/replace.kak" noload config %{ + ## currently not working well + # map global user r -docstring 'Replace' ': replace' +} + +########################################################### +# explore files (https://github.com/alexherbo2/explore.kak) +# use fd instead of find +########################################################### +plug "alexherbo2/explore.kak" config %{ + define-command -hidden -override explore-files-recursive -params 0..1 %{ + explore-files-display "fd %sh(test $kak_opt_explore_files_show_hidden = true && echo --hidden)" %arg(1) + } +} + +# TODO: check out snippets +# plug "alexherbo2/snippets.kak" config %{ +# } + +# TODO: check out tagbar +# plug "andreyorst/tagbar.kak" config %{ +# set-option global tagbar_sort false +# set-option global tagbar_size 40 +# set-option global tagbar_display_anon false +#} config %{ +# if you have wrap highlighter enamled in you configuration +# # files it's better to turn it off for tagbar, using this hook: +# hook global WinSetOption filetype=tagbar %{ +# remove-highlighter window/wrap +# # you can also disable rendering whitespaces here, line numbers, and +# # matching characters +# } +#} + +# set-option global fzf_filesearch_cmd "fd '%s'" # with inspiration from # https://github.com/Delapouite/dotfiles/blob/master/link/kak/kakrc @@ -20,6 +104,9 @@ hook global InsertEnd .* %{ lint } +# defines tabe and vsplit commands +# def -file-completion -params 1 tabe %{ tmux-terminal-window edit %arg{1} } + # spaces instead tabs map global insert ' '