Hi all, right now I succeed to use LanguageServer.jl on vim 8.1 with vim-lsp plugin; I will describe what I did below. I would be happy if it was helpful for others. Many thanks for the maintainers of LanguageServer.jl, this is definitely a great work.
Julia side
I could not get it work with v1.1.0, probably we need v1.0.3 currently. It may be solved for the future version.
- Install julia v1.0.3
- Open julia v1.0.3 and type
]add LanguageServer SymbolServer
- Save the
startlanguageserver.jl
(see below) as a file in your computer
- startlanguageserver.jl
import LanguageServer
import Pkg
import SymbolServer
envpath = dirname(Pkg.Types.Context().env.project_file)
const DEPOT_DIR_NAME = ".julia"
depotpath = if Sys.iswindows()
joinpath(ENV["USERPROFILE"], DEPOT_DIR_NAME)
else
joinpath(ENV["HOME"], DEPOT_DIR_NAME)
end
server = LanguageServer.LanguageServerInstance(stdin, stdout, false, envpath, depotpath, Dict())
server.runlinter = true
run(server)
Vim side
Install vim-lsp
and its requirements.
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Cited from the README of vim-lsp
, please use your favorite plugin manager. If you want autocompletion, add some requirements.
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Write the lines below into your vimrc. You need to arrange the path to the executable and the script; s:julia_exe
and s:julia_lsp_startscript
.
- vimrc
let s:julia_exe = 'path/to/julia-1.0.3-executable'
let s:julia_lsp_startscript = 'path/to/startlanguageserver.jl'
if executable('julia')
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'julia',
\ 'cmd': {server_info->[s:julia_exe, '--startup-file=no', '--history-file=no', s:julia_lsp_startscript]},
\ 'whitelist': ['julia'],
\ })
endif
FYI, I’m using windows 10 and vim 8.1.878.