Skip to main content
  1. Posts/

Setting up Sumneko Lua Language Server for Nvim-lsp

··360 words·2 mins·
Table of Contents

Update log
  • 2022-08-13: update nvim lsp config for lua-language-server.

In this post, I will share how to set up sumneko lua for nvim-lspconfig.

Install sumneko lua

Install using package manager

From macOS, we can install lua-language-server directly using HomeBrew:

brew install lua-language-server

Install using releases

Now lua-language-server provides binary release for Windows, macOS and Linux, download it from its release page.

Install from source

We can also build it from source. First, we need to install its dependency packages.


On Linux, install ninja from its binary release:


mkdir -p $HOME/local/bin
unzip -d $HOME/local/bin

On macOS, install ninja via homebrew:

brew install ninja

C++ compiler

We 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

cd lua-language-server
# if the cloning speed is too slow, edit .gitmodules and replace
# with, which should be faster than github.
git submodule update --init --recursive

# build on Linux
cd 3rd/luamake
cd ../..
./3rd/luamake/luamake rebuild

After 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"

Config for nvim-lspconfig

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")

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.



Pylsp setup for Neovim in 2023
··1020 words·5 mins
Setting up Neovim for C++ Development with LSP
··1254 words·6 mins
Set up Fuzzy Completion for Vim-lsp
··267 words·2 mins