1
1
#! /bin/sh
2
2
# Actual launcher. This does the hard work of figuring out the best way
3
3
# to launch the language server or the debugger.
4
- #
5
4
6
5
# Running this script is a one-time action per project launch, so we opt for
7
6
# code simplicity instead of performance. Hence some potentially redundant
11
10
12
11
did_relaunch=$1
13
12
13
+ case " ${did_relaunch} " in
14
+ " " )
15
+ # Get the user's preferred shell
16
+ preferred_shell=$( basename " $SHELL " )
17
+ if [ " $preferred_shell " = " bash" ]; then
18
+ >&2 echo " Preffered shell is bash, relaunching"
19
+ exec " $( which bash) " " $0 " relaunch
20
+ elif [ " $preferred_shell " = " zsh" ]; then
21
+ >&2 echo " Preffered shell is zsh, relaunching"
22
+ exec " $( which zsh) " " $0 " relaunch
23
+ else
24
+ >&2 echo " Preffered shell $preferred_shell is not supported, continuing in POSIX shell"
25
+ fi
26
+ ;;
27
+ * )
28
+ # We have an arg2, so we got relaunched
29
+ ;;
30
+ esac
31
+
14
32
ASDF_DIR=${ASDF_DIR:- " ${HOME} /.asdf" }
15
33
16
34
asdf_vm=" ${ASDF_DIR} /asdf.sh"
17
35
18
- >&2 echo " Looking for ASDF install in $asdf_vm "
19
-
36
+ >&2 echo " Looking for ASDF install"
20
37
if test -f " ${asdf_vm} "
21
38
then
22
- # asdf-vm does not support the plain posix shell. Figure out
23
- # which one we need and relaunch ourselves with that.
24
- case " ${did_relaunch} " in
25
- " " )
26
- if which bash > /dev/null
27
- then
28
- >&2 echo " ASDF found, relaunching in bash shell"
29
- exec " $( which bash) " " $0 " relaunch
30
- elif which zsh > /dev/null
31
- then
32
- >&2 echo " ASDF found, relaunching in zsh shell"
33
- exec " $( which zsh) " " $0 " relaunch
34
- else
35
- >&2 echo " ASDF found, but could not locate ASDF compatible shell"
36
- fi
37
- ;;
38
- * )
39
- # We have an arg2, so we got relaunched. Therefore, we're running in a
40
- # shell that supports asdf-vm.
41
- >&2 echo " Sourcing ASDF"
42
- . " ${asdf_vm} "
43
- ;;
44
- esac
39
+ >&2 echo " ASDF install found in $asdf_vm , sourcing"
40
+ # shellcheck disable=SC1090
41
+ . " ${asdf_vm} "
42
+ else
43
+ >&2 echo " ASDF not found"
44
+ >&2 echo " Looking for rtx executable"
45
+
46
+ if which rtx > /dev/null
47
+ then
48
+ >&2 echo " rtx executable found in $( which rtx) , activating"
49
+ preferred_shell=$( basename " $SHELL " )
50
+ eval " $( $( which rtx) activate " $preferred_shell " ) "
51
+ else
52
+ >&2 echo " rtx not found"
53
+ fi
45
54
fi
46
55
47
56
# In case that people want to tweak the path, which Elixir to use, or
@@ -53,6 +62,7 @@ els_setup="${XDG_CONFIG_HOME:-$HOME/.config}/elixir_ls/setup.sh"
53
62
if test -f " ${els_setup} "
54
63
then
55
64
>&2 echo " Running setup script $els_setup "
65
+ # shellcheck disable=SC1090
56
66
. " ${els_setup} "
57
67
fi
58
68
@@ -82,4 +92,5 @@ export MIX_ENV=prod
82
92
# we need to make sure it doesn't interfere with LSP/DAP
83
93
echo " " | elixir " $SCRIPTPATH /quiet_install.exs" > /dev/null || exit 1
84
94
95
+ # shellcheck disable=SC2086
85
96
exec elixir $ELS_ELIXIR_OPTS --erl " -kernel standard_io_encoding latin1 +sbwt none +sbwtdcpu none +sbwtdio none $ELS_ERL_OPTS " " $SCRIPTPATH /launch.exs"
0 commit comments