From e8f2ebb737593c509b40a8a7e5a0d48ca7ed0faf Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 6 Nov 2014 19:17:13 +0000 Subject: [PATCH] Tweak completer scripts --- rc/clang.kak | 11 ++++++----- rc/jedi.kak | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/rc/clang.kak b/rc/clang.kak index d8877b71..b1c0f11b 100644 --- a/rc/clang.kak +++ b/rc/clang.kak @@ -23,15 +23,16 @@ def clang-complete %{ rmhooks buffer clang-cleanup } }" - # this runs in a detached shell, asynchronously, so that kakoune does not hang while clang is running. - # As completions references a cursor position and a buffer timestamp, only valid completions should be + # this runs in a detached shell, asynchronously, so that kakoune does + # not hang while clang is running. As completions references a cursor + # position and a buffer timestamp, only valid completions should be # displayed. ( pos=-:${kak_cursor_line}:${kak_cursor_column} cd $(dirname ${kak_buffile}) header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" - compl=$(clang++ -x c++ -fsyntax-only ${kak_opt_clang_options} -Xclang -code-completion-at=${pos} - < ${dir}/buf 2>&1 | - tee ${dir}/fifo | grep ^COMPLETION: | grep -v '(Hidden)' | sed -re 's/^COMPLETION: ([^:]+) :.*/\1/; s/:/\\:/g' | uniq | paste -s -d ':') + compl=$(clang++ -x c++ -fsyntax-only ${kak_opt_clang_options} -Xclang -code-completion-at=${pos} - < ${dir}/buf 2> ${dir}/fifo | + grep ^COMPLETION: | grep -v '(Hidden)' | sed -re 's/^COMPLETION: (.+) : .*/\1/; s/:/\\:/g' | uniq | paste -s -d ':') echo "eval -client ${kak_client} %[ echo completed; set 'buffer=${kak_buffile}' clang_completions %[${header}:${compl}] ]" | kak -p ${kak_session} ) > /dev/null 2>&1 < /dev/null & @@ -39,7 +40,7 @@ def clang-complete %{ } def clang-enable-autocomplete %{ - set window completers %sh{ echo "'option=clang_completions:${kak_opt_completers}'" } + set window completers %rec{option=clang_completions:%opt{completers}} hook window -group clang-autocomplete InsertIdle .* %{ try %{ exec -draft (\.|->|::).\' echo 'completing...' diff --git a/rc/jedi.kak b/rc/jedi.kak index 7d53b4b4..02e0c90f 100644 --- a/rc/jedi.kak +++ b/rc/jedi.kak @@ -21,7 +21,7 @@ def jedi-complete %{ cd $(dirname ${kak_buffile}) header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" - compl=$( (python | 2>&1 tee "${dir}/fifo") <<-END + compl=$(python 2> "${dir}/fifo" <<-END import jedi script=jedi.Script(open('$dir/buf', 'r').read(), $kak_cursor_line, $kak_cursor_column - 1, '$kak_buffile') print ':'.join([str(c.name) for c in script.completions()]) @@ -34,7 +34,7 @@ def jedi-complete %{ } def jedi-enable-autocomplete %{ - set window completers %sh{ echo "'option=jedi_completions:${kak_opt_completers}'" } + set window completers %rec{option=jedi_completions:%opt{completers}} } hook window -group jedi-autocomplete InsertIdle .* %{ try %{ exec -draft \..\' echo 'completing...'