build: replace luacheck with selene, add nix devshell and pre-commit (#20)

* build: replace luacheck with selene

Problem: luacheck is unmaintained (last release 2018) and required
suppressing four warning classes to avoid false positives. It also
lacks first-class vim/neovim awareness.

Solution: switch to selene with std='vim' for vim-aware linting.
Replace the luacheck CI job with selene, update the Makefile lint
target, and delete .luacheckrc.

* build: add nix devshell and pre-commit hooks

Problem: oil.nvim had no reproducible dev environment. The .envrc
set up a Python venv for the now-removed docgen pipeline, and there
were no pre-commit hooks for local formatting checks.

Solution: add flake.nix with stylua, selene, and prettier in the
devshell. Replace the stale Python .envrc with 'use flake'. Add
.pre-commit-config.yaml with stylua and prettier hooks matching
other plugins in the repo collection.

* fix: format with stylua

* build(selene): configure lints and add inline suppressions

Problem: selene fails on 5 errors and 3 warnings from upstream code
patterns that are intentional (mixed tables in config API, unused
callback parameters, identical if branches for readability).

Solution: globally allow mixed_table and unused_variable (high volume,
inherent to the codebase design). Add inline selene:allow directives
for the 8 remaining issues: if_same_then_else (4), mismatched_arg_count
(1), empty_if (2), global_usage (1). Remove .envrc from tracking.

* build: switch typecheck action to mrcjkb/lua-typecheck-action

Problem: oil.nvim used stevearc/nvim-typecheck-action, which required
cloning the action repo locally for the Makefile lint target. All
other plugins in the collection use mrcjkb/lua-typecheck-action.

Solution: swap to mrcjkb/lua-typecheck-action@v0 for consistency.
Remove the nvim-typecheck-action git clone from the Makefile and
.gitignore. Drop LuaLS from the local lint target since it requires
a full language server install — CI handles it.
This commit is contained in:
Barrett Ruth 2026-02-21 23:52:27 -05:00 committed by GitHub
parent df53b172a9
commit 86f553cd0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 2762 additions and 2649 deletions

View file

@ -1,10 +1,10 @@
require("plenary.async").tests.add_to_env()
local constants = require("oil.constants")
local parser = require("oil.mutator.parser")
local test_adapter = require("oil.adapters.test")
local test_util = require("tests.test_util")
local util = require("oil.util")
local view = require("oil.view")
require('plenary.async').tests.add_to_env()
local constants = require('oil.constants')
local parser = require('oil.mutator.parser')
local test_adapter = require('oil.adapters.test')
local test_util = require('tests.test_util')
local util = require('oil.util')
local view = require('oil.view')
local FIELD_ID = constants.FIELD_ID
local FIELD_META = constants.FIELD_META
@ -14,101 +14,101 @@ local function set_lines(bufnr, lines)
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, lines)
end
describe("parser", function()
describe('parser', function()
after_each(function()
test_util.reset_editor()
end)
it("detects new files", function()
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('detects new files', function()
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
"a.txt",
'a.txt',
})
local diffs = parser.parse(bufnr)
assert.are.same({ { entry_type = "file", name = "a.txt", type = "new" } }, diffs)
assert.are.same({ { entry_type = 'file', name = 'a.txt', type = 'new' } }, diffs)
end)
it("detects new directories", function()
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('detects new directories', function()
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
"foo/",
'foo/',
})
local diffs = parser.parse(bufnr)
assert.are.same({ { entry_type = "directory", name = "foo", type = "new" } }, diffs)
assert.are.same({ { entry_type = 'directory', name = 'foo', type = 'new' } }, diffs)
end)
it("detects new links", function()
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('detects new links', function()
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
"a.txt -> b.txt",
'a.txt -> b.txt',
})
local diffs = parser.parse(bufnr)
assert.are.same(
{ { entry_type = "link", name = "a.txt", type = "new", link = "b.txt" } },
{ { entry_type = 'link', name = 'a.txt', type = 'new', link = 'b.txt' } },
diffs
)
end)
it("detects deleted files", function()
local file = test_adapter.test_set("/foo/a.txt", "file")
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('detects deleted files', function()
local file = test_adapter.test_set('/foo/a.txt', 'file')
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {})
local diffs = parser.parse(bufnr)
assert.are.same({
{ name = "a.txt", type = "delete", id = file[FIELD_ID] },
{ name = 'a.txt', type = 'delete', id = file[FIELD_ID] },
}, diffs)
end)
it("detects deleted directories", function()
local dir = test_adapter.test_set("/foo/bar", "directory")
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('detects deleted directories', function()
local dir = test_adapter.test_set('/foo/bar', 'directory')
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {})
local diffs = parser.parse(bufnr)
assert.are.same({
{ name = "bar", type = "delete", id = dir[FIELD_ID] },
{ name = 'bar', type = 'delete', id = dir[FIELD_ID] },
}, diffs)
end)
it("detects deleted links", function()
local file = test_adapter.test_set("/foo/a.txt", "link")
file[FIELD_META] = { link = "b.txt" }
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('detects deleted links', function()
local file = test_adapter.test_set('/foo/a.txt', 'link')
file[FIELD_META] = { link = 'b.txt' }
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {})
local diffs = parser.parse(bufnr)
assert.are.same({
{ name = "a.txt", type = "delete", id = file[FIELD_ID] },
{ name = 'a.txt', type = 'delete', id = file[FIELD_ID] },
}, diffs)
end)
it("ignores empty lines", function()
local file = test_adapter.test_set("/foo/a.txt", "file")
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('ignores empty lines', function()
local file = test_adapter.test_set('/foo/a.txt', 'file')
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
local cols = view.format_entry_cols(file, {}, {}, test_adapter, false)
local lines = util.render_table({ cols }, {})
table.insert(lines, "")
table.insert(lines, " ")
table.insert(lines, '')
table.insert(lines, ' ')
set_lines(bufnr, lines)
local diffs = parser.parse(bufnr)
assert.are.same({}, diffs)
end)
it("errors on missing filename", function()
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('errors on missing filename', function()
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
"/008",
'/008',
})
local _, errors = parser.parse(bufnr)
assert.are_same({
{
message = "Malformed ID at start of line",
message = 'Malformed ID at start of line',
lnum = 0,
end_lnum = 1,
col = 0,
@ -116,16 +116,16 @@ describe("parser", function()
}, errors)
end)
it("errors on empty dirname", function()
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('errors on empty dirname', function()
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
"/008 /",
'/008 /',
})
local _, errors = parser.parse(bufnr)
assert.are.same({
{
message = "No filename found",
message = 'No filename found',
lnum = 0,
end_lnum = 1,
col = 0,
@ -133,17 +133,17 @@ describe("parser", function()
}, errors)
end)
it("errors on duplicate names", function()
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('errors on duplicate names', function()
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
"foo",
"foo/",
'foo',
'foo/',
})
local _, errors = parser.parse(bufnr)
assert.are.same({
{
message = "Duplicate filename",
message = 'Duplicate filename',
lnum = 1,
end_lnum = 2,
col = 0,
@ -151,18 +151,18 @@ describe("parser", function()
}, errors)
end)
it("errors on duplicate names for existing files", function()
local file = test_adapter.test_set("/foo/a.txt", "file")
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('errors on duplicate names for existing files', function()
local file = test_adapter.test_set('/foo/a.txt', 'file')
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
"a.txt",
string.format("/%d a.txt", file[FIELD_ID]),
'a.txt',
string.format('/%d a.txt', file[FIELD_ID]),
})
local _, errors = parser.parse(bufnr)
assert.are.same({
{
message = "Duplicate filename",
message = 'Duplicate filename',
lnum = 1,
end_lnum = 2,
col = 0,
@ -170,52 +170,52 @@ describe("parser", function()
}, errors)
end)
it("ignores new dirs with empty name", function()
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('ignores new dirs with empty name', function()
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
"/",
'/',
})
local diffs = parser.parse(bufnr)
assert.are.same({}, diffs)
end)
it("parses a rename as a delete + new", function()
local file = test_adapter.test_set("/foo/a.txt", "file")
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('parses a rename as a delete + new', function()
local file = test_adapter.test_set('/foo/a.txt', 'file')
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
string.format("/%d b.txt", file[FIELD_ID]),
string.format('/%d b.txt', file[FIELD_ID]),
})
local diffs = parser.parse(bufnr)
assert.are.same({
{ type = "new", id = file[FIELD_ID], name = "b.txt", entry_type = "file" },
{ type = "delete", id = file[FIELD_ID], name = "a.txt" },
{ type = 'new', id = file[FIELD_ID], name = 'b.txt', entry_type = 'file' },
{ type = 'delete', id = file[FIELD_ID], name = 'a.txt' },
}, diffs)
end)
it("detects a new trailing slash as a delete + create", function()
local file = test_adapter.test_set("/foo", "file")
vim.cmd.edit({ args = { "oil-test:///" } })
it('detects a new trailing slash as a delete + create', function()
local file = test_adapter.test_set('/foo', 'file')
vim.cmd.edit({ args = { 'oil-test:///' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
string.format("/%d foo/", file[FIELD_ID]),
string.format('/%d foo/', file[FIELD_ID]),
})
local diffs = parser.parse(bufnr)
assert.are.same({
{ type = "new", name = "foo", entry_type = "directory" },
{ type = "delete", id = file[FIELD_ID], name = "foo" },
{ type = 'new', name = 'foo', entry_type = 'directory' },
{ type = 'delete', id = file[FIELD_ID], name = 'foo' },
}, diffs)
end)
it("detects renamed files that conflict", function()
local afile = test_adapter.test_set("/foo/a.txt", "file")
local bfile = test_adapter.test_set("/foo/b.txt", "file")
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('detects renamed files that conflict', function()
local afile = test_adapter.test_set('/foo/a.txt', 'file')
local bfile = test_adapter.test_set('/foo/b.txt', 'file')
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
string.format("/%d a.txt", bfile[FIELD_ID]),
string.format("/%d b.txt", afile[FIELD_ID]),
string.format('/%d a.txt', bfile[FIELD_ID]),
string.format('/%d b.txt', afile[FIELD_ID]),
})
local diffs = parser.parse(bufnr)
local first_two = { diffs[1], diffs[2] }
@ -227,22 +227,22 @@ describe("parser", function()
return a.id < b.id
end)
assert.are.same({
{ name = "b.txt", type = "new", id = afile[FIELD_ID], entry_type = "file" },
{ name = "a.txt", type = "new", id = bfile[FIELD_ID], entry_type = "file" },
{ name = 'b.txt', type = 'new', id = afile[FIELD_ID], entry_type = 'file' },
{ name = 'a.txt', type = 'new', id = bfile[FIELD_ID], entry_type = 'file' },
}, first_two)
assert.are.same({
{ name = "a.txt", type = "delete", id = afile[FIELD_ID] },
{ name = "b.txt", type = "delete", id = bfile[FIELD_ID] },
{ name = 'a.txt', type = 'delete', id = afile[FIELD_ID] },
{ name = 'b.txt', type = 'delete', id = bfile[FIELD_ID] },
}, last_two)
end)
it("views link targets with trailing slashes as the same", function()
local file = test_adapter.test_set("/foo/mydir", "link")
file[FIELD_META] = { link = "dir/" }
vim.cmd.edit({ args = { "oil-test:///foo/" } })
it('views link targets with trailing slashes as the same', function()
local file = test_adapter.test_set('/foo/mydir', 'link')
file[FIELD_META] = { link = 'dir/' }
vim.cmd.edit({ args = { 'oil-test:///foo/' } })
local bufnr = vim.api.nvim_get_current_buf()
set_lines(bufnr, {
string.format("/%d mydir/ -> dir/", file[FIELD_ID]),
string.format('/%d mydir/ -> dir/', file[FIELD_ID]),
})
local diffs = parser.parse(bufnr)
assert.are.same({}, diffs)