]> Freerunner's - dotfiles.git/commitdiff
kak: overhaul kakoune's shell integration
authorAndre Ramnitz <tux.rising@gmail.com>
Tue, 19 Dec 2023 18:15:08 +0000 (19:15 +0100)
committerAndre Ramnitz <tux.rising@gmail.com>
Sun, 18 Aug 2024 16:18:52 +0000 (18:18 +0200)
27 files changed:
.gitmodules
bin/.local/bin/kcr-edit-search [new file with mode: 0755]
bin/.local/bin/kcr-fzf [new file with mode: 0755]
bin/.local/bin/kcr-fzf-buffers [new file with mode: 0755]
bin/.local/bin/kcr-fzf-files [new file with mode: 0755]
bin/.local/bin/kcr-fzf-grep [new file with mode: 0755]
bin/.local/bin/kcr-fzf-shell [new file with mode: 0755]
bin/.local/bin/kks [deleted file]
fish/.config/fish/fish_variables
fish/.config/fish/functions/:cat.fish [new file with mode: 0644]
fish/.config/fish/functions/K.fish [new file with mode: 0644]
fish/.config/fish/functions/a.fish [new file with mode: 0644]
fish/.config/fish/functions/k.fish
fish/.config/fish/functions/ka.fish [deleted file]
fish/.config/fish/functions/kcd.fish [deleted file]
fish/.config/fish/functions/kkd.fish [deleted file]
fish/.config/fish/functions/kl.fish [new file with mode: 0644]
fish/.config/fish/functions/ks.fish
foot/.config/foot/foot.ini
hypr/.config/hypr/hyprland.conf
hypr/.config/hypr/scripts/daemons.sh
kak/.config/kak/kakrc
kak/.config/kak/plugins/.build/kak-harpoon/config [new file with mode: 0644]
kak/.config/kak/plugins/kak-harpoon [new submodule]
kak/.config/kak/plugins/kakoune-filetree [new submodule]
kak/.config/kak/plugins/powerline.kak [new submodule]
kak/.config/kak/plugins/tabs.kak [deleted submodule]

index 9f126a68d1340d1416fe40803d4eed4d0c2045c3..07795eb289b38758c52c62d2f95655790b8f4c49 100644 (file)
@@ -46,3 +46,7 @@
        path = kak/.config/kak/plugins/tabs.kak
        url = https://github.com/enricozb/tabs.kak
        branch = main
