How lazydev.nvim manages LuaLS workspaces
mainlazydev.nvim optimizes LuaLS by lazily updating workspace libraries based on your code. It automatically detects and loads modules for:
- require statements: e.g.,
require("nvim-treesitter") - module annotations: e.g.,
---@module "nvim-treesitter"
This approach ensures faster autocompletion because only the modules actually used in your open files are loaded into the LuaLS workspace.
Limitations to note:
- If a file only uses types from a plugin without
require-ing it or using a module annotation, those types won't be available. To fix this, pre-load the plugin using thelibraryoption. - Completion for module names in
require(...)only returns modules currently loaded in your workspace. To see all available modules, use thenvim-cmp,blink.cmp, orcoq_nvimcompletion sources provided bylazydev. - Neovim >= 0.10: Neovim types are no longer included or required.