LuaLS / LuaLS/lua-language-server
Lazy load workspace libraries
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
I'm using sumneko_lua with Neovim and I wanted to have completions from the Lua plugins I have installed, so I inserted all the paths to the plugins that I have into `Lua.workspace.library`
But the problem is that it that sumneko_lua loads *all* the files inside those libraries right on startup, causing a massive increase to my RAM usage. Normally sumneko_lua only takes up 100-200 MB, but after adding 40+ library paths, sumneko now takes up to 600-700 MB.
Is it possible to load the libraries into the workspace, _only_ when it is needed?
For example, I don't believe the library needs to be loaded when you're only completing a require statement:
```lua
local foobar = require("foob|
```
sumneko_lua only needs to scan the directories listed in `Lua.workspace.library` to find the correct files.
Once the require statement is completed, and its return value is interacted with:
```lua
local foobar = require("foobar")
foobar.call_functi|
```
sumneko_lua can now then load the library in order to produce the completions.
Is it possible for something like this to be implemented?
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 Lua.workspace.library paths are loaded and how require-statement completion finds matching files. Then examine when the required library becomes available for member completions. Done means library paths are searched without loading every file at startup, while completions such as require("foobar") and foobar.call_function still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, neovim
- Domain
- devtools, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100