fix(ci): resolve lua-language-server warnings (#32)

Problem: reload_spec.lua called io.open() without nil checks, causing
need-check-nil warnings. Adding ${3rd}/busted and ${3rd}/luassert to
workspace.library caused lua-language-server 3.7.4 to run diagnostics
on its own bundled meta files, surfacing pre-existing cast-local-type
bugs in luassert's annotations that are not ours to fix.

Solution: use assert(io.open(...)) in reload_spec.lua to satisfy the
nil check. Remove busted/luassert library paths from .luarc.json since
they only benefit spec/ which is not type-checked in CI. Narrow the
lua-language-server check in scripts/ci.sh to lua/ to match CI.
This commit is contained in:
Barrett Ruth 2026-03-04 14:28:52 -05:00 committed by GitHub
parent 50a21a787d
commit dd27374833
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 12 deletions

View file

@ -2,12 +2,7 @@
"runtime.version": "LuaJIT",
"runtime.path": ["lua/?.lua", "lua/?/init.lua"],
"diagnostics.globals": ["vim", "jit"],
"workspace.library": [
"$VIMRUNTIME/lua",
"${3rd}/luv/library",
"${3rd}/busted/library",
"${3rd}/luassert/library"
],
"workspace.library": ["$VIMRUNTIME/lua", "${3rd}/luv/library"],
"workspace.checkThirdParty": false,
"workspace.ignoreDir": [".direnv"],
"completion.callSnippet": "Replace"

View file

@ -13,7 +13,8 @@
...
}:
let
forEachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system});
forEachSystem =
f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system});
in
{
formatter = forEachSystem (pkgs: pkgs.nixfmt-tree);

View file

@ -6,5 +6,5 @@ git ls-files '*.lua' | xargs nix develop --command selene --display-style quiet
nix develop --command prettier --check .
nix fmt
git diff --exit-code -- '*.nix'
nix develop --command lua-language-server --check . --checklevel=Warning
nix develop --command lua-language-server --check lua/ --checklevel=Warning
nix develop --command busted

View file

@ -13,13 +13,13 @@ describe('reload', function()
describe('inject', function()
it('injects script before </body>', function()
local path = os.tmpname()
local f = io.open(path, 'w')
local f = assert(io.open(path, 'w'))
f:write('<html><body><p>hello</p></body></html>')
f:close()
reload.inject(path)
local fr = io.open(path, 'r')
local fr = assert(io.open(path, 'r'))
local content = fr:read('*a')
fr:close()
os.remove(path)
@ -33,13 +33,13 @@ describe('reload', function()
it('appends script when no </body>', function()
local path = os.tmpname()
local f = io.open(path, 'w')
local f = assert(io.open(path, 'w'))
f:write('<html><p>hello</p></html>')
f:close()
reload.inject(path)
local fr = io.open(path, 'r')
local fr = assert(io.open(path, 'r'))
local content = fr:read('*a')
fr:close()
os.remove(path)