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

feat(lua_ls): update recommended settings #2750

Merged
merged 1 commit into from
Aug 8, 2023
Merged

Conversation

lewis6991
Copy link
Member

@lewis6991 lewis6991 commented Aug 8, 2023

See: neovim/neovim#24592

  • Only override settings if there is no .luarc.json(c) file present.
  • Prefer setting workspace to VIMRUNTIME over 'runtimepath'

- Only override settings if there is no `.luarc.json(c)` file present.
- Prefer setting workspace to `VIMRUNTIME` over `'runtimepath'`
@lewis6991 lewis6991 merged commit 2071b4e into neovim:master Aug 8, 2023
9 checks passed
@icp1994
Copy link

icp1994 commented Aug 10, 2023

After applying changes from this patch, I get diagnostics warnings for "Undefined global vim" even though I have included that settings.

Previous setup:

lspconfig.lua_ls.setup({
	settings = {
		Lua = {
			runtime = {
				version = "LuaJIT",
			},
			diagnostics = {
				globals = { "vim" },
			},
			workspace = {
				library = vim.api.nvim_get_runtime_file("", true),
				checkThirdParty = false,
			},
		},
	},
})

Current setup

lspconfig.lua_ls.setup({
	on_attach = on_attach,
	capabilities = capabilities,
	on_init = function(client)
		local path = client.workspace_folders[1].name
		if not vim.loop.fs_stat(path .. "/.luarc.json") then
			client.config.settings = vim.tbl_deep_extend("force", client.config.settings.Lua, {
				runtime = {
					version = "LuaJIT",
				},
				diagnostics = {
					globals = { "vim" },
				},
				workspace = {
					library = { vim.env.VIMRUNTIME },
					checkThirdParty = false,
				},
			})
			client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
		end
	end,
})

NVIM v0.9.1

@lewis6991
Copy link
Member Author

Are you sure you haven't got a misconfigured .luarc.json in your workspace?

@icp1994
Copy link

icp1994 commented Aug 10, 2023

No, but also just found out #2755 :p

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

Successfully merging this pull request may close these issues.

None yet

3 participants