Today we are going to start a series on how to install Language Server Protocol (LSP) for different programming languages on Neovim.
This article assumes you already know:
In this first article of the series we will configure the LSP for Lua .
Lua uses the LSP that is in the repository https://github.com/sumneko/lua-language-server, the same one used in VS Code .
For this article we are going to use Ubuntu 22.04 , if it is in a different version or different operating system or even in another distribution, just use search
from your package manager.
First of all, make sure you have the following packages/software installed on your system:
Example:
In this case I will store it in
${HOME}/.config/lsp
, change the path if you are more interested
Create the directory and enter it
lua-language-server
binaryWith the following commands in order:
$PATH
Neovim already has several LSPs built in, what is missing is for it to find the path to the binary in its $PATH
.
To do this, run the commands below:
If you used a path other than
~/.config/lsp
, change it accordingly.
Add LSP support for Lua as per the configuration style you chose. In this case, as an example, let’s use init.lua
.
vim ~/.config/nvim/init.lua
And add the code below
If everything is ok, you will have: function details, error and warning information, autocomplete according to tables and so on. Examples: