How to configure neovim's Lua LS for Love2D
Jeremy

Jeremy @je12emy

About: All around nerd

Location:
Costa Rica
Joined:
Jan 24, 2021

How to configure neovim's Lua LS for Love2D

Publish Date: Dec 24 '24
3 1

I've been trying out Love2D by recreating old retro games, I like how simple Love is, and I get to use neovim as my editor of choice. While browsing the Lua LS documentation, I noticed this on the "Add-ons" page.

Addons can be used to add additional content for the Lua Language Server by doing the following:

  • Providing definitions for a framework/library/API.

This had bothered me for a while, since using Love's API does not provide any sort of competition.

First, pick a directory to store all your add-ons. Mine will be ~/.local/share/LuaAddons.

mkdir ~/.local/share/LuaAddons
cd ~/.local/share/LuaAddons
Enter fullscreen mode Exit fullscreen mode

Here we will grab a copy of the Love2D add-on.

git clone https://github.com/LuaCATS/love2d.git
Enter fullscreen mode Exit fullscreen mode

Open your neovim configuration and edit Lua LS's set-up snippet.

lspconfig.lua_ls.setup {
    settings = {
        Lua = {
            workspace = {
                -- Path to your Addons directory
                userThirdParty = {os.getenv("HOME") .. ".local/share/LuaAddons"},
                checkThirdParty = "Apply"
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

This should be everything you need to get a nice competition menu when using love.

Editor screenshot

You can check the official documentation for reference.

Comments 1 total

  • Mike Purdy
    Mike PurdyDec 30, 2024

    Nice - thanks for taking the time to write this up, was helpful.

Add comment