Here is the configuration for some capabilities of Julia’s LanguageServer.jl and Neovim’s built-in Language Server Protocol (LSP) client, and some instructions to install this setup.
I’m hoping people can try it with neovim and report issues if they come across it. The more people that use this, the better this functionality will get.
.vimrc code corresponding to the capability is linked below the each screencapture.
Jump to definition
If you’d like to use this you will need the following:
- neovim v0.5.0
neovim/nvim-lsp repository contains language server configurations for a bunch of languages.
Once you have
neovim/nvim-lsp installed with your favorite plugin manager, you can run
That will download and install
SymbolServer.jl into your global environment.
You may also want
JuliaEditorSupport/julia-vim for syntax highlighting and other niceties.
At the moment you’ll have to make some changes to
julials file. The changes required are in this PR: https://github.com/neovim/nvim-lsp/pull/258.
And, at the moment neovim v0.5.0 isn’t released yet. You’ll have to get the latest commit on
master and build from source, or download a release from the
nightly tag on github.
This also means that the lsp client is not stable yet.
And there may be bugs.
One such bug that I ran into is that LanguageServer.jl does not support
textDocument/typeDeclaration, but the neovim LSP client still sends the request if the user makes that request call.
This causes LanguageServer.jl to crash, and this looks like a silent failure from the user perspective.
This is resolved in this PR: https://github.com/neovim/neovim/pull/12421.
You can make the same changes locally to your
Here is a minimal
.vimrc configuration that works with
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
lua << EOF
autocmd Filetype julia setlocal omnifunc=v:lua.vim.lsp.omnifunc
nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
Once you have this, you should be able to open a
.jl file and
LanguageServer.jl will start up!
It may take some time for
SymbolServer.jl to cache the symbols the first time you run it, so be prepared to wait for a while.
You can type
:lua print(vim.lsp.get_log_path())<CR> in neovim to get the path to the language server log file.
When you see
[ Info: Received new data from Julia Symbol Server. you should be good to go.
Originally posted over here: https://blog.kdheepak.com/neovim-languageserver-julia.html