diff --git a/.config/kak/autoload/clipboard.kak b/.config/kak/autoload/clipboard.kak new file mode 100644 index 00000000..c3a3cf1d --- /dev/null +++ b/.config/kak/autoload/clipboard.kak @@ -0,0 +1,6 @@ +map -docstring "yank the selection into the clipboard" global user y " wl-copy" + +map -docstring "paste the clipboard" global user p " wl-paste -n" +map -docstring "paste the clipboard before" global user P "! wl-paste -n" +map -docstring "replace with the clipboard" global user R '"_d! wl-paste -n' + diff --git a/.config/kak/autoload/git-mode.kak b/.config/kak/autoload/git-mode.kak new file mode 100644 index 00000000..887031e6 --- /dev/null +++ b/.config/kak/autoload/git-mode.kak @@ -0,0 +1,18 @@ +declare-user-mode git +map -docstring "git" global user g ": enter-user-mode git" +map -docstring "lazygit kak cwd" global git g ": terminal lazygit" + +define-command lazygit-buffer-dir %{ + evaluate-commands %sh{ + ROOT="$(env -C "$(dirname $kak_buffile)" git rev-parse --show-toplevel)" + printf "terminal lazygit -p %s" "$ROOT" + } +} +map -docstring "lazygit buffer directory" global git G ": lazygit-buffer-dir" + +define-command git-blame %{ + info %sh{ + git -C $(dirname $(realpath $kak_buffile)) blame -L $kak_cursor_line,$kak_cursor_line $(realpath $kak_buffile) + } +} +map -docstring "blame" global git b ": git-blame" diff --git a/.config/kak/autoload/match.kak b/.config/kak/autoload/match.kak deleted file mode 100644 index e69de29b..00000000 diff --git a/.config/kak/autoload/ui-mode.kak b/.config/kak/autoload/ui-mode.kak new file mode 100644 index 00000000..f1d2973c --- /dev/null +++ b/.config/kak/autoload/ui-mode.kak @@ -0,0 +1,51 @@ +declare-user-mode ui +map -docstring "UI" global user u ": enter-user-mode ui" + +define-command ui-wrap-enable -docstring "enable wrap" %{ + add-highlighter window/wrap wrap -word -indent + echo -markup "{Information}wrap enabled" +} + +define-command ui-wrap-disable -docstring "disable wrap" %{ + remove-highlighter window/wrap + echo -markup "{Information}wrap disabled" +} + +define-command -override ui-wrap-toggle -docstring "toggle wrap" %{ + try %{ ui-wrap-enable } catch %{ ui-wrap-disable } +} +map -docstring "toggle soft wrap" global ui w ": ui-wrap-toggle" + +declare-option str base_scrolloff %opt{scrolloff} + +define-command ui-scrolloff-toggle -docstring "toggle scrolloff" %{ + evaluate-commands %sh{ + CUR="$kak_opt_scrolloff" + IFS=, + read TARG HOR <<<$kak_opt_base_scrolloff + IFS=, + read VSCROLL _ <<<$kak_opt_scrolloff + if [ "$VSCROLL" = 99 ]; then + final="$TARG,$HOR" + else + final="99,$HOR" + fi + echo "set-option window scrolloff $final" + } +} + +map -docstring 'toggle screen centering' global ui z ": ui-scrolloff-toggle" + +declare-option bool autowrap false + +define-command autowrap-toggle -docstring "toggle autowrap" %{ + evaluate-commands %sh{ + if [ "$kak_opt_autowrap" = "true" ]; then + echo "autowrap-disable" + echo "set-option window autowrap false" + else + echo "autowrap-enable" + echo "set-option window autowrap true" + fi + } +} diff --git a/.config/kak/autoload/pickers.kak b/.config/kak/autoload/yazi.kak similarity index 70% rename from .config/kak/autoload/pickers.kak rename to .config/kak/autoload/yazi.kak index aadda3ba..748c51d4 100644 --- a/.config/kak/autoload/pickers.kak +++ b/.config/kak/autoload/yazi.kak @@ -1,6 +1,7 @@ -define-command open_yazi %{ +define-command open-yazi %{ evaluate-commands %sh{ rm -f /tmp/yazi-path &>/dev/null + # TODO: make this use %opt{termcmd} instead footclient -d error yazi $kak_buffile --chooser-file=/tmp/yazi-path &>/dev/null P="$(cat /tmp/yazi-path)" out="info -markup -title {title}Yazi" @@ -9,7 +10,6 @@ define-command open_yazi %{ else echo "edit $P" fi - } } -map -docstring "open file in yazi" global user ": open_yazi" +map -docstring "open file in yazi" global user ": open-yazi" diff --git a/.config/kak/kakrc b/.config/kak/kakrc index aba21e24..270dffe3 100644 --- a/.config/kak/kakrc +++ b/.config/kak/kakrc @@ -9,15 +9,6 @@ hook global ModuleLoaded wayland %{ set-option global termcmd 'footclient sh -c' } -# open tutor (needs curl) -define-command trampoline -docstring "open a tutorial" %{ - evaluate-commands %sh{ - tramp_file=$(mktemp -t "kakoune-trampoline.XXXXXXXX") - echo "edit -fifo $tramp_file *TRAMPOLINE*" - curl -s https://raw.githubusercontent.com/mawww/kakoune/master/contrib/TRAMPOLINE -o "$tramp_file" - } -} - # This gets overridden by editorconfig but we set sane default anyways set-option global tabstop 4 set-option global indentwidth 4 @@ -35,73 +26,13 @@ add-highlighter global/regex-escaped regex \\[\[\]\(\)\{\}fnrtv0\\dwshDWSH] 0:rg add-highlighter global/ number-lines -hlcursor -relative -separator " " add-highlighter global/ show-whitespaces -lf "" -tab "" -only-trailing add-highlighter global/ show-matching -# add-highlighter global/wrap wrap -word -indent -declare-user-mode ui -map -docstring "UI" global user u ": enter-user-mode ui" - -define-command ui-wrap-enable -docstring "enable wrap" %{ - add-highlighter window/wrap wrap -word -indent - echo -markup "{Information}wrap enabled" -} - -define-command ui-wrap-disable -docstring "disable wrap" %{ - remove-highlighter window/wrap - echo -markup "{Information}wrap disabled" -} - -define-command -override ui-wrap-toggle -docstring "toggle wrap" %{ - try %{ ui-wrap-enable } catch %{ ui-wrap-disable } -} -map -docstring "toggle soft wrap" global ui w ": ui-wrap-toggle" - -declare-option str base_scrolloff %opt{scrolloff} - -define-command ui-scrolloff-toggle -docstring "toggle scrolloff" %{ - evaluate-commands %sh{ - CUR="$kak_opt_scrolloff" - IFS=, - read TARG HOR <<<$kak_opt_base_scrolloff - IFS=, - read VSCROLL _ <<<$kak_opt_scrolloff - if [ "$VSCROLL" = 99 ]; then - final="$TARG,$HOR" - else - final="99,$HOR" - fi - echo "set-option window scrolloff $final" - } -} - -map -docstring 'toggle screen centering' global ui z ": ui-scrolloff-toggle" - -declare-option bool autowrap false - -define-command autowrap-toggle -docstring "toggle autowrap" %{ - evaluate-commands %sh{ - if [ "$kak_opt_autowrap" = "true" ]; then - echo "autowrap-disable" - echo "set-option window autowrap false" - else - echo "autowrap-enable" - echo "set-option window autowrap true" - fi - } -} - -# map -docstring "toggle autowrap" global ui a ": autowrap-toggle" hook global WinCreate .* %{ ui-wrap-enable ui-scrolloff-toggle } -map -docstring "yank the selection into the clipboard" global user y " wl-copy" - -map -docstring "paste the clipboard" global user p " wl-paste -n" -map -docstring "paste the clipboard before" global user P "! wl-paste -n" -map -docstring "replace with the clipboard" global user R '"_d! wl-paste -n' - map -docstring "quit" global user q ": q" map -docstring "quit" global normal ": q" map -docstring "quit" global user Q ": q!" @@ -130,24 +61,6 @@ map global normal _ map -docstring "comment line" global normal "#" ": comment-line" map -docstring "comment block" global normal "" ": comment-block" -declare-user-mode git -map -docstring "git" global user g ": enter-user-mode git" -map -docstring "lazygit kak cwd" global git g ": terminal lazygit" - -define-command lazygit-buffer-dir %{ - evaluate-commands %sh{ - ROOT="$(env -C "$(dirname $kak_buffile)" git rev-parse --show-toplevel)" - printf "terminal lazygit -p %s" "$ROOT" - } -} -map -docstring "lazygit buffer directory" global git G ": lazygit-buffer-dir" - -define-command git-blame %{ - info %sh{ - git -C $(dirname $(realpath $kak_buffile)) blame -L $kak_cursor_line,$kak_cursor_line $(realpath $kak_buffile) - } -} -map -docstring "blame" global git b ": git-blame" map -docstring "format" global normal = ": format-buffer" map -docstring "format" global normal ": format-selections" diff --git a/.config/kak/scripts/kakfmt.bak b/.config/kak/scripts/kakfmt.bak deleted file mode 100755 index 5751fa03..00000000 --- a/.config/kak/scripts/kakfmt.bak +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; - -my $Indent = 0; -my $Blank_Lines = 0; -my $Open = qr/[{\[(]$/; -my $Close = qr/^[}\])]/; -while (<>) { - s/^\h*//; - $Blank_Lines++, next if m/^$/; - my $Comment = m/^#/; - $Indent-- if m/$Close/ and not $Comment; - $Blank_Lines = 0, print "\n" if $Blank_Lines; - print "\t" x $Indent, $_; - $Indent++ if m/$Open/ and not $Comment; -} diff --git a/.config/kak/scripts/nav.fish b/.config/kak/scripts/nav.fish deleted file mode 100755 index b9a19a5b..00000000 --- a/.config/kak/scripts/nav.fish +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env fish - -echo nav \ No newline at end of file diff --git a/.config/kak/scripts/nav.py b/.config/kak/scripts/nav.py deleted file mode 100755 index 4435c61d..00000000 --- a/.config/kak/scripts/nav.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -# TODO: works great for moving within wrapped line, -# not quite when moving from wrapped to normal and vice versa -# 1. Detect line-wrap status of target line before deciding to do vertical jump or visual column shift -# 2. Load the target line in addition -# 3. Use the same wrap_width logic to compare visual row availability -# on the target line - -# Basically, look at the target line, and figure out the logical column -# number that corresponds to the visual column number we see right now. - -# ISSUE: does not work if the line has indentation - -# Also TODO: once this is ironed out, re-write it in Rust for le speed - -import sys -import re - -session_id = sys.argv[1] -line_n = int(sys.argv[2]) -col = int(sys.argv[3]) - -width = int(sys.argv[4]) -count = int(sys.argv[5]) - -path = sys.argv[6] -direction = sys.argv[7] -digits = len(str(count)) -wrap_width = width - (digits + 3) -line = "" -with open(path, "r") as f: - for n, l in enumerate(f, start=1): - if n == line_n: - line = l -# match = re.match(r"^(\s*)", line) -# if match: -# indent = match.group(1) -# indent_len = len(indent) -# else: -# indent_len = 0 - -# content = line[indent_len:] -content = line -indent_len = 0 - -chunks = [content[i : i + wrap_width] for i in range(0, len(content), wrap_width)] -visual_row = col // wrap_width -visual_col = col % wrap_width - -new_visual_row = visual_row + (-1 if direction == "up" else 1) -if 0 <= new_visual_row < len(chunks): - target_chunk = chunks[new_visual_row] - new_col = min(visual_col, len(target_chunk) - 1) - new_abs_col = indent_len + (new_visual_row * wrap_width + new_col) - diff = abs(new_abs_col - col) - key = "h" if direction == "up" else "l" - print(f"{diff}{key}") -else: - print("j" if direction == "down" else "k")