From ee7cab82b47a9c67cd06ec41bb9f6bc34b77a1be Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 16 Mar 2018 12:25:17 +0000 Subject: [PATCH 1/3] Make racer support scripts more POSIX compliant --- rc/extra/racer.kak | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/rc/extra/racer.kak b/rc/extra/racer.kak index 6e2b07b5..cf0359ef 100644 --- a/rc/extra/racer.kak +++ b/rc/extra/racer.kak @@ -111,13 +111,12 @@ define-command racer-go-definition -docstring "Jump to where the rust identifier 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" - if [[ "$racer_file" == ${RUST_SRC_PATH}* ]]; then - printf %s\\n "set-option buffer readonly true" # The definition resides on the standard library, and the new buffer should be readonly - else - if [[ "$racer_file" == ${HOME}/.cargo/registry/src* ]]; then - printf %s\\n "set-option buffer readonly true" # The definition resides on an external crate, and the new buffer should be readonly - fi - fi + case ${racer_file} in + "${RUST_SRC_PATH}"*) + printf %s\\n "set-option buffer readonly true";; # The definition resides on the standard library, and the new buffer should be readonly + "${HOME}/.cargo/registry/src/"*) + printf %s\\n "set-option buffer readonly true";; # The definition resides on an external crate, and the new buffer should be readonly + esac else printf %s\\n "echo -debug 'racer could not find a definition'" fi @@ -137,9 +136,11 @@ define-command racer-show-doc -docstring "Show the documentation about the rust racer_match=$(printf %s\\n "$racer_data" | cut -f1) if [ "$racer_match" = "MATCH" ]; then racer_doc=$(printf %s\\n "$racer_data" | cut -f9 ) + remove_surrond_quotes_regex='s/^"\(.*\)"$/\1/g' + escape_at_sign_regex="s/@/\\\\@/g" racer_doc=$(printf %s\\n "$racer_doc" | - sed -e 's/^"\(.*\)"$/\1/g' | # Remove leading and trailing quotes - sed -e "s/@/\\\\@/g") # Escape all @ so that it can be properly used in the string expansion + sed -e "$remove_surrond_quotes_regex" \ + -e "$escape_at_sign_regex") printf "info %%@$racer_doc@" else printf %s\\n "echo -debug 'racer could not find a definition'" From 484164580eb5700e44e1882c9eaf674e94725712 Mon Sep 17 00:00:00 2001 From: Marc Date: Sat, 17 Mar 2018 20:27:11 +0000 Subject: [PATCH 2/3] CARGO_HOME to identify racer dependencies --- rc/extra/racer.kak | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/rc/extra/racer.kak b/rc/extra/racer.kak index cf0359ef..3149892e 100644 --- a/rc/extra/racer.kak +++ b/rc/extra/racer.kak @@ -112,10 +112,8 @@ define-command racer-go-definition -docstring "Jump to where the rust identifier racer_file=$(printf %s\\n "$racer_data" | cut -f5 ) printf %s\\n "edit -existing '$racer_file' $racer_line $racer_column" case ${racer_file} in - "${RUST_SRC_PATH}"*) - printf %s\\n "set-option buffer readonly true";; # The definition resides on the standard library, and the new buffer should be readonly - "${HOME}/.cargo/registry/src/"*) - printf %s\\n "set-option buffer readonly true";; # The definition resides on an external crate, and the new buffer should be readonly + "${RUST_SRC_PATH}"* | "${CARGO_HOME:-$HOME/.cargo}"/registry/src/*) + printf %s\\n "set-option buffer readonly true";; esac else printf %s\\n "echo -debug 'racer could not find a definition'" @@ -139,8 +137,15 @@ define-command racer-show-doc -docstring "Show the documentation about the rust remove_surrond_quotes_regex='s/^"\(.*\)"$/\1/g' escape_at_sign_regex="s/@/\\\\@/g" racer_doc=$(printf %s\\n "$racer_doc" | - sed -e "$remove_surrond_quotes_regex" \ - -e "$escape_at_sign_regex") + sed -e ' + + # Remove leading and trailing quotes + s/^"\(.*\)"$/\1/g + + # Escape all @ so that it can be properly used in the string expansion + s/@/\\@/g + + ') printf "info %%@$racer_doc@" else printf %s\\n "echo -debug 'racer could not find a definition'" From b3cc80126ad5ab6728dd90949a573f2052d5ad3c Mon Sep 17 00:00:00 2001 From: Marc Date: Sun, 18 Mar 2018 10:46:46 +0000 Subject: [PATCH 3/3] Remove unused var in racer support --- rc/extra/racer.kak | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rc/extra/racer.kak b/rc/extra/racer.kak index 3149892e..e7f67779 100644 --- a/rc/extra/racer.kak +++ b/rc/extra/racer.kak @@ -133,10 +133,9 @@ define-command racer-show-doc -docstring "Show the documentation about the rust racer_data=$(racer --interface tab-text complete-with-snippet ${cursor} "${kak_buffile}" "${dir}/buf" | sed -n 2p ) racer_match=$(printf %s\\n "$racer_data" | cut -f1) if [ "$racer_match" = "MATCH" ]; then - racer_doc=$(printf %s\\n "$racer_data" | cut -f9 ) - remove_surrond_quotes_regex='s/^"\(.*\)"$/\1/g' - escape_at_sign_regex="s/@/\\\\@/g" - racer_doc=$(printf %s\\n "$racer_doc" | + racer_doc=$( + printf %s\\n "$racer_data" | + cut -f9 | sed -e ' # Remove leading and trailing quotes