-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
Your workspace is set to 'x'. Lua language server refused to load this dir. #2975
Comments
Add |
This is the template for lua_ls in neovim, where exactly do I add it? Thanks! require'lspconfig'.lua_ls.setup {
on_init = function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc') then
return
end
end
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT'
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
}
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
-- library = vim.api.nvim_get_runtime_file("", true)
}
})
end,
settings = {
Lua = {}
}
} |
I don't know much about neovim, but according to the nvim-lspconfig's doc: https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#lua_ls
maybe you have to this flag to the require'lspconfig'.lua_ls.setup {
cmd = { "lua-language-server", "--force-accept-workspace" },
on_init = function(client)
... -- your original code above
end,
settings = {
Lua = {}
}
} |
Thanks for answering! I tried to add |
By looking into the source code of luals, this error msg is generated during the workspace init logic, when the workspace path is lua-language-server/script/workspace/workspace.lua Lines 46 to 54 in cdb1b09
I guess this logic is to prevent LuaLS preloading too much files, because by default LuaLS will load every files recursively under root workspace path.
Anyway I tried to add a There is another bug 🐛By further debugging, seems that the arg parsing pattern in the Lines 20 to 28 in cdb1b09
The workaroundTry to use cc @sumneko
|
It did not work initially but then I updated lua_ls and now that command you gave me the last time worked, thanks :) |
How are you using the lua-language-server?
NeoVim
Which OS are you using?
Windows
What is the issue affecting?
Other
Expected Behaviour
For this error not to occur, everything else is working just fine.
Actual Behaviour
error is occuring even though the LSP works just fine and has been working for years prior to this with the exact same setup with no problems. Not sure what happened here but this error comes up, I remove it and everything is back working like normal. Only happens in the home dir.
Reproduction steps
Additional Notes
No response
Log File
No response
The text was updated successfully, but these errors were encountered: