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:
parent
df53b172a9
commit
86f553cd0a
72 changed files with 2762 additions and 2649 deletions
|
|
@ -1,11 +1,11 @@
|
|||
require("plenary.async").tests.add_to_env()
|
||||
local TmpDir = require("tests.tmpdir")
|
||||
local actions = require("oil.actions")
|
||||
local oil = require("oil")
|
||||
local test_util = require("tests.test_util")
|
||||
local view = require("oil.view")
|
||||
require('plenary.async').tests.add_to_env()
|
||||
local TmpDir = require('tests.tmpdir')
|
||||
local actions = require('oil.actions')
|
||||
local oil = require('oil')
|
||||
local test_util = require('tests.test_util')
|
||||
local view = require('oil.view')
|
||||
|
||||
a.describe("regression tests", function()
|
||||
a.describe('regression tests', function()
|
||||
local tmpdir
|
||||
a.before_each(function()
|
||||
tmpdir = TmpDir.new()
|
||||
|
|
@ -19,37 +19,37 @@ a.describe("regression tests", function()
|
|||
end)
|
||||
|
||||
-- see https://github.com/stevearc/oil.nvim/issues/25
|
||||
a.it("can edit dirs that will be renamed to an existing buffer", function()
|
||||
vim.cmd.edit({ args = { "README.md" } })
|
||||
a.it('can edit dirs that will be renamed to an existing buffer', function()
|
||||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
vim.cmd.vsplit()
|
||||
vim.cmd.edit({ args = { "%:p:h" } })
|
||||
assert.equals("oil", vim.bo.filetype)
|
||||
vim.cmd.wincmd({ args = { "p" } })
|
||||
assert.equals("markdown", vim.bo.filetype)
|
||||
vim.cmd.edit({ args = { "%:p:h" } })
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
assert.equals("oil", vim.bo.filetype)
|
||||
vim.cmd.edit({ args = { '%:p:h' } })
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
vim.cmd.wincmd({ args = { 'p' } })
|
||||
assert.equals('markdown', vim.bo.filetype)
|
||||
vim.cmd.edit({ args = { '%:p:h' } })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
end)
|
||||
|
||||
-- https://github.com/stevearc/oil.nvim/issues/37
|
||||
a.it("places the cursor on correct entry when opening on file", function()
|
||||
vim.cmd.edit({ args = { "." } })
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
a.it('places the cursor on correct entry when opening on file', function()
|
||||
vim.cmd.edit({ args = { '.' } })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
local entry = oil.get_cursor_entry()
|
||||
assert.not_nil(entry)
|
||||
assert.not_equals("README.md", entry and entry.name)
|
||||
vim.cmd.edit({ args = { "README.md" } })
|
||||
assert.not_equals('README.md', entry and entry.name)
|
||||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
view.delete_hidden_buffers()
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
entry = oil.get_cursor_entry()
|
||||
assert.equals("README.md", entry and entry.name)
|
||||
assert.equals('README.md', entry and entry.name)
|
||||
end)
|
||||
|
||||
-- https://github.com/stevearc/oil.nvim/issues/64
|
||||
a.it("doesn't close floating windows oil didn't open itself", function()
|
||||
local winid = vim.api.nvim_open_win(vim.fn.bufadd("README.md"), true, {
|
||||
relative = "editor",
|
||||
local winid = vim.api.nvim_open_win(vim.fn.bufadd('README.md'), true, {
|
||||
relative = 'editor',
|
||||
row = 1,
|
||||
col = 1,
|
||||
width = 100,
|
||||
|
|
@ -64,7 +64,7 @@ a.describe("regression tests", function()
|
|||
|
||||
-- https://github.com/stevearc/oil.nvim/issues/64
|
||||
a.it("doesn't close splits on oil.close", function()
|
||||
vim.cmd.edit({ args = { "README.md" } })
|
||||
vim.cmd.edit({ args = { 'README.md' } })
|
||||
vim.cmd.vsplit()
|
||||
local winid = vim.api.nvim_get_current_win()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
|
|
@ -78,71 +78,71 @@ a.describe("regression tests", function()
|
|||
end)
|
||||
|
||||
-- https://github.com/stevearc/oil.nvim/issues/79
|
||||
a.it("Returns to empty buffer on close", function()
|
||||
a.it('Returns to empty buffer on close', function()
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
oil.close()
|
||||
assert.not_equals("oil", vim.bo.filetype)
|
||||
assert.equals("", vim.api.nvim_buf_get_name(0))
|
||||
assert.not_equals('oil', vim.bo.filetype)
|
||||
assert.equals('', vim.api.nvim_buf_get_name(0))
|
||||
end)
|
||||
|
||||
a.it("All buffers set nomodified after save", function()
|
||||
tmpdir:create({ "a.txt" })
|
||||
a.it('All buffers set nomodified after save', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
a.util.scheduler()
|
||||
vim.cmd.edit({ args = { "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") } })
|
||||
vim.cmd.edit({ args = { 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') } })
|
||||
local first_dir = vim.api.nvim_get_current_buf()
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
test_util.feedkeys({ "dd", "itest/<esc>", "<CR>" }, 10)
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
test_util.feedkeys({ 'dd', 'itest/<esc>', '<CR>' }, 10)
|
||||
vim.wait(1000, function()
|
||||
return vim.bo.modifiable
|
||||
end, 10)
|
||||
test_util.feedkeys({ "p" }, 10)
|
||||
test_util.feedkeys({ 'p' }, 10)
|
||||
a.util.scheduler()
|
||||
oil.save({ confirm = false })
|
||||
vim.wait(1000, function()
|
||||
return vim.bo.modifiable
|
||||
end, 10)
|
||||
tmpdir:assert_fs({
|
||||
["test/a.txt"] = "a.txt",
|
||||
['test/a.txt'] = 'a.txt',
|
||||
})
|
||||
-- The first oil buffer should not be modified anymore
|
||||
assert.falsy(vim.bo[first_dir].modified)
|
||||
end)
|
||||
|
||||
a.it("refreshing buffer doesn't lose track of it", function()
|
||||
vim.cmd.edit({ args = { "." } })
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
vim.cmd.edit({ args = { '.' } })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
vim.cmd.edit({ bang = true })
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
assert.are.same({ bufnr }, require("oil.view").get_all_buffers())
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
assert.are.same({ bufnr }, require('oil.view').get_all_buffers())
|
||||
end)
|
||||
|
||||
a.it("can copy a file multiple times", function()
|
||||
a.it('can copy a file multiple times', function()
|
||||
test_util.actions.open({ tmpdir.path })
|
||||
vim.api.nvim_feedkeys("ifoo.txt", "x", true)
|
||||
vim.api.nvim_feedkeys('ifoo.txt', 'x', true)
|
||||
test_util.actions.save()
|
||||
vim.api.nvim_feedkeys("yyp$ciWbar.txt", "x", true)
|
||||
vim.api.nvim_feedkeys("yyp$ciWbaz.txt", "x", true)
|
||||
vim.api.nvim_feedkeys('yyp$ciWbar.txt', 'x', true)
|
||||
vim.api.nvim_feedkeys('yyp$ciWbaz.txt', 'x', true)
|
||||
test_util.actions.save()
|
||||
assert.are.same({ "bar.txt", "baz.txt", "foo.txt" }, test_util.parse_entries(0))
|
||||
assert.are.same({ 'bar.txt', 'baz.txt', 'foo.txt' }, test_util.parse_entries(0))
|
||||
tmpdir:assert_fs({
|
||||
["foo.txt"] = "",
|
||||
["bar.txt"] = "",
|
||||
["baz.txt"] = "",
|
||||
['foo.txt'] = '',
|
||||
['bar.txt'] = '',
|
||||
['baz.txt'] = '',
|
||||
})
|
||||
end)
|
||||
|
||||
-- https://github.com/stevearc/oil.nvim/issues/355
|
||||
a.it("can open files from floating window", function()
|
||||
tmpdir:create({ "a.txt" })
|
||||
a.it('can open files from floating window', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
a.util.scheduler()
|
||||
oil.open_float(tmpdir.path)
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
test_util.wait_for_autocmd({ 'User', pattern = 'OilEnter' })
|
||||
actions.select.callback()
|
||||
vim.wait(1000, function()
|
||||
return vim.fn.expand("%:t") == "a.txt"
|
||||
return vim.fn.expand('%:t') == 'a.txt'
|
||||
end, 10)
|
||||
assert.equals("a.txt", vim.fn.expand("%:t"))
|
||||
assert.equals('a.txt', vim.fn.expand('%:t'))
|
||||
end)
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue