Skip to content

Commit f9ae150

Browse files
authored
Make launcher easier wrappable for different install locations (#467)
* add ELS_INSTALL_PREFIX to launch scripts * add ELS_INSTALL_PREFIX to debug scripts * add ELS_INSTALL_PREFIX to README * fix copy and paste error in debugger start script
1 parent b453e9a commit f9ae150

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ accomplished by adding `>/dev/null` and/or `2>/dev/null` at the end of any line
251251
output, and for a windows batch script you will want `@echo off` at the top and `>nul` on every
252252
line.
253253

254+
## Environment variables
255+
256+
* `ELS_INSTALL_PREFIX`: The folder where the language server got installed to. If set eq. through a wrapper script, it makes maintaining multiple versions/instances on the same host much easier. If not set or empty, a heuristic will be used to discover the install location.
257+
254258
## Acknowledgements and related projects
255259

256260
ElixirLS isn't the first frontend-independent server for Elixir language support. The original was [Alchemist Server](https://github.com/tonini/alchemist-server/), which powers the [Alchemist](https://github.com/tonini/alchemist.el) plugin for Emacs. Another project, [Elixir Sense](https://github.com/elixir-lsp/elixir_sense), builds upon Alchemist and powers the [Elixir plugin for Atom](https://github.com/msaraiva/atom-elixir) as well as another VS Code plugin, [VSCode Elixir](https://github.com/fr1zle/vscode-elixir). ElixirLS uses Elixir Sense for several code insight features. Credit for those projects goes to their respective authors.

apps/elixir_ls_utils/priv/debugger.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/bin/sh
22
# Launches the debugger. This script must be in the same directory as the compiled .ez archives.
33

4-
dir=$(dirname "$0")
4+
if [ -z "${ELS_INSTALL_PREFIX}" ]; then
5+
dir=$(dirname "$0")
6+
else
7+
dir=${ELS_INSTALL_PREFIX}
8+
fi
59

610
export ELS_MODE=debugger
711
export ELS_SCRIPT="ElixirLS.Debugger.CLI.main()"

apps/elixir_ls_utils/priv/language_server.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/bin/sh
22
# Launches the language server. This script must be in the same directory as the compiled .ez archives.
33

4-
dir=$(dirname "$0")
4+
if [ -z "${ELS_INSTALL_PREFIX}" ]; then
5+
dir=$(dirname "$0")
6+
else
7+
dir=${ELS_INSTALL_PREFIX}
8+
fi
59

610
export ELS_MODE=language_server
711
export ELS_SCRIPT="ElixirLS.LanguageServer.CLI.main()"

apps/elixir_ls_utils/priv/launch.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ readlink_f () {
6161
fi
6262
}
6363

64-
SCRIPT=$(readlink_f "$0")
65-
SCRIPTPATH=$(dirname "$SCRIPT")
64+
if [ -z "${ELS_INSTALL_PREFIX}" ]; then
65+
SCRIPT=$(readlink_f "$0")
66+
SCRIPTPATH=$(dirname "$SCRIPT")
67+
else
68+
SCRIPTPATH=${ELS_INSTALL_PREFIX}
69+
fi
70+
6671
export ERL_LIBS="$SCRIPTPATH:$ERL_LIBS"
6772

6873
exec elixir --erl "+sbwt none +sbwtdcpu none +sbwtdio none" -e "$ELS_SCRIPT"

0 commit comments

Comments
 (0)