DEV Community

Jeremy
Jeremy

Posted on

1

How to configure neovim's Lua LS for Love2D

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.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (1)

Collapse
 
mikepurdy profile image
Mike Purdy •

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

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay