gopls: Fix format/imports error reporting

Remove unnecessary single quotes and whitespaces in %file{}
Do not delete error file before sending to debug buffer
Fix gopls definition error handling and empty sting check
Silence shellcheck warnings
This commit is contained in:
VÖRÖSKŐI András 2020-10-16 22:40:58 +02:00
parent 1de058cdf8
commit cbbab07aab

View File

@ -55,22 +55,22 @@ define-command -hidden -params 1 gopls-cmd %{
gopls-prepare gopls-prepare
evaluate-commands %sh{ evaluate-commands %sh{
dir=${kak_opt_gopls_tmp_dir} dir=${kak_opt_gopls_tmp_dir}
gopls $1 -w ${kak_buffile} 2> "${dir}/stderr" gopls "$1" -w "${kak_buffile}" 2> "${dir}/stderr"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# show error messages in *debug* buffer # show error messages in *debug* buffer
printf %s\\n "echo -debug %file{ '${dir}/stderr' }" printf %s\\n "echo -debug %file{${dir}/stderr}"
fi fi
rm -r "${dir}"
} }
edit! edit!
evaluate-commands %sh{ rm -r "${kak_opt_gopls_tmp_dir}" }
} }
# gopls definition # gopls definition
define-command -hidden -params 0 gopls-def %{ define-command -hidden -params 0 gopls-def %{
evaluate-commands %sh{ evaluate-commands %sh{
jump=$( gopls definition ${kak_buffile}:${kak_cursor_line}:${kak_cursor_column} \ jump=$( gopls definition "${kak_buffile}:${kak_cursor_line}:${kak_cursor_column}" 2> /dev/null \
|sed -e 's/-.*//; s/:/ /g; q' 2> /dev/null ) |sed -e 's/-.*//; s/:/ /g; q' )
if [ "cat ${jump}" != "" ]; then if [ -n "${jump}" ]; then
printf %s\\n "evaluate-commands -try-client '${kak_opt_jumpclient}' %{ printf %s\\n "evaluate-commands -try-client '${kak_opt_jumpclient}' %{
edit ${jump} edit ${jump}
}" }"
@ -84,7 +84,7 @@ define-command -hidden -params 0 gopls-ref %{
evaluate-commands %sh{ evaluate-commands %sh{
dir=${kak_opt_gopls_tmp_dir} dir=${kak_opt_gopls_tmp_dir}
mkfifo "${dir}/fifo" mkfifo "${dir}/fifo"
( gopls references ${kak_buffile}:${kak_cursor_line}:${kak_cursor_column} \ ( gopls references "${kak_buffile}:${kak_cursor_line}:${kak_cursor_column}" \
> "${dir}/fifo" 2> /dev/null & ) > /dev/null 2>&1 < /dev/null > "${dir}/fifo" 2> /dev/null & ) > /dev/null 2>&1 < /dev/null
# using filetype=grep for nice hilight and <ret> mapping # using filetype=grep for nice hilight and <ret> mapping
printf %s\\n "evaluate-commands -try-client '${kak_opt_toolsclient}' %{ printf %s\\n "evaluate-commands -try-client '${kak_opt_toolsclient}' %{