kickstart.nvim icon indicating copy to clipboard operation
kickstart.nvim copied to clipboard

"Undefined global `vim`" after updating to Neovim v0.10.1

Open feketegy opened this issue 1 year ago • 5 comments

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.

image

To Reproduce

  1. Update Neovim to v0.10.1
  2. 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

feketegy avatar Oct 03 '24 11:10 feketegy

add globals = { 'vim' }, to the diagnostics section of your lua_ls server

iton0 avatar Oct 03 '24 16:10 iton0

@feketegy did this resolve your issue? if yes please close this issue

iton0 avatar Oct 08 '24 18:10 iton0

@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" },
			},
		},
	},
},
}

charlieolinsky avatar Oct 19 '24 22:10 charlieolinsky

my bad it should be globals instead of global; ill update my comment above to reflect this as well.

iton0 avatar Oct 19 '24 23:10 iton0

@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

charlieolinsky avatar Oct 19 '24 23:10 charlieolinsky

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.

wwalker avatar Aug 30 '25 21:08 wwalker