This commit is contained in:
Maxime Coste 2019-06-15 10:47:01 +10:00
commit c1d56334c0

View File

@ -10,6 +10,8 @@ declare-option -docstring "list of paths to tag files to parse when looking up a
declare-option -hidden completions ctags_completions declare-option -hidden completions ctags_completions
declare-option -docstring "shell command to run" str readtagscmd "readtags"
define-command -params ..1 \ define-command -params ..1 \
-shell-script-candidates %{ -shell-script-candidates %{
realpath() { ( cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) } realpath() { ( cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) }
@ -36,7 +38,7 @@ If no symbol is passed then the current selection is used as symbol name} \
done | awk '!x[$0]++' | # remove duplicates done | awk '!x[$0]++' | # remove duplicates
while read -r tags; do while read -r tags; do
printf '!TAGROOT\t%s\n' "$(realpath "${tags%/*}")/" printf '!TAGROOT\t%s\n' "$(realpath "${tags%/*}")/"
readtags -t "$tags" "$tagname" ${kak_opt_readtagscmd} -t "$tags" "$tagname"
done | awk -F '\t|\n' ' done | awk -F '\t|\n' '
/^!TAGROOT\t/ { tagroot=$2 } /^!TAGROOT\t/ { tagroot=$2 }
/[^\t]+\t[^\t]+\t\/\^.*\$?\// { /[^\t]+\t[^\t]+\t\/\^.*\$?\// {
@ -68,7 +70,7 @@ define-command ctags-complete -docstring "Complete the current selection" %{
compl=$( compl=$(
eval "set -- $kak_opt_ctagsfiles" eval "set -- $kak_opt_ctagsfiles"
for ctagsfile in "$@"; do for ctagsfile in "$@"; do
readtags -p -t "$ctagsfile" ${kak_selection} ${kak_opt_readtagscmd} -p -t "$ctagsfile" ${kak_selection}
done | awk '{ uniq[$1]++ } END { for (elem in uniq) printf " %1$s||%1$s", elem }' done | awk '{ uniq[$1]++ } END { for (elem in uniq) printf " %1$s||%1$s", elem }'
) )
printf %s\\n "evaluate-commands -client ${kak_client} set-option buffer=${kak_bufname} ctags_completions ${header}${compl}" | \ printf %s\\n "evaluate-commands -client ${kak_client} set-option buffer=${kak_bufname} ctags_completions ${header}${compl}" | \
@ -85,7 +87,7 @@ define-command ctags-funcinfo -docstring "Display ctags information about a sele
f=${kak_selection%?} f=${kak_selection%?}
sig='\tsignature:(.*)' sig='\tsignature:(.*)'
csn='\t(class|struct|namespace):(\S+)' csn='\t(class|struct|namespace):(\S+)'
sigs=$(readtags -e -Q '(eq? $kind "f")' "${f}" | sed -re "s/^.*${csn}.*${sig}$/\3 [\2::${f}]/ ;t ;s/^.*${sig}$/\1 [${f}]/") sigs=$(${kak_opt_readtagscmd} -e -Q '(eq? $kind "f")' "${f}" | sed -re "s/^.*${csn}.*${sig}$/\3 [\2::${f}]/ ;t ;s/^.*${sig}$/\1 [${f}]/")
if [ -n "$sigs" ]; then if [ -n "$sigs" ]; then
printf %s\\n "evaluate-commands -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column -style above '$sigs'}" printf %s\\n "evaluate-commands -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column -style above '$sigs'}"
fi fi