-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
On nightly, the default config for lua_ls is broken #3052
Comments
library = {
vim.env.VIMRUNTIME ..'/lua' |
Hello @glepnir, I am familiar with the In the provided
Also, this issue contains a link to the issue where that line is discussed: #2948 I do think that this issue is
Could you run the Best regards! |
https://github.com/neovim/nvim-lspconfig/blob/master/test/minimal_init.lua there already provie a min test file. |
local on_windows = vim.loop.os_uname().version:match("Windows")
local function join_paths(...)
local path_sep = on_windows and "\\" or "/"
local result = table.concat({ ... }, path_sep)
return result
end
vim.cmd([[set runtimepath=$VIMRUNTIME]])
local temp_dir = vim.loop.os_getenv("TEMP") or "/tmp"
vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))
local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local lspconfig_path = join_paths(package_root, "test", "start", "nvim-lspconfig")
if vim.fn.isdirectory(lspconfig_path) ~= 1 then
vim.fn.system({ "git", "clone", "https://github.com/neovim/nvim-lspconfig", lspconfig_path })
end
vim.lsp.set_log_level("trace")
require("vim.lsp.log").set_format_func(vim.inspect)
local nvim_lsp = require("lspconfig")
local on_attach = function(_, bufnr)
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings.
local opts = { buffer = bufnr, noremap = true, silent = true }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set("n", "<space>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
end
-- Add the server that troubles you here
-- local name = 'pyright'
-- local cmd = { 'pyright-langserver', '--stdio' } -- needed for elixirls, lua_ls, omnisharp
-- if not name then
-- print 'You have not defined a server name, please edit minimal_init.lua'
-- end
-- if not nvim_lsp[name].document_config.default_config.cmd and not cmd then
-- print [[You have not defined a server default cmd for a server
-- that requires it please edit minimal_init.lua]]
-- end
local settings = {
Lua = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
runtime = { version = "LuaJIT" },
workspace = { -- Make the server aware of Neovim runtime files
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
-- vim.env.VIMRUNTIME .. "/lua", -- does not solve the problem
-- Depending on the usage, you might want to add additional paths here.
-- E.g.: For using `vim.*` functions, add vim.env.VIMRUNTIME/lua.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
},
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true)
},
},
}
nvim_lsp["lua_ls"].setup({
-- cmd = cmd,
-- on_attach = on_attach,
on_init = function(client)
local path = client.workspace_folders[1].name
if not vim.loop.fs_stat(path .. "/.luarc.json") and not vim.loop.fs_stat(path .. "/.luarc.jsonc") then
client.config.settings = vim.tbl_deep_extend("force", client.config.settings, settings)
end
return true
end,
})
print(
[[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
) Is the code above usable for you? |
See this PR |
Description
On nightly, without a
luarc.json
, the suggested default config forlua_ls
is broken.When a
.luarc.jsonc
is present in the directory of the config, I can complete global "vim":When I remove
.luarc.jsonc
, the code inside the condition inon_init
kicks in. As a result, there is no completion for global "vim", and warnings appear:Reproduce:
repro
provided below, openinit.lua
, and observe the warnings.vim.
and press<c-x><c-o>
. Only text suggestions appear.Repeat the steps, switch the handlers:
Nightly version:
NVIM v0.10.0-dev-2507+g3df1211eb
Using
0.9.5
, everything works as expected.Repro:
Related:
1 Neovim issue, closed
2 PR luarc
3 nvim-lspconf, undefined variable vim
The text was updated successfully, but these errors were encountered: