yazi: wire lua_ls type checking for font-dark previewer#9
Merged
Conversation
Add the official yazi LuaCATS stubs (types.yazi plugin) and a .luarc.json so lua_ls resolves the yazi runtime globals (ya, rt, fs, Command, Err) when editing modules/home-manager/yazi/font-dark.yazi/main.lua. - flake.nix: add yazi-plugins input (github:yazi-rs/plugins, flake=false) - yazi module: deploy types.yazi to ~/.config/yazi/plugins/types.yazi - .luarc.json: Lua 5.4 runtime, types.yazi on workspace.library, Err global - main.lua: fix the diagnostics surfaced by the now-working LSP — "64" pointsize (Command:arg takes strings), rename the shadowed `err` local, and suppress the one upstream stub false-positive on ya.preview_widget (runtime accepts Error/nil; stub annotates Renderable only — see yazi-plugin/src/utils/preview.rs)
Replace the hardcoded `#dcd7ba` fill (which was kanagawa-wave's fg, not this dragon flavor's `#c5c9c5`) with a value chosen at runtime from `rt.term.light`: near-black on light terminals, fujiWhite on dark ones. yazi exposes no flat palette or general "foreground" field — `th` is only per-widget style tables — so light/dark mode is the cleanest theme-aware signal available without hardcoding a flavor color.
Replace the binary `rt.term.light` heuristic with the flavor's actual foreground, read at runtime via `th.mgr.border_style:raw().fg` (yazi has no flat palette; `:raw()` serializes a Style to a table whose fg/bg are "#RRGGBB" strings). Falls back to fujiWhite if unset.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes
lua_lsresolve yazi's Lua runtime API when editingmodules/home-manager/yazi/font-dark.yazi/main.lua, then clears everydiagnostic the now-working LSP surfaces.
Previously, opening the previewer override flagged
ya,rt,fs,Command,Erras undefined globals — the file lives outsideconfig/nvim/, so itinherited no Lua type info.
Changes
flake.nix— addyazi-pluginsinput (github:yazi-rs/plugins,flake = false); the officialtypes.yaziLuaCATS stubs aren't in nixpkgs.modules/home-manager/yazi/default.nix— deploytypes.yazito~/.config/yazi/plugins/types.yazi(annotations-only; never referenced by a previewer/preloader/fetcher, so yazi never executes it)..luarc.json(new) —runtime.version: Lua 5.4,types.yazionworkspace.library, andErras a declared global. lua_ls picks this dir up as its root via the existing.luarc.jsonroot-marker.main.lua— resolve the real diagnostics:"64"pointsize (Command:argtakes strings), rename the shadowederrlocal, and one documented---@diagnostic disable-next-linefor an upstream stub false-positive.On the one suppression
ya.preview_widgetaccepts a Renderable, anError, ornilat runtime(
yazi-plugin/src/utils/preview.rs), buttypes.yaziannotates the parameteras only
Renderable|Renderable[]. The code is correct; the stub is incomplete.yazi's own shipped preset triggers the same warning against yazi's own stubs.
Verification
nix build .#darwinConfigurations.k.system— passes.lua-language-server --checkon the file — no problems found.stylua --check(as efm runs it) — clean.