LuaLS / LuaLS/lua-language-server
require path with custom package.loaders
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
In my project I'm adding new package.loaders which means I'm able to import things that are not real files.
```lua
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.
```lua
---@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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
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.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100