From: Andre Ramnitz Date: Sat, 16 Dec 2023 18:47:09 +0000 (+0100) Subject: kak: update config X-Git-Tag: v0.2~311 X-Git-Url: https://git.ramnitz.eu/?a=commitdiff_plain;h=b655f25652e0208786278da349695e4c395e274c;p=dotfiles.git kak: update config --- diff --git a/.gitmodules b/.gitmodules index 0d7408af..9f126a68 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,10 +6,6 @@ path = kak/.config/kak/plugins/plug.kak url = https://github.com/andreyorst/plug.kak branch = master -[submodule "powerline.kak"] - path = kak/.config/kak/plugins/powerline.kak - url = https://github.com/andreyorst/powerline.kak - branch = master [submodule "shellcheck.kak"] path = kak/.config/kak/plugins/shellcheck.kak url = https://github.com/whereswaldon/shellcheck.kak @@ -42,3 +38,11 @@ path = kak/.config/kak/plugins/dabruin.kak url = https://git.sr.ht/~nasmevka/dabruin.kak branch = main +[submodule "kakoune-find"] + path = kak/.config/kak/plugins/kakoune-find + url = https://github.com/occivink/kakoune-find + branch = master +[submodule "kakounse-tabs"] + path = kak/.config/kak/plugins/tabs.kak + url = https://github.com/enricozb/tabs.kak + branch = main diff --git a/kak/.config/kak/kakrc b/kak/.config/kak/kakrc index cffc58bd..e97a433d 100644 --- a/kak/.config/kak/kakrc +++ b/kak/.config/kak/kakrc @@ -10,21 +10,9 @@ eval %sh{ kks init } # ───────────────────── source "%val{config}/plugins/plug.kak/rc/plug.kak" plug "andreyorst/plug.kak" noload - - plug "andreyorst/powerline.kak" defer powerline %{ - powerline-format global 'mode_info git bufname filetype client session line_column position' - } defer powerline_bufname %{ - set-option global powerline_shorten_bufname 'short' - } defer powerline_freerunner %{ - powerline-theme freerunner - } config %{ - powerline-start - } - plug "Ersikan/bookmarks.kak" %{ hook global WinCreate .* bookmarks-enable } - plug "andreyorst/smarttab.kak" defer smarttab %{ # when 'backspace' is pressed, 4 spaces are deleted at once set-option global softtabstop 4 @@ -36,11 +24,16 @@ plug "andreyorst/plug.kak" noload plug "whereswaldon/shellcheck.kak" plug "kakounedotcom/prelude.kak" plug "occivink/kakoune-sudo-write" + plug "occivink/kakoune-find" plug "foot.kak" plug "https://git.sr.ht/~nasmevka/dabruin.kak" + plug "https://github.com/enricozb/tabs.kak" # Look and Feel # ───────────── +set-option global tabs_modelinefmt '%val{cursor_line}:%val{cursor_char_column} {{mode_info}} ' +set-option global tabs_options --minified + add-highlighter global/trailing-whitespace regex '\h+$' 0:Error # trailing whitespaces in red add-highlighter global/todos regex '(//|#|/\*)\h*(TODO|WARNING|FIXME)[:]?[^\n]*' 2:+bu # highlight comment tags add-highlighter global/ show-matching # show matching brackets @@ -49,11 +42,6 @@ colorscheme dabruin set-option global tabstop 4 set-option global indentwidth 4 -# run on file open -hook global BufOpenFile .* %{ - modeline-parse -} - # dynamic scrolloff # ───────────────── hook global WinCreate [^*].* %{ @@ -129,6 +117,8 @@ map -docstring 'select lines downwards' global normal X TLx # see #inc map global normal ': inc %val{count} +' map global normal ': inc %val{count} -' +map global normal Q q # map q to Q +map global normal q -docstring 'tabs mode' ': enter-user-mode tabs' # map q to tabs mode # default user mode # # ────────── @@ -137,16 +127,21 @@ map global user -docstring 'disable autocomplete' A ': set-option -remove buffer map global user -docstring 'edit kakrc' e ': e ~/.config/kak/kakrc' map global user -docstring 'clean tabs and trailing whitespace in selections' c ': clean-selections' map global user -docstring 'clean tabs and trailing whitespace in the buffer' C ': clean-buffer' -map global user -docstring 'next buffer' n ': buffer-next' -map global user -docstring 'previous buffer' p ': buffer-previous' -map global user -docstring 'comment-line' l ': comment-line' +map global user -docstring 'buffer backward' b ': buffer-previous' +map global user -docstring 'buffer forward' n ': buffer-next' map global user -docstring 'lint-buffer' L ': buffer *lint-output*' map global user -docstring 'relative line numbers enable' r ': add-highlighter window/nl number-lines -relative -hlcursor' map global user -docstring 'relative line numbers disable' R ': remove-highlighter window/nl' map global user -docstring 'wrap enable' w ': add-highlighter buffer/bw wrap' map global user -docstring 'wrap disable' W ': remove-highlighter buffer/bw' +# tabs user mode +# # ────────── +map global normal -docstring 'kks mode' ': enter-user-mode kks' + + # kks user mode +# # ────────── declare-user-mode kks map global normal -docstring 'kks mode' ': enter-user-mode kks' map global kks f -docstring 'files' ': kks-connect terminal-popup kks-files' @@ -164,3 +159,67 @@ set-option global foot_normal_flags '' set-option global foot_popup_flags '-a popup' set-option global foot_panel_cmd 'foot' +# suspend and resume +# # ────────── +def suspend-and-resume \ + -params 1..2 \ + -docstring 'suspend-and-resume []: backgrounds current kakoune client and runs specified cli command. Upon exit of command the optional kak command is executed.' \ + %{ evaluate-commands %sh{ + + # Note we are adding '&& fg' which resumes the kakoune client process after the cli command exits + cli_cmd="$1 && fg" + post_resume_cmd="$2" + + # automation is different platform to platform + platform=$(uname -s) + case $platform in + Darwin) + automate_cmd="sleep 0.01; osascript -e 'tell application \"System Events\" to keystroke \"$cli_cmd\" & return '" + kill_cmd="/bin/kill" + break + ;; + Linux) + automate_cmd="sleep 0.2; xdotool type '$cli_cmd'; xdotool key Return" + kill_cmd="/usr/bin/kill" + break + ;; + esac + + # Uses platforms automation to schedule the typing of our cli command + nohup sh -c "$automate_cmd" > /dev/null 2>&1 & + # Send kakoune client to the background + $kill_cmd -SIGTSTP $kak_client_pid + + # ...At this point the kakoune client is paused until the " && fg " gets run in the $automate_cmd + + # Upon resume, run the kak command is specified + if [ ! -z "$post_resume_cmd" ]; then + echo "$post_resume_cmd" + fi +}} + +def for-each-line \ + -docstring "for-each-line : run command with the value of each line in the file" \ + -params 2 \ + %{ evaluate-commands %sh{ + + while read f; do + printf "$1 $f\n" + done < "$2" +}} + +def toggle-ranger %{ + suspend-and-resume \ + "ranger --choosefiles=/tmp/ranger-files-%val{client_pid}" \ + "for-each-line edit /tmp/ranger-files-%val{client_pid}" +} + +map global user f ': toggle-ranger' -docstring 'select files in ranger' + + +# run on file open +# ───────────── +hook global BufOpenFile .* %{ + modeline-parse +} + diff --git a/kak/.config/kak/plugins/bookmarks.kak b/kak/.config/kak/plugins/bookmarks.kak index 2e92602e..a8ed9af0 160000 --- a/kak/.config/kak/plugins/bookmarks.kak +++ b/kak/.config/kak/plugins/bookmarks.kak @@ -1 +1 @@ -Subproject commit 2e92602eef5ed1717660689765b93583eecce099 +Subproject commit a8ed9af060d6e5367ab54a6da6769d20d96be5c8 diff --git a/kak/.config/kak/plugins/kakoune-find b/kak/.config/kak/plugins/kakoune-find new file mode 160000 index 00000000..09afcc85 --- /dev/null +++ b/kak/.config/kak/plugins/kakoune-find @@ -0,0 +1 @@ +Subproject commit 09afcc8520d4c92928fe69da4c370b9979aa90d3 diff --git a/kak/.config/kak/plugins/powerline.kak b/kak/.config/kak/plugins/powerline.kak deleted file mode 160000 index 7ce52bc7..00000000 --- a/kak/.config/kak/plugins/powerline.kak +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7ce52bc766eef25d43040b8651d85bb189bcb896 diff --git a/kak/.config/kak/plugins/tabs.kak b/kak/.config/kak/plugins/tabs.kak new file mode 160000 index 00000000..ae66830f --- /dev/null +++ b/kak/.config/kak/plugins/tabs.kak @@ -0,0 +1 @@ +Subproject commit ae66830ffcc9b6a1ca58ebd4bb37ded58d3cdfdf