Closed tmillr closed 1 month ago
LuaLS 3.9.3
Is this a typo? Latest version is 3.10.3. And please share a concrete (minimal) file to test with. (Just because the error occurred with every file you happened to test with doesn't mean it'll occur with every file. I for example cannot reproduce the error.)
It's also important to show how you
script/core/hint.lua:320: attempt to index a nil value (local 'last')
This logic is under the if case mode == 'All'
, where local mode = config.get(uri, 'Lua.hint.semicolon')
=> So this issue happens only when Lua.hint.semicolon
is set to All
The default value for Lua.hint.semicolon
is SameLine
. Once I changed it to All
in the .luarc.json
(with hint.enable = true
of course) of a new workspace, even for an empty file, this error starts to trigger. 🤔
.luarc.json
{
"hint.enable": true,
"hint.semicolon": "All"
}
test.lua
, and observe the error when you open the file3.10.3
I guess when a block (global scope / if case / etc.) have no statement, the src[]
is actually an empty array.
local a
=> no errorsif true then end
=> error
if true then local a end
=> no errorI believe a simple fix like checking #src > 0
should be enough 🤔 Maybe @tmillr you can test about it and then open PR?
if mode == 'All' and #src > 0 then
local last = src[#src]
...
LuaLS 3.9.3
Is this a typo?
No it's not. I use the latest version from nixpkgs unstable, which does seem to lag behind somewhat (because with nix multiple pkgs are updated at once, but only if/when all of them pass tests and don't error). Vim plugins and lua pkgs are usually 1-2 weeks behind.
And please share a concrete (minimal) file to test with. (Just because the error occurred with every file you happened to test with doesn't mean it'll occur with every file. I for example cannot reproduce the error.)
Sorry but I don't have one at this point, but I'll update my OP to include the config I'm using. The error actually appears at "random", but often enough to be annoying. From the error message (attempt to index nil
), it appears to be an internal logic error.
How are you using the lua-language-server?
NeoVim 0.10.1 LuaLS 3.9.3
Which OS are you using?
MacOS
What is the issue affecting?
Other
Expected Behaviour
no error
Actual Behaviour
Almost every time I open a file in my editor, I get this error (multiple at a time):
Reproduction steps
Open an existing Lua file in neovim.
Additional Notes
Config:
Log File
No response