Commit 33292ec
Eric Bower
·
2026-09-08 21:38:30 -0400 EDT
parent 9da9c80
feat(kak): ctags symbol search
4 files changed,
+127,
-36
+33,
-0
1@@ -0,0 +1,33 @@
2+#!/usr/bin/env bash
3+file="$1"
4+
5+awk '
6+ /^(pub )?const [a-zA-Z0-9_]+ = (struct|enum|union|opaque)/ {
7+ match($0, /const ([a-zA-Z0-9_]+)/, m)
8+ curr_struct = m[1]
9+ }
10+ /^};?/ {
11+ curr_struct = ""
12+ }
13+ /(pub |inline |export |extern )*fn [a-zA-Z0-9_]+/ {
14+ match($0, /fn ([a-zA-Z0-9_]+)/, m)
15+ fn_name = m[1]
16+ if (fn_name != "") {
17+ recv = curr_struct
18+ if (recv == "" && match($0, /\((self|it): \*?([a-zA-Z0-9_]+)/, r)) {
19+ recv = r[2]
20+ }
21+ label = (recv != "" ? recv " > " fn_name : fn_name) " : " NR
22+ gsub("!", "!!", label)
23+ action = "execute-keys %|" NR "gvc|"
24+ out = out "%!" label "! %!evaluate-commands %# try %& " action " & # !"
25+ }
26+ }
27+ END {
28+ if (length(out) == 0) {
29+ print "echo -markup \"{Error}No functions found in current file\""
30+ } else {
31+ print "menu " out
32+ }
33+ }
34+' "$file"
+9,
-0
1@@ -0,0 +1,9 @@
2+**/.claude/settings.local.json
3+
4+# Ctags
5+tags
6+tags.lock
7+tags.temp
8+.tags*
9+*.tags
10+.kak.*.namecache
+55,
-36
1@@ -34,16 +34,6 @@ map global user B ":delete-buffer-picker<ret>" -docstring "delete buffer"
2
3 define-command find -docstring "find files" -params 1 %{ edit %arg{1} }
4 complete-command find shell-script-candidates %{ fd -t f }
5-# complete-command find shell-script-candidates %{
6-# find . -type d \
7-# \( -name .git -o -name .jj \
8-# -o -name .zig-cache -o -name zig-pkg -o -name zig-out \
9-# -o -name node_modules \
10-# -o -name __pycache__ -o -name .mypy_cache \
11-# -o -name .pytest_cache -o -name .ruff_cache -o -name .venv \
12-# \) -prune \
13-# -o -type f -print | sed 's|^\./||'
14-# }
15
16 define-command dowrap %{ # soft-wrap command
17 add-highlighter buffer/ wrap -indent -word -marker "… "
18@@ -100,30 +90,59 @@ define-command delete-buffer-picker %{
19 }
20 }
21
22-evaluate-commands %sh{
23- if command -V kak-lsp >/dev/null 2>/dev/null ; then
24- kak-lsp --kakoune -s $kak_session
25- echo "
26- set-option global modelinefmt \"%opt{lsp_modeline} %opt{modelinefmt}\"
27- map global user <l> %{: enter-user-mode lsp<ret>} -docstring 'LSP commands'
28- map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
29- map global object d '<a-semicolon>lsp-diagnostic-object error warning<ret>' -docstring 'LSP errors and warnings'
30- map global object D '<a-semicolon>lsp-diagnostic-object error<ret>' -docstring 'LSP errors'
31-
32- hook global BufSetOption filetype=python %{
33- set-option buffer lsp_servers %{
34- [pyright]
35- command = 'pyright-langserver'
36- args = ['--stdio']
37- root_globs = ['pyrightconfig.json', 'pyproject.toml', 'setup.py', 'setup.cfg', 'requirements.txt', 'Pipfile', '.git']
38- }
39- lsp-enable-window
40- }
41- hook global WinSetOption filetype=(python|go|javascript|typescript|zig) %{
42- lsp-enable-window
43- }
44- "
45- else
46- echo "echo -debug kak-lsp not found in PATH"
47- fi
48+# evaluate-commands %sh{
49+# if command -V kak-lsp >/dev/null 2>/dev/null ; then
50+# kak-lsp --kakoune -s $kak_session
51+# echo "
52+# set-option global modelinefmt \"%opt{lsp_modeline} %opt{modelinefmt}\"
53+# map global user <l> %{: enter-user-mode lsp<ret>} -docstring 'LSP commands'
54+# map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
55+# map global object d '<a-semicolon>lsp-diagnostic-object error warning<ret>' -docstring 'LSP errors and warnings'
56+# map global object D '<a-semicolon>lsp-diagnostic-object error<ret>' -docstring 'LSP errors'
57+#
58+# hook global BufSetOption filetype=python %{
59+# set-option buffer lsp_servers %{
60+# [pyright]
61+# command = 'pyright-langserver'
62+# args = ['--stdio']
63+# root_globs = ['pyrightconfig.json', 'pyproject.toml', 'setup.py', 'setup.cfg', 'requirements.txt', 'Pipfile', '.git']
64+# }
65+# lsp-enable-window
66+# }
67+# hook global WinSetOption filetype=(python|go|javascript|typescript|zig) %{
68+# lsp-enable-window
69+# }
70+# "
71+# else
72+# echo "echo -debug kak-lsp not found in PATH"
73+# fi
74+# }
75+
76+set-option global ctagsfiles 'tags'
77+map global user d '<a-i>w: ctags-search<ret>' -docstring 'ctags jump to definition'
78+map global user D ': ctags-generate<ret>' -docstring 'generate tags file'
79+map global user s ': ctags-file-symbols<ret>' -docstring 'search symbols in current file'
80+
81+define-command ctags-file-symbols -docstring "Browse and jump to functions in current file" %{
82+ require-module menu
83+ evaluate-commands %sh{
84+ kak-file-symbols "$kak_buffile"
85+ }
86+}
87+
88+hook global WinCreate .* %{
89+ ctags-enable-autoinfo
90+}
91+hook global InsertCompletionShow .* %{
92+ try %{ ctags-complete }
93+}
94+hook global BufWritePost .* %{
95+ ctags-update-tags
96+}
97+
98+hook global WinSetOption filetype=zig %{
99+ evaluate-commands %sh{
100+ cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}"
101+ printf 'set-option window ctagsfiles "tags" "%s/tags/zig_std.tags"\n' "$cache_dir"
102+ }
103 }
1@@ -0,0 +1,30 @@
2+--recurse=yes
3+--tag-relative=yes
4+--pattern-length-limit=0
5+--fields=+Sn
6+--exclude=.git
7+--exclude=.jj
8+--exclude=.zig-cache
9+--exclude=zig-pkg
10+--exclude=zig-out
11+--exclude=node_modules
12+--exclude=__pycache__
13+--exclude=.mypy_cache
14+--exclude=.pytest_cache
15+--exclude=.ruff_cache
16+--exclude=.venv
17+--exclude=target
18+
19+# Zig language definition
20+--langdef=Zig
21+--map-Zig=.zig
22+--kinddef-Zig=f,function,functions
23+--kinddef-Zig=t,type,types
24+--kinddef-Zig=c,const,constants
25+--kinddef-Zig=v,variable,variables
26+--kinddef-Zig=e,error,errors
27+--regex-Zig=/(pub\s+)?(inline\s+|export\s+|extern\s+)?fn\s+([a-zA-Z0-9_]+)/\3/f/
28+--regex-Zig=/(pub\s+)?const\s+([a-zA-Z0-9_]+)\s*=\s*(struct|enum|union|opaque)/\2/t/
29+--regex-Zig=/(pub\s+)?const\s+([a-zA-Z0-9_]+)\s*=\s*error\b/\2/e/
30+--regex-Zig=/(pub\s+)?const\s+([a-zA-Z0-9_]+)/\2/c/
31+--regex-Zig=/(pub\s+)?var\s+([a-zA-Z0-9_]+)/\2/v/