11#! /bin/sh
22# Actual launcher. This does the hard work of figuring out the best way
33# to launch the language server or the debugger.
4- #
54
65# Running this script is a one-time action per project launch, so we opt for
76# code simplicity instead of performance. Hence some potentially redundant
1110
1211did_relaunch=$1
1312
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+
1432ASDF_DIR=${ASDF_DIR:- " ${HOME} /.asdf" }
1533
1634asdf_vm=" ${ASDF_DIR} /asdf.sh"
1735
18- >&2 echo " Looking for ASDF install in $asdf_vm "
19-
36+ >&2 echo " Looking for ASDF install"
2037if test -f " ${asdf_vm} "
2138then
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
4554fi
4655
4756# 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"
5362if test -f " ${els_setup} "
5463then
5564 >&2 echo " Running setup script $els_setup "
65+ # shellcheck disable=SC1090
5666 . " ${els_setup} "
5767fi
5868
@@ -82,4 +92,5 @@ export MIX_ENV=prod
8292# we need to make sure it doesn't interfere with LSP/DAP
8393echo " " | elixir " $SCRIPTPATH /quiet_install.exs" > /dev/null || exit 1
8494
95+ # shellcheck disable=SC2086
8596exec 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