Commit 7a51d43

Eric Bower  ·  2026-09-08 21:44:48 -0400 EDT
parent 33292ec
fix: ctags zig
4 files changed,  +49, -5
+28, -0
......@@ -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))"
+18, -5
......@@ -23,8 +23,21 @@
2323 --kinddef-Zig=c,const,constants
2424 --kinddef-Zig=v,variable,variables
2525 --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
+2, -0
......@@ -14,6 +14,7 @@ TRACKED_FILES=(
1414 dot/editorconfig
1515 dot_config/vim/vimrc
1616 dot/bashrc
17+ dot_ctags.d/
1718 )
1819
1920 TRACKED_LOCATIONS=(
......@@ -30,6 +31,7 @@ TRACKED_LOCATIONS=(
3031 ~/.editorconfig
3132 ~/.vim/vimrc
3233 ~/.bashrc
34+ ~/.ctags.d/
3335 )
3436
3537 find_files() {
+1, -0
......@@ -12,6 +12,7 @@ bluez
1212 bluez-utils
1313 brightnessctl
1414 cmake
15+ctags
1516 difftastic
1617 direnv
1718 dkms