Autocomplete/Intellisense for VSCode and Neovim

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
bjerb
Prole
Posts: 1
Joined: Tue Jun 11, 2024 1:32 am

Autocomplete/Intellisense for VSCode and Neovim

Post by bjerb »

I spent a good while trying to get autocomplete to work correctly with the Love2d API. I typically use Neovim for editing for my day job, and I have Mason doing the automatic installation of language servers, so the typical language server setup was no big deal. However, I'm new to Lua, so I didn't know how to deal with that pesky "Undefined global `love`" error. Most suggestions seemed to say that you should simply put "love" in your language server's globals config. But that quite frankly sucks because you don't get any autocomplete of API methods or types.

After a couple of hours of googling and sadness I finally found a configuration that works with the lua language server, the most popular one by sumneko. Here's the config I landed on for Neovim that actually gives autocomplete for the love2d API:

Code: Select all

        Lua = {
            workspace = {
                library = {
                    "${3rd}/love2d/library",
                },
            },
        }
Additionally, for any folks out there that are using VSCode, here's the simplest settings snippet that got intellisense/autocomplete to work for me:

Code: Select all

{
    "Lua.runtime.version": "LuaJIT",
    "Lua.workspace.library": [
        "${3rd}/love2d/library"
    ]
}
You also need to install the lua language server extension, it's just titled "Lua" by sumneko.

Hope that helps someone else out there.
el_mariachi
Prole
Posts: 1
Joined: Thu Jul 04, 2024 9:09 am

Re: Autocomplete/Intellisense for VSCode and Neovim

Post by el_mariachi »

Hey I just registered to let you know you helped me a lot with this post! I was in the same situation as you, I wasted a lot of time trying making love autocomplete on VSCode, so many thanks!
Planetary
Prole
Posts: 1
Joined: Wed Dec 18, 2024 4:18 pm

Re: Autocomplete/Intellisense for VSCode and Neovim

Post by Planetary »

This solved my issue! Yay.

Putting the VS Code snippet into .vscode/settings.json, and restarting, now shows correct Intellisense (might take a few seconds to load). It was driving me nuts.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 12 guests