Closed Mikilio closed 1 year ago
There is nothing wrong here. That is just how Lua visibility rules for labels work.
Trying to run your code, indeed returns a syntax error.
Sorry for my ignorance but why is that mark not visible?
I am using the latest lsp with VSCode, I do get an error on the line goto view_err
that says "No visible label 'view_err' ".
Try updating to the latest lsp, or reloading the client.
The reason for why that label is not visible is that it is in a scope unreachable by the if statement scope, effectively you are doing:
do
::view_err:: -- valid everywhere inside of this block
-- etc
end
do -- a new block
-- etc
goto view_err
end
Instead of trying to use goto, simply define a function instead:
local function view_err()
err_msg("Could not launch viewer.")
-- etc
end
if not lproc or lproc == "" then
return view_err()
end
-- etc
if not vpis or vpid == "" then
return view_err()
end
Thank you! I was confused because my LSP only found the error upon saving and opening again. But that solves it for me.
How are you using the lua-language-server?
NeoVim
Which OS are you using?
Linux
What is the issue affecting?
Diagnostics/Syntax Checking
Expected Behaviour
Should pass
Actual Behaviour
Ich get two warnings:
Reproduction steps
Have the above code snippet inside a function
Additional Notes
No response
Log File
No response