-
Notifications
You must be signed in to change notification settings - Fork 82
Vim and Neovim
Vim and Neovim are able to use the Julia LanguageServer via LanguageClient-neovim with completion from nvim-completion-manager.
The following is a basic minimal config (vimrc
for Vim; init.vim
for Neovim) using
vim-plug:
call g:plug#begin()
Plug 'JuliaEditorSupport/julia-vim'
Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'}
Plug 'roxma/nvim-completion-manager' " optional
call g:plug#end()
" julia
let g:default_julia_version = '1.0'
" language server
let g:LanguageClient_autoStart = 1
let g:LanguageClient_serverCommands = {
\ 'julia': ['julia', '--startup-file=no', '--history-file=no', '-e', '
\ using LanguageServer;
\ using Pkg;
\ import StaticLint;
\ import SymbolServer;
\ env_path = dirname(Pkg.Types.Context().env.project_file);
\ debug = false;
\
\ server = LanguageServer.LanguageServerInstance(stdin, stdout, debug, env_path, "");
\ server.runlinter = true;
\ run(server);
\ ']
\ }
nnoremap <silent> K :call LanguageClient_textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient_textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient_textDocument_rename()<CR>
Note:
-
The
LanguageServer
,SymbolServer
andStaticLint
packages must be installed in Julia (1.x), i.e.julia> using Pkg julia> Pkg.add("LanguageServer") julia> Pkg.add("SymbolServer") julia> Pkg.add("StaticLint")
-
If Julia (0.6 or greater) is not present in the
PATH
environment, either add the julia binary folder toPATH
or directly reference thejulia
binary ing:LanguageClient_serverCommands
, e.g. for macOS:let g:LanguageClient_serverCommands = { \ 'julia': ['/Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia', ...
-
See vim-plug for more details on installing/managing packages in Vim/Neovim
SpaceVim have a layer to use LanguageServer.jl, the setup is automatic once you installed the Julia layer.
Check out this thread on discourse: https://discourse.julialang.org/t/neovim-languageserver-jl/37286/7?u=kdheepak OR this blog post. This provides examples of using neovim's built in language server protocol and using deoplete with deoplete-lsp.
You can also see examples of using neovim, nvim-lsp, completion-nvim and diagnostic-nvim here:
https://github.com/kdheepak/dotfiles/blob/47a38e20ef4bef7a189927646eee3c91f911ffd7/vimrc
Plug 'nvim-lua/diagnostic-nvim' | " better neovim built in lsp diagnostics
Plug 'nvim-lua/completion-nvim' | " better neovim built in lsp completion
...
autocmd BufEnter * lua require'completion'.on_attach()
lua << EOF
local nvim_lsp = require'nvim_lsp'
local on_attach_vim = function()
require'diagnostic'.on_attach()
end
nvim_lsp.julials.setup({on_attach=on_attach_vim})
EOF
let g:diagnostic_auto_popup_while_jump = 0
let g:diagnostic_enable_virtual_text = 0
let g:diagnostic_enable_underline = 0
let g:completion_timer_cycle = 200 "default value is 80