Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/language_server/lib/language_server/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,9 @@ defmodule ElixirLS.LanguageServer.Server do
mix_target = Map.get(settings, "mixTarget")
project_dir = Map.get(settings, "projectDir")
additional_watched_extensions = Map.get(settings, "additionalWatchedExtensions", [])
stdlib_src_dir = to_string(Map.get(settings, "stdlibSrcDir", ""))

stdlib_src_dir =
to_string(Map.get(settings, "stdlibSrcDir", System.get_env("ELX_STDLIB_PATH", "")))

if stdlib_src_dir != "" do
Application.put_env(:language_server, :elixir_src, stdlib_src_dir)
Expand Down
35 changes: 25 additions & 10 deletions scripts/launch.fish
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@

# First order of business, see whether we can setup asdf

function readlink_f
cd (dirname $argv[1]) || exit 1
set filename (basename $argv[1])
if test -L $filename
readlink_f (readlink $filename)
else
echo (pwd -P)"/$filename"
end
end

function export_stdlib_path
set -l current_dir (pwd)

set -l which_elixir_expr $argv[1]
set -gx ELX_STDLIB_PATH (readlink_f (eval $which_elixir_expr) | string replace -r '(.*)\/bin\/elixir' '$1')
# readlink_f changes the current directory (since fish doesn't have
# subshells), so it needs to be restored.
cd $current_dir
end

echo "Looking for asdf install" >&2

# Check if we have the asdf binary for version >= 0.16.0
Expand All @@ -25,6 +45,7 @@ if test -n "$asdf"
else
echo "asdf executable found at $asdf. Using ASDF_DIR=$ASDF_DIR, ASDF_DATA_DIR=$ASDF_DATA_DIR." >&2
end
export_stdlib_path "asdf which elixir"
else
# Fallback to old method for asdf version <= 0.15.x
test -n "$ASDF_DIR"; or set ASDF_DIR "$HOME/.asdf"
Expand All @@ -33,6 +54,7 @@ else
echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing" >&2
# Source the old asdf.sh script for versions <= 0.15.0
source "$ASDF_SH"
export_stdlib_path "asdf which elixir"
else
echo "asdf not found" >&2
echo "Looking for mise executable" >&2
Expand All @@ -41,6 +63,7 @@ else
if test -n "$mise"
echo "mise executable found at $mise, activating" >&2
source ( "$mise" env -s fish )
export_stdlib_path "mise which elixir"
else
echo "mise not found" >&2
echo "Looking for rtx executable" >&2
Expand All @@ -49,6 +72,7 @@ else
if test -n "$rtx"
echo "rtx executable found at $rtx, activating" >&2
source ( "$rtx" env -s fish )
export_stdlib_path "rtx which elixir"
else
echo "rtx not found" >&2
echo "Looking for vfox executable" >&2
Expand All @@ -59,6 +83,7 @@ else
source ( "$vfox" activate fish )
else
echo "vfox not found" >&2
export_stdlib_path "which elixir"
end
end
end
Expand All @@ -84,16 +109,6 @@ end
# script so we can correctly configure the Erlang library path to
# include the local .ez files, and then do what we were asked to do.

function readlink_f
cd (dirname $argv[1]) || exit 1
set filename (basename $argv[1])
if test -L $filename
readlink_f (readlink $filename)
else
echo (pwd -P)"/$filename"
end
end

if test -z "$ELS_INSTALL_PREFIX"
set -l current_dir (pwd)
set scriptpath (dirname (readlink_f (status -f)))
Expand Down
33 changes: 23 additions & 10 deletions scripts/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ esac
# First order of business, see whether we can setup asdf
echo "Looking for asdf install" >&2

readlink_f () {
cd "$(dirname "$1")" > /dev/null || exit 1
filename="$(basename "$1")"
if [ -h "$filename" ]; then
readlink_f "$(readlink "$filename")"
else
echo "$(pwd -P)/$filename"
fi
}

export_stdlib_path () {
which_elixir_expr=$1
stdlib_path=$(eval "$which_elixir_expr")
stdlib_real_path=$(readlink_f "$stdlib_path")
ELX_STDLIB_PATH=$(echo "$stdlib_real_path" | sed "s/\(.*\)\/bin\/elixir/\1/")
export ELX_STDLIB_PATH
}

# Check if we have the asdf binary for version >= 0.16.0
if command -v asdf >/dev/null 2>&1; then
asdf_version=$(asdf --version 2>/dev/null)
Expand All @@ -58,6 +76,7 @@ if command -v asdf >/dev/null 2>&1; then
else
>&2 echo "asdf executable found at $(command -v asdf). Using ASDF_DIR=${ASDF_DIR}, ASDF_DATA_DIR=${ASDF_DATA_DIR}."
fi
export_stdlib_path "asdf which elixir"
else
# Fallback to old method for version <= 0.15.x
ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"}
Expand All @@ -66,6 +85,7 @@ else
>&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing"
# Source the old asdf.sh script for versions <= 0.15.0
. "$ASDF_SH"
export_stdlib_path "asdf which elixir"
else
>&2 echo "asdf not found"
>&2 echo "Looking for mise executable"
Expand All @@ -74,6 +94,7 @@ else
if command -v mise >/dev/null 2>&1; then
>&2 echo "mise executable found at $(command -v mise), activating"
eval "$($(command -v mise) env -s "$preferred_shell")"
export_stdlib_path "mise which elixir"
else
>&2 echo "mise not found"
>&2 echo "Looking for rtx executable"
Expand All @@ -82,6 +103,7 @@ else
if command -v rtx >/dev/null 2>&1; then
>&2 echo "rtx executable found at $(command -v rtx), activating"
eval "$($(command -v rtx) env -s "$preferred_shell")"
export_stdlib_path "rtx which elixir"
else
>&2 echo "rtx not found"
>&2 echo "Looking for vfox executable"
Expand All @@ -92,6 +114,7 @@ else
eval "$($(command -v vfox) activate "$preferred_shell")"
else
>&2 echo "vfox not found"
export_stdlib_path "which elixir"
fi
fi
fi
Expand All @@ -115,16 +138,6 @@ fi
# script so we can correctly configure the Erlang library path to
# include the local .ez files, and then do what we were asked to do.

readlink_f () {
cd "$(dirname "$1")" > /dev/null || exit 1
filename="$(basename "$1")"
if [ -h "$filename" ]; then
readlink_f "$(readlink "$filename")"
else
echo "$(pwd -P)/$filename"
fi
}

if [ -z "${ELS_INSTALL_PREFIX}" ]; then
SCRIPT=$(readlink_f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
Expand Down
Loading