AutoYADM commit: 2025-07-18 17:19:43

This commit is contained in:
Daniel Fichtinger 2025-07-18 17:19:43 -04:00
parent 8f2f9512e7
commit 5e68dc889e
2 changed files with 28 additions and 19 deletions

View file

@ -0,0 +1,10 @@
provide-module local-kakrc %—
# syntax highlighting
hook global BufCreate (.*/)?\.kakrc %{
set-option buffer filetype kak
}
# load proj. config
define-command root-load-kakrc %{
try %{ source %exp{%opt{root_path}/.kakrc} }
}

View file

@ -1,5 +1,5 @@
provide-module root %∴ provide-module root %∴
declare-option str-list root_globs .git .kakrc kakrc declare-option str-list root_globs .kakrc kakrc .git
declare-option str root_path %sh{ echo "$PWD" } declare-option str root_path %sh{ echo "$PWD" }
declare-option -hidden str root_prev_pwd %opt{root_path} declare-option -hidden str root_prev_pwd %opt{root_path}
# recursively discovers the root dir based on root_globs # recursively discovers the root dir based on root_globs
@ -23,26 +23,20 @@ provide-module root %∴
printf 'echo "Discovered root: %s"\n' "$root" printf 'echo "Discovered root: %s"\n' "$root"
} }
} }
# project-specific configuration
hook global BufCreate (.*/)?(\.kakrc\.local|\.kakrc\.local|\.kakrc) %{
set-option buffer filetype kak
}
define-command root-load-kakrc %{
try %{ source .kakrc } catch %{
try %{ source .kakrc.local } catch %{ try %{ source .local.kakrc } }
}
}
# change the cwd to root
define-command -hidden root-cd-root-impl %{ define-command -hidden root-cd-root-impl %{
set-option global root_prev_pwd %sh{ echo "$PWD" } set-option global root_prev_pwd %sh{ echo "$PWD" }
change-directory %opt{root_path} change-directory %opt{root_path}
echo "CWD: %opt{root_path}" echo "CWD: %opt{root_path}"
} }
# change cwd back to what it was before
define-command -hidden root-cd-return-impl %{ define-command -hidden root-cd-return-impl %{
change-directory %opt{root_prev_pwd} change-directory %opt{root_prev_pwd}
echo "CWD: %opt{root_prev_pwd}" echo "CWD: %opt{root_prev_pwd}"
} }
# toggle between root and previous cwd
define-command root-cd %{ define-command root-cd %{
evaluate-commands %sh{ evaluate-commands %sh{
if [ "$PWD" != "$kak_opt_root_path" ]; then if [ "$PWD" != "$kak_opt_root_path" ]; then
@ -53,11 +47,16 @@ provide-module root %∴
} }
} }
# edit a file, relative to root
define-command -params 1 root-edit %{ define-command -params 1 root-edit %{
edit %exp{%opt{root_path}/%arg{1}} edit %exp{%opt{root_path}/%arg{1}}
} }
complete-command root-edit shell-script-candidates %{
fd -H -tf --exclude '.git' --base-directory "$kak_opt_root_path" .
}
alias global root root-discover
alias global re root-edit alias global re root-edit
alias global rc root-cd