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'"