AutoYADM commit: 2025-07-18 16:18:24
This commit is contained in:
parent
905b3e3d67
commit
5cf0eb449d
1 changed files with 19 additions and 0 deletions
|
@ -1,5 +1,24 @@
|
|||
provide-module root %∴
|
||||
declare-option str-list root_globs .git .kakrc kakrc
|
||||
declare-option str project_root %sh{ echo "$PWD" }
|
||||
define-command root-discover %{
|
||||
evaluate-commands %sh{
|
||||
globs="$kak_opt_root_globs"
|
||||
dir="$PWD"
|
||||
|
||||
while [ "$dir" != "/" ]; do
|
||||
for glob in $globs; do
|
||||
match=$(fd -H -td -1 --glob "$glob" "$dir" --max-depth 1 2>/dev/null | head -n1)
|
||||
if [ -n "$match" ]; then
|
||||
root="$match"
|
||||
break
|
||||
fi
|
||||
done
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
printf 'set-option global project_root "%s"\n' "$root"
|
||||
}
|
||||
}
|
||||
# project-specific configuration
|
||||
hook global BufCreate (.*/)?(\.kakrc\.local|\.kakrc\.local|\.kakrc) %{
|
||||
set-option buffer filetype kak
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue