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
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
# ─────────────────────
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
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
set-option global tabstop 4
set-option global indentwidth 4
-# run on file open
-hook global BufOpenFile .* %{
- modeline-parse
-}
-
# dynamic scrolloff
# ─────────────────
hook global WinCreate [^*].* %{
# see #inc
map global normal <c-a> ': inc %val{count} +<ret>'
map global normal <c-x> ': inc %val{count} -<ret>'
+map global normal Q q # map q to Q
+map global normal q -docstring 'tabs mode' ': enter-user-mode tabs<ret>' # map q to tabs mode
# default user mode
# # ──────────
map global user -docstring 'edit kakrc' e ': e ~/.config/kak/kakrc<ret>'
map global user -docstring 'clean tabs and trailing whitespace in selections' c ': clean-selections<ret>'
map global user -docstring 'clean tabs and trailing whitespace in the buffer' C ': clean-buffer<ret>'
-map global user -docstring 'next buffer' n ': buffer-next<ret>'
-map global user -docstring 'previous buffer' p ': buffer-previous<ret>'
-map global user -docstring 'comment-line' l ': comment-line<ret>'
+map global user -docstring 'buffer backward' b ': buffer-previous<ret>'
+map global user -docstring 'buffer forward' n ': buffer-next<ret>'
map global user -docstring 'lint-buffer' L ': buffer *lint-output*<ret>'
map global user -docstring 'relative line numbers enable' r ': add-highlighter window/nl number-lines -relative -hlcursor<ret>'
map global user -docstring 'relative line numbers disable' R ': remove-highlighter window/nl<ret>'
map global user -docstring 'wrap enable' w ': add-highlighter buffer/bw wrap<ret>'
map global user -docstring 'wrap disable' W ': remove-highlighter buffer/bw<ret>'
+# tabs user mode
+# # ──────────
+map global normal <c-p> -docstring 'kks mode' ': enter-user-mode kks<ret>'
+
+
# kks user mode
+# # ──────────
declare-user-mode kks
map global normal <c-p> -docstring 'kks mode' ': enter-user-mode kks<ret>'
map global kks f -docstring 'files' ': kks-connect terminal-popup kks-files<ret>'
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 <cli command> [<kak command after 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 <command> <path to file>: 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<ret>' -docstring 'select files in ranger'
+
+
+# run on file open
+# ─────────────
+hook global BufOpenFile .* %{
+ modeline-parse
+}
+