LuaLS / LuaLS/lua-language-server

Support for module-style includes?

Ouverte
#3,195 10 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Lua
Étoiles
4.4k
Forks
442
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par comparer les paramètres Lua.runtime.path, Lua.workspace.library et Lua.runtime.special décrits dans l’issue, en particulier avec import mappé sur require. Reproduisez les imports relatifs au projet sous src/script-game et vérifiez que les diagnostics, l’accès à la définition et les complétions fonctionnent sans chemin de bibliothèque absolu.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
lua
Domaine
tooling
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.