Commit a7f32e9
Eric Bower
·
2026-09-16 10:59:11 -0400 EDT
parent 95a80d6
fix: ctags
5 files changed,
+41,
-10
| ... | ... | @@ -89,7 +89,7 @@ if [[ -f "package.json" && -d "node_modules" ]]; then | |
| 89 | 89 | fi | |
| 90 | 90 | while IFS= read -r dts; do | |
| 91 | 91 | [[ -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) | |
| 93 | 93 | ||
| 94 | 94 | if [[ ${#ts_targets[@]} -gt 0 ]]; then | |
| 95 | 95 | echo "Indexing TypeScript types into ${target}..." |
| ... | ... | @@ -6,13 +6,37 @@ if ! command -v ctags >/dev/null 2>&1; then | |
| 6 | 6 | exit 1 | |
| 7 | 7 | fi | |
| 8 | 8 | ||
| 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 | |
| 17 | 11 | exit 1 | |
| 18 | 12 | 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 @@ | |
| 1 | 1 | font-size = 13 | |
| 2 | 2 | gtk-titlebar = false | |
| 3 | 3 | theme = Monokai Classic | |
| 4 | + | unfocused-split-opacity = 1 |
+1,
-0
+6,
-1
| ... | ... | @@ -118,14 +118,19 @@ define-command delete-buffer-picker %{ | |
| 118 | 118 | # fi | |
| 119 | 119 | # } | |
| 120 | 120 | ||
| 121 | + | set-option global ctagscmd 'ctags-project' | |
| 121 | 122 | set-option global ctagsfiles 'tags' '.tags_deps' | |
| 122 | 123 | map global user d '<a-i>w: ctags-search<ret>' -docstring 'ctags jump to definition' | |
| 123 | 124 | map global user D ': ctags-generate<ret>' -docstring 'generate tags file' | |
| 124 | 125 | map global user s ': ctags-file-symbols<ret>' -docstring 'search symbols in current file' | |
| 125 | 126 | ||
| 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" %{ | |
| 127 | 128 | echo -markup "{Information}generating dependency tags in background..." | |
| 128 | 129 | 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 | + | ||
| 129 | 134 | if ctags-deps; then | |
| 130 | 135 | msg="dependency tags generated" | |
| 131 | 136 | else |