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,9 +1,9 @@
|
|||
require("plenary.async").tests.add_to_env()
|
||||
local TmpDir = require("tests.tmpdir")
|
||||
local files = require("oil.adapters.files")
|
||||
local test_util = require("tests.test_util")
|
||||
require('plenary.async').tests.add_to_env()
|
||||
local TmpDir = require('tests.tmpdir')
|
||||
local files = require('oil.adapters.files')
|
||||
local test_util = require('tests.test_util')
|
||||
|
||||
a.describe("files adapter", function()
|
||||
a.describe('files adapter', function()
|
||||
local tmpdir
|
||||
a.before_each(function()
|
||||
tmpdir = TmpDir.new()
|
||||
|
|
@ -15,159 +15,159 @@ a.describe("files adapter", function()
|
|||
test_util.reset_editor()
|
||||
end)
|
||||
|
||||
a.it("tmpdir creates files and asserts they exist", function()
|
||||
tmpdir:create({ "a.txt", "foo/b.txt", "foo/c.txt", "bar/" })
|
||||
a.it('tmpdir creates files and asserts they exist', function()
|
||||
tmpdir:create({ 'a.txt', 'foo/b.txt', 'foo/c.txt', 'bar/' })
|
||||
tmpdir:assert_fs({
|
||||
["a.txt"] = "a.txt",
|
||||
["foo/b.txt"] = "foo/b.txt",
|
||||
["foo/c.txt"] = "foo/c.txt",
|
||||
["bar/"] = true,
|
||||
['a.txt'] = 'a.txt',
|
||||
['foo/b.txt'] = 'foo/b.txt',
|
||||
['foo/c.txt'] = 'foo/c.txt',
|
||||
['bar/'] = true,
|
||||
})
|
||||
end)
|
||||
|
||||
a.it("Creates files", function()
|
||||
a.it('Creates files', function()
|
||||
local err = a.wrap(files.perform_action, 2)({
|
||||
url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "a.txt",
|
||||
entry_type = "file",
|
||||
type = "create",
|
||||
url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt',
|
||||
entry_type = 'file',
|
||||
type = 'create',
|
||||
})
|
||||
assert.is_nil(err)
|
||||
tmpdir:assert_fs({
|
||||
["a.txt"] = "",
|
||||
['a.txt'] = '',
|
||||
})
|
||||
end)
|
||||
|
||||
a.it("Creates directories", function()
|
||||
a.it('Creates directories', function()
|
||||
local err = a.wrap(files.perform_action, 2)({
|
||||
url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "a",
|
||||
entry_type = "directory",
|
||||
type = "create",
|
||||
url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a',
|
||||
entry_type = 'directory',
|
||||
type = 'create',
|
||||
})
|
||||
assert.is_nil(err)
|
||||
tmpdir:assert_fs({
|
||||
["a/"] = true,
|
||||
['a/'] = true,
|
||||
})
|
||||
end)
|
||||
|
||||
a.it("Deletes files", function()
|
||||
tmpdir:create({ "a.txt" })
|
||||
a.it('Deletes files', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
a.util.scheduler()
|
||||
local url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "a.txt"
|
||||
local url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||
local err = a.wrap(files.perform_action, 2)({
|
||||
url = url,
|
||||
entry_type = "file",
|
||||
type = "delete",
|
||||
entry_type = 'file',
|
||||
type = 'delete',
|
||||
})
|
||||
assert.is_nil(err)
|
||||
tmpdir:assert_fs({})
|
||||
end)
|
||||
|
||||
a.it("Deletes directories", function()
|
||||
tmpdir:create({ "a/" })
|
||||
local url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "a"
|
||||
a.it('Deletes directories', function()
|
||||
tmpdir:create({ 'a/' })
|
||||
local url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||
local err = a.wrap(files.perform_action, 2)({
|
||||
url = url,
|
||||
entry_type = "directory",
|
||||
type = "delete",
|
||||
entry_type = 'directory',
|
||||
type = 'delete',
|
||||
})
|
||||
assert.is_nil(err)
|
||||
tmpdir:assert_fs({})
|
||||
end)
|
||||
|
||||
a.it("Moves files", function()
|
||||
tmpdir:create({ "a.txt" })
|
||||
a.it('Moves files', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
a.util.scheduler()
|
||||
local src_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "a.txt"
|
||||
local dest_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "b.txt"
|
||||
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
||||
local err = a.wrap(files.perform_action, 2)({
|
||||
src_url = src_url,
|
||||
dest_url = dest_url,
|
||||
entry_type = "file",
|
||||
type = "move",
|
||||
entry_type = 'file',
|
||||
type = 'move',
|
||||
})
|
||||
assert.is_nil(err)
|
||||
tmpdir:assert_fs({
|
||||
["b.txt"] = "a.txt",
|
||||
['b.txt'] = 'a.txt',
|
||||
})
|
||||
end)
|
||||
|
||||
a.it("Moves directories", function()
|
||||
tmpdir:create({ "a/a.txt" })
|
||||
a.it('Moves directories', function()
|
||||
tmpdir:create({ 'a/a.txt' })
|
||||
a.util.scheduler()
|
||||
local src_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "a"
|
||||
local dest_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "b"
|
||||
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b'
|
||||
local err = a.wrap(files.perform_action, 2)({
|
||||
src_url = src_url,
|
||||
dest_url = dest_url,
|
||||
entry_type = "directory",
|
||||
type = "move",
|
||||
entry_type = 'directory',
|
||||
type = 'move',
|
||||
})
|
||||
assert.is_nil(err)
|
||||
tmpdir:assert_fs({
|
||||
["b/a.txt"] = "a/a.txt",
|
||||
["b/"] = true,
|
||||
['b/a.txt'] = 'a/a.txt',
|
||||
['b/'] = true,
|
||||
})
|
||||
end)
|
||||
|
||||
a.it("Copies files", function()
|
||||
tmpdir:create({ "a.txt" })
|
||||
a.it('Copies files', function()
|
||||
tmpdir:create({ 'a.txt' })
|
||||
a.util.scheduler()
|
||||
local src_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "a.txt"
|
||||
local dest_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "b.txt"
|
||||
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a.txt'
|
||||
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b.txt'
|
||||
local err = a.wrap(files.perform_action, 2)({
|
||||
src_url = src_url,
|
||||
dest_url = dest_url,
|
||||
entry_type = "file",
|
||||
type = "copy",
|
||||
entry_type = 'file',
|
||||
type = 'copy',
|
||||
})
|
||||
assert.is_nil(err)
|
||||
tmpdir:assert_fs({
|
||||
["a.txt"] = "a.txt",
|
||||
["b.txt"] = "a.txt",
|
||||
['a.txt'] = 'a.txt',
|
||||
['b.txt'] = 'a.txt',
|
||||
})
|
||||
end)
|
||||
|
||||
a.it("Recursively copies directories", function()
|
||||
tmpdir:create({ "a/a.txt" })
|
||||
a.it('Recursively copies directories', function()
|
||||
tmpdir:create({ 'a/a.txt' })
|
||||
a.util.scheduler()
|
||||
local src_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "a"
|
||||
local dest_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "b"
|
||||
local src_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'a'
|
||||
local dest_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'b'
|
||||
local err = a.wrap(files.perform_action, 2)({
|
||||
src_url = src_url,
|
||||
dest_url = dest_url,
|
||||
entry_type = "directory",
|
||||
type = "copy",
|
||||
entry_type = 'directory',
|
||||
type = 'copy',
|
||||
})
|
||||
assert.is_nil(err)
|
||||
tmpdir:assert_fs({
|
||||
["b/a.txt"] = "a/a.txt",
|
||||
["b/"] = true,
|
||||
["a/a.txt"] = "a/a.txt",
|
||||
["a/"] = true,
|
||||
['b/a.txt'] = 'a/a.txt',
|
||||
['b/'] = true,
|
||||
['a/a.txt'] = 'a/a.txt',
|
||||
['a/'] = true,
|
||||
})
|
||||
end)
|
||||
|
||||
a.it("Editing a new oil://path/ creates an oil buffer", function()
|
||||
local tmpdir_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "/"
|
||||
a.it('Editing a new oil://path/ creates an oil buffer', function()
|
||||
local tmpdir_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. '/'
|
||||
vim.cmd.edit({ args = { tmpdir_url } })
|
||||
test_util.wait_oil_ready()
|
||||
local new_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "newdir"
|
||||
local new_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'newdir'
|
||||
vim.cmd.edit({ args = { new_url } })
|
||||
test_util.wait_oil_ready()
|
||||
assert.equals("oil", vim.bo.filetype)
|
||||
assert.equals('oil', vim.bo.filetype)
|
||||
-- The normalization will add a '/'
|
||||
assert.equals(new_url .. "/", vim.api.nvim_buf_get_name(0))
|
||||
assert.equals(new_url .. '/', vim.api.nvim_buf_get_name(0))
|
||||
end)
|
||||
|
||||
a.it("Editing a new oil://file.rb creates a normal buffer", function()
|
||||
local tmpdir_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "/"
|
||||
a.it('Editing a new oil://file.rb creates a normal buffer', function()
|
||||
local tmpdir_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. '/'
|
||||
vim.cmd.edit({ args = { tmpdir_url } })
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
local new_url = "oil://" .. vim.fn.fnamemodify(tmpdir.path, ":p") .. "file.rb"
|
||||
test_util.wait_for_autocmd('BufReadPost')
|
||||
local new_url = 'oil://' .. vim.fn.fnamemodify(tmpdir.path, ':p') .. 'file.rb'
|
||||
vim.cmd.edit({ args = { new_url } })
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
assert.equals("ruby", vim.bo.filetype)
|
||||
assert.equals(vim.fn.fnamemodify(tmpdir.path, ":p") .. "file.rb", vim.api.nvim_buf_get_name(0))
|
||||
assert.equals(tmpdir.path .. "/file.rb", vim.fn.bufname())
|
||||
test_util.wait_for_autocmd('BufReadPost')
|
||||
assert.equals('ruby', vim.bo.filetype)
|
||||
assert.equals(vim.fn.fnamemodify(tmpdir.path, ':p') .. 'file.rb', vim.api.nvim_buf_get_name(0))
|
||||
assert.equals(tmpdir.path .. '/file.rb', vim.fn.bufname())
|
||||
end)
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue