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