LuaLS / LuaLS/lua-language-server

Support for module-style includes?

Offen
#3,195 10 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?

Other

Which OS are you using?

Windows

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

Lua files from my project are found automatically without adding a workspace library path.

Actual Behaviour

Incorrect diagnostics due to LSP seemingly being unable to find the lua files in the path. Also go to definition and such don't work.

Reproduction steps

.

Additional Notes

I have a lot of files in my project which I import like so:

import 'game.physics'
import 'game.ball.request'
import 'game.world'

Note that we use import instead of require. It doesn't do anything special regarding the paths, and I have the following setting:

"Lua.runtime.special": {
	"import" : "require"
}

These paths are relative to the workspace, plus some folders. The actual paths are like so:

<workspace>/src/script-game/game/physics.lua
<workspace>/src/script-game/game/ball/request.lua
<workspace>/src/script-game/game/world.lua

From reading the documentation, it seems like the default Lua.runtime.path should pick these files up no problem, but I get diagnostics like "Undefined global "physics"", and I can't go to definition or get completions for those files (details omitted, sorry):
Image


If I then add a config for Lua.workspace.library, I can make it work:

"Lua.workspace.library": [
	"<workspace>\\src\\script-game"
],

But this feels wrong. These are my files and they're part of my project. I shouldn't need to add them as a library path, should I? Additionally, I could only get it to work as an absolute path, so I need to update this whenever I switch projects. I tried "src/script-game" and "src\script-game" and both reverted back to the broken behaviour.

Am I missing something? Do I need to set something custom in Lua.runtime.path?

Log File

Unfortunately I can't provide this as most of it is under NDA.

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 damit, die in diesem Issue beschriebenen Einstellungen Lua.runtime.path, Lua.workspace.library und Lua.runtime.special zu vergleichen, insbesondere wenn import auf require abgebildet ist. Reproduzieren Sie die projektrelativen Importe unter src/script-game und überprüfen Sie, dass Diagnosen, „Gehe zu Definition“ und Vervollständigungen ohne einen absoluten Bibliothekspfad funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

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

Neue Issues direkt in Ihr Postfach

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