Install Lua LSP for Neovim

Assuming you're here because you want LSP(Language Server Protocol) for your neovim setup, but your Linux distro doesn't provide the latest version of lua-language-server, so in this article we'll install lua-language-server from source.

Dependencies installation

Make sure that you have, Ninja Build, GCC(some distros need G++ as well), and Clang.

To install the dependencies on Gentoo run:

sudo emerge -qav sys-devel/gcc sys-devel/clang dev-util/ninja 

Compiling LSP's source code

Cloning the repo:
  • Clone LSP's repo into a directory where you keep bins and stuff
  • I use ~/.local/bin so I'll just clone it there
  • git clone ~/.local/bin/lua-language-server
  • cd ~/.local/bin/lua-language-server
Compile the stuff:
  • Download the sub-modules of the cloned repo
  • git submodule update --recursive
  • Download the ninja luamake rules
  • cd 3rd/luamake
  • git submodule update --init
  • Run the compile script
  • compile/
  • cd ../../
  • ./3rd/luamake/luamake rebuild
Add the the executables' path to your path
SHELL_NAME=`basename $SHELL`
echo 'export PATH="${HOME}/.local/bin/lua-language-server/bin:${PATH}"' >> $SHELL_RC

Now re-login or run

source $SHELL_RC
Require the new installed lsp server

Add this line to ~/.config/nvim/init.lua or to where you put lsp's config in Neovim

require('lspconfig').sumneko_lua.setup {}

Restart Neovim and your good to go.