Commit 7a51d43
Eric Bower
·
2026-09-08 21:44:48 -0400 EDT
parent 33292ec
fix: ctags zig
4 files changed,
+49,
-5
| ... | ... | @@ -0,0 +1,28 @@ | |
| 1 | + | #!/usr/bin/env bash | |
| 2 | + | set -euo pipefail | |
| 3 | + | ||
| 4 | + | if ! command -v zig >/dev/null 2>&1; then | |
| 5 | + | echo "error: zig not found in PATH" >&2 | |
| 6 | + | exit 1 | |
| 7 | + | fi | |
| 8 | + | ||
| 9 | + | if ! command -v ctags >/dev/null 2>&1; then | |
| 10 | + | echo "error: ctags not found in PATH" >&2 | |
| 11 | + | exit 1 | |
| 12 | + | fi | |
| 13 | + | ||
| 14 | + | std_dir="$(zig env | grep '\.std_dir' | sed -E 's/.*"([^"]+)".*/\1/')" | |
| 15 | + | ||
| 16 | + | if [[ -z "${std_dir}" || ! -d "${std_dir}" ]]; then | |
| 17 | + | echo "error: could not locate zig std directory" >&2 | |
| 18 | + | exit 1 | |
| 19 | + | fi | |
| 20 | + | ||
| 21 | + | cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/tags" | |
| 22 | + | target="${cache_dir}/zig_std.tags" | |
| 23 | + | ||
| 24 | + | mkdir -p "${cache_dir}" | |
| 25 | + | ||
| 26 | + | echo "Generating Zig standard library tags from ${std_dir}..." | |
| 27 | + | ctags -f "${target}" "${std_dir}" | |
| 28 | + | echo "Saved tags to ${target} ($(du -h "${target}" | cut -f1))" |
| ... | ... | @@ -23,8 +23,21 @@ | |
| 23 | 23 | --kinddef-Zig=c,const,constants | |
| 24 | 24 | --kinddef-Zig=v,variable,variables | |
| 25 | 25 | --kinddef-Zig=e,error,errors | |
| 26 | - | --regex-Zig=/(pub\s+)?(inline\s+|export\s+|extern\s+)?fn\s+([a-zA-Z0-9_]+)/\3/f/ | |
| 27 | - | --regex-Zig=/(pub\s+)?const\s+([a-zA-Z0-9_]+)\s*=\s*(struct|enum|union|opaque)/\2/t/ | |
| 28 | - | --regex-Zig=/(pub\s+)?const\s+([a-zA-Z0-9_]+)\s*=\s*error\b/\2/e/ | |
| 29 | - | --regex-Zig=/(pub\s+)?const\s+([a-zA-Z0-9_]+)/\2/c/ | |
| 30 | - | --regex-Zig=/(pub\s+)?var\s+([a-zA-Z0-9_]+)/\2/v/ | |
| 26 | + | ||
| 27 | + | # Functions & Methods | |
| 28 | + | --regex-Zig=/(pub\s+)?(inline\s+|export\s+|extern\s+)?fn\s+([a-zA-Z0-9_]+)/\3/f/p | |
| 29 | + | ||
| 30 | + | # Types: structs, enums, unions, opaques | |
| 31 | + | --regex-Zig=/(pub\s+)?const\s+([a-zA-Z0-9_]+)\s*=\s*(struct|enum|union|opaque)/\2/t/p | |
| 32 | + | ||
| 33 | + | # Error sets | |
| 34 | + | --regex-Zig=/(pub\s+)?const\s+([a-zA-Z0-9_]+)\s*=\s*error\b/\2/e/p | |
| 35 | + | ||
| 36 | + | # Exclude @import statements and discard variables (_) | |
| 37 | + | --regex-Zig=/(pub\s+)?const\s+[a-zA-Z0-9_]+\s*=\s*@import\b/{_}/c/{placeholder}px | |
| 38 | + | --regex-Zig=/(pub\s+)?const\s+_\s*=/{_}/c/{placeholder}px | |
| 39 | + | --regex-Zig=/(pub\s+)?var\s+_\s*=/{_}/v/{placeholder}px | |
| 40 | + | ||
| 41 | + | # Constants & Variables | |
| 42 | + | --regex-Zig=/(pub\s+)?const\s+([a-zA-Z0-9_]+)/\2/c/p | |
| 43 | + | --regex-Zig=/(pub\s+)?var\s+([a-zA-Z0-9_]+)/\2/v/p |
M
link.sh
+2,
-0
| ... | ... | @@ -14,6 +14,7 @@ TRACKED_FILES=( | |
| 14 | 14 | dot/editorconfig | |
| 15 | 15 | dot_config/vim/vimrc | |
| 16 | 16 | dot/bashrc | |
| 17 | + | dot_ctags.d/ | |
| 17 | 18 | ) | |
| 18 | 19 | ||
| 19 | 20 | TRACKED_LOCATIONS=( |
| ... | ... | @@ -30,6 +31,7 @@ TRACKED_LOCATIONS=( | |
| 30 | 31 | ~/.editorconfig | |
| 31 | 32 | ~/.vim/vimrc | |
| 32 | 33 | ~/.bashrc | |
| 34 | + | ~/.ctags.d/ | |
| 33 | 35 | ) | |
| 34 | 36 | ||
| 35 | 37 | find_files() { |
+1,
-0