summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-11-28 18:45:39 +0000
committerMaxime Coste <frrrwww@gmail.com>2013-11-28 18:48:09 +0000
commitfcf3e9e138c2089822527cfdeb04e706b6ee38d2 (patch)
tree699ab584a88f4f4bad50c769748d69c4c55b02ea /src
parent50325e62b06c4df3c428a19166b45b95e78511c1 (diff)
Improve ctags support
* cleanup tag command * add a tag-complete command * add a gentags command for launching ctags in the background
Diffstat (limited to 'src')
-rw-r--r--src/rc/ctags.kak38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/rc/ctags.kak b/src/rc/ctags.kak
index 237e94f7..26db6314 100644
--- a/src/rc/ctags.kak
+++ b/src/rc/ctags.kak
@@ -25,18 +25,25 @@ def -shell-params \
fi
}}
+def tag-complete %{ eval -draft %{
+ exec <space>hb<a-k>^\w+$<ret>
+ %sh{ (
+ compl=$(readtags -p "$kak_selection" | cut -f 1 | sort | uniq)
+ compl=${compl//:/\\:}
+ compl=${compl//$'\n'/:}
+ compl="${kak_cursor_line}.${kak_cursor_column}+${#kak_selection}@${kak_timestamp}:${compl}"
+ echo "set buffer=$kak_bufname completions '${compl}'" | socat -u stdin UNIX-CONNECT:/tmp/kak-${kak_session}
+ ) >& /dev/null < /dev/null & }
+}}
+
def funcinfo %{
eval -draft %{
- exec [(<space>B;
+ exec [(<space>B<a-k>[a-zA-Z_]+\(<ret>
%sh{
- if [[ "$kak_selection" =~ [a-zA-Z_]+\( ]]; then
- sigs=$(readtags -e ${kak_selection%(} | grep kind:f | sed -re 's/^(\S+).*(class|struct|namespace):(\S+).*signature:(.*)$/\4 [\3::\1]/')
- if [[ -n "$sigs" ]]; then
- echo "eval -client ${kak_client} %{info -anchor right '$sigs'}"
- exit
- fi
+ sigs=$(readtags -e ${kak_selection%(} | grep kind:f | sed -re 's/^(\S+).*(class|struct|namespace):(\S+).*signature:(.*)$/\4 [\3::\1]/')
+ if [[ -n "$sigs" ]]; then
+ echo "eval -client ${kak_client} %{info -anchor right '$sigs'}"
fi
- echo info
}
}
}
@@ -49,3 +56,18 @@ def ctags-enable-autoinfo %{
}
def ctags-disable-autoinfo %{ rmhooks window ctags-autoinfo }
+
+decl str ctagsopts "-R ."
+
+def gentags %{
+ echo launching tag generation in the background
+ %sh{ (
+ if ctags -f .tags.kaktmp ${kak_opt_ctagsopts}; then
+ mv .tags.kaktmp tags
+ msg="tags generation complete"
+ else
+ msg="tags generation failed"
+ fi
+ echo "eval -client $kak_client echo ${msg}" | socat -u stdin UNIX-CONNECT:/tmp/kak-${kak_session}
+ ) >& /dev/null < /dev/null & }
+}