Crash on startup: groups/init.lua:44 attempt to index local 'mod' (a nil value)
- Vorherrschende Sprache
- Lua
- Sterne
- 11
- Forks
- 1
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
## Bug Report
**Error message:**
```
.../vaporlush/lua/vaporlush/groups/init.lua:44: attempt to index local 'mod' (a nil value)
stack traceback:
...groups/init.lua:44: in function 'get'
...groups/init.lua:135: in function 'setup'
...vaporlush/lua/vaporlush/init.lua:31: in function 'load'
...vaporlush/colors/vapor.lua:3: in main chunk
```
## Environment
- Neovim with `vim.pack.add` (NOT lazy.nvim)
- colorscheme applied via `vim.cmd[[colorscheme vapor]]` in `after/plugin/colorscheme.lua`
## Root Cause Analysis
In `groups/init.lua`, `M.get(name, colors, opts)` calls `M.get_group(name)` which calls `Util.mod("vaporlush.groups." .. name)`. This returns `nil` under some conditions, causing the crash at line 44 (`return mod.mappings(colors, opts)`).
**Suspected causes:**
1. `plugins.all = package.loaded.lazy == nil` evaluates to `true` when `lazy.nvim` is not used (e.g. with `vim.pack.add`). This enables ALL plugin groups including `cmp`. However `nvim-cmp` may not be installed.
2. There may be an issue with `Util.mod`'s `loadfile` path when modules are loaded in certain orders (e.g. `treesitter.lua` requires `vaporlush.groups.base` via standard `require` at the top level, which can affect `package.loaded` state before `Util.mod` processes it).
3. The `vapor.lua` colors file does `package.loaded['vaporlush'] = nil` before calling `require("vaporlush").load()`, which could cause subtle module reloading issues with `Util.mod`'s path caching.
## Workaround Applied
Added a nil guard in `M.get` to prevent the crash:
```lua
function M.get(name, colors, opts)
local mod = M.get_group(name)
if not mod then
vim.notify("vaporlush: failed to load highlight group: " .. name, vim.log.levels.WARN)
return {}
end
return mod.mappings(colors, opts)
end
```
## Steps to Reproduce
1. Use `vim.pack.add` instead of `lazy.nvim` (so `package.loaded.lazy == nil`)
2. Call `vaporlush.setup({transparent = true, cache = true})`
3. Apply colorscheme via `vim.cmd[[colorscheme vapor]]`
4. Crash occurs in `groups/init.lua:44`
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.