@@ -23,10 +23,14 @@ instruction_msg() {
23
23
(>&2 printf " \\ 033[0;35m%s\\ 033[0m\\ n" " $1 " )
24
24
}
25
25
26
- err_fix () {
27
- instruction_msg " "
28
- instruction_msg " Consider installing ghc-${GHC_VERSION} via ghcup"
29
- instruction_msg " or build HLS from source."
26
+ err_exit () {
27
+ msg=" Couldn't find a working/matching GHC installation. Consider installing ghc-${GHC_VERSION} via ghcup or build HLS from source."
28
+ # adjust Content-Length when changing json
29
+ json=" {\" jsonrpc\" :\" 2.0\" , \" method\" :\" window/showMessage\" , \" params\" : {\" type\" : 1, \" message\" : \" ${msg} \" }}"
30
+ printf " %s\r\n" " Content-Length: 203"
31
+ printf " %s\r\n"
32
+ printf " %s" " ${json} "
33
+ unset msg json
30
34
}
31
35
32
36
err_ghc_pkg () {
@@ -105,13 +109,13 @@ infer_ghc_pkg() {
105
109
# try GHC_LIBDIR from the environment (e.g. user set it, or haskell-language-server-wrapper)
106
110
if [ -n " ${GHC_LIBDIR} " ] &&
107
111
[ -n " ${GHC_BIN} " ] &&
108
- { debug_msg " Trying method: GHC_LIBDIR and GHC_BIN from env" ; HLS_WRAPPER_VERBOSE=1 ; check_ghc " ${GHC_LIBDIR} " " ${GHC_BIN} " " $( infer_ghc_pkg " ${GHC_BIN} " ) " || { err_fix ; exit 1 ; } ; }
112
+ { debug_msg " Trying method: GHC_LIBDIR and GHC_BIN from env" ; HLS_WRAPPER_VERBOSE=1 ; check_ghc " ${GHC_LIBDIR} " " ${GHC_BIN} " " $( infer_ghc_pkg " ${GHC_BIN} " ) " || { err_exit ; exit 1 ; } ; }
109
113
then
110
114
:
111
115
# try GHC_BIN from the environment (e.g. user set it)
112
116
elif [ -n " ${GHC_BIN} " ] &&
113
117
GHC_LIBDIR=" $( " ${GHC_BIN} " --print-libdir) " &&
114
- { debug_msg " Trying method: GHC_BIN from env" ; HLS_WRAPPER_VERBOSE=1 ; check_ghc " ${GHC_LIBDIR} " " ${GHC_BIN} " " $( infer_ghc_pkg " ${GHC_BIN} " ) " || { err_fix ; exit 2 ; } ; }
118
+ { debug_msg " Trying method: GHC_BIN from env" ; HLS_WRAPPER_VERBOSE=1 ; check_ghc " ${GHC_LIBDIR} " " ${GHC_BIN} " " $( infer_ghc_pkg " ${GHC_BIN} " ) " || { err_exit ; exit 2 ; } ; }
115
119
then
116
120
:
117
121
# try ghcup
143
147
else
144
148
HLS_WRAPPER_VERBOSE=1
145
149
err_msg " All methods exhausted!"
146
- err_msg " Couldn't find a working/matching GHC installation"
147
- err_fix
150
+ err_exit
148
151
err_msg " exiting..."
149
152
exit 42
150
153
fi
0 commit comments