luttje / glua-api-snippets

Scrapes the Garry's Mod Wiki in order to build Lua Language Server comments that will provide IDE suggestions and autocompletion.
MIT License
15 stars 5 forks source link

Use `dofile` to represent include functions #33

Closed b0mbie closed 5 months ago

b0mbie commented 5 months ago

Closes #32.

Changes Lua.runtime.special in the language server addon config to make the functions include and IncludeCS be represented by Lua 5.1's dofile.

This was done because using require instead will yield incorrect code completion for the path, as the language server will think you're filling in a require path, which will not work at all. dofile will offer much better completion for paths, and the language server will be able to correctly identify the return type(s) from the function call.

luttje commented 5 months ago

Great PR, thanks for helping out.

I take it from your PR that you tested this configuration locally? Does LuaLS indeed function better with this change?

If so let me know and I'll merge it ASAP 😁

b0mbie commented 5 months ago

image Using dofile here does provide path completion.

Unfortunately... image image The return type of the call is always ...any, so I made a very incorrect claim about the language server filling in the type. Sorry. (I could've sworn I had the type be correct at some point...)

luttje commented 5 months ago

Ah well that's a shame, but a useful contribution nonetheless thanks to helpful path completion. Thanks again!

luttje commented 5 months ago

Hmm oops, I only now noticed the commit is directly to the lua-language-server-addon branch. That branch is automatically kept up to date by a GitHub workflow. I'll update the main to reflect your changes for you