Setup Neovim for Lua Development
Lua Development in Neovim
Even if you don't plan on doing any Lua development in Neovim it is probably a good idea to enable lua support.
One reason for this is that pretty much all of Neovim's future development/configuration will be done in lua.
This article will show you how to turn Neovim into a lua IDE.
Installation Instructions
-
Install
ninja
- Arch:
sudo pacman -S ninja
- Ubuntu:
sudo apt install ninja-build
- Mac:
brew install ninja
- Arch:
-
Clone Lua Language Server Repo
-
Build language Lua Server
-
Linux:
-
Mac:
-
Configure Language Server
Now create file to hold the config and source it somewhere:
Make sure that the root path and binary paths are pointing to the correct installation location or nothing will work
(Optional) Formatting and Auto-Format
The sumneko language server doesn't support format out of the box
We can install a formatter and use the efm-language-server
server to support it
The efm-language-server
is a general purpose language-server
Install Lua Formatter
First install LuaRocks
Then run:
Install efm-language-server
-
Linux (you will need to have go installed, also you will need to put the go/bin dir in your PATH)
-
Mac:
Configure Formatting
Now you can call: lua vim.lsp.buf.formatting()
And for auto-format add this to a .vim file and source it: