sublimelsp / LSP-lua

Convenience package with a lua language server bundled
MIT License
24 stars 5 forks source link

Mark '...' as defined global not working. #20

Closed rogeriodec closed 2 years ago

rogeriodec commented 3 years ago

I'm using Roblox-Lua and there are some internal global variables that don't need to be declared, such as "workspace", "Vector3", etc. LSP-Lua is showing this warning:

image

If I choose `Mark 'workspace' as defined global, it changes nothing: image

What's wrong?

rchl commented 3 years ago

It's supposed to update your project settings with something like:

Screenshot 2021-07-04 at 23 53 48

Make sure that you have opened a folder instead of a single file. And ideally save the workspace as a project so that your settings are preserved.

(Note that there are warnings in project settings when using LSP-json but that hopefully doesn't affect the behavior)

rogeriodec commented 3 years ago

Thanks. In fact, I had to create a project for it. I've never actually used projects before, but that's okay.

image

However, there is an issue: If I Mark a variable as defined global, ALL other variables that appear underlined with the same problem are no longer charged.

Before:

image

After:

image

To get the correct result, I have to close the file and open it again:

image

rwols commented 3 years ago

What you probably want is to use the Lua.workspace.library setting to point to a Roblox interface. I don't know exactly how that works though. I believe @zainthemaynnn got that working.

https://github.com/sublimelsp/LSP-lua/blob/3dbb0e5ae41f96e36bc8f0be5b11202d08b96e62/LSP-lua.sublime-settings#L162-L166

rogeriodec commented 3 years ago

Actually @rchl solved the original problem. My last post is to inform another behavior.