Skip to content

Commit

Permalink
feat(julials): Better configurability for LanguageServer.jl install l…
Browse files Browse the repository at this point in the history
…ocation.
  • Loading branch information
fredrikekre committed Aug 17, 2021
1 parent acb4208 commit 4995d0b
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions lua/lspconfig/julials.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ local cmd = {
'--history-file=no',
'-e',
[[
using Pkg
Pkg.instantiate()
using LanguageServer
# Load LanguageServer.jl
if length(ARGS) > 0
# If there is an argument, use this as the load path for finding
# the installation of LanguageServer.jl
old_load_path = copy(LOAD_PATH)
push!(empty!(LOAD_PATH), expanduser(ARGS[1]))
using LanguageServer
append!(empty!(LOAD_PATH), old_load_path)
else
using LanguageServer
end
depot_path = get(ENV, "JULIA_DEPOT_PATH", "")
project_path = let
dirname(something(
Expand Down Expand Up @@ -38,9 +46,6 @@ local cmd = {
configs.julials = {
default_config = {
cmd = cmd,
on_new_config = function(new_config, root_dir)
new_config.cmd_cwd = root_dir
end,
filetypes = { 'julia' },
root_dir = function(fname)
return util.find_git_ancestor(fname) or util.path.dirname(fname)
Expand All @@ -51,13 +56,31 @@ configs.julials = {
description = [[
https://github.com/julia-vscode/julia-vscode
`LanguageServer.jl` can be installed with `julia` and `Pkg`:
LanguageServer.jl can be installed with `julia` and `Pkg`:
```sh
julia -e 'using Pkg; Pkg.add("LanguageServer")'
```
This installs LanguageServer.jl into your global julia environment where the default launch
command will look for the package.
It is possible to use a separate package environment for the LanguageServer.jl installation.
For example, to install in a folder `~/.local/share/nvim/lspconfig/julia-ls` use the following command:
```sh
julia -e 'using Pkg; Pkg.add("LanguageServer"); Pkg.add("SymbolServer")'
julia --project=~/.local/share/nvim/lspconfig/julia-ls -e 'using Pkg; Pkg.add("LanguageServer")'
```
and modify the language server launch command accordingly in your init file, e.g.
```lua
require'lspconfig'.julials.setup{
on_new_config = function(new_config, _)
-- Default cmd takes one optional argument, so push the custom LanguageServer.jl
-- install location to that table
table.insert(new_config.cmd, "~/.local/share/nvim/lspconfig/julia-ls")
end,
}
```
This installs LanguageServer.jl into your global julia environment.
In order to have LanguageServer.jl pick up installed packages or dependencies in a Julia project, you must first instantiate the project:
Note: In order to have LanguageServer.jl pick up installed packages or dependencies in a
Julia project, you must make sure that the project is instantiated:
```sh
julia --project=/path/to/my/project -e 'using Pkg; Pkg.instantiate()'
```
Expand Down

0 comments on commit 4995d0b

Please sign in to comment.