+[submodule "kak/.config/kak/plugins/kak-harpoon"]
+       path = kak/.config/kak/plugins/kak-harpoon
+       url = https://github.com/raiguard/kak-harpoon
+       branch = main
diff --git a/bin/.local/bin/kcr-edit-search b/bin/.local/bin/kcr-edit-search
new file mode 100755 (executable)
index 0000000..c510649
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# Open files from search results.
+#
+# Usage:
+#
+# kcr edit-search [input: <file>:<line>:<column>:<text>]
+
+# Execute the following Kakoune commands.
+#
+# Input: <file>:<line>:<column>:<text>
+# Output: <file>␤<line>␤<column>
+select_each_line='<a-s>_'
+select_search_fields='s^(.+?):(\d+):(\d+):(.+?)$<ret>'
+save_selections='Z'
+select_file_save_and_restore='1s<ret>"fZz'
+select_line_save_and_restore='2s<ret>"f<a-Z>az'
+select_column_save_and_restore='3s<ret>"f<a-Z>az'
+select_data='"fz'
+prepare_output='y%<a-R>a<ret><esc>'
+delete_end_of_file='ged'
+
+kak -f "${select_each_line}${select_search_fields}${save_selections}${select_file_save_and_restore}${select_line_save_and_restore}${select_column_save_and_restore}${select_data}${prepare_output}${delete_end_of_file}" |
+
+while read file; read line; read column; do
+  kcr edit "$file" "+$line:$column"
+done
diff --git a/bin/.local/bin/kcr-fzf b/bin/.local/bin/kcr-fzf
new file mode 100755 (executable)
index 0000000..5af5259
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+"kcr-fzf-$@"
diff --git a/bin/.local/bin/kcr-fzf-buffers b/bin/.local/bin/kcr-fzf-buffers
new file mode 100755 (executable)
index 0000000..71efdfe
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Open buffers.
+#
+# Usage:
+#
+# kcr fzf buffers [patterns]
+
+# – fzf (https://github.com/junegunn/fzf)
+# – bat (https://github.com/sharkdp/bat)
+
+kcr get --raw --value buflist |
+grep -F "$*" |
+fzf --preview 'kcr cat --raw {} | bat --file-name {} --style=numbers --color=always --line-range :500' --header='Select a buffer to open' --prompt='(b)>' |
+
+# Open buffers
+while read name; do
+  kcr send buffer "$name"
+done
diff --git a/bin/.local/bin/kcr-fzf-files b/bin/.local/bin/kcr-fzf-files
new file mode 100755 (executable)
index 0000000..3253bb8
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Open files.
+#
+# Usage:
+#
+# kcr fzf files [paths]
+
+# – fzf (https://github.com/junegunn/fzf)
+# – fd (https://github.com/sharkdp/fd)
+# – bat (https://github.com/sharkdp/bat)
+
+fd --type file . "$@" |
+fzf --preview 'bat --style=numbers --color=always --line-range :500 {}' --header='Select a file to open' --prompt='(f)>' |
+
+# Open files
+while read file; do
+  kcr edit "$file"
+done
diff --git a/bin/.local/bin/kcr-fzf-grep b/bin/.local/bin/kcr-fzf-grep
new file mode 100755 (executable)
index 0000000..e3605c8
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Open files by content.
+#
+# Usage:
+#
+# kcr fzf grep [paths]
+
+# – fzf (https://github.com/junegunn/fzf)
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+# Not pretty but robust.
+# https://github.com/junegunn/fzf/issues/2581
+export PATHS_PATH=$(mktemp)
+trap 'rm "$PATHS_PATH"' EXIT
+for path do
+  echo "$path" >> "$PATHS_PATH"
+done
+
+SHELL=sh fzf --phony --delimiter ':' --ansi --bind 'change:reload(while read path; do set -- "$@" "$path"; done < "$PATHS_PATH"; rg --color=always --column --with-filename --fixed-strings -- {q} "$@" || true),enter:execute(kcr edit {1} +{2}:{3})+abort' --preview 'highlight_line={2} line_range_begin=$((line = highlight_line - (FZF_PREVIEW_LINES / 4) && line < 1 ? 1 : line)) line_range_end=$((line_range_begin + FZF_PREVIEW_LINES)) && bat --style=numbers --color=always --line-range "$line_range_begin:$line_range_end" --highlight-line {2} {1} 2> /dev/null' --header='Select a file to open' --prompt='(g)>'
diff --git a/bin/.local/bin/kcr-fzf-shell b/bin/.local/bin/kcr-fzf-shell
new file mode 100755 (executable)
index 0000000..33faa3a
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# Start an interactive shell.
+#
+# Usage:
+#
+# kcr fzf shell [command] [arguments]
+
+# – fzf (https://github.com/junegunn/fzf)
+
+set_environment() {
+  session=$1 client=${2#null} buffer_name=${3#null} working_directory=$4
+}
+
+# Run fzf with the session list
+rows=$(
+  kcr list --raw |
+  fzf --header='Select a session to switch to' --prompt='(s)>'
+)
+
+IFS='
+'
+for row in $rows; do
+  IFS='        '
+  set_environment $row
+
+  # Start an interactive shell
+  KAKOUNE_SESSION=$session KAKOUNE_CLIENT=$client kcr shell "$@"
+done
diff --git a/bin/.local/bin/kks b/bin/.local/bin/kks
deleted file mode 100755 (executable)
index fa37670..0000000
Binary files a/bin/.local/bin/kks and /dev/null differ
index 8ede98f4c53232e053c7048c276406a18499afe6..d5b57ecc0260d92690f04117089ba027d1fcc99c 100644 (file)
@@ -1,7 +1,8 @@
 # This file contains fish universal variable definitions.
 # VERSION: 3.0
-SETUVAR --export EDITOR:kks\x20edit
-SETUVAR --export KKS_DEFAULT_SESSION:default
+SETUVAR --export EDITOR:kcr\x20edit
+SETUVAR --export FZF_DEFAULT_OPTS:--multi\x20--layout=reverse\x20--preview-window=down:60%
+SETUVAR --export KCR_DEFAULT_SESSION:default
 SETUVAR --export VDPAU_DRIVER:radeonsi
 SETUVAR __fish_initialized:3400
 SETUVAR fish_color_autosuggestion:8e908c
diff --git a/fish/.config/fish/functions/:cat.fish b/fish/.config/fish/functions/:cat.fish
new file mode 100644 (file)
index 0000000..c82ad68
--- /dev/null
@@ -0,0 +1,3 @@
+function :cat --wraps='kcr cat --raw' --description 'alias :cat=kcr cat --raw'
+  kcr cat --raw $argv; 
+end
diff --git a/fish/.config/fish/functions/K.fish b/fish/.config/fish/functions/K.fish
new file mode 100644 (file)
index 0000000..bf4cb13
--- /dev/null
@@ -0,0 +1,3 @@
+function K --wraps=kcr-fzf-shell --description 'alias K=kcr-fzf-shell'
+  kcr-fzf-shell $argv; 
+end
diff --git a/fish/.config/fish/functions/a.fish b/fish/.config/fish/functions/a.fish
new file mode 100644 (file)
index 0000000..1e2c651
--- /dev/null
@@ -0,0 +1,3 @@
+function a --wraps='kcr attach' --description 'alias a=kcr attach'
+  kcr attach $argv; 
+end
index fd78e07ff0de64229bd55acf74f874fb321706b5..ad41f0dd220f85320c43da51d2eecc2865b29c26 100644 (file)
@@ -1,3 +1,3 @@
-function k --wraps='kks edit' --description 'alias k=kks edit'
-  kks edit $argv; 
+function k --wraps='kks edit' --wraps='kcr attach' --wraps='kcr edit' --description 'alias k=kcr edit'
+  kcr edit $argv; 
 end
diff --git a/fish/.config/fish/functions/ka.fish b/fish/.config/fish/functions/ka.fish
deleted file mode 100644 (file)
index acb3ce4..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-function ka --wraps='kks attach' --description 'alias ka=kks attach'
-  kks attach $argv; 
-end
diff --git a/fish/.config/fish/functions/kcd.fish b/fish/.config/fish/functions/kcd.fish
deleted file mode 100644 (file)
index eaf3ee6..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-function kcd --wraps='cd $(kks get %sh{pwd})' --description 'alias kcd=cd $(kks get %sh{pwd})'
-  cd $(kks get %sh{pwd}) $argv; 
-end
diff --git a/fish/.config/fish/functions/kkd.fish b/fish/.config/fish/functions/kkd.fish
deleted file mode 100644 (file)
index 58e7dbc..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-function kkd --wraps='kks kill; unset KKS_SESSION KKS_CLIENT' --description 'alias kkd=kks kill; unset KKS_SESSION KKS_CLIENT'
-  kks kill; unset KKS_SESSION KKS_CLIENT $argv; 
-end
diff --git a/fish/.config/fish/functions/kl.fish b/fish/.config/fish/functions/kl.fish
new file mode 100644 (file)
index 0000000..a9dda47
--- /dev/null
@@ -0,0 +1,3 @@
+function kl --wraps='kcr list' --description 'alias kl=kcr list'
+  kcr list $argv; 
+end
index a6205821539e4f1bc0c3e9fe59f282059f3eec74..63d3f45de48b6367d75b90990e5c0073f82ddaca 100644 (file)
@@ -1,3 +1,3 @@
-function ks --wraps='eval $(kks-select)' --description 'alias ks=eval $(kks-select)'
-  eval $(kks-select) $argv; 
+function ks --wraps='kcr shell --session' --description 'alias ks=kcr shell --session'
+  kcr shell --session $argv; 
 end
index ebc42643308bbcbd32d4be343c4c2a34645f073c..c9199c814dabec073ab27ee48dbc1ab0715a0b31 100644 (file)
@@ -80,29 +80,37 @@ label-letters=adfghjkl
 [colors]
 alpha=0.90
 
-# background=242424
-# foreground=ffffff
+background=242124
+foreground=f5f5f5
 # flash=7f7f00
 # flash-alpha=0.5
 
 ## Normal/regular colors (color palette 0-7)
-# regular0=242424  # black
+regular0=242424    # black
 # regular1=f62b5a  # red
 # regular2=47b413  # green
-# regular3=e3c401  # yellow
+regular2=91bc61   # bright green
+regular3=ffb852    # yellow
 # regular4=24acd4  # blue
-# regular5=f2affd  # magenta
+regular4=5d81d2
+regular5=776d96 # magenta
 # regular6=13c299  # cyan
-# regular7=e6e6e6  # white
+regular6=90e0e0
+regular7=f5f5f5  # white
 
 ## Bright colors (color palette 8-15)
-# bright0=616161   # bright black
+bright0=3d4c59     # bright black
 # bright1=ff4d51   # bright red
 # bright2=35d450   # bright green
+bright2=91bc61   # bright green
 # bright3=e9e836   # bright yellow
+bright3=ffb852   # bright yellow
 # bright4=5dc5f8   # bright blue
+bright4=5d81d2
 # bright5=feabf2   # bright magenta
+bright5=776d96 # magenta
 # bright6=24dfc4   # bright cyan
+bright6=90e0e0
 # bright7=ffffff   # bright white
 
 ## dimmed colors (see foot.ini(5) man page)
index 37656cb103838cb14b1ad30ac89a4ffb2f08ce67..10e343efff352678fa822eefeb9ff617fc8bc0ce 100644 (file)
@@ -173,6 +173,7 @@ windowrulev2 = float, size 1560 1000, pin, workspace special:overlay, class:^(or
 windowrule = float, ^(firefox)$
 windowrulev2 = opacity 1.0 override 0.8 override, group, class:^(foot)$
 windowrulev2 = float, opacity 1.0 override 0.8 override, class:^(popup)$
+windowrulev2 = float, noanim, stayfocused, maxsize 1280 800, center, opacity 1.0 override, class:^(kakpopup)$
 windowrule = float, ^(openrgb)$
 windowrule = float, ^(org.kde.*)$
 # windowrule = float, ^(org.kde.okular)$
index 8ae5f5bf72616954fb966811b824a52887344225..f25aefa245c4c78337393a6ab09d264c33cb2b2c 100755 (executable)
@@ -15,7 +15,7 @@ if [[ ! $(pidof swww-daemon) ]]; then
 fi
 
 openrgb -p simple.orp &
-kak -d -s default &
+kak -d -s default & # kakoune default server
 
 wl-paste --type  text --watch cliphist store &
 wl-paste --type image --watch cliphist store &
index e97a433d8d84f7cc68088cb2cbd0e82c6d2e5b62..bf62166d02b4249a1a0575760e53bd15497bb3a0 100644 (file)
@@ -1,13 +1,11 @@
 # Clipboard (wayland) integration
+# ──────────────────────────────────────────────────────────────────────────────
 hook global NormalKey y %{ nop %sh{
   printf %s "$kak_main_reg_dquote" | wl-copy > /dev/null 2>&1 &
 }}
 
-# Kakoune shell integration, see https://github.com/kkga/kks
-eval %sh{ kks init }
-
 # Enable PLUGin manager
-# ─────────────────────
+# ──────────────────────────────────────────────────────────────────────────────
 source "%val{config}/plugins/plug.kak/rc/plug.kak"
 plug "andreyorst/plug.kak" noload
     plug "Ersikan/bookmarks.kak" %{
@@ -22,18 +20,25 @@ plug "andreyorst/plug.kak" noload
        hook global WinSetOption filetype=(c|cpp) smarttab
     }
     plug "whereswaldon/shellcheck.kak"
-    plug "kakounedotcom/prelude.kak"
+    plug "occivink/kakoune-filetree"
     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"
+    plug "andreyorst/powerline.kak" defer powerline_freerunner %{
+        powerline-format global 'mode_info git bufname session client line_column position '
+        powerline-theme freerunner
+        powerline-separator triangle
+    } config %{
+        powerline-start
+    }
+    plug "raiguard/kak-harpoon" %{
+        hook global WinCreate .* harpoon-add-bindings
+    }
 
-# Look and Feel
-# ─────────────
-set-option global tabs_modelinefmt '%val{cursor_line}:%val{cursor_char_column} {{mode_info}} '
-set-option global tabs_options --minified
 
+# Look and Feel
+# ──────────────────────────────────────────────────────────────────────────────
 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
@@ -42,8 +47,9 @@ colorscheme dabruin
 set-option global tabstop 4
 set-option global indentwidth 4
 
+
 # dynamic scrolloff
-# ─────────────────
+# ──────────────────────────────────────────────────────────────────────────────
 hook global WinCreate [^*].* %{
     hook -once window WinDisplay .* %{
         hook window WinResize [0-9]*\.[0-9]* %{
@@ -54,8 +60,9 @@ hook global WinCreate [^*].* %{
     }
 }
 
+
 # Different Cursor color in insert mode
-# ─────────────────────────────────────
+# ──────────────────────────────────────────────────────────────────────────────
 # Shades of blue/cyan for normal mode
 set-face global PrimarySelection white,blue+F
 set-face global SecondarySelection black,blue+F
@@ -66,12 +73,12 @@ set-face global SecondaryCursorEol black,bright-blue
 
 # Shades of green/yellow for insert mode.
 hook global ModeChange (push|pop):.*:insert %{
-    set-face window PrimarySelection white,green+F
-    set-face window SecondarySelection black,green+F
-    set-face window PrimaryCursor black,bright-yellow+F
-    set-face window SecondaryCursor black,bright-green+F
-    set-face window PrimaryCursorEol black,bright-yellow
-    set-face window SecondaryCursorEol black,bright-green
+    set-face window PrimarySelection black,yellow+F
+    set-face window SecondarySelection black,yellow+F
+    set-face window PrimaryCursor black,bright-red+F
+    set-face window SecondaryCursor black,bright-yellow+F
+    set-face window PrimaryCursorEol black,bright-red
+    set-face window SecondaryCursorEol black,bright-yellow
 }
 
 # Undo colour changes when we leave insert mode.
@@ -84,12 +91,14 @@ hook global ModeChange (push|pop):insert:.* %{
     unset-face window SecondaryCursorEol
 }
 
+
 # Enable editor config
-# ────────────────────
+# ──────────────────────────────────────────────────────────────────────────────
 hook global WinCreate ^[^*]+$ %{ editorconfig-load }
 
+
 # Extra editor commands
-# ─────────────────────
+# ──────────────────────────────────────────────────────────────────────────────
 # tab replacement
 define-command clean-selections -docstring 'Replace tabs with spaces and trim trailing whitespace' %{ try %{
     execute-keys -draft @s\h+$<ret>d
@@ -109,7 +118,7 @@ define-command -hidden -params 2 inc %{ try %{
 
 
 # Various mappings
-# ────────────────
+# ──────────────────────────────────────────────────────────────────────────────
 map global normal '#' :comment-line<ret> -docstring 'comment line'
 map global normal '<a-#>' :comment-block<ret> -docstring 'comment block'
 map global goto m '<esc>m;' -docstring 'matching char'
@@ -118,10 +127,11 @@ map -docstring 'select lines downwards' global normal X T<ret>Lx
 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
+#map global normal q -docstring 'tabs mode' ': enter-user-mode tabs<ret>' # map q to tabs mode
+
 
 # default user mode
-# ──────────
+# ──────────────────────────────────────────────────────────────────────────────
 map global user -docstring 'enable autocomplete' a ': set-option -add buffer autocomplete insert<ret>'
 map global user -docstring 'disable autocomplete' A ': set-option -remove buffer autocomplete insert<ret>'
 map global user -docstring 'edit kakrc' e ': e ~/.config/kak/kakrc<ret>'
@@ -135,91 +145,126 @@ map global user -docstring 'relative line numbers disable' R ': remove-highlight
 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>'
-map global kks F       -docstring 'files (all)'      ': kks-connect terminal-popup kks-files -HI<ret>'
-map global kks g       -docstring 'git files'        ': kks-connect terminal-popup kks-git-files<ret>'
-map global kks b       -docstring 'buffers'          ': kks-connect terminal-popup kks-buffers<ret>'
-map global kks /       -docstring 'live grep'        ': kks-connect terminal-popup kks-grep<ret>'
-map global kks l       -docstring 'lines in buffer'  ': kks-connect terminal-popup kks-lines<ret>'
-map global kks r       -docstring 'recent files'     ': kks-connect terminal-popup kks-mru<ret>'
-map global kks <a-f>   -docstring 'filetypes'        ': kks-connect terminal-popup kks-filetypes<ret>'
 
+# terminal config (via foot.kak)
+# ──────────────────────────────────────────────────────────────────────────────
 set-option global foot_normal_cmd 'foot'
 set-option global foot_popup_cmd 'foot'
 set-option global foot_normal_flags ''
-set-option global foot_popup_flags '-a popup'
+set-option global foot_popup_flags '-a kakpopup'
 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{
+# # 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{
 
-    while read f; do
-        printf "$1 $f\n"
-    done < "$2"
-}}
+#     # Note we are adding '&& fg' which resumes the kakoune client process after the cli command exits
+#     cli_cmd="$1 && fg"
+#     post_resume_cmd="$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}"
-}
+#     # 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
 
-map global user f ': toggle-ranger<ret>' -docstring 'select files in ranger'
+#     # 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
 }
 
+# session manager
+# ──────────────────────────────────────────────────────────────────────────────
+evaluate-commands %sh{
+    kcr init kakoune
+}
+
+# kakoune.cr Mappings
+map -docstring 'new client' global normal <c-t> ': new<ret>'
+map -docstring 'terminal (popup)' global normal <c-ret> ': connect terminal-popup<ret>'
+map -docstring 'git (popup)' global normal <c-l> ': connect terminal-popup gitui<ret>'
+#map -docstring 'file explorer' global normal <c-e> ': connect terminal-panel sidetree --select %val{buffile}<ret>'
+map -docstring 'file picker' global normal <c-f> ': connect terminal-popup kcr fzf files<ret>'
+map -docstring 'buffer picker' global normal <c-b> ': connect terminal-popup kcr fzf buffers<ret>'
+map global normal <q> <Q>
+unmap global normal <q>
+map -docstring 'buffer picker' global normal <q> ': connect terminal-popup kcr fzf buffers<ret>'
+map -docstring 'grep picker' global normal <c-g> ': connect terminal-popup kcr fzf grep<ret>'
+#map -docstring 'grep picker (buffer)' global normal <c-r> ': connect terminal-popup kcr fzf grep %val{buflist}<ret>'
+
+
+# Reload kakrc and .kak when saving.
+# ──────────────────────────────────────────────────────────────────────────────
+# Adds -override to definitions (unless they seem to be python defs!)
+# Evals provide module directly
+
+def resource -params 1 %{
+    eval %sh{
+        file=$(dirname "$1")/.reload.kak
+        cat "$1" |
+            sed 's/^def \([^:]*\)$/def -override \1/'   |
+            sed 's/^define-command /def -override /'    |
+            sed 's/^addhl /addhl -override/'            |
+            sed 's/^add-highlighter /addhl -override /' |
+            sed 's/^provide-module \w\+ /eval /'        |
+            cat > "$file"
+        printf %s "
+            source $file
+            nop %sh{
+                rm $file
+            }
+        "
+    }
+    echo Reloaded %arg{1}
+}
+
+rmhooks global reload-kak
+hook -group reload-kak global BufWritePost (.*kakrc|.*\.kak) %{
+     resource %val{hook_param}
+}
diff --git a/kak/.config/kak/plugins/.build/kak-harpoon/config b/kak/.config/kak/plugins/.build/kak-harpoon/config
new file mode 100644 (file)
index 0000000..8b5a70e
--- /dev/null
@@ -0,0 +1,19 @@
+try %{ 
+
+        hook global WinCreate .* harpoon-add-bindings
+     } catch %{
+    echo -debug "Error while evaluating 'kak-harpoon' configuration: %val{error}"
+
+    set-option -add current plug_conf_errors "Error while evaluating 'kak-harpoon' configuration:"
+    set-option -add current plug_conf_errors %sh{ printf "\n    " }
+    set-option -add current plug_conf_errors %val{error}
+    set-option -add current plug_conf_errors %sh{ printf "\n\n" }
+
+    hook -once -group plug-conf-err global WinDisplay .* %{
+        info -style modal -title "plug.kak error" "%opt{plug_conf_errors}"
+        on-key %{
+            info -style modal
+            execute-keys -with-maps -with-hooks %val{key}
+        }
+    }
+}
diff --git a/kak/.config/kak/plugins/kak-harpoon b/kak/.config/kak/plugins/kak-harpoon
new file mode 160000 (submodule)
index 0000000..15e0a01
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 15e0a01d2c5720c576375e7e6b271a5f84dcad2a
diff --git a/kak/.config/kak/plugins/kakoune-filetree b/kak/.config/kak/plugins/kakoune-filetree
new file mode 160000 (submodule)
index 0000000..be8158c
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit be8158ce83e295830a48057c0580fe17a843d661
diff --git a/kak/.config/kak/plugins/powerline.kak b/kak/.config/kak/plugins/powerline.kak
new file mode 160000 (submodule)
index 0000000..43e60c4
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 43e60c48d7f6da98055ee6a4d02fa949e5ef2805
diff --git a/kak/.config/kak/plugins/tabs.kak b/kak/.config/kak/plugins/tabs.kak
deleted file mode 160000 (submodule)
index ae66830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit ae66830ffcc9b6a1ca58ebd4bb37ded58d3cdfdf