LuaLS / LuaLS/lua-language-server

Error when exporting Lua language server documentation

Offen
#3,170 3 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Lua
Sterne
4.4k
Forks
442
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Other

Expected Behaviour

documentation export

Actual Behaviour

I encountered an error when trying to export documentation using the Lua language server (sumneko.lua-3.14.0):
[error]: script\cli\doc\export.lua:61: bad argument #1 to 'canonical' (bee::path expected, got nil)

Reproduction steps
  1. Install sumneko.lua-3.14.0 extension in VS Code
  2. Create a simple Lua project with documentation comments
  3. Try to export documentation (through command palette)
Additional Notes

This appears to be a regression or oversight in the extension where it attempts to use a variable before it's defined. The fix is straightforward and might help other users encountering the same issue.

Solution

I fixed this by modifying script\cli\doc\export.lua to define the DOC variable with a simpler fallback approach that doesn't rely on non-existent functions:

-- Define DOC variable to avoid nil error
local DOC = DOC or (ws.rootUri and fs.path(furi.decode(ws.rootUri)) or fs.current_path())

This simple fix ensures that DOC is always defined with a valid path value before it's used in the getLocalPath function, allowing the documentation export functionality to work properly.

Log File

[00:02:10.453][error][#0]: script\cli\doc\export.lua:61: bad argument #1 to 'canonical' (bee::path expected, got nil)
stack traceback:
[C]: in function 'bee.filesystem.canonical'
script\cli\doc\export.lua:61: in field 'getLocalPath'
script\cli\doc\export.lua:170: in field '?'
script\cli\doc\export.lua:118: in field 'documentObject'
script\cli\doc\export.lua:261: in field 'variable'
script\cli\doc\export.lua:235: in field '?'
script\cli\doc\export.lua:118: in field 'documentObject'
script\cli\doc\export.lua:287: in field 'makeDocs'
script\cli\doc\init.lua:162: in function 'cli.doc.makeDoc'
script\core\command\exportDocument.lua:10: in function 'core.command.exportDocument'
script\provider\provider.lua:1009: in function <script\provider\provider.lua:987>
[C]: in function 'xpcall'
script\proto\proto.lua:202: in function <script\proto\proto.lua:177>

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit script/cli/doc/export.lua, insbesondere mit getLocalPath in Zeile 61, und reproduzieren Sie den Fehler, indem Sie die Dokumentation über die Befehlspalette von VS Code in einem Lua-Projekt exportieren. Überprüfen Sie den vorgeschlagenen Pfad-Fallback und stellen Sie sicher, dass der Dokumentationsexport ohne den kanonischen nil-path-Fehler abgeschlossen wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
lua, vscode
Bereich
documentation
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.