From ae86ffcbf9f12c97a7e75661e73ceeae5f264576 Mon Sep 17 00:00:00 2001 From: Steven Chan Date: Sun, 12 Feb 2017 14:07:52 -0800 Subject: [PATCH 1/2] 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. --- rc/base/ctags.kak | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rc/base/ctags.kak b/rc/base/ctags.kak index f15eee82..d860f3d8 100644 --- a/rc/base/ctags.kak +++ b/rc/base/ctags.kak @@ -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(/", keys); gsub(/\t/, "", keys); - out = out " %{" $2 " {MenuInfo}" re "} %{evaluate-commands %{ try %{ edit %{" tagroot $2 "}; execute-keys %{/\\Q" keys "vc} } catch %{ echo %{unable to find tag} } } }" + out = out " %{" $2 " {MenuInfo}" re "} %{evaluate-commands %{ try %{ edit %{" path($2) "}; execute-keys %{/\\Q" keys "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' %{