Neovim + LanguageServer.jl

kdheepak
Thu, 09 Apr 2020 16:13:25 +0000
Tooling

neovim has built in lsp support and can be integrated with any language server. I thought I’d describe the set up for using LanguageServer.jl and neovim.

You need to use the latest version of neovim at the moment. I’m using the HEAD, the version information is below.

$ nvim --version
NVIM v0.5.0-nightly-71-g1f56f9a4b
Build type: Release
LuaJIT 2.0.5

Use your favorite plugin manager to add the following package neovim/nvim-lsp to your vimrc. I am using vim-plug.

Plug 'neovim/nvim-lsp'  | " collection of common configurations for the Nvim LSP client.

Also add the following lines anywhere in your vimrc below the plugin section.

lua << EOF
    require'nvim_lsp'.julials.setup{}
EOF

And you can configure maps to run vim.lsp.{functions}:

nnoremap <silent> <leader>ld    <cmd>lua vim.lsp.buf.declaration()<CR>
nnoremap <silent> <leader>lh    <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> <leader>ld    <cmd>lua vim.lsp.util.show_line_diagnostics()<CR>
nnoremap <silent> <leader>lk    <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> <leader>lr    <cmd>lua vim.lsp.buf.references()<CR>

You can run :LspInstall julials in neovim to install LanguageServer.jl. Or you can do so manually in your global environment.

And that’s it!

I’ve posted my configuration here if anyone wants to take a look at the full file for how this is set up:

github.com

kdheepak/dotfiles/blob/40d2ab63ed2eca62e4e8e4e5cb44942641c19430/.vimrc#L537-L548

537. lua << EOF


538.     require'nvim_lsp'.nimls.setup{}


539.     require'nvim_lsp'.julials.setup{}


540.     require'nvim_lsp'.pyls.setup{}


541.     require'nvim_lsp'.vimls.setup{}


542. EOF





544. nnoremap <silent> <leader>ld    <cmd>lua vim.lsp.buf.declaration()<CR>


545. nnoremap <silent> <leader>lh    <cmd>lua vim.lsp.buf.hover()<CR>


546. nnoremap <silent> <leader>ld    <cmd>lua vim.lsp.util.show_line_diagnostics()<CR>


547. nnoremap <silent> <leader>lk    <cmd>lua vim.lsp.buf.signature_help()<CR>


548. nnoremap <silent> <leader>lr    <cmd>lua vim.lsp.buf.references()<CR>

101 posts - 29 participants