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
| ... | ... | @@ -0,0 +1,33 @@ | |
| 1 | + | #!/usr/bin/env bash | |
| 2 | + | file="$1" | |
| 3 | + | ||
| 4 | + | awk ' | |
| 5 | + | /^(pub )?const [a-zA-Z0-9_]+ = (struct|enum|union|opaque)/ { | |
| 6 | + | match($0, /const ([a-zA-Z0-9_]+)/, m) | |
| 7 | + | curr_struct = m[1] | |
| 8 | + | } | |
| 9 | + | /^};?/ { | |
| 10 | + | curr_struct = "" | |
| 11 | + | } | |
| 12 | + | /(pub |inline |export |extern )*fn [a-zA-Z0-9_]+/ { | |
| 13 | + | match($0, /fn ([a-zA-Z0-9_]+)/, m) | |
| 14 | + | fn_name = m[1] | |
| 15 | + | if (fn_name != "") { | |
| 16 | + | recv = curr_struct | |
| 17 | + | if (recv == "" && match($0, /\((self|it): \*?([a-zA-Z0-9_]+)/, r)) { | |
| 18 | + | recv = r[2] | |
| 19 | + | } | |
| 20 | + | label = (recv != "" ? recv " > " fn_name : fn_name) " : " NR | |
| 21 | + | gsub("!", "!!", label) | |
| 22 | + | action = "execute-keys %|" NR "gvc|" | |
| 23 | + | out = out "%!" label "! %!evaluate-commands %# try %& " action " & # !" | |
| 24 | + | } | |
| 25 | + | } | |
| 26 | + | END { | |
| 27 | + | if (length(out) == 0) { | |
| 28 | + | print "echo -markup \"{Error}No functions found in current file\"" | |
| 29 | + | } else { | |
| 30 | + | print "menu " out | |
| 31 | + | } | |
| 32 | + | } | |
| 33 | + | ' "$file" |
+9,
-0
| ... | ... | @@ -0,0 +1,9 @@ | |
| 1 | + | **/.claude/settings.local.json | |
| 2 | + | ||
| 3 | + | # Ctags | |
| 4 | + | tags | |
| 5 | + | tags.lock | |
| 6 | + | tags.temp | |
| 7 | + | .tags* | |
| 8 | + | *.tags | |
| 9 | + | .kak.*.namecache |
+55,
-36
| ... | ... | @@ -34,16 +34,6 @@ map global user B ":delete-buffer-picker<ret>" -docstring "delete buffer" | |
| 34 | 34 | ||
| 35 | 35 | define-command find -docstring "find files" -params 1 %{ edit %arg{1} } | |
| 36 | 36 | complete-command find shell-script-candidates %{ fd -t f } | |
| 37 | - | # complete-command find shell-script-candidates %{ | |
| 38 | - | # find . -type d \ | |
| 39 | - | # \( -name .git -o -name .jj \ | |
| 40 | - | # -o -name .zig-cache -o -name zig-pkg -o -name zig-out \ | |
| 41 | - | # -o -name node_modules \ | |
| 42 | - | # -o -name __pycache__ -o -name .mypy_cache \ | |
| 43 | - | # -o -name .pytest_cache -o -name .ruff_cache -o -name .venv \ | |
| 44 | - | # \) -prune \ | |
| 45 | - | # -o -type f -print | sed 's|^\./||' | |
| 46 | - | # } | |
| 47 | 37 | ||
| 48 | 38 | define-command dowrap %{ # soft-wrap command | |
| 49 | 39 | add-highlighter buffer/ wrap -indent -word -marker "… " |
| ... | ... | @@ -100,30 +90,59 @@ define-command delete-buffer-picker %{ | |
| 100 | 90 | } | |
| 101 | 91 | } | |
| 102 | 92 | ||
| 103 | - | evaluate-commands %sh{ | |
| 104 | - | if command -V kak-lsp >/dev/null 2>/dev/null ; then | |
| 105 | - | kak-lsp --kakoune -s $kak_session | |
| 106 | - | echo " | |
| 107 | - | set-option global modelinefmt \"%opt{lsp_modeline} %opt{modelinefmt}\" | |
| 108 | - | map global user <l> %{: enter-user-mode lsp<ret>} -docstring 'LSP commands' | |
| 109 | - | map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder' | |
| 110 | - | map global object d '<a-semicolon>lsp-diagnostic-object error warning<ret>' -docstring 'LSP errors and warnings' | |
| 111 | - | map global object D '<a-semicolon>lsp-diagnostic-object error<ret>' -docstring 'LSP errors' | |
| 112 | - | ||
| 113 | - | hook global BufSetOption filetype=python %{ | |
| 114 | - | set-option buffer lsp_servers %{ | |
| 115 | - | [pyright] | |
| 116 | - | command = 'pyright-langserver' | |
| 117 | - | args = ['--stdio'] | |
| 118 | - | root_globs = ['pyrightconfig.json', 'pyproject.toml', 'setup.py', 'setup.cfg', 'requirements.txt', 'Pipfile', '.git'] | |
| 119 | - | } | |
| 120 | - | lsp-enable-window | |
| 121 | - | } | |
| 122 | - | hook global WinSetOption filetype=(python|go|javascript|typescript|zig) %{ | |
| 123 | - | lsp-enable-window | |
| 124 | - | } | |
| 125 | - | " | |
| 126 | - | else | |
| 127 | - | echo "echo -debug kak-lsp not found in PATH" | |
| 128 | - | fi | |
| 93 | + | # evaluate-commands %sh{ | |
| 94 | + | # if command -V kak-lsp >/dev/null 2>/dev/null ; then | |
| 95 | + | # kak-lsp --kakoune -s $kak_session | |
| 96 | + | # echo " | |
| 97 | + | # set-option global modelinefmt \"%opt{lsp_modeline} %opt{modelinefmt}\" | |
| 98 | + | # map global user <l> %{: enter-user-mode lsp<ret>} -docstring 'LSP commands' | |
| 99 | + | # map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder' | |
| 100 | + | # map global object d '<a-semicolon>lsp-diagnostic-object error warning<ret>' -docstring 'LSP errors and warnings' | |
| 101 | + | # map global object D '<a-semicolon>lsp-diagnostic-object error<ret>' -docstring 'LSP errors' | |
| 102 | + | # | |
| 103 | + | # hook global BufSetOption filetype=python %{ | |
| 104 | + | # set-option buffer lsp_servers %{ | |
| 105 | + | # [pyright] | |
| 106 | + | # command = 'pyright-langserver' | |
| 107 | + | # args = ['--stdio'] | |
| 108 | + | # root_globs = ['pyrightconfig.json', 'pyproject.toml', 'setup.py', 'setup.cfg', 'requirements.txt', 'Pipfile', '.git'] | |
| 109 | + | # } | |
| 110 | + | # lsp-enable-window | |
| 111 | + | # } | |
| 112 | + | # hook global WinSetOption filetype=(python|go|javascript|typescript|zig) %{ | |
| 113 | + | # lsp-enable-window | |
| 114 | + | # } | |
| 115 | + | # " | |
| 116 | + | # else | |
| 117 | + | # echo "echo -debug kak-lsp not found in PATH" | |
| 118 | + | # fi | |
| 119 | + | # } | |
| 120 | + | ||
| 121 | + | set-option global ctagsfiles 'tags' | |
| 122 | + | map global user d '<a-i>w: ctags-search<ret>' -docstring 'ctags jump to definition' | |
| 123 | + | map global user D ': ctags-generate<ret>' -docstring 'generate tags file' | |
| 124 | + | map global user s ': ctags-file-symbols<ret>' -docstring 'search symbols in current file' | |
| 125 | + | ||
| 126 | + | define-command ctags-file-symbols -docstring "Browse and jump to functions in current file" %{ | |
| 127 | + | require-module menu | |
| 128 | + | evaluate-commands %sh{ | |
| 129 | + | kak-file-symbols "$kak_buffile" | |
| 130 | + | } | |
| 131 | + | } | |
| 132 | + | ||
| 133 | + | hook global WinCreate .* %{ | |
| 134 | + | ctags-enable-autoinfo | |
| 135 | + | } | |
| 136 | + | hook global InsertCompletionShow .* %{ | |
| 137 | + | try %{ ctags-complete } | |
| 138 | + | } | |
| 139 | + | hook global BufWritePost .* %{ | |
| 140 | + | ctags-update-tags | |
| 141 | + | } | |
| 142 | + | ||
| 143 | + | hook global WinSetOption filetype=zig %{ | |
| 144 | + | evaluate-commands %sh{ | |
| 145 | + | cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}" | |
| 146 | + | printf 'set-option window ctagsfiles "tags" "%s/tags/zig_std.tags"\n' "$cache_dir" | |
| 147 | + | } | |
| 129 | 148 | } |
| ... | ... | @@ -0,0 +1,30 @@ | |
| 1 | + | --recurse=yes | |
| 2 | + | --tag-relative=yes | |
| 3 | + | --pattern-length-limit=0 | |
| 4 | + | --fields=+Sn | |
| 5 | + | --exclude=.git | |
| 6 | + | --exclude=.jj | |
| 7 | + | --exclude=.zig-cache | |
| 8 | + | --exclude=zig-pkg | |
| 9 | + | --exclude=zig-out | |
| 10 | + | --exclude=node_modules | |
| 11 | + | --exclude=__pycache__ | |
| 12 | + | --exclude=.mypy_cache | |
| 13 | + | --exclude=.pytest_cache | |
| 14 | + | --exclude=.ruff_cache | |
| 15 | + | --exclude=.venv | |
| 16 | + | --exclude=target | |
| 17 | + | ||
| 18 | + | # Zig language definition | |
| 19 | + | --langdef=Zig | |
| 20 | + | --map-Zig=.zig | |
| 21 | + | --kinddef-Zig=f,function,functions | |
| 22 | + | --kinddef-Zig=t,type,types | |
| 23 | + | --kinddef-Zig=c,const,constants | |
| 24 | + | --kinddef-Zig=v,variable,variables | |
| 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/ |