LuaLS / LuaLS/lua-language-server

require path with custom package.loaders

Aperta
#2,644 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Lua
Stelle
4.4k
Fork
442
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

In my project I'm adding new package.loaders which means I'm able to import things that are not real files.

local bindings = require "bindings.core" -- This is not a real file

Any path starting with bindings. is treated differently. Is there a way to instruct the Lua Language Server to treat those specific requires in a special way and have them returning the right type annotation?
I'd like to not specify the @type every time I'm requiring these special packages.

---@type CoreBindings  <---- I'm forced to specify the type
local bindings = require "bindings.core" 

If there's a valid solution I'd need it to work outside of VS code. I'm running LuaLS as a standalone check.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Start by tracing how standalone LuaLS resolves require "bindings.core" and applies package.loaders information to type inference. Define how a configuration for the bindings. prefix would be supplied outside VS Code, then verify that the require receives CoreBindings without a repeated @type annotation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
lua
Ambito
devtools
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.