Clean racer support functions
This commit is contained in:
parent
2f41fdb683
commit
2bf8941d99
|
@ -102,20 +102,18 @@ define-command racer-go-definition -docstring "Jump to where the rust identifier
|
||||||
}
|
}
|
||||||
%sh{
|
%sh{
|
||||||
dir=${kak_opt_racer_tmp_dir}
|
dir=${kak_opt_racer_tmp_dir}
|
||||||
(
|
cursor="${kak_cursor_line} $((${kak_cursor_column} - 1))"
|
||||||
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_data=$(racer --interface tab-text find-definition ${cursor} ${kak_buffile} ${dir}/buf | head -n 1)
|
racer_match=$(printf %s\\n "$racer_data" | cut -f1 )
|
||||||
racer_match=$(printf %s\\n "$racer_data" | cut -f1 )
|
if [ "$racer_match" = "MATCH" ]; then
|
||||||
if [[ "$racer_match" == "MATCH" ]]; then
|
racer_line=$(printf %s\\n "$racer_data" | cut -f3 )
|
||||||
racer_line=$(printf %s\\n "$racer_data" | cut -f3 )
|
racer_column=$(printf %s\\n "$racer_data" | cut -f4 )
|
||||||
racer_column=$(printf %s\\n "$racer_data" | cut -f4 )
|
racer_file=$(printf %s\\n "$racer_data" | cut -f5 )
|
||||||
racer_file=$(printf %s\\n "$racer_data" | cut -f5 )
|
printf %s\\n "edit -existing '$racer_file' $racer_line $racer_column"
|
||||||
printf %s\\n "edit -existing '$racer_file' $racer_line $racer_column"
|
#printf %s\\n "set-option buffer readonly true"
|
||||||
printf %s\\n "set-option buffer readonly true"
|
else
|
||||||
else
|
printf %s\\n "echo -debug 'racer could not find a definition'"
|
||||||
printf %s\\n "echo -debug 'racer could not find a definition'"
|
fi
|
||||||
fi
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,20 +125,16 @@ define-command racer-show-doc -docstring "Show the documentation about the rust
|
||||||
}
|
}
|
||||||
%sh{
|
%sh{
|
||||||
dir=${kak_opt_racer_tmp_dir}
|
dir=${kak_opt_racer_tmp_dir}
|
||||||
(
|
cursor="${kak_cursor_line} ${kak_cursor_column}"
|
||||||
printf -v NEWLINE '\n'
|
racer_data=$(racer --interface tab-text complete-with-snippet ${cursor} "${kak_buffile}" "${dir}/buf" | head -n 2 | tail -n 1)
|
||||||
cursor="${kak_cursor_line} ${kak_cursor_column}"
|
racer_match=$(printf %s\\n "$racer_data" | cut -f1)
|
||||||
racer_data=$(racer --interface tab-text complete-with-snippet ${cursor} ${kak_buffile} ${dir}/buf | head -n 2 | tail -n 1)
|
if [ "$racer_match" = "MATCH" ]; then
|
||||||
racer_match=$(printf %s\\n "$racer_data" | cut -f1)
|
racer_doc=$(printf %s\\n "$racer_data" | cut -f9 )
|
||||||
printf %s\\n "info %@.$racer_match.@"
|
racer_doc=$(printf %s\\n "$racer_doc" | sed -e 's/^"\(.*\)"$/\1/g')
|
||||||
if [[ "$racer_match" == "MATCH" ]]; then
|
racer_doc=$(printf %s\\n "$racer_doc" | sed -e "s/@/\\\\@/g")
|
||||||
racer_doc=$(printf %s\\n "$racer_data" | cut -f9 | xargs )
|
printf "info %%@$racer_doc@"
|
||||||
racer_doc=$(printf %s\\n "$racer_doc" | sed -e "s/\\\n/\\$NEWLINE/g")
|
else
|
||||||
racer_doc=$(printf %s\\n "$racer_doc" | sed -e "s/@/\\@/g")
|
printf %s\\n "echo -debug 'racer could not find a definition'"
|
||||||
printf %s\\n "info %@$racer_doc@"
|
fi
|
||||||
else
|
|
||||||
printf %s\\n "echo -debug 'racer could not find a definition'"
|
|
||||||
fi
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user