LuaLS / LuaLS/lua-language-server

Relative paths do not work with `workspace.library` and `diagnostics.libraryFiles` & `.gitmodules`-related issue

Offen
#2,905 8 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?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Type Checking, Diagnostics/Syntax Checking, Libraries

Expected Behaviour

workspace.library and diagnostics.libraryFiles work together even if workspace.library is a relative path on-disk. All that is needed is the path specified.

If I clone busted / luassert into my repository and point relative paths to those directories, lua-language-server should treat these directories as third-party and will ignore any issues they may have during diagnostics / type-checking.

Original context: https://github.com/jeffzi/llscheck/issues/7

Actual Behaviour

workspace.library and diagnostics.libraryFiles seem to only omit diagnostics if it is given an absolute path. Relative paths are still read into the workspace but lua-language-server still reports issues on them anyway. Effectively diagnostics.libraryFiles is ignored.

Reproduction steps

Jean-Francois nicely provided a minimum reproduction of the issue.

Reproduction Summary

The README.md from the above repository has concise reproduction steps but to further simplify...

  • If you run lua-language-server --check . --logpath logs, it says that there are errors.
  • There is a .luarc.json in the repository
    • If you change the "workspace.library": ["annotations"] to "workspace.library": ["$PWD/annotations"]
  • If you run lua-language-server --check . --logpath logs again, it succeeds

To conclude, the relative path was not respected but the $PWD-prefixed path is.

Experiments with .gitmodules

I noticed that if you empty out the .gitmodules file or delete it completely, neither relative paths or absolute paths work. lua-language-server will treat any issues within busted / luassert as if they are errors in my project even though they're meant to be third-party.

Additional Notes

It would be very nice if lua-language-server removed the dependency on .gitmodules. A relative path to workspace.library and diagnostics.libraryFiles: "Disable" in my opinion should be all you need to provide for lua-language-server to know not to report diagnostics from there.

Additionally if we could allow relative paths so as to not need to add $PWD that would be nice.

Log File
{
    "file:///home/selecaoone/repositories/luals-example/./annotations/luassert/library/luassert/mock.lua": [
        {
            "code": "cast-local-type",
            "message": "This variable is defined as type `luassert.mock`. Cannot convert its type to `function`.\n- `function` cannot match `luassert.mock`\n- Type `function` cannot match `table`\n- Type `function` cannot match `luassert.mock`",
            "range": {
                "end": {
                    "character": 13,
                    "line": 15
                },
                "start": {
                    "character": 9,
                    "line": 15
                }
            },
            "severity": 2,
            "source": "Lua Diagnostics."
        }
    ],
    "file:///home/selecaoone/repositories/luals-example/./annotations/luassert/library/luassert/stub.lua": [
        {
            "code": "cast-local-type",
            "message": "This variable is defined as type `luassert.stub`. Cannot convert its type to `function`.\n- `function` cannot match `luassert.stub`\n- Type `function` cannot match `table`\n- Type `function` cannot match `luassert.stub`",
            "range": {
                "end": {
                    "character": 13,
                    "line": 12
                },
                "start": {
                    "character": 9,
                    "line": 12
                }
            },
            "severity": 2,
            "source": "Lua Diagnostics."
        }
    ]
}

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

Beginne mit der verknüpften minimalen Reproduktion und ihrer README.md und führe dann lua-language-server --check . --logpath logs mit dem .luarc.json des Repositorys aus. Vergleiche relative und mit $PWD präfixierte workspace.library-Werte, einschließlich des Vorhandenseins oder Fehlens von .gitmodules; als abgeschlossen gilt die Aufgabe, wenn relative Bibliothekspfade und diagnostics.libraryFiles Diagnosen konsistent unterdrücken, ohne von .gitmodules abzuhängen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
lua
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

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