summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorMike Vink <ivi@vinkies.net>2025-09-30 19:50:21 +0200
committerMike Vink <ivi@vinkies.net>2025-09-30 19:50:21 +0200
commit68c6fb81de8840854c7d33ae64684f94a0d703ff (patch)
treebd4a7296d268e109ca229ed4acf349b45718c51d /.config
parentab11187605662d8bcd59ee43eeac8722bd3b690f (diff)
kak: move over autoload stuff
Diffstat (limited to '.config')
-rw-r--r--.config/kak/autoload/connect.kak133
-rwxr-xr-x.config/kak/autoload/connect/aliases/:6
-rwxr-xr-x.config/kak/autoload/connect/aliases/:a4
-rwxr-xr-x.config/kak/autoload/connect/aliases/:b21
-rwxr-xr-x.config/kak/autoload/connect/aliases/:e71
-rwxr-xr-x.config/kak/autoload/connect/aliases/:f22
-rwxr-xr-x.config/kak/autoload/connect/aliases/:o3
-rwxr-xr-x.config/kak/autoload/connect/aliases/:t3
-rwxr-xr-x.config/kak/autoload/connect/aliases/@6
-rwxr-xr-x.config/kak/autoload/connect/aliases/a4
-rwxr-xr-x.config/kak/autoload/connect/aliases/b21
-rwxr-xr-x.config/kak/autoload/connect/aliases/e71
-rwxr-xr-x.config/kak/autoload/connect/aliases/f22
-rwxr-xr-x.config/kak/autoload/connect/aliases/o3
-rwxr-xr-x.config/kak/autoload/connect/aliases/t3
-rwxr-xr-x.config/kak/autoload/connect/commands/:attach4
-rwxr-xr-x.config/kak/autoload/connect/commands/:buffer21
-rwxr-xr-x.config/kak/autoload/connect/commands/:bwd4
-rwxr-xr-x.config/kak/autoload/connect/commands/:cat7
-rwxr-xr-x.config/kak/autoload/connect/commands/:cd!4
-rwxr-xr-x.config/kak/autoload/connect/commands/:edit71
-rwxr-xr-x.config/kak/autoload/connect/commands/:edit-search25
-rwxr-xr-x.config/kak/autoload/connect/commands/:edit-wait27
-rwxr-xr-x.config/kak/autoload/connect/commands/:fifo22
-rwxr-xr-x.config/kak/autoload/connect/commands/:get12
-rwxr-xr-x.config/kak/autoload/connect/commands/:it4
-rwxr-xr-x.config/kak/autoload/connect/commands/:ls6
-rwxr-xr-x.config/kak/autoload/connect/commands/:make9
-rwxr-xr-x.config/kak/autoload/connect/commands/:open3
-rwxr-xr-x.config/kak/autoload/connect/commands/:pwd3
-rwxr-xr-x.config/kak/autoload/connect/commands/:send6
-rwxr-xr-x.config/kak/autoload/connect/commands/:terminal3
-rw-r--r--.config/kak/autoload/connect/env/.git.env.kak.54n8Ol2
-rw-r--r--.config/kak/autoload/connect/env/default.env3
-rw-r--r--.config/kak/autoload/connect/env/git.env1
-rw-r--r--.config/kak/autoload/connect/env/kakoune.env4
-rw-r--r--.config/kak/autoload/connect/env/overrides.env6
-rw-r--r--.config/kak/autoload/connect/modules/broot/broot.kak18
-rwxr-xr-x.config/kak/autoload/connect/modules/dmenu/aliases/:dmenu11
-rwxr-xr-x.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-buffers12
-rwxr-xr-x.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-files11
-rwxr-xr-x.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-grep11
-rw-r--r--.config/kak/autoload/connect/modules/dmenu/dmenu.kak33
-rwxr-xr-x.config/kak/autoload/connect/modules/dolphin/commands/:dolphin15
-rw-r--r--.config/kak/autoload/connect/modules/dolphin/dolphin.kak15
-rw-r--r--.config/kak/autoload/connect/modules/fifo/fifo.kak12
-rwxr-xr-x.config/kak/autoload/connect/modules/fzf/aliases/:fzf12
-rwxr-xr-x.config/kak/autoload/connect/modules/fzf/commands/:fzf-buffers15
-rwxr-xr-x.config/kak/autoload/connect/modules/fzf/commands/:fzf-files12
-rwxr-xr-x.config/kak/autoload/connect/modules/fzf/commands/:fzf-grep11
-rw-r--r--.config/kak/autoload/connect/modules/fzf/fzf.kak34
-rwxr-xr-x.config/kak/autoload/connect/modules/fzy/aliases/:fzy11
-rwxr-xr-x.config/kak/autoload/connect/modules/fzy/commands/:fzy-buffers12
-rwxr-xr-x.config/kak/autoload/connect/modules/fzy/commands/:fzy-files11
-rwxr-xr-x.config/kak/autoload/connect/modules/fzy/commands/:fzy-grep11
-rw-r--r--.config/kak/autoload/connect/modules/fzy/fzy.kak33
-rw-r--r--.config/kak/autoload/connect/modules/lf/lf.kak15
-rw-r--r--.config/kak/autoload/connect/modules/nnn/nnn.kak18
-rwxr-xr-x.config/kak/autoload/connect/modules/rofi/aliases/:rofi11
-rwxr-xr-x.config/kak/autoload/connect/modules/rofi/commands/:rofi-buffers12
-rwxr-xr-x.config/kak/autoload/connect/modules/rofi/commands/:rofi-files11
-rwxr-xr-x.config/kak/autoload/connect/modules/rofi/commands/:rofi-grep11
-rw-r--r--.config/kak/autoload/connect/modules/rofi/rofi.kak33
-rwxr-xr-x.config/kak/autoload/connect/modules/wofi/aliases/:wofi11
-rwxr-xr-x.config/kak/autoload/connect/modules/wofi/commands/:wofi-buffers12
-rwxr-xr-x.config/kak/autoload/connect/modules/wofi/commands/:wofi-files11
-rwxr-xr-x.config/kak/autoload/connect/modules/wofi/commands/:wofi-grep11
-rw-r--r--.config/kak/autoload/connect/modules/wofi/wofi.kak33
-rwxr-xr-x.config/kak/autoload/connect/tools/realpath10
-rw-r--r--.config/kak/autoload/rc/prelude.kak5
-rw-r--r--.config/kak/autoload/rc/prelude.sh24
-rw-r--r--.config/kak/autoload/snippets.kak396
-rw-r--r--.config/kak/kakrc11
-rw-r--r--.config/kak/snippets.kak29
74 files changed, 1604 insertions, 0 deletions
diff --git a/.config/kak/autoload/connect.kak b/.config/kak/autoload/connect.kak
new file mode 100644
index 0000000..5e78305
--- /dev/null
+++ b/.config/kak/autoload/connect.kak
@@ -0,0 +1,133 @@
+# Save the connect paths
+declare-option -hidden str connect_root_path %sh(dirname "$kak_source")
+declare-option -hidden str connect_modules_path "%opt{connect_root_path}/connect/modules"
+
+# Default modules
+hook global ModuleLoaded connect %{
+ require-module connect-fifo
+}
+
+provide-module connect %{
+ # Modules
+ require-module prelude
+
+ # Options
+ declare-option -docstring 'connect environment' str connect_environment
+
+ # Connect paths
+ declare-option -docstring 'connect paths' str-list connect_paths
+
+ # Internal variable to mirror the connect paths as PATH.
+ declare-option -hidden str connect_environment_paths
+
+ # Watch the connect_paths option
+ hook -group connect-watch-connect-paths global WinSetOption 'connect_paths=.*' %{
+ evaluate-commands %sh{
+ # Prelude
+ . "$kak_opt_prelude_path"
+
+ eval "set -- $kak_quoted_opt_connect_paths"
+
+ # Iterate paths
+ paths=''
+ for path do
+ paths=$paths:$path
+ done
+
+ # Update the option
+ kak_escape set-option global connect_environment_paths "$paths"
+ }
+ }
+
+ # Initialize the option with the user config paths
+ set-option global connect_paths "%val{config}/connect/aliases" "%val{config}/connect/commands"
+
+ # Commands
+ define-command connect-terminal -params .. -shell-completion -docstring 'Open a new terminal' %{
+ connect terminal %arg{@}
+ }
+
+ define-command connect-popup -params 1.. -shell-completion -docstring 'Open a new popup' %{
+ connect popup %arg{@}
+ }
+
+ define-command connect-repl -params .. -shell-completion -docstring 'Open a new REPL' %{
+ connect repl-new %arg{@}
+ }
+
+ define-command connect-shell -params 1.. -shell-completion -docstring 'Execute commands in a shell' %{
+ connect sh %arg{@}
+ }
+
+ define-command connect-detach -params .. -shell-completion -docstring 'Write an attachable program to connect.sh and detach the client' %{
+ connect detach %arg{@}
+ }
+
+ define-command connect -params 1.. -command-completion -docstring 'Run the given command as <command> sh -c {connect} -- [arguments]. Example: connect terminal sh' %{
+ %arg{1} sh -c %{
+ kak_opt_prelude_path=$1
+ kak_opt_connect_root_path=$2
+ kak_opt_connect_environment=$3
+ kak_opt_connect_environment_paths=$4
+ kak_session=$5
+ kak_client=$6
+ kak_server_working_directory=$7
+
+ . "$kak_opt_connect_root_path/connect/env/default.env"
+ . "$kak_opt_connect_root_path/connect/env/overrides.env"
+ . "$kak_opt_connect_root_path/connect/env/kakoune.env"
+ . "$kak_opt_connect_root_path/connect/env/git.env"
+
+ eval "$kak_opt_connect_environment"
+
+ shift 8
+
+ cd "$kak_server_working_directory"
+
+ [ "$1" ] && "$@" || "$SHELL"
+ } -- \
+ %opt{prelude_path} \
+ %opt{connect_root_path} \
+ %opt{connect_environment} \
+ %opt{connect_environment_paths} \
+ %val{session} \
+ %val{client} \
+ %sh{pwd} \
+ %arg{@}
+ }
+
+ # Note:
+ #
+ # The `sh` command is out of connect.kak’s scope,
+ # as the command does not connect things.
+ # It is used as an interface to run GUI programs.
+ #
+ # Example: connect sh dolphin
+ define-command sh -params 1.. -shell-completion -docstring 'Execute commands in a shell' %{
+ nop %sh{
+ setsid "$@" < /dev/null > /dev/null 2>&1 &
+ }
+ }
+
+ define-command detach -params 1.. -shell-completion -docstring 'Write an attachable program to connect.sh and detach the client' %{
+ # Could be simpler with `echo -to-file <file> -append <text>`
+ # https://github.com/mawww/kakoune/issues/3874
+ echo -to-file "%val{client_env_PWD}/connect.sh~" -quoting shell %arg{@}
+
+ # Remove connect.sh on source
+ nop %sh{
+ echo 'rm "$0"' | cat - "$kak_client_env_PWD/connect.sh~" > "$kak_client_env_PWD/connect.sh"
+ rm "$kak_client_env_PWD/connect.sh~"
+ }
+
+ # Detach the client
+ quit
+ }
+
+ # Aliases
+ alias global > connect-terminal
+ alias global + connect-popup
+ alias global @ connect-repl
+ alias global $ connect-shell
+ alias global & connect-detach
+}
diff --git a/.config/kak/autoload/connect/aliases/: b/.config/kak/autoload/connect/aliases/:
new file mode 100755
index 0000000..86f90a6
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/:
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+. "$KAKOUNE_PRELUDE"
+
+# Send commands to the client
+kak_escape evaluate-commands -try-client "$KAKOUNE_CLIENT" "$@" | kak -p "$KAKOUNE_SESSION"
diff --git a/.config/kak/autoload/connect/aliases/:a b/.config/kak/autoload/connect/aliases/:a
new file mode 100755
index 0000000..2894021
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/:a
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Reattach to the session.
+kak -c "$KAKOUNE_SESSION" "$@"
diff --git a/.config/kak/autoload/connect/aliases/:b b/.config/kak/autoload/connect/aliases/:b
new file mode 100755
index 0000000..c44118a
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/:b
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Open buffers.
+#
+# Usage:
+#
+# :buffer <buffer>
+# [buffers] | :buffer
+
+# Read buffers from stdin
+if [ ! -t 0 ]; then
+ while read buffer; do
+ set -- "$buffer" "$@"
+ done
+fi
+
+# Open buffer
+:send -verbatim buffer "$@"
+
+# Focus back the client
+:send focus
diff --git a/.config/kak/autoload/connect/aliases/:e b/.config/kak/autoload/connect/aliases/:e
new file mode 100755
index 0000000..45708f2
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/:e
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+# Open files.
+#
+# Usage:
+#
+# :edit <file>
+# :edit +<line> <file>
+# :edit +<line>:<column> <file>
+# [files] | :edit
+#
+# Note: Order matters.
+
+. "$KAKOUNE_PRELUDE"
+
+# Read files from stdin when a terminal is available.
+# Reason: kak-desktop
+if [ ! -t 0 -a -t 1 ]; then
+ while read file; do
+ set -- "$file" "$@"
+ done
+fi
+
+# Skip options
+[ "$1" = '--' ] && shift
+
+# Open files at the given position (line and column) if specified (before or after the file).
+commands=$(
+ while [ "$1" ]; do
+ case "$1" in
+ ('+'*':'*)
+ line=${1#+}; line=${line%:*}
+ column=${1#*:}
+ file=$(realpath "$2")
+ shift 2
+ kak_escape edit "$file" "$line" "$column"
+ ;;
+ ('+'*)
+ line=${1#+}
+ file=$(realpath "$2")
+ shift 2
+ kak_escape edit "$file" "$line"
+ ;;
+ (*)
+ file=$(realpath "$1")
+ shift
+ case "$1" in
+ ('+'*':'*)
+ line=${1#+}; line=${line%:*}
+ column=${1#*:}
+ shift
+ kak_escape edit "$file" "$line" "$column"
+ ;;
+ ('+'*)
+ line=${1#+}
+ shift
+ kak_escape edit "$file" "$line"
+ ;;
+ (*)
+ kak_escape edit "$file"
+ ;;
+ esac
+ ;;
+ esac
+ done
+)
+
+:send "$commands"
+
+# Focus back the client
+:send focus
diff --git a/.config/kak/autoload/connect/aliases/:f b/.config/kak/autoload/connect/aliases/:f
new file mode 100755
index 0000000..ea2ede0
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/:f
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Edit fifo buffer in a client
+mkfifo buffer.fifo
+trap 'rm buffer.fifo' EXIT
+:send edit! -fifo "$PWD/buffer.fifo" '*fifo*'
+
+# Send to fifo buffer the output of the given command,
+# or read from stdin if available.
+#
+# Example:
+#
+# :fifo make
+#
+if test $# -gt 0; then
+ "$@" > buffer.fifo 2>&1 &
+elif test ! -t 0; then
+ cat > buffer.fifo
+fi
+
+# Focus back the client
+:send focus
diff --git a/.config/kak/autoload/connect/aliases/:o b/.config/kak/autoload/connect/aliases/:o
new file mode 100755
index 0000000..6d5ad49
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/:o
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+:terminal :attach "$@"
diff --git a/.config/kak/autoload/connect/aliases/:t b/.config/kak/autoload/connect/aliases/:t
new file mode 100755
index 0000000..3ec0933
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/:t
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+:send '>' "$@"
diff --git a/.config/kak/autoload/connect/aliases/@ b/.config/kak/autoload/connect/aliases/@
new file mode 100755
index 0000000..86f90a6
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/@
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+. "$KAKOUNE_PRELUDE"
+
+# Send commands to the client
+kak_escape evaluate-commands -try-client "$KAKOUNE_CLIENT" "$@" | kak -p "$KAKOUNE_SESSION"
diff --git a/.config/kak/autoload/connect/aliases/a b/.config/kak/autoload/connect/aliases/a
new file mode 100755
index 0000000..2894021
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/a
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Reattach to the session.
+kak -c "$KAKOUNE_SESSION" "$@"
diff --git a/.config/kak/autoload/connect/aliases/b b/.config/kak/autoload/connect/aliases/b
new file mode 100755
index 0000000..c44118a
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/b
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Open buffers.
+#
+# Usage:
+#
+# :buffer <buffer>
+# [buffers] | :buffer
+
+# Read buffers from stdin
+if [ ! -t 0 ]; then
+ while read buffer; do
+ set -- "$buffer" "$@"
+ done
+fi
+
+# Open buffer
+:send -verbatim buffer "$@"
+
+# Focus back the client
+:send focus
diff --git a/.config/kak/autoload/connect/aliases/e b/.config/kak/autoload/connect/aliases/e
new file mode 100755
index 0000000..45708f2
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/e
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+# Open files.
+#
+# Usage:
+#
+# :edit <file>
+# :edit +<line> <file>
+# :edit +<line>:<column> <file>
+# [files] | :edit
+#
+# Note: Order matters.
+
+. "$KAKOUNE_PRELUDE"
+
+# Read files from stdin when a terminal is available.
+# Reason: kak-desktop
+if [ ! -t 0 -a -t 1 ]; then
+ while read file; do
+ set -- "$file" "$@"
+ done
+fi
+
+# Skip options
+[ "$1" = '--' ] && shift
+
+# Open files at the given position (line and column) if specified (before or after the file).
+commands=$(
+ while [ "$1" ]; do
+ case "$1" in
+ ('+'*':'*)
+ line=${1#+}; line=${line%:*}
+ column=${1#*:}
+ file=$(realpath "$2")
+ shift 2
+ kak_escape edit "$file" "$line" "$column"
+ ;;
+ ('+'*)
+ line=${1#+}
+ file=$(realpath "$2")
+ shift 2
+ kak_escape edit "$file" "$line"
+ ;;
+ (*)
+ file=$(realpath "$1")
+ shift
+ case "$1" in
+ ('+'*':'*)
+ line=${1#+}; line=${line%:*}
+ column=${1#*:}
+ shift
+ kak_escape edit "$file" "$line" "$column"
+ ;;
+ ('+'*)
+ line=${1#+}
+ shift
+ kak_escape edit "$file" "$line"
+ ;;
+ (*)
+ kak_escape edit "$file"
+ ;;
+ esac
+ ;;
+ esac
+ done
+)
+
+:send "$commands"
+
+# Focus back the client
+:send focus
diff --git a/.config/kak/autoload/connect/aliases/f b/.config/kak/autoload/connect/aliases/f
new file mode 100755
index 0000000..ea2ede0
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/f
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Edit fifo buffer in a client
+mkfifo buffer.fifo
+trap 'rm buffer.fifo' EXIT
+:send edit! -fifo "$PWD/buffer.fifo" '*fifo*'
+
+# Send to fifo buffer the output of the given command,
+# or read from stdin if available.
+#
+# Example:
+#
+# :fifo make
+#
+if test $# -gt 0; then
+ "$@" > buffer.fifo 2>&1 &
+elif test ! -t 0; then
+ cat > buffer.fifo
+fi
+
+# Focus back the client
+:send focus
diff --git a/.config/kak/autoload/connect/aliases/o b/.config/kak/autoload/connect/aliases/o
new file mode 100755
index 0000000..6d5ad49
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/o
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+:terminal :attach "$@"
diff --git a/.config/kak/autoload/connect/aliases/t b/.config/kak/autoload/connect/aliases/t
new file mode 100755
index 0000000..3ec0933
--- /dev/null
+++ b/.config/kak/autoload/connect/aliases/t
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+:send '>' "$@"
diff --git a/.config/kak/autoload/connect/commands/:attach b/.config/kak/autoload/connect/commands/:attach
new file mode 100755
index 0000000..2894021
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:attach
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Reattach to the session.
+kak -c "$KAKOUNE_SESSION" "$@"
diff --git a/.config/kak/autoload/connect/commands/:buffer b/.config/kak/autoload/connect/commands/:buffer
new file mode 100755
index 0000000..c44118a
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:buffer
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Open buffers.
+#
+# Usage:
+#
+# :buffer <buffer>
+# [buffers] | :buffer
+
+# Read buffers from stdin
+if [ ! -t 0 ]; then
+ while read buffer; do
+ set -- "$buffer" "$@"
+ done
+fi
+
+# Open buffer
+:send -verbatim buffer "$@"
+
+# Focus back the client
+:send focus
diff --git a/.config/kak/autoload/connect/commands/:bwd b/.config/kak/autoload/connect/commands/:bwd
new file mode 100755
index 0000000..310edc4
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:bwd
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Buffer working directory
+dirname `:it`
diff --git a/.config/kak/autoload/connect/commands/:cat b/.config/kak/autoload/connect/commands/:cat
new file mode 100755
index 0000000..6ea41a2
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:cat
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# Get the current buffer content.
+mkfifo buffer.fifo
+trap 'rm buffer.fifo' EXIT
+:send write -method overwrite buffer.fifo
+cat buffer.fifo
diff --git a/.config/kak/autoload/connect/commands/:cd! b/.config/kak/autoload/connect/commands/:cd!
new file mode 100755
index 0000000..a936e3c
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:cd!
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Sync to your current working directory
+:send cd "$PWD"
diff --git a/.config/kak/autoload/connect/commands/:edit b/.config/kak/autoload/connect/commands/:edit
new file mode 100755
index 0000000..45708f2
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:edit
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+# Open files.
+#
+# Usage:
+#
+# :edit <file>
+# :edit +<line> <file>
+# :edit +<line>:<column> <file>
+# [files] | :edit
+#
+# Note: Order matters.
+
+. "$KAKOUNE_PRELUDE"
+
+# Read files from stdin when a terminal is available.
+# Reason: kak-desktop
+if [ ! -t 0 -a -t 1 ]; then
+ while read file; do
+ set -- "$file" "$@"
+ done
+fi
+
+# Skip options
+[ "$1" = '--' ] && shift
+
+# Open files at the given position (line and column) if specified (before or after the file).
+commands=$(
+ while [ "$1" ]; do
+ case "$1" in
+ ('+'*':'*)
+ line=${1#+}; line=${line%:*}
+ column=${1#*:}
+ file=$(realpath "$2")
+ shift 2
+ kak_escape edit "$file" "$line" "$column"
+ ;;
+ ('+'*)
+ line=${1#+}
+ file=$(realpath "$2")
+ shift 2
+ kak_escape edit "$file" "$line"
+ ;;
+ (*)
+ file=$(realpath "$1")
+ shift
+ case "$1" in
+ ('+'*':'*)
+ line=${1#+}; line=${line%:*}
+ column=${1#*:}
+ shift
+ kak_escape edit "$file" "$line" "$column"
+ ;;
+ ('+'*)
+ line=${1#+}
+ shift
+ kak_escape edit "$file" "$line"
+ ;;
+ (*)
+ kak_escape edit "$file"
+ ;;
+ esac
+ ;;
+ esac
+ done
+)
+
+:send "$commands"
+
+# Focus back the client
+:send focus
diff --git a/.config/kak/autoload/connect/commands/:edit-search b/.config/kak/autoload/connect/commands/:edit-search
new file mode 100755
index 0000000..e0bfd0f
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:edit-search
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Open files from search result.
+#
+# Input format: <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
+ :edit "$file" "+$line:$column"
+done
diff --git a/.config/kak/autoload/connect/commands/:edit-wait b/.config/kak/autoload/connect/commands/:edit-wait
new file mode 100755
index 0000000..dcf9856
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:edit-wait
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# Open files
+:edit "$@"
+
+# Prompt and wait
+printf '[e]dit, [c]ontinue or [a]bort'
+read key
+
+# Attach the session
+[ "$key" = 'e' ] && :attach; edit_exit_code=$?
+
+# Close buffers
+for file do
+ :send delete-buffer "$file"
+done
+
+# Set exit code
+case "$key" in
+ e) exit_code=$edit_exit_code ;;
+ c) exit_code=0 ;;
+ a) exit_code=1 ;;
+ *) exit_code=1 ;;
+esac
+
+# Exit code
+exit "$exit_code"
diff --git a/.config/kak/autoload/connect/commands/:fifo b/.config/kak/autoload/connect/commands/:fifo
new file mode 100755
index 0000000..ea2ede0
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:fifo
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Edit fifo buffer in a client
+mkfifo buffer.fifo
+trap 'rm buffer.fifo' EXIT
+:send edit! -fifo "$PWD/buffer.fifo" '*fifo*'
+
+# Send to fifo buffer the output of the given command,
+# or read from stdin if available.
+#
+# Example:
+#
+# :fifo make
+#
+if test $# -gt 0; then
+ "$@" > buffer.fifo 2>&1 &
+elif test ! -t 0; then
+ cat > buffer.fifo
+fi
+
+# Focus back the client
+:send focus
diff --git a/.config/kak/autoload/connect/commands/:get b/.config/kak/autoload/connect/commands/:get
new file mode 100755
index 0000000..288841e
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:get
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Get a value from a client.
+#
+# Example:
+#
+# :get -quoting shell %val{selections}
+#
+mkfifo connect.fifo
+trap 'rm connect.fifo' EXIT
+:send echo -to-file "$PWD/connect.fifo" "$@"
+cat connect.fifo
diff --git a/.config/kak/autoload/connect/commands/:it b/.config/kak/autoload/connect/commands/:it
new file mode 100755
index 0000000..56da647
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:it
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Get the current buffer path.
+:get %val{buffile}
diff --git a/.config/kak/autoload/connect/commands/:ls b/.config/kak/autoload/connect/commands/:ls
new file mode 100755
index 0000000..f847da8
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:ls
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# List buffers
+kak_quoted_buflist=$(:get -quoting shell %val{buflist})
+eval "set -- $kak_quoted_buflist"
+printf '%s\n' "$@"
diff --git a/.config/kak/autoload/connect/commands/:make b/.config/kak/autoload/connect/commands/:make
new file mode 100755
index 0000000..bb87319
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:make
@@ -0,0 +1,9 @@
+#!/bin/sh
+. "$KAKOUNE_PRELUDE"
+
+key="$1"
+shift
+
+
+kak_escape map pistarchio "$key" "$*" | kak -p "$KAKOUNE_SESSION"
+# kak_escape evaluate-commands -try-client t "$@" | kak -p "$KAKOUNE_SESSION"
diff --git a/.config/kak/autoload/connect/commands/:open b/.config/kak/autoload/connect/commands/:open
new file mode 100755
index 0000000..6d5ad49
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:open
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+:terminal :attach "$@"
diff --git a/.config/kak/autoload/connect/commands/:pwd b/.config/kak/autoload/connect/commands/:pwd
new file mode 100755
index 0000000..2e313b9
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:pwd
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+:get %sh{pwd}
diff --git a/.config/kak/autoload/connect/commands/:send b/.config/kak/autoload/connect/commands/:send
new file mode 100755
index 0000000..86f90a6
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:send
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+. "$KAKOUNE_PRELUDE"
+
+# Send commands to the client
+kak_escape evaluate-commands -try-client "$KAKOUNE_CLIENT" "$@" | kak -p "$KAKOUNE_SESSION"
diff --git a/.config/kak/autoload/connect/commands/:terminal b/.config/kak/autoload/connect/commands/:terminal
new file mode 100755
index 0000000..3ec0933
--- /dev/null
+++ b/.config/kak/autoload/connect/commands/:terminal
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+:send '>' "$@"
diff --git a/.config/kak/autoload/connect/env/.git.env.kak.54n8Ol b/.config/kak/autoload/connect/env/.git.env.kak.54n8Ol
new file mode 100644
index 0000000..75bfc92
--- /dev/null
+++ b/.config/kak/autoload/connect/env/.git.env.kak.54n8Ol
@@ -0,0 +1,2 @@
+ek-shell viya
+xport GIT_EDITOR=:edit-wait
diff --git a/.config/kak/autoload/connect/env/default.env b/.config/kak/autoload/connect/env/default.env
new file mode 100644
index 0000000..4464956
--- /dev/null
+++ b/.config/kak/autoload/connect/env/default.env
@@ -0,0 +1,3 @@
+export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-~/.config}
+export XDG_DATA_HOME=${XDG_DATA_HOME:-~/.local/share}
+export XDG_CACHE_HOME=${XDG_CACHE_HOME:-~/.cache}
diff --git a/.config/kak/autoload/connect/env/git.env b/.config/kak/autoload/connect/env/git.env
new file mode 100644
index 0000000..c7e5fd1
--- /dev/null
+++ b/.config/kak/autoload/connect/env/git.env
@@ -0,0 +1 @@
+export GIT_EDITOR=:edit-wait
diff --git a/.config/kak/autoload/connect/env/kakoune.env b/.config/kak/autoload/connect/env/kakoune.env
new file mode 100644
index 0000000..4cdd854
--- /dev/null
+++ b/.config/kak/autoload/connect/env/kakoune.env
@@ -0,0 +1,4 @@
+export IN_KAKOUNE_CONNECT=1
+export KAKOUNE_SESSION=$kak_session
+export KAKOUNE_CLIENT=$kak_client
+export KAKOUNE_PRELUDE=$kak_opt_prelude_path
diff --git a/.config/kak/autoload/connect/env/overrides.env b/.config/kak/autoload/connect/env/overrides.env
new file mode 100644
index 0000000..59772ca
--- /dev/null
+++ b/.config/kak/autoload/connect/env/overrides.env
@@ -0,0 +1,6 @@
+# Connect paths
+paths=$kak_opt_connect_root_path/connect
+PATH=$kak_opt_connect_environment_paths:$paths/aliases:$paths/commands:$PATH:$paths/tools
+
+VISUAL=:edit
+EDITOR=:edit
diff --git a/.config/kak/autoload/connect/modules/broot/broot.kak b/.config/kak/autoload/connect/modules/broot/broot.kak
new file mode 100644
index 0000000..3ebbd6e
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/broot/broot.kak
@@ -0,0 +1,18 @@
+# Broot
+# https://dystroy.org/broot/
+
+provide-module connect-broot %{
+ # Modules
+ require-module connect
+
+ # Register our paths
+ set-option -add global connect_paths "%opt{connect_modules_path}/broot/aliases" "%opt{connect_modules_path}/broot/commands"
+
+ # Commands
+ define-command broot -params .. -file-completion -docstring 'Open files with Broot' %{
+ > broot %arg{@}
+ }
+
+ # Aliases
+ alias global br broot
+}
diff --git a/.config/kak/autoload/connect/modules/dmenu/aliases/:dmenu b/.config/kak/autoload/connect/modules/dmenu/aliases/:dmenu
new file mode 100755
index 0000000..1aca671
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/dmenu/aliases/:dmenu
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# dmenu
+# https://tools.suckless.org/dmenu/
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+
+fd --type file . "$@" |
+dmenu -l 20 -i -p 'Open files' |
+:edit
diff --git a/.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-buffers b/.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-buffers
new file mode 100755
index 0000000..377bdd1
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-buffers
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# dmenu
+# https://tools.suckless.org/dmenu/
+
+# Arguments
+pattern=$1
+
+:ls |
+grep -F "$pattern" |
+dmenu -l 20 -i -p 'Open buffers' |
+:buffer
diff --git a/.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-files b/.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-files
new file mode 100755
index 0000000..1aca671
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-files
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# dmenu
+# https://tools.suckless.org/dmenu/
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+
+fd --type file . "$@" |
+dmenu -l 20 -i -p 'Open files' |
+:edit
diff --git a/.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-grep b/.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-grep
new file mode 100755
index 0000000..d6634ba
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/dmenu/commands/:dmenu-grep
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# dmenu
+# https://tools.suckless.org/dmenu/
+
+# Dependencies:
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+rg --column --with-filename '.+' "$@" |
+dmenu -l 20 -i -p 'Open files (search by content)' |
+:edit-search
diff --git a/.config/kak/autoload/connect/modules/dmenu/dmenu.kak b/.config/kak/autoload/connect/modules/dmenu/dmenu.kak
new file mode 100644
index 0000000..c5dd5e0
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/dmenu/dmenu.kak
@@ -0,0 +1,33 @@
+# dmenu
+# https://tools.suckless.org/dmenu/
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+provide-module connect-dmenu %{
+ # Modules
+ require-module connect
+
+ # Register our paths
+ set-option -add global connect_paths "%opt{connect_modules_path}/dmenu/aliases" "%opt{connect_modules_path}/dmenu/commands"
+
+ # Commands
+ # Files
+ define-command dmenu-files -params .. -file-completion -docstring 'Open files with dmenu' %{
+ $ :dmenu-files %arg{@}
+ }
+
+ # Buffers
+ define-command dmenu-buffers -params ..1 -buffer-completion -docstring 'Open buffers with dmenu' %{
+ $ :dmenu-buffers %arg{@}
+ }
+
+ # Grep
+ define-command dmenu-grep -params .. -file-completion -docstring 'Open files (search by content) with dmenu' %{
+ $ :dmenu-grep %arg{@}
+ }
+
+ # Aliases
+ alias global dmenu dmenu-files
+}
diff --git a/.config/kak/autoload/connect/modules/dolphin/commands/:dolphin b/.config/kak/autoload/connect/modules/dolphin/commands/:dolphin
new file mode 100755
index 0000000..48d12e7
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/dolphin/commands/:dolphin
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Dolphin
+# https://dolphin.kde.org
+
+# Unlike most applications,
+# Dolphin does not honor the current working directory,
+# and opens in the home directory.
+
+# Mitigate the need to explicitely type `dolphin` with the current path.
+if [ $# = 0 ]; then
+ set -- '.'
+fi
+
+dolphin "$@"
diff --git a/.config/kak/autoload/connect/modules/dolphin/dolphin.kak b/.config/kak/autoload/connect/modules/dolphin/dolphin.kak
new file mode 100644
index 0000000..ceb3d12
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/dolphin/dolphin.kak
@@ -0,0 +1,15 @@
+# Dolphin
+# https://dolphin.kde.org
+
+provide-module connect-dolphin %{
+ # Modules
+ require-module connect
+
+ # Register our paths
+ set-option -add global connect_paths "%opt{connect_modules_path}/dolphin/aliases" "%opt{connect_modules_path}/dolphin/commands"
+
+ # Commands
+ define-command dolphin -params .. -file-completion -docstring 'Open files with Dolphin' %{
+ $ :dolphin %arg{@}
+ }
+}
diff --git a/.config/kak/autoload/connect/modules/fifo/fifo.kak b/.config/kak/autoload/connect/modules/fifo/fifo.kak
new file mode 100644
index 0000000..3866337
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fifo/fifo.kak
@@ -0,0 +1,12 @@
+provide-module connect-fifo %{
+ # Modules
+ require-module connect
+
+ # Register our paths
+ set-option -add global connect_paths "%opt{connect_modules_path}/fifo/aliases" "%opt{connect_modules_path}/fifo/commands"
+
+ # Commands
+ define-command fifo -params 1.. -shell-completion -docstring 'Run command in a fifo buffer' %{
+ $ :fifo %arg{@}
+ }
+}
diff --git a/.config/kak/autoload/connect/modules/fzf/aliases/:fzf b/.config/kak/autoload/connect/modules/fzf/aliases/:fzf
new file mode 100755
index 0000000..060d91d
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fzf/aliases/:fzf
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# fzf
+# https://github.com/junegunn/fzf
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+# – bat (https://github.com/sharkdp/bat)
+
+fd --type file . "$@" |
+fzf --preview-window=down:60% --preview 'bat --style=numbers --color=always --line-range :500 {}' --prompt='(f)>' |
+:edit
diff --git a/.config/kak/autoload/connect/modules/fzf/commands/:fzf-buffers b/.config/kak/autoload/connect/modules/fzf/commands/:fzf-buffers
new file mode 100755
index 0000000..e507fe2
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fzf/commands/:fzf-buffers
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# fzf
+# https://github.com/junegunn/fzf
+
+# Dependencies:
+# – bat (https://github.com/sharkdp/bat)
+
+# Arguments
+pattern=$1
+
+:ls |
+grep -F "$pattern" |
+fzf --preview-window=down:60% --preview 'bat --style=numbers --color=always --line-range :500 {}' --prompt='(b)>' |
+:buffer
diff --git a/.config/kak/autoload/connect/modules/fzf/commands/:fzf-files b/.config/kak/autoload/connect/modules/fzf/commands/:fzf-files
new file mode 100755
index 0000000..060d91d
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fzf/commands/:fzf-files
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# fzf
+# https://github.com/junegunn/fzf
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+# – bat (https://github.com/sharkdp/bat)
+
+fd --type file . "$@" |
+fzf --preview-window=down:60% --preview 'bat --style=numbers --color=always --line-range :500 {}' --prompt='(f)>' |
+:edit
diff --git a/.config/kak/autoload/connect/modules/fzf/commands/:fzf-grep b/.config/kak/autoload/connect/modules/fzf/commands/:fzf-grep
new file mode 100755
index 0000000..8a1d52b
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fzf/commands/:fzf-grep
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# fzf
+# https://github.com/junegunn/fzf
+
+# Dependencies:
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+rg --column --with-filename '.+' "$@" |
+fzf --prompt='(g)>' |
+:edit-search
diff --git a/.config/kak/autoload/connect/modules/fzf/fzf.kak b/.config/kak/autoload/connect/modules/fzf/fzf.kak
new file mode 100644
index 0000000..07ef3c3
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fzf/fzf.kak
@@ -0,0 +1,34 @@
+# fzf
+# https://github.com/junegunn/fzf
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+# – bat (https://github.com/sharkdp/bat)
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+provide-module connect-fzf %{
+ # Modules
+ require-module connect
+
+ # Register our paths
+ set-option -add global connect_paths "%opt{connect_modules_path}/fzf/aliases" "%opt{connect_modules_path}/fzf/commands"
+
+ # Commands
+ # Files
+ define-command fzf-files -params .. -file-completion -docstring 'Open files with fzf' %{
+ + :fzf-files %arg{@}
+ }
+
+ # Buffers
+ define-command fzf-buffers -params ..1 -buffer-completion -docstring 'Open buffers with fzf' %{
+ + :fzf-buffers %arg{@}
+ }
+
+ # Grep
+ define-command fzf-grep -params .. -file-completion -docstring 'Open files (search by content) with fzf' %{
+ + :fzf-grep %arg{@}
+ }
+
+ # Aliases
+ alias global fzf fzf-files
+}
diff --git a/.config/kak/autoload/connect/modules/fzy/aliases/:fzy b/.config/kak/autoload/connect/modules/fzy/aliases/:fzy
new file mode 100755
index 0000000..a5ee743
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fzy/aliases/:fzy
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# fzy
+# https://github.com/jhawthorn/fzy
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+
+fd --type file . "$@" |
+fzy --prompt='(f)>' |
+:edit
diff --git a/.config/kak/autoload/connect/modules/fzy/commands/:fzy-buffers b/.config/kak/autoload/connect/modules/fzy/commands/:fzy-buffers
new file mode 100755
index 0000000..16da2fd
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fzy/commands/:fzy-buffers
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# fzy
+# https://github.com/jhawthorn/fzy
+
+# Arguments
+pattern=$1
+
+:ls |
+grep -F "$pattern" |
+fzy --prompt='(b)>' |
+:buffer
diff --git a/.config/kak/autoload/connect/modules/fzy/commands/:fzy-files b/.config/kak/autoload/connect/modules/fzy/commands/:fzy-files
new file mode 100755
index 0000000..a5ee743
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fzy/commands/:fzy-files
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# fzy
+# https://github.com/jhawthorn/fzy
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+
+fd --type file . "$@" |
+fzy --prompt='(f)>' |
+:edit
diff --git a/.config/kak/autoload/connect/modules/fzy/commands/:fzy-grep b/.config/kak/autoload/connect/modules/fzy/commands/:fzy-grep
new file mode 100755
index 0000000..e6d17d4
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fzy/commands/:fzy-grep
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# fzy
+# https://github.com/jhawthorn/fzy
+
+# Dependencies:
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+rg --column --with-filename '.+' "$@" |
+fzy --prompt='(g)>' |
+:edit-search
diff --git a/.config/kak/autoload/connect/modules/fzy/fzy.kak b/.config/kak/autoload/connect/modules/fzy/fzy.kak
new file mode 100644
index 0000000..42708f3
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/fzy/fzy.kak
@@ -0,0 +1,33 @@
+# fzy
+# https://github.com/jhawthorn/fzy
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+provide-module connect-fzy %{
+ # Modules
+ require-module connect
+
+ # Register our paths
+ set-option -add global connect_paths "%opt{connect_modules_path}/fzy/aliases" "%opt{connect_modules_path}/fzy/commands"
+
+ # Commands
+ # Files
+ define-command fzy-files -params .. -file-completion -docstring 'Open files with fzy' %{
+ + :fzy-files %arg{@}
+ }
+
+ # Buffers
+ define-command fzy-buffers -params ..1 -buffer-completion -docstring 'Open buffers with fzy' %{
+ + :fzy-buffers %arg{@}
+ }
+
+ # Grep
+ define-command fzy-grep -params .. -file-completion -docstring 'Open files (search by content) with fzy' %{
+ + :fzy-grep %arg{@}
+ }
+
+ # Aliases
+ alias global fzy fzy-files
+}
diff --git a/.config/kak/autoload/connect/modules/lf/lf.kak b/.config/kak/autoload/connect/modules/lf/lf.kak
new file mode 100644
index 0000000..6609f85
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/lf/lf.kak
@@ -0,0 +1,15 @@
+# lf
+# https://github.com/gokcehan/lf
+
+provide-module connect-lf %{
+ # Modules
+ require-module connect
+
+ # Register our paths
+ set-option -add global connect_paths "%opt{connect_modules_path}/lf/aliases" "%opt{connect_modules_path}/lf/commands"
+
+ # Commands
+ define-command lf -params .. -file-completion -docstring 'Open files with lf' %{
+ > lf %arg{@}
+ }
+}
diff --git a/.config/kak/autoload/connect/modules/nnn/nnn.kak b/.config/kak/autoload/connect/modules/nnn/nnn.kak
new file mode 100644
index 0000000..da81a75
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/nnn/nnn.kak
@@ -0,0 +1,18 @@
+# nnn
+# https://github.com/jarun/nnn
+
+provide-module connect-nnn %{
+ # Modules
+ require-module connect
+
+ # Register our paths
+ set-option -add global connect_paths "%opt{connect_modules_path}/nnn/aliases" "%opt{connect_modules_path}/nnn/commands"
+
+ # Commands
+ define-command nnn -params .. -file-completion -docstring 'Open files with nnn' %{
+ > nnn %arg{@}
+ }
+
+ # Aliases
+ alias global n nnn
+}
diff --git a/.config/kak/autoload/connect/modules/rofi/aliases/:rofi b/.config/kak/autoload/connect/modules/rofi/aliases/:rofi
new file mode 100755
index 0000000..cf79a9a
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/rofi/aliases/:rofi
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Rofi
+# https://github.com/davatorium/rofi
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+
+fd --type file . "$@" |
+rofi -dmenu -i -p 'Open files' |
+:edit
diff --git a/.config/kak/autoload/connect/modules/rofi/commands/:rofi-buffers b/.config/kak/autoload/connect/modules/rofi/commands/:rofi-buffers
new file mode 100755
index 0000000..29b4a8f
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/rofi/commands/:rofi-buffers
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Rofi
+# https://github.com/davatorium/rofi
+
+# Arguments
+pattern=$1
+
+:ls |
+grep -F "$pattern" |
+rofi -dmenu -i -p 'Open buffers' |
+:buffer
diff --git a/.config/kak/autoload/connect/modules/rofi/commands/:rofi-files b/.config/kak/autoload/connect/modules/rofi/commands/:rofi-files
new file mode 100755
index 0000000..cf79a9a
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/rofi/commands/:rofi-files
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Rofi
+# https://github.com/davatorium/rofi
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+
+fd --type file . "$@" |
+rofi -dmenu -i -p 'Open files' |
+:edit
diff --git a/.config/kak/autoload/connect/modules/rofi/commands/:rofi-grep b/.config/kak/autoload/connect/modules/rofi/commands/:rofi-grep
new file mode 100755
index 0000000..c4adb7b
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/rofi/commands/:rofi-grep
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Rofi
+# https://github.com/davatorium/rofi
+
+# Dependencies:
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+rg --column --with-filename '.+' "$@" |
+rofi -dmenu -i -p 'Open files (search by content)' |
+:edit-search
diff --git a/.config/kak/autoload/connect/modules/rofi/rofi.kak b/.config/kak/autoload/connect/modules/rofi/rofi.kak
new file mode 100644
index 0000000..d1af9c8
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/rofi/rofi.kak
@@ -0,0 +1,33 @@
+# Rofi
+# https://github.com/davatorium/rofi
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+provide-module connect-rofi %{
+ # Modules
+ require-module connect
+
+ # Register our paths
+ set-option -add global connect_paths "%opt{connect_modules_path}/rofi/aliases" "%opt{connect_modules_path}/rofi/commands"
+
+ # Commands
+ # Files
+ define-command rofi-files -params .. -file-completion -docstring 'Open files with Rofi' %{
+ $ :rofi-files %arg{@}
+ }
+
+ # Buffers
+ define-command rofi-buffers -params ..1 -buffer-completion -docstring 'Open buffers with Rofi' %{
+ $ :rofi-buffers %arg{@}
+ }
+
+ # Grep
+ define-command rofi-grep -params .. -file-completion -docstring 'Open files (search by content) with Rofi' %{
+ $ :rofi-grep %arg{@}
+ }
+
+ # Aliases
+ alias global rofi rofi-files
+}
diff --git a/.config/kak/autoload/connect/modules/wofi/aliases/:wofi b/.config/kak/autoload/connect/modules/wofi/aliases/:wofi
new file mode 100755
index 0000000..658c607
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/wofi/aliases/:wofi
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Wofi
+# https://hg.sr.ht/~scoopta/wofi
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+
+fd --type file . "$@" |
+wofi --dmenu --prompt 'Open files' |
+:edit
diff --git a/.config/kak/autoload/connect/modules/wofi/commands/:wofi-buffers b/.config/kak/autoload/connect/modules/wofi/commands/:wofi-buffers
new file mode 100755
index 0000000..10ff559
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/wofi/commands/:wofi-buffers
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Wofi
+# https://hg.sr.ht/~scoopta/wofi
+
+# Arguments
+pattern=$1
+
+:ls |
+grep -F "$pattern" |
+wofi --dmenu --prompt 'Open buffers' |
+:buffer
diff --git a/.config/kak/autoload/connect/modules/wofi/commands/:wofi-files b/.config/kak/autoload/connect/modules/wofi/commands/:wofi-files
new file mode 100755
index 0000000..658c607
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/wofi/commands/:wofi-files
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Wofi
+# https://hg.sr.ht/~scoopta/wofi
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+
+fd --type file . "$@" |
+wofi --dmenu --prompt 'Open files' |
+:edit
diff --git a/.config/kak/autoload/connect/modules/wofi/commands/:wofi-grep b/.config/kak/autoload/connect/modules/wofi/commands/:wofi-grep
new file mode 100755
index 0000000..e5ccc3b
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/wofi/commands/:wofi-grep
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Wofi
+# https://hg.sr.ht/~scoopta/wofi
+
+# Dependencies:
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+rg --column --with-filename '.+' "$@" |
+wofi --dmenu --prompt 'Open files (search by content)' |
+:edit-search
diff --git a/.config/kak/autoload/connect/modules/wofi/wofi.kak b/.config/kak/autoload/connect/modules/wofi/wofi.kak
new file mode 100644
index 0000000..082419e
--- /dev/null
+++ b/.config/kak/autoload/connect/modules/wofi/wofi.kak
@@ -0,0 +1,33 @@
+# Wofi
+# https://hg.sr.ht/~scoopta/wofi
+
+# Dependencies:
+# – fd (https://github.com/sharkdp/fd)
+# – ripgrep (https://github.com/BurntSushi/ripgrep)
+
+provide-module connect-wofi %{
+ # Modules
+ require-module connect
+
+ # Register our paths
+ set-option -add global connect_paths "%opt{connect_modules_path}/wofi/aliases" "%opt{connect_modules_path}/wofi/commands"
+
+ # Commands
+ # Files
+ define-command wofi-files -params .. -file-completion -docstring 'Open files with Wofi' %{
+ $ :wofi-files %arg{@}
+ }
+
+ # Buffers
+ define-command wofi-buffers -params ..1 -buffer-completion -docstring 'Open buffers with Wofi' %{
+ $ :wofi-buffers %arg{@}
+ }
+
+ # Grep
+ define-command wofi-grep -params .. -file-completion -docstring 'Open files (search by content) with Wofi' %{
+ $ :wofi-grep %arg{@}
+ }
+
+ # Aliases
+ alias global wofi wofi-files
+}
diff --git a/.config/kak/autoload/connect/tools/realpath b/.config/kak/autoload/connect/tools/realpath
new file mode 100755
index 0000000..d8691f3
--- /dev/null
+++ b/.config/kak/autoload/connect/tools/realpath
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# realpath for macOS
+# https://flummox-engineering.blogspot.com/2014/06/getting-absolute-path-in-bash-in-osx.html
+case "$1" in
+ /*) path=$1 ;;
+ *) path=$PWD/$1 ;;
+esac
+
+printf '%s' "$path"
diff --git a/.config/kak/autoload/rc/prelude.kak b/.config/kak/autoload/rc/prelude.kak
new file mode 100644
index 0000000..6454ef0
--- /dev/null
+++ b/.config/kak/autoload/rc/prelude.kak
@@ -0,0 +1,5 @@
+declare-option -hidden str prelude_root_path %sh(dirname "$kak_source")
+
+provide-module prelude %{
+ declare-option -docstring 'Path to the prelude of shell blocks' str prelude_path "%opt{prelude_root_path}/prelude.sh"
+}
diff --git a/.config/kak/autoload/rc/prelude.sh b/.config/kak/autoload/rc/prelude.sh
new file mode 100644
index 0000000..c7dead6
--- /dev/null
+++ b/.config/kak/autoload/rc/prelude.sh
@@ -0,0 +1,24 @@
+kak_escape() {
+ for text do
+ printf "'"
+ while true; do
+ case "$text" in
+ *"'"*)
+ head=${text%%"'"*}
+ tail=${text#*"'"}
+ printf "%s''" "$head"
+ text=$tail
+ ;;
+ *)
+ printf "%s' " "$text"
+ break
+ ;;
+ esac
+ done
+ done
+ printf "${KAK_ESCAPE_EOF:-\n}"
+}
+
+kak_escape_partial() {
+ KAK_ESCAPE_EOF=' ' kak_escape "$@"
+}
diff --git a/.config/kak/autoload/snippets.kak b/.config/kak/autoload/snippets.kak
new file mode 100644
index 0000000..d1316c2
--- /dev/null
+++ b/.config/kak/autoload/snippets.kak
@@ -0,0 +1,396 @@
+provide-module snippets ''
+require-module snippets
+
+declare-option -hidden regex snippets_triggers_regex "\A\z" # doing <a-k>\A\z<ret> will always fail
+
+hook global WinSetOption 'snippets=$' %{
+ set window snippets_triggers_regex "\A\z"
+}
+
+hook global WinSetOption 'snippets=.+$' %{
+ set window snippets_triggers_regex %sh{
+ eval set -- "$kak_quoted_opt_snippets"
+ if [ $(($#%3)) -ne 0 ]; then printf '\A\z'; exit; fi
+ res=""
+ while [ $# -ne 0 ]; do
+ if [ -n "$2" ]; then
+ if [ -z "$res" ]; then
+ res="$2"
+ else
+ res="$res|$2"
+ fi
+ fi
+ shift 3
+ done
+ if [ -z "$res" ]; then
+ printf '\A\z'
+ else
+ printf '(?:%s)' "$res"
+ fi
+ }
+}
+
+define-command snippets-expand-trigger -params ..1 %{
+ eval -save-regs '/snc' %{
+ # -draft so that we don't modify anything in case of failure
+ eval -draft %{
+ # ideally early out in here to avoid going to the (expensive) shell scope
+ eval %arg{1}
+ # this shell scope generates a block that looks like this
+ # except with single quotes instead of %{..}
+ #
+ # try %{
+ # reg / "\Atrig1\z"
+ # exec -draft <a-k><ret>d
+ # reg c "snipcommand1"
+ # } catch %{
+ # reg / "\Atrig2\z"
+ # exec -draft <a-k><ret>d
+ # reg c "snipcommand2"
+ # } catch %{
+ # ..
+ # }
+
+ eval %sh{
+ quadrupleupsinglequotes()
+ {
+ rest="$1"
+ while :; do
+ beforequote="${rest%%"'"*}"
+ if [ "$rest" = "$beforequote" ]; then
+ printf %s "$rest"
+ break
+ fi
+ printf "%s''''" "$beforequote"
+ rest="${rest#*"'"}"
+ done
+ }
+
+ eval set -- "$kak_quoted_opt_snippets"
+ if [ $(($#%3)) -ne 0 ]; then exit; fi
+ first=0
+ while [ $# -ne 0 ]; do
+ if [ -z "$2" ]; then
+ shift 3
+ continue
+ fi
+ if [ $first -eq 0 ]; then
+ printf "try '\n"
+ first=1
+ else
+ printf "' catch '\n"
+ fi
+ # put the trigger into %reg{/} as \Atrig\z
+ printf "reg / ''\\\A"
+ # we're at two levels of nested single quotes (one for try ".." catch "..", one for reg "..")
+ # in the arbitrary user input (snippet trigger and snippet name)
+ quadrupleupsinglequotes "$2"
+ printf "\\\z''\n"
+ printf "exec s<ret>d\n"
+ printf "reg n ''"
+ quadrupleupsinglequotes "$1"
+ printf "''\n"
+ printf "reg c ''"
+ quadrupleupsinglequotes "$3"
+ printf "''\n"
+ shift 3
+ done
+ printf "'"
+ }
+ # preserve the selections generated by the snippet, since -draft will discard them
+ eval %reg{c}
+ reg s %val{selections_desc}
+ }
+ eval select %reg{s}
+ echo "Snippet '%reg{n}' expanded"
+ }
+}
+
+hook global WinSetOption 'snippets_auto_expand=false$' %{
+ rmhooks window snippets-auto-expand
+}
+hook global WinSetOption 'snippets_auto_expand=true$' %{
+ rmhooks window snippets-auto-expand
+ hook -group snippets-auto-expand window InsertChar .* %{
+ try %{
+ snippets-expand-trigger %{ # no need to save-regs '/', since expand-trigger does that for us
+ reg / "(%opt{snippets_triggers_regex})|."
+ exec ';<a-/><ret>'
+ reg / "\A(%opt{snippets_triggers_regex})\z"
+ exec '<a-k><ret>'
+ }
+ }
+ }
+}
+
+declare-option str-list snippets
+# this one must be declared after the hook, otherwise it might not be enabled right away
+declare-option bool snippets_auto_expand true
+
+define-command snippets-impl -hidden -params 1.. %{
+ eval %sh{
+ use=$1
+ shift 1
+ index=4
+ while [ $# -ne 0 ]; do
+ if [ "$1" = "$use" ]; then
+ printf "eval %%arg{%s}" "$index"
+ exit
+ fi
+ index=$((index + 3))
+ shift 3
+ done
+ printf "fail 'Snippet not found'"
+ }
+}
+
+define-command snippets -params 1 -shell-script-candidates %{
+ eval set -- "$kak_quoted_opt_snippets"
+ if [ $(($#%3)) -ne 0 ]; then exit; fi
+ while [ $# -ne 0 ]; do
+ printf '%s\n' "$1"
+ shift 3
+ done
+} %{
+ snippets-impl %arg{1} %opt{snippets}
+}
+
+define-command snippets-info %{
+ info -title Snippets %sh{
+ eval set -- "$kak_quoted_opt_snippets"
+ if [ $(($#%3)) -ne 0 ]; then printf "Invalid 'snippets' value"; exit; fi
+ if [ $# -eq 0 ]; then printf 'No snippets defined'; exit; fi
+ maxtriglen=0
+ while [ $# -ne 0 ]; do
+ if [ ${#2} -gt $maxtriglen ]; then
+ maxtriglen=${#2}
+ fi
+ shift 3
+ done
+ eval set -- "$kak_quoted_opt_snippets"
+ while [ $# -ne 0 ]; do
+ if [ $maxtriglen -eq 0 ]; then
+ printf '%s\n' "$1"
+ else
+ if [ "$2" = "" ]; then
+ printf "%${maxtriglen}s %s\n" "" "$1"
+ else
+ printf "%${maxtriglen}s ➡ %s\n" "$2" "$1"
+ fi
+ fi
+ shift 3
+ done
+ }
+}
+
+define-command snippets-insert -hidden -params 1 %<
+ eval -save-regs 's' %<
+ eval -draft -save-regs '"' %<
+ # paste the snippet
+ reg dquote %arg{1}
+ exec P
+
+ # replace $n with newlines
+ eval -draft -verbatim try %<
+ # select $n and $$ (to avoid transforming escaped $)
+ exec 's\$\$|\$n<ret><a-k>\$n<ret>c
+<esc>'
+ >
+
+ # replace leading tabs with the appropriate indent
+ try %<
+ reg dquote %sh<
+ if [ $kak_opt_indentwidth -eq 0 ]; then
+ printf '\t'
+ else
+ printf "%${kak_opt_indentwidth}s"
+ fi
+ >
+ exec -draft '<a-s>s\A\t+<ret>s.<ret>R'
+ >
+
+ # align everything with the current line
+ eval -draft -itersel -save-regs '"' %<
+ try %<
+ exec -draft -save-regs '/' '<a-s>),xs^\s+<ret>y'
+ exec -draft '<a-s>)<a-,>P'
+ >
+ >
+
+ reg s %val{selections_desc}
+ # process placeholders
+ try %<
+ # select all placeholders ${..} and escaped-$ (== $$)
+ exec 's\$\$|\$\{(\}\}|[^}])*\}<ret>'
+ # nonsense test text to check the regex
+ # qwldqwld {qldwlqwld} qlwdl$qwld {qwdlqwld}}qwdlqwldl}
+ # lqlwdl$qwldlqwdl$qwdlqwld {qwd$$lqwld} $qwdlqwld$
+ # ${asd.as.d.} lqwdlqwld $$${as.dqdqw}
+
+ # remove one $ from all $$, and leading $ from ${..}
+ exec -draft '<a-:><a-;>;d'
+ # unselect the $
+ exec '<a-K>\A\$\z<ret>'
+ # we're left with only {..} placeholders, process them...
+ eval reg dquote %sh<
+ eval set -- "$kak_quoted_selections"
+ for sel do
+ # remove trailing }
+ sel="${sel%\}}"
+ # and leading {
+ sel="${sel#{}"
+ # de-double }}
+ tmp="$sel"
+ sel=""
+ while true; do
+ case "$tmp" in
+ *}}*)
+ sel="${sel}${tmp%%\}\}*}}"
+ tmp=${tmp#*\}\}}
+ ;;
+ *)
+ sel="${sel}${tmp}"
+ break
+ ;;
+ esac
+ done
+ # and quote the result in '..', with escaping (== doubling of ')
+ tmp="$sel"
+ sel=""
+ while true; do
+ case "$tmp" in
+ *\'*)
+ sel="${sel}${tmp%%\'*}''"
+ tmp=${tmp#*\'}
+ ;;
+ *)
+ sel="${sel}${tmp}"
+ break
+ ;;
+ esac
+ done
+ # all done, print it
+ # nothing like some good old posix-shell text processing
+ printf "'%s' " "$sel"
+ done
+ >
+ exec R
+ reg s %val{selections_desc}
+ >
+ >
+ try %{ select %reg{s} }
+ >
+>
+
+define-command snippets-menu-impl -hidden -params .. %{
+ eval %sh{
+ if [ $# -eq 0 ]; then
+ printf 'fail "No snippets defined"'
+ exit
+ fi
+ if [ $(($#%3)) -ne 0 ]; then
+ exit
+ fi
+ printf 'menu'
+ i=1
+ while [ $# -ne 0 ]; do
+ printf ' %%arg{%s}' $i
+ printf ' "snippets %%arg{%s}"' $i
+ i=$((i+3))
+ shift 3
+ done
+ }
+}
+
+define-command snippets-menu %{
+ require-module menu
+ snippets-menu-impl %opt{snippets}
+}
+
+provide-module phantom-selection %{
+
+set-face global PhantomSelection black,green+F
+
+declare-option -hidden str-list phantom_selections
+declare-option -hidden range-specs phantom_selections_ranges
+
+add-highlighter global/ ranges phantom_selections_ranges
+
+define-command -hidden phantom-selection-store-and-highlight %{
+ set window phantom_selections %reg{^}
+ set window phantom_selections_ranges %val{timestamp}
+ eval -no-hooks -draft -itersel %{
+ set -add window phantom_selections_ranges "%val{selection_desc}|PhantomSelection"
+ }
+}
+
+define-command -hidden phantom-selection-iterate-impl -params 1 %{
+ eval -save-regs ^ %{
+ reg ^ %opt{phantom_selections}
+ try %{
+ exec z
+ exec %arg{1}
+ # keep the main selection and put all the other in the mark
+ # a recent change to Kakoune swaps <space> with "," (and
+ # <a-space> with <a-,>). Try both to make sure we clear selections
+ # both with and without this breaking change. Pad them with <esc>
+ # to cancel out the key with the other behavior.
+ evaluate-commands %sh{
+ if [ "$kak_main_reg_hash" -lt "$kak_selection_count" ]
+ then printf '%s\n' "exec -save-regs '' 'Z'" phantom-selection-store-and-highlight "exec '<space><esc><,><esc>'"
+ else printf '%s\n' phantom-selection-clear "exec '<space><esc><,><esc>'"
+ fi
+ }
+ } catch %{
+ fail 'No phantom selections'
+ }
+ }
+}
+
+define-command phantom-selection-iterate-next -docstring "
+Turn secondary selections into phantoms and select the next phantom
+" %{
+ phantom-selection-iterate-impl ')'
+}
+
+define-command phantom-selection-iterate-prev -docstring "
+Turn secondary selections into phantoms and select the previous phantom
+" %{
+ phantom-selection-iterate-impl '('
+}
+
+define-command phantom-selection-clear -docstring "
+Remove all phantom selections
+" %{
+ unset window phantom_selections
+ unset window phantom_selections_ranges
+}
+
+define-command phantom-selection-select-all -docstring "
+Select all phantom selections
+" %{
+ eval -save-regs ^ %{
+ reg ^ %opt{phantom_selections}
+ try %{
+ exec z
+ echo ""
+ } catch %{
+ fail 'No phantom selections'
+ }
+ }
+}
+
+define-command phantom-selection-add-selection -docstring "
+Create phantoms out of the current selections
+" %{
+ eval -draft -save-regs ^ %{
+ reg ^ %opt{phantom_selections}
+ try %{ exec "<a-z>a" }
+ exec -save-regs '' "Z"
+ phantom-selection-store-and-highlight
+ }
+}
+
+}
+
+require-module phantom-selection
diff --git a/.config/kak/kakrc b/.config/kak/kakrc
index c00e099..68e9a3b 100644
--- a/.config/kak/kakrc
+++ b/.config/kak/kakrc
@@ -126,6 +126,17 @@ define-command -override -docstring %{
write
}
+# https://sourceforge.net/p/skim-app/wiki/TeX_and_PDF_Synchronization/
+# /Applications/Skim.app/Contents/SharedSupport/displayline -b -g -- 1 build/default/default.pdf src/index.tex
+set-option global snippets_auto_expand false
+hook global WinSetOption filetype=latex %{
+ try source ~/.config/kak/snippets.kak
+ hook global BufWritePost .*.tex %{
+ echo "snippets written"
+ try source ~/.config/kak/snippets.kak
+ }
+}
+
hook global WinSetOption filetype=python %{
set-option buffer formatcmd 'ruff format -'
hook buffer -group format BufWritePost .* format-but-write
diff --git a/.config/kak/snippets.kak b/.config/kak/snippets.kak
new file mode 100644
index 0000000..1980d72
--- /dev/null
+++ b/.config/kak/snippets.kak
@@ -0,0 +1,29 @@
+echo "sourced snippets"
+
+map buffer normal <a-f> ": phantom-selection-iterate-next<ret>"
+map buffer normal <a-F> ": phantom-selection-iterate-prev<ret>"
+map buffer insert <a-f> "<esc>: try phantom-selection-iterate-next<ret>i"
+map buffer insert <a-F> "<esc>: try phantom-selection-iterate-prev<ret>i"
+
+set buffer snippets 'frac1' '//' %{
+ phantom-selection-clear
+ snippets-insert %@\frac{ ${} }{ ${} } ${}@
+ phantom-selection-add-selection
+ phantom-selection-iterate-next
+}
+set -add buffer snippets 'frac2' %<((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/> %{
+ phantom-selection-clear
+ snippets-insert "\frac{ %reg{1} }{ ${} } ${}"
+ phantom-selection-add-selection
+ phantom-selection-iterate-next
+}
+set -add buffer snippets 'frac3' '([^\n]+\))/' %{
+ phantom-selection-clear
+
+ exec "i%reg{1}<esc>hm_"
+ exec %{"sd}
+ snippets-insert "\frac { %reg{s} }{ ${} } ${}"
+
+ phantom-selection-add-selection
+ phantom-selection-iterate-next
+}