"Undefined global `vim`" after updating to Neovim v0.10.1
Describe the bug
After updating Neovim to v0.10.1 I'm getting the following warning in the init.lua file: Undefined global 'vim'
The code action shows the error is coming from lua_ls.
To Reproduce
- Update Neovim to v0.10.1
- Open the init.lua file
Desktop
- OS: macOS Sonoma 14.5
- Terminal: wezterm 20240203-110809-5046fc22
Neovim Version
NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1725453128
add globals = { 'vim' }, to the diagnostics section of your lua_ls server
@feketegy did this resolve your issue? if yes please close this issue
@iton0 I am having the same issue, I tried adding global as shown below but the issue persists
lua_ls = {
-- cmd = {...},
-- filetypes = { ...},
-- capabilities = {},
settings = {
Lua = {
completion = {
callSnippet = "Replace",
},
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
diagnostics = {
disable = { "missing-fields" },
globals = { "vim" },
},
},
},
},
}
my bad it should be globals instead of global; ill update my comment above to reflect this as well.
@iton0 I updated my comment to reflect 'globals' instead of 'global'. That also did not work.
I found a different solution, if you are in the directory .config/nvim (where your init.lua is) and you add an empty .stylua.toml file it removes the warnings. Not sure why that worked but it did
Setting diagnostics = { globals = "vim"} did not help me either.
I finally found that removing the dense-analysis/ale plugin made the Undefined global \vim`.` warnings go away.