Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined global for builtins #1788

Open
ddickstein opened this issue Dec 26, 2022 · 12 comments
Open

Undefined global for builtins #1788

ddickstein opened this issue Dec 26, 2022 · 12 comments
Labels
enhancement New feature or request

Comments

@ddickstein
Copy link

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

I think I'm encountering the same issue as #1600. In my case it happens sporadically - reloading a lua file in Neovim will often randomly introduce or resolve this behavior.

I'm running version 3.6.4-1 installed from pacman.

Actual Behaviour

Seeing warnings on all builtins as "undefined global"

Reproduction steps

I'm not sure how to reproduce reliably - it seems to happen somewhat randomly when I load the buffer.

Additional Notes

No response

Log File

(I'm time-constrained at the moment but I plan to add this later)

@andrewferrier
Copy link

Ditto - I'm seeing the same problem:

MacOS 12.5.1
NVIM v0.8.0
Sumneko 3.6.3

@zenoli
Copy link

zenoli commented Dec 29, 2022

Same for me. The problem sometimes disappears when I open certain lua files but it's hard to reproduce consistently.

Ubuntu LTS 22.04
Nvim v0.9.0-dev-47-gcfdb4cbad
Sumneko v3.6.4

@sumneko
Copy link
Collaborator

sumneko commented Jan 3, 2023

Check neovim/nvim-lspconfig#2355

@sumneko sumneko added the Info Needed More information is required label Jan 3, 2023
@caldwell-63
Copy link

caldwell-63 commented Feb 9, 2023

Nothing really helpful there.

In my case, out of all globals, I'm getting warnings only for the type standard function: Undefined global 'type'

Really weird, I can't tell where is the root of the problem, is it the Language Server, nvim-lspconfig, the neovim lsp implementation, or something else.

@sumneko
Copy link
Collaborator

sumneko commented Feb 13, 2023

Nothing really helpful there.

In my case, out of all globals, I'm getting warnings only for the type standard function: Undefined global 'type'

Really weird, I can't tell where is the root of the problem, is it the Language Server, nvim-lspconfig, the neovim lsp implementation, or something else.

Please open an issue about it.

@L3MON4D3
Copy link

L3MON4D3 commented Mar 10, 2023

I've also had this issue, and for me explicitly extending Lua.workspace.library with one of the meta-directories worked, ie.

nvim_lsp.lua_ls.setup {
    settings = {
        Lua = {
            workspace = {
                library = vim.tbl_extend("keep",
                    -- this will probably vary depending on setup, not sure if plugins like mason even install it.
                    {"/usr/lib/lua-language-server/meta/template"},
                    -- and runtime-directories.
                    vim.api.nvim_get_runtime_file("", true)),
            },
        },
    },
}

(might have undesired consequences, but I haven't found any so far 🤷)

@sumneko
Copy link
Collaborator

sumneko commented Mar 11, 2023

Please try to startup server with parameters --meta=<WRITEABLE_PATH>.
Maybe it generated meta files failed.

@L3MON4D3
Copy link

Ah, yes you're right 👍
cmd = {sumneko_binary, "--logpath", "/home/simon/.cache/lua-language-server/", "--metapath", "/home/simon/.cache/lua-language-server/meta/"} works perfectly, thank you!

@benjamineskola
Copy link

I've encountered this when the directory lua-language-server is installed into is not writable by the user. As with the above comment I had to set logpath (or the LS failed to start at all) and metapath (or there would be these undefined global errors).

Perhaps the defaults for logpath and metapath ought to be in a writable directory by default (like $XDG_CONFIG_HOME or $HOME/.cache or on macOS $HOME/Library/Caches?)

@godalming123
Copy link

godalming123 commented Apr 20, 2023

For me when I use lsp-zero I do not get this error but with the kickstart.nvim default config I do? strange

@sumneko sumneko added enhancement New feature or request and removed Info Needed More information is required labels Apr 24, 2023
@wsdjeg
Copy link

wsdjeg commented Jun 19, 2023

I got same issue in win 11, and fix by this suggession, #1788 (comment)

@idbrii
Copy link

idbrii commented Aug 10, 2023

L3MON4D3's comment helped solve this undefined built-ins for me too, but since I'm using vim-lsp-settings, I solved it with this in my vimrc:

call lsp_settings#set('sumneko-lua-language-server', 'args', ["--metapath", expand('~/.vim-cache/lsp/meta')])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants