Fixes for ctags.kak

1. Fix #2250. Enable ctags to handle absolute file paths.
   Only prepend tagroot to tag location if it is a relative file path.

2. Include signature field in the default ctags command.
   The regex for displaying signature info includes a mandatory pattern
   for 'signature' field, but the field is not a default option for the ctags command.
   If the tags file is generated by the as-is ctags command, pattern matching will fail,
   and the whole ctags line for the selected function will be displayed instead.
This commit is contained in:
Steven Chan 2017-02-12 14:07:52 -08:00 committed by Steven Chan
parent cb7401439b
commit ae86ffcbf9

View File

@ -39,10 +39,13 @@ If no symbol is passed then the current selection is used as symbol name} \
re=$0;
sub(".*\t/\\^", "", re); sub("\\$?/$", "", re); gsub("(\\{|\\}|\\\\E).*$", "", re);
keys=re; gsub(/</, "<lt>", keys); gsub(/\t/, "<c-v><c-i>", keys);
out = out " %{" $2 " {MenuInfo}" re "} %{evaluate-commands %{ try %{ edit %{" tagroot $2 "}; execute-keys %{/\\Q" keys "<ret>vc} } catch %{ echo %{unable to find tag} } } }"
out = out " %{" $2 " {MenuInfo}" re "} %{evaluate-commands %{ try %{ edit %{" path($2) "}; execute-keys %{/\\Q" keys "<ret>vc} } catch %{ echo %{unable to find tag} } } }"
}
/[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{evaluate-commands %{ edit %{" tagroot $2 "} %{" $3 "}}}" }
END { print ( length(out) == 0 ? "echo -markup %{{Error}no such tag " ENVIRON["tagname"] "}" : "menu -markup -auto-single " out ) }'
/[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{evaluate-commands %{ edit %{" path($2) "} %{" $3 "}}}" }
END { print ( length(out) == 0 ? "echo -markup %{{Error}no such tag " ENVIRON["tagname"] "}" : "menu -markup -auto-single " out ) }
# Ensure x is an absolute file path, by prepending with tagroot
function path(x) { return x ~/^\// ? x : tagroot x }'
}}
define-command ctags-complete -docstring "Insert completion candidates for the current selection into the buffer's local variables" %{ evaluate-commands -draft %{
@ -76,7 +79,7 @@ define-command ctags-enable-autoinfo -docstring "Automatically display ctags inf
define-command ctags-disable-autoinfo -docstring "Disable automatic ctags information displaying" %{ remove-hooks window ctags-autoinfo }
declare-option -docstring "shell command to run" \
str ctagscmd "ctags -R"
str ctagscmd "ctags -R --fields=+S"
declare-option -docstring "path to the directory in which the tags file will be generated" str ctagspaths "."
define-command ctags-generate -docstring 'Generate tag file asynchronously' %{