LuaLS / LuaLS/lua-language-server

VS Code variable resolution in @source annotations/relativity of paths

Offen
#3,388 0 Kommentare 0 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?

Linux

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

Intuitively, I expected:

  1. ---@source annotations in meta files with relative paths to be resolved relative to the workspace
  2. VS Code variables in the @source path to be resolved when resolving a path
Actual Behaviour
  1. @source paths are resolved relative to the meta file itself
  2. VS Code variables in the path are not resolved
Reproduction steps
  1. Create .vscode/luals/library/foo.d.lua with:
    ---@meta
    --- @class foo
    _G.foo = {}
    
    ---@source grault/foo.lua:1
    function bar() end
    
  2. Create baz.lua with:
    require("foo")
    local quux = foo.bar()
    
  3. In extension settings, set:
    {
      "Lua.workspace.userThirdParty": ["${fileWorkspaceFolder}/LuaLS"]
    }
    

[!NOTE]
The variable ${fileWorkspaceFolder} resolves correctly and adds the meta file to the list of search paths

  1. Open baz.lua in VS Code editor
  2. Right click bar
  3. Select Go to Definition
  4. Observe:
    VS Code opens a non-existent source file tab to .vscode/luals/library/grault/foo.lua
Additional Notes

This could be two separate issues, but they're tightly related -- one as a Documentation Issue that the relativity of the resolution of the path should be added to the docs, and two as a Bug/Feature Request that VS Code variables be resolved in the @source paths as they are in the settings

Attempting to work around this using VS Code variables has the variable unresolved and taken literally. For example, setting the @source path to /${fileWorkspaceFolder}/grault/foo.lua:1 causes VS Code to open a tab to that literal string instead of the expected /home/me/my_project/grault/foo.lua:1

Log File

No response

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

Reproduziere das Beispiel mit .vscode/luals/library/foo.d.lua, baz.lua und der workspace.userThirdParty-Einstellung. Beginne damit nachzuverfolgen, wie @source-Pfade aufgelöst werden und wie VS Code-Variablen erweitert werden, und überprüfe anschließend das Verhalten relativer Pfade und die Variablensubstitution anhand des erwarteten Go to Definition-Ziels. Dokumentiere die gewählte Pfadrelativität, falls sie unverändert bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
lua, vscode
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

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