Commit a7f32e9

Eric Bower  ·  2026-09-16 10:59:11 -0400 EDT
parent 95a80d6
fix: ctags
5 files changed,  +41, -10
+1, -1
......@@ -89,7 +89,7 @@ if [[ -f "package.json" && -d "node_modules" ]]; then
8989 fi
9090 while IFS= read -r dts; do
9191 [[ -f "$dts" ]] && ts_targets+=("$dts")
92- done < <(find node_modules -maxdepth 4 -name "*.d.ts" ! -path "*/node_modules/@types/*" 2>/dev/null | head -n 500)
92+ done < <(find node_modules -maxdepth 5 -name "*.d.ts" ! -path "*/node_modules/@types/*" 2>/dev/null)
9393
9494 if [[ ${#ts_targets[@]} -gt 0 ]]; then
9595 echo "Indexing TypeScript types into ${target}..."
+32, -8
......@@ -6,13 +6,37 @@ if ! command -v ctags >/dev/null 2>&1; then
66 exit 1
77 fi
88
9-echo "Generating tags in $(pwd)..."
10-
11-if ctags -R --fields=+S -f .tags.tmp .; then
12- mv .tags.tmp tags
13- echo "Saved tags ($(du -h tags | cut -f1 | xargs))"
14-else
15- rm -f .tags.tmp
16- echo "error: tags generation failed" >&2
9+if ! command -v fd >/dev/null 2>&1; then
10+ echo "error: fd not found in PATH" >&2
1711 exit 1
1812 fi
13+
14+outfile=""
15+paths=()
16+while [[ $# -gt 0 ]]; do
17+ case "$1" in
18+ -f) outfile="$2"; shift 2 ;;
19+ *) paths+=("$1"); shift ;;
20+ esac
21+done
22+
23+if [[ -z "$outfile" ]]; then
24+ echo "error: -f <outfile> is required" >&2
25+ exit 1
26+fi
27+
28+[[ ${#paths[@]} -eq 0 ]] && paths=(".")
29+
30+# .tsx isn't mapped to the TypeScript parser by default in Universal Ctags,
31+# so every .tsx component would otherwise go untagged.
32+ctags_flags=(--map-TypeScript=+.tsx --fields=+S -f "$outfile")
33+
34+# A single-file target (e.g. per-file tag update on save) is tagged directly.
35+if [[ ${#paths[@]} -eq 1 && -f "${paths[0]}" ]]; then
36+ exec ctags "${ctags_flags[@]}" "${paths[0]}"
37+fi
38+
39+# Directory targets: fd respects .gitignore, so build output, dependency
40+# dirs, and caches (which can hold single lines many MB long, e.g. turbo
41+# manifests) never get scanned and bloat the tags file.
42+fd -t f -H --no-require-git -E .git . "${paths[@]}" | ctags "${ctags_flags[@]}" -L -
+1, -0
......@@ -1,3 +1,4 @@
11 font-size = 13
22 gtk-titlebar = false
33 theme = Monokai Classic
4+unfocused-split-opacity = 1
+1, -0
......@@ -7,3 +7,4 @@ tags.temp
77 .tags*
88 *.tags
99 .kak.*.namecache
10+.file_tags.kaktmp
+6, -1
......@@ -118,14 +118,19 @@ define-command delete-buffer-picker %{
118118 # fi
119119 # }
120120
121+set-option global ctagscmd 'ctags-project'
121122 set-option global ctagsfiles 'tags' '.tags_deps'
122123 map global user d '<a-i>w: ctags-search<ret>' -docstring 'ctags jump to definition'
123124 map global user D ': ctags-generate<ret>' -docstring 'generate tags file'
124125 map global user s ': ctags-file-symbols<ret>' -docstring 'search symbols in current file'
125126
126-define-command ctags-generate-deps -docstring "Generate .tags_deps for third-party dependencies" %{
127+define-command ctags-deps -docstring "Generate .tags_deps for third-party dependencies" %{
127128 echo -markup "{Information}generating dependency tags in background..."
128129 nop %sh{ (
130+ trap - INT QUIT
131+ while ! mkdir .tags_deps.kaklock 2>/dev/null; do sleep 1; done
132+ trap 'rmdir .tags_deps.kaklock' EXIT
133+
129134 if ctags-deps; then
130135 msg="dependency tags generated"
131136 else