From 2f41fdb683644aefed4ef2534522c9b54183c08e Mon Sep 17 00:00:00 2001 From: Marc Date: Tue, 13 Mar 2018 13:52:09 +0000 Subject: [PATCH] Tweak the bash code on the racer support --- rc/extra/racer.kak | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/rc/extra/racer.kak b/rc/extra/racer.kak index 45ecb8fc..57ac37a1 100644 --- a/rc/extra/racer.kak +++ b/rc/extra/racer.kak @@ -105,11 +105,11 @@ define-command racer-go-definition -docstring "Jump to where the rust identifier ( cursor="${kak_cursor_line} $((${kak_cursor_column} - 1))" racer_data=$(racer --interface tab-text find-definition ${cursor} ${kak_buffile} ${dir}/buf | head -n 1) - racer_match=$(echo "$racer_data" | cut -f1 ) + racer_match=$(printf %s\\n "$racer_data" | cut -f1 ) if [[ "$racer_match" == "MATCH" ]]; then - racer_line=$(echo "$racer_data" | cut -f3 ) - racer_column=$(echo "$racer_data" | cut -f4 ) - racer_file=$(echo "$racer_data" | cut -f5 ) + racer_line=$(printf %s\\n "$racer_data" | cut -f3 ) + racer_column=$(printf %s\\n "$racer_data" | cut -f4 ) + racer_file=$(printf %s\\n "$racer_data" | cut -f5 ) printf %s\\n "edit -existing '$racer_file' $racer_line $racer_column" printf %s\\n "set-option buffer readonly true" else @@ -128,15 +128,16 @@ define-command racer-show-doc -docstring "Show the documentation about the rust %sh{ dir=${kak_opt_racer_tmp_dir} ( - cursor="${kak_cursor_line} $((${kak_cursor_column} - 1))" + printf -v NEWLINE '\n' + cursor="${kak_cursor_line} ${kak_cursor_column}" racer_data=$(racer --interface tab-text complete-with-snippet ${cursor} ${kak_buffile} ${dir}/buf | head -n 2 | tail -n 1) - racer_match=$(echo "$racer_data" | cut -f1 ) - printf %s\\n "info '$racer_data'" + racer_match=$(printf %s\\n "$racer_data" | cut -f1) + printf %s\\n "info %@.$racer_match.@" if [[ "$racer_match" == "MATCH" ]]; then - racer_doc=$(echo "$racer_data" | cut -f9 | xargs ) - racer_doc=$(echo "${racer_doc//\\n/ -}") # This is a bit ugly and probably should be replaced with something better than a new line in the code itself, but I couldn't work how - printf %s\\n "info '$racer_doc'" + racer_doc=$(printf %s\\n "$racer_data" | cut -f9 | xargs ) + racer_doc=$(printf %s\\n "$racer_doc" | sed -e "s/\\\n/\\$NEWLINE/g") + racer_doc=$(printf %s\\n "$racer_doc" | sed -e "s/@/\\@/g") + printf %s\\n "info %@$racer_doc@" else printf %s\\n "echo -debug 'racer could not find a definition'" fi