
In this post, I will share how to set up sumneko lua for nvim-lspconfig.
From macOS, we can install lua-language-server directly using HomeBrew:
brew install lua-language-serverNow lua-language-server provides binary release for Windows, macOS and Linux, download it from its release page.
We can also build it from source. First, we need to install its dependency packages.
On Linux, install ninja from its binary release:
wget https://hub.fastgit.xyz/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip
mkdir -p $HOME/local/bin
unzip ninja-linux.zip -d $HOME/local/binOn macOS, install ninja via homebrew:
brew install ninjaWe need to install a cpp compile that support c++ 17, gcc-7.3 is fine. Clang 12.0 is also fine.
Build lua-language-server:
mkdir -p $HOME/tools/ && cd $HOME/tools
git clone --depth=1 https://hub.fastgit.xyz/sumneko/lua-language-server
cd lua-language-server
# if the cloning speed is too slow, edit .gitmodules and replace github.com
# with hub.fastgit.org, which should be faster than github.
git submodule update --init --recursive
# build on Linux
cd 3rd/luamake
compile/install.sh
cd ../..
./3rd/luamake/luamake rebuildAfter that, we should add the path to lua-language-server to PATH:
# For macOS
export PATH="$HOME/tools/lua-language-server/bin/macOS:$PATH"
# For Linux
export PATH="$HOME/tools/lua-language-server/bin/Linux:$PATH"Following the instructions on the nvim-lspconfig repo, it is pretty straight forward to config sumneko-lua for Nvim. Here is a working config for me:
local runtime_path = vim.split(package.path, ";")
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
lspconfig.sumneko_lua.setup({
on_attach = custom_attach,
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
-- Setup your lua path
path = runtime_path,
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
})For the complete config for lsp, check my config here.

In this post, I will share how to set up sumneko lua for nvim-lspconfig.
From macOS, we can install lua-language-server directly using HomeBrew:
brew install lua-language-serverNow lua-language-server provides binary release for Windows, macOS and Linux, download it from its release page.
We can also build it from source. First, we need to install its dependency packages.
On Linux, install ninja from its binary release:
wget https://hub.fastgit.xyz/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip
mkdir -p $HOME/local/bin
unzip ninja-linux.zip -d $HOME/local/binOn macOS, install ninja via homebrew:
brew install ninjaWe need to install a cpp compile that support c++ 17, gcc-7.3 is fine. Clang 12.0 is also fine.
Build lua-language-server:
mkdir -p $HOME/tools/ && cd $HOME/tools
git clone --depth=1 https://hub.fastgit.xyz/sumneko/lua-language-server
cd lua-language-server
# if the cloning speed is too slow, edit .gitmodules and replace github.com
# with hub.fastgit.org, which should be faster than github.
git submodule update --init --recursive
# build on Linux
cd 3rd/luamake
compile/install.sh
cd ../..
./3rd/luamake/luamake rebuildAfter that, we should add the path to lua-language-server to PATH:
# For macOS
export PATH="$HOME/tools/lua-language-server/bin/macOS:$PATH"
# For Linux
export PATH="$HOME/tools/lua-language-server/bin/Linux:$PATH"Following the instructions on the nvim-lspconfig repo, it is pretty straight forward to config sumneko-lua for Nvim. Here is a working config for me:
local runtime_path = vim.split(package.path, ";")
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
lspconfig.sumneko_lua.setup({
on_attach = custom_attach,
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
-- Setup your lua path
path = runtime_path,
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
})For the complete config for lsp, check my config here.