Skip to content

Commit 238abfb

Browse files
authored
Merge pull request #93 from alanz/hie-wrapper
Use the exe hie-wrapper from haskell-ide-engine
2 parents c0b38a6 + d7d5478 commit 238abfb

File tree

4 files changed

+116
-71
lines changed

4 files changed

+116
-71
lines changed

hie-vscode.bat

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
set HIE_SERVER_PATH=
44
for /f "delims=" %%p in ('where hie') do set HIE_SERVER_PATH=%%p
55

6-
if [%HIE_SERVER_PATH%] == [] (
6+
set HIE_WRAPPER_PATH=
7+
for /f "delims=" %%p in ('where hie-wrapper') do set HIE_WRAPPER_PATH=%%p
8+
9+
rem Need to check that neither is found
10+
if [%HIE_WRAPPER_PATH%] == [] (
711
echo Content-Length: 100
812
echo:
913
echo {"jsonrpc":"2.0","id":1,"error":{"code":-32099,"message":"Cannot find hie.exe in the path"}}
1014
exit 1
1115
)
1216

13-
hie --lsp %1 %2 %3 %4 %5 %6 %7 %8 %9
17+
rem Need to run hie-wrapper if found, else hie
18+
hie-wrapper --lsp %1 %2 %3 %4 %5 %6 %7 %8 %9

hie-vscode.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/bin/sh
22

33
export HIE_SERVER_PATH=`which hie`
4+
export HIE_WRAPPER_PATH=`which hie-wrapper`
45

5-
if [ "X" = "X$HIE_SERVER_PATH" ]; then
6+
if [ "X" = "X$HIE_WRAPPER_PATH" ]; then
7+
hie-wrapper --lsp $@
8+
elif [ "X" = "X$HIE_SERVER_PATH" ]; then
69
echo "Content-Length: 100\r\n\r"
710
echo '{"jsonrpc":"2.0","id":1,"error":{"code":-32099,"message":"Cannot find hie.exe in the path"}}'
811
exit 1

hie-wrapper-old.sh

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/usr/bin/env bash
2+
DEBUG=1
3+
indent=""
4+
function debug {
5+
if [[ $DEBUG == 1 ]]; then
6+
echo "$indent$@" >> /tmp/hie-wrapper.log
7+
fi
8+
}
9+
10+
curDir=`pwd`
11+
debug "Launching HIE for project located at $curDir"
12+
indent=" "
13+
14+
GHCBIN='ghc'
15+
# If a .stack-work exists, assume we are using stack.
16+
if [ -d ".stack-work" ]; then
17+
debug "Using stack GHC version"
18+
GHCBIN='stack ghc --'
19+
else
20+
debug "Using plain GHC version"
21+
fi
22+
versionNumber=`$GHCBIN --version`
23+
debug $versionNumber
24+
25+
HIEBIN='hie'
26+
BACKUP_HIEBIN='hie'
27+
# Match the version number with a HIE version, and provide a fallback without
28+
# the patch number.
29+
30+
# GHC 8.0.*
31+
if [[ $versionNumber = *"8.0.1"* ]]; then
32+
debug "Project is using GHC 8.0.1"
33+
HIEBIN='hie-8.0.1'
34+
BACKUP_HIEBIN='hie-8.0'
35+
elif [[ $versionNumber = *"8.0.2"* ]]; then
36+
debug "Project is using GHC 8.0.2"
37+
HIEBIN='hie-8.0.2'
38+
BACKUP_HIEBIN='hie-8.0'
39+
elif [[ $versionNumber = *"8.0"* ]]; then
40+
debug "Project is using GHC 8.0.*"
41+
HIEBIN='hie-8.0'
42+
43+
# GHC 8.2.*
44+
elif [[ $versionNumber = *"8.2.1"* ]]; then
45+
debug "Project is using GHC 8.2.1"
46+
HIEBIN='hie-8.2.1'
47+
BACKUP_HIEBIN='hie-8.2'
48+
elif [[ $versionNumber = *"8.2.2"* ]]; then
49+
debug "Project is using GHC 8.2.2"
50+
HIEBIN='hie-8.2.2'
51+
BACKUP_HIEBIN='hie-8.2'
52+
elif [[ $versionNumber = *"8.2"* ]]; then
53+
debug "Project is using GHC 8.2.*"
54+
HIEBIN='hie-8.2'
55+
56+
# GHC 8.4.*
57+
elif [[ $versionNumber = *"8.4.3"* ]]; then
58+
debug "Project is using GHC 8.4.3"
59+
HIEBIN='hie-8.4.3'
60+
BACKUP_HIEBIN='hie-8.4'
61+
elif [[ $versionNumber = *"8.4.2"* ]]; then
62+
debug "Project is using GHC 8.4.2"
63+
HIEBIN='hie-8.4.2'
64+
BACKUP_HIEBIN='hie-8.4'
65+
elif [[ $versionNumber = *"8.4"* ]]; then
66+
debug "Project is using GHC 8.4.*"
67+
HIEBIN='hie-8.4'
68+
69+
else
70+
debug "WARNING: GHC version does not match any of the checked ones."
71+
fi
72+
73+
if [ -x "$(command -v $HIEBIN)" ]; then
74+
debug "$HIEBIN was found on path"
75+
elif [ -x "$(command -v $BACKUP_HIEBIN)" ]; then
76+
debug "Backup $BACKUP_HIEBIN was found on path"
77+
HIEBIN=$BACKUP_HIEBIN
78+
else
79+
debug "Falling back to plain hie"
80+
HIEBIN='hie'
81+
fi
82+
83+
debug "Starting HIE"
84+
85+
# Check that HIE is working
86+
export HIE_SERVER_PATH=`which $HIEBIN`
87+
88+
if [ "X" = "X$HIE_SERVER_PATH" ]; then
89+
echo "Content-Length: 100\r\n\r"
90+
echo '{"jsonrpc":"2.0","id":1,"error":{"code":-32099,"message":"Cannot find hie in the path"}}'
91+
exit 1
92+
fi
93+
94+
# Run directly
95+
$HIEBIN --lsp $@
96+
# $HIEBIN --lsp
97+
98+
# Run with a log
99+
# $HIEBIN --lsp -d -l /tmp/hie.log $@
100+
# $HIEBIN --lsp -d -l /tmp/hie.log --ekg $@
101+
# $HIEBIN --lsp -d -l /tmp/hie.log --vomit $@
102+
103+
# Run with a log and a direct dump of the server output
104+
# $HIEBIN --lsp -d -l /tmp/hie.log | tee /tmp/hie-wire.log

hie-wrapper.sh

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -11,75 +11,8 @@ curDir=`pwd`
1111
debug "Launching HIE for project located at $curDir"
1212
indent=" "
1313

14-
GHCBIN='ghc'
15-
# If a .stack-work exists, assume we are using stack.
16-
if [ -d ".stack-work" ]; then
17-
debug "Using stack GHC version"
18-
GHCBIN='stack ghc --'
19-
else
20-
debug "Using plain GHC version"
21-
fi
22-
versionNumber=`$GHCBIN --version`
23-
debug $versionNumber
24-
25-
HIEBIN='hie'
26-
BACKUP_HIEBIN='hie'
27-
# Match the version number with a HIE version, and provide a fallback without
28-
# the patch number.
29-
30-
# GHC 8.0.*
31-
if [[ $versionNumber = *"8.0.1"* ]]; then
32-
debug "Project is using GHC 8.0.1"
33-
HIEBIN='hie-8.0.1'
34-
BACKUP_HIEBIN='hie-8.0'
35-
elif [[ $versionNumber = *"8.0.2"* ]]; then
36-
debug "Project is using GHC 8.0.2"
37-
HIEBIN='hie-8.0.2'
38-
BACKUP_HIEBIN='hie-8.0'
39-
elif [[ $versionNumber = *"8.0"* ]]; then
40-
debug "Project is using GHC 8.0.*"
41-
HIEBIN='hie-8.0'
42-
43-
# GHC 8.2.*
44-
elif [[ $versionNumber = *"8.2.1"* ]]; then
45-
debug "Project is using GHC 8.2.1"
46-
HIEBIN='hie-8.2.1'
47-
BACKUP_HIEBIN='hie-8.2'
48-
elif [[ $versionNumber = *"8.2.2"* ]]; then
49-
debug "Project is using GHC 8.2.2"
50-
HIEBIN='hie-8.2.2'
51-
BACKUP_HIEBIN='hie-8.2'
52-
elif [[ $versionNumber = *"8.2"* ]]; then
53-
debug "Project is using GHC 8.2.*"
54-
HIEBIN='hie-8.2'
55-
56-
# GHC 8.4.*
57-
elif [[ $versionNumber = *"8.4.3"* ]]; then
58-
debug "Project is using GHC 8.4.3"
59-
HIEBIN='hie-8.4.3'
60-
BACKUP_HIEBIN='hie-8.4'
61-
elif [[ $versionNumber = *"8.4.2"* ]]; then
62-
debug "Project is using GHC 8.4.2"
63-
HIEBIN='hie-8.4.2'
64-
BACKUP_HIEBIN='hie-8.4'
65-
elif [[ $versionNumber = *"8.4"* ]]; then
66-
debug "Project is using GHC 8.4.*"
67-
HIEBIN='hie-8.4'
68-
69-
else
70-
debug "WARNING: GHC version does not match any of the checked ones."
71-
fi
72-
73-
if [ -x "$(command -v $HIEBIN)" ]; then
74-
debug "$HIEBIN was found on path"
75-
elif [ -x "$(command -v $BACKUP_HIEBIN)" ]; then
76-
debug "Backup $BACKUP_HIEBIN was found on path"
77-
HIEBIN=$BACKUP_HIEBIN
78-
else
79-
debug "Falling back to plain hie"
80-
HIEBIN='hie'
81-
fi
8214

15+
HIEBIN='hie-wrapper'
8316
debug "Starting HIE"
8417

8518
# Check that HIE is working

0 commit comments

Comments
 (0)