-
-
Notifications
You must be signed in to change notification settings - Fork 334
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 :) |
There seems to be a side-effect, now the server scans the home dir and apparently it's not suppose to do that and I am getting a different error message about scanning too many files and files being to big etc. Is there another or better solution here for me? I have default settings for neovim mostly so I would guess this would be the case for others too? As said before this never happened before and all of a sudden it started happening with no changes in my config. Maybe from a update of either neovim or lua_ls. |
You're right, this warning exists because luals thinks that it will scan too much file, but adding
I git blamed the relevant code: lua-language-server/script/workspace/workspace.lua Lines 46 to 56 in cdb1b09
I am unfamiliar with neovim (I use vscode), but here are some questions/suggestions in my mind:
Hope this can provide some insight on how to solve your problems 🙂 @leet0rz |
@tomlau10 I am simply just opening .wezterm.lua - the config file for wezterm, not a project or anything like that. I am getting the warning that it is refusing because it's the home dir and if I add the force workspace setting it will give warnings that there are too many files being scanned or files being too big etc. Do you know if I can set that up inside the lsp settings instead of having a file? I tried to put it under workspace in the lsp and adding ignoreDir there but did not seem to be working. |
I just find a relevant (?) FAQ: https://luals.github.io/wiki/faq/#why-is-the-server-scanning-the-wrong-folder
There seems to be a single file mode? 🤔 Then I went to test with
I think it's certainly related to your From my side, I may try to setup a neovim editor with lua_ls to test this situation when I have time. |
I just setup neovim on my windows PC and configured luals with the template config provided here: And I can reproduce your situation that, opening a file in home folder will trigger scan all folders 😕 testing env: luals-3.15.3, neovim-0.10.3, nvim-lspconfig-1.3.0
testing env: luals-3.9.3, neovim-0.10.3, nvim-lspconfig-1.3.0I downgraded my luals to 3.9.3, which is a stable version that I used a while ago, then repeat all testing testing env: luals-3.15.3, neovim-0.10.3, nvim-lspconfig-1.0.0Then I downgraded nvim-lspconfig to a version before you create this issue, which is
git bisect resultI then do a git bisect on nvim-lspconfig (which is a git repo)
suggestions
After going through the debugging above, I believe so.
The culprit PR neovim/nvim-lspconfig#3450 is merged on Nov 24, 2024, and you created this issue on Nov 30, 2024. |
update🤔 I believe this is a related issue: neovim/nvim-lspconfig#3531
vim.lsp.config['luals'] = {
-- Command and arguments to start the server.
cmd = { 'lua-language-server' },
-- Filetypes to automatically attach to.
filetypes = { 'lua' },
-- Sets the "root directory" to the parent directory of the file in the
-- current buffer that contains either a ".luarc.json" or a
-- ".luarc.jsonc" file. Files that share a root directory will reuse
-- the connection to the same LSP server.
root_markers = { '.luarc.json', '.luarc.jsonc' },
-- Specific settings to send to the server. The schema for this is
-- defined by the server. For example the schema for lua-language-server
-- can be found here https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json
settings = {
Lua = {
runtime = {
version = 'LuaJIT',
}
}
}
}
vim.lsp.enable('luals') With this setup, I can now open |
@tomlau10 very cool, that seems to be working so far, none of the errors are showing up and I can just place it right into my settings no issues so far. I'll message back if I find anything, strange that I am the only one reporting this, I wonder if this is happening with linux too or if it's a windows related issue and I guess not everyone is on nightly either but it is strange that I am the only person to be reporting this if that is the case lol. Maybe I can set up other LSPs like that too and just get rid of lspconfig, that would be nice. |
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: