Fix tabs in clang.kak and improve escaping

This commit is contained in:
Maxime Coste 2015-01-30 13:42:13 +00:00
parent 47c8a4378f
commit b4661e37d2

View File

@ -34,33 +34,35 @@ def -shell-params clang-parse %{
cd $(dirname ${kak_buffile}) cd $(dirname ${kak_buffile})
if [ "$1" == "-complete" ]; then if [ "$1" == "-complete" ]; then
pos=-:${kak_cursor_line}:${kak_cursor_column} pos=-:${kak_cursor_line}:${kak_cursor_column}
header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}"
compl=$(clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} \ compl=$(clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} \
-Xclang -code-completion-brief-comments -Xclang -code-completion-at=${pos} - < ${dir}/buf 2> ${dir}/stderr | -Xclang -code-completion-brief-comments -Xclang -code-completion-at=${pos} - < ${dir}/buf 2> ${dir}/stderr |
awk -F ': ' -e ' awk -F ': ' -e '
/^COMPLETION:/ && ! /\(Hidden\)/ { /^COMPLETION:/ && ! /\(Hidden\)/ {
gsub(/[[{<]#|#[}>]/, "", $3) gsub(/[[{<]#|#[}>]/, "", $3)
gsub(/#]/, " ", $3) gsub(/#]/, " ", $3)
gsub(/:: /, "::", $3) gsub(/:: /, "::", $3)
gsub(/ +$/, "", $3) gsub(/ +$/, "", $3)
id=substr($2, 1, length($2)-1) id=substr($2, 1, length($2)-1)
gsub(/:/, "\\:", id) gsub(/:/, "\\:", id)
desc=$4 ? $3 "\\n" $4 : $3 gsub(/"/, "\\\"", id)
gsub(/:/, "\\:", desc) desc=$4 ? $3 "\\n" $4 : $3
if (id in completions) gsub(/:/, "\\:", desc)
completions[id]=completions[id] "\\n" desc gsub(/"/, "\\\"", desc)
else if (id in completions)
completions[id]=desc completions[id]=completions[id] "\\n" desc
} else
END { completions[id]=desc
for (id in completions) }
print id "@" completions[id] END {
}' | sort | paste -s -d ':' | sed -e 's/\\n/\n/g') for (id in completions)
echo "eval -client ${kak_client} echo completed print id "@" completions[id]
set 'buffer=${kak_buffile}' clang_completions %[${header}:${compl}]" | kak -p ${kak_session} }' | sort | paste -s -d ':' | sed -e 's/\\n/\n/g')
echo "eval -client ${kak_client} echo completed
set 'buffer=${kak_buffile}' clang_completions \"${header}:${compl}\"" | kak -p ${kak_session}
else else
clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} - < ${dir}/buf 2> ${dir}/stderr clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} - < ${dir}/buf 2> ${dir}/stderr
fi fi
flags=$(cat ${dir}/stderr | sed -rne " flags=$(cat ${dir}/stderr | sed -rne "