From 2781056ce6b70c20b2412ba05833680683d12ef5 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 9 Nov 2012 19:10:08 +0100 Subject: [PATCH] Add a rc/ctags.kak for a :tag implementation using exuberant ctags --- src/rc/ctags.kak | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/rc/ctags.kak diff --git a/src/rc/ctags.kak b/src/rc/ctags.kak new file mode 100644 index 00000000..48fdc749 --- /dev/null +++ b/src/rc/ctags.kak @@ -0,0 +1,26 @@ +# Kakoune Exuberant CTags support script +# +# This script requires the readtags command available in ctags source but +# not installed by default + +def -shell-params \ + -shell-completion 'readtags -p "$1" | cut -f 1 | sort | uniq' \ + tag \ + %{ %sh{ + if [[ -z "$1" ]]; then tagname=${kak_selection}; else tagname=$1; fi + matches=$(readtags ${tagname}) + if [[ -z "${matches}" ]]; then + echo "echo tag not found ${tagname}" + else + menuparam=$(readtags ${tagname} | perl -i -ne ' + /([^\t]+)\t([^\t]+)\t\/\^(.*)\$\// and print "%{$2 [$3]} %{try %{ edit %{$2}; exec %{%s\\Q$3} } catch %{ echo %{unable to find tag} } } "; + /([^\t]+)\t([^\t]+)\t(\d+)/ and print "%{$2:$3} %{edit %{$2}; exec %{$3g}} "; + ') + + if [[ -z "${menuparam}" ]]; then + echo "echo no such tag ${tagname}"; + else + echo "menu -auto-single ${menuparam//$'\n'/ }"; + fi + fi + }}