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,8 +1,8 @@
|
|||
local cache = require("oil.cache")
|
||||
local config = require("oil.config")
|
||||
local files = require("oil.adapters.files")
|
||||
local fs = require("oil.fs")
|
||||
local util = require("oil.util")
|
||||
local cache = require('oil.cache')
|
||||
local config = require('oil.config')
|
||||
local files = require('oil.adapters.files')
|
||||
local fs = require('oil.fs')
|
||||
local util = require('oil.util')
|
||||
|
||||
local uv = vim.uv or vim.loop
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ end
|
|||
---Gets the location of the home trash dir, creating it if necessary
|
||||
---@return string
|
||||
local function get_trash_dir()
|
||||
local trash_dir = fs.join(assert(uv.os_homedir()), ".Trash")
|
||||
local trash_dir = fs.join(assert(uv.os_homedir()), '.Trash')
|
||||
touch_dir(trash_dir)
|
||||
return trash_dir
|
||||
end
|
||||
|
|
@ -25,7 +25,7 @@ end
|
|||
M.normalize_url = function(url, callback)
|
||||
local scheme, path = util.parse_url(url)
|
||||
assert(path)
|
||||
callback(scheme .. "/")
|
||||
callback(scheme .. '/')
|
||||
end
|
||||
|
||||
---@param url string
|
||||
|
|
@ -34,8 +34,8 @@ end
|
|||
M.get_entry_path = function(url, entry, cb)
|
||||
local trash_dir = get_trash_dir()
|
||||
local path = fs.join(trash_dir, entry.name)
|
||||
if entry.type == "directory" then
|
||||
path = "oil://" .. path
|
||||
if entry.type == 'directory' then
|
||||
path = 'oil://' .. path
|
||||
end
|
||||
cb(path)
|
||||
end
|
||||
|
|
@ -51,7 +51,7 @@ M.list = function(url, column_defs, cb)
|
|||
---@diagnostic disable-next-line: param-type-mismatch, discard-returns
|
||||
uv.fs_opendir(trash_dir, function(open_err, fd)
|
||||
if open_err then
|
||||
if open_err:match("^ENOENT: no such file or directory") then
|
||||
if open_err:match('^ENOENT: no such file or directory') then
|
||||
-- If the directory doesn't exist, treat the list as a success. We will be able to traverse
|
||||
-- and edit a not-yet-existing directory.
|
||||
return cb()
|
||||
|
|
@ -111,35 +111,35 @@ M.get_column = function(name)
|
|||
return nil
|
||||
end
|
||||
|
||||
M.supported_cross_adapter_actions = { files = "move" }
|
||||
M.supported_cross_adapter_actions = { files = 'move' }
|
||||
|
||||
---@param action oil.Action
|
||||
---@return string
|
||||
M.render_action = function(action)
|
||||
if action.type == "create" then
|
||||
return string.format("CREATE %s", action.url)
|
||||
elseif action.type == "delete" then
|
||||
return string.format(" PURGE %s", action.url)
|
||||
elseif action.type == "move" then
|
||||
if action.type == 'create' then
|
||||
return string.format('CREATE %s', action.url)
|
||||
elseif action.type == 'delete' then
|
||||
return string.format(' PURGE %s', action.url)
|
||||
elseif action.type == 'move' then
|
||||
local src_adapter = assert(config.get_adapter_by_scheme(action.src_url))
|
||||
local dest_adapter = assert(config.get_adapter_by_scheme(action.dest_url))
|
||||
if src_adapter.name == "files" then
|
||||
if src_adapter.name == 'files' then
|
||||
local _, path = util.parse_url(action.src_url)
|
||||
assert(path)
|
||||
local short_path = files.to_short_os_path(path, action.entry_type)
|
||||
return string.format(" TRASH %s", short_path)
|
||||
elseif dest_adapter.name == "files" then
|
||||
return string.format(' TRASH %s', short_path)
|
||||
elseif dest_adapter.name == 'files' then
|
||||
local _, path = util.parse_url(action.dest_url)
|
||||
assert(path)
|
||||
local short_path = files.to_short_os_path(path, action.entry_type)
|
||||
return string.format("RESTORE %s", short_path)
|
||||
return string.format('RESTORE %s', short_path)
|
||||
else
|
||||
return string.format(" %s %s -> %s", action.type:upper(), action.src_url, action.dest_url)
|
||||
return string.format(' %s %s -> %s', action.type:upper(), action.src_url, action.dest_url)
|
||||
end
|
||||
elseif action.type == "copy" then
|
||||
return string.format(" %s %s -> %s", action.type:upper(), action.src_url, action.dest_url)
|
||||
elseif action.type == 'copy' then
|
||||
return string.format(' %s %s -> %s', action.type:upper(), action.src_url, action.dest_url)
|
||||
else
|
||||
error("Bad action type")
|
||||
error('Bad action type')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -147,20 +147,20 @@ end
|
|||
---@param cb fun(err: nil|string)
|
||||
M.perform_action = function(action, cb)
|
||||
local trash_dir = get_trash_dir()
|
||||
if action.type == "create" then
|
||||
if action.type == 'create' then
|
||||
local _, path = util.parse_url(action.url)
|
||||
assert(path)
|
||||
path = trash_dir .. path
|
||||
if action.entry_type == "directory" then
|
||||
if action.entry_type == 'directory' then
|
||||
uv.fs_mkdir(path, 493, function(err)
|
||||
-- Ignore if the directory already exists
|
||||
if not err or err:match("^EEXIST:") then
|
||||
if not err or err:match('^EEXIST:') then
|
||||
cb()
|
||||
else
|
||||
cb(err)
|
||||
end
|
||||
end) -- 0755
|
||||
elseif action.entry_type == "link" and action.link then
|
||||
elseif action.entry_type == 'link' and action.link then
|
||||
local flags = nil
|
||||
local target = fs.posix_to_os_path(action.link)
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
|
|
@ -168,33 +168,33 @@ M.perform_action = function(action, cb)
|
|||
else
|
||||
fs.touch(path, config.new_file_mode, cb)
|
||||
end
|
||||
elseif action.type == "delete" then
|
||||
elseif action.type == 'delete' then
|
||||
local _, path = util.parse_url(action.url)
|
||||
assert(path)
|
||||
local fullpath = trash_dir .. path
|
||||
fs.recursive_delete(action.entry_type, fullpath, cb)
|
||||
elseif action.type == "move" or action.type == "copy" then
|
||||
elseif action.type == 'move' or action.type == 'copy' then
|
||||
local src_adapter = assert(config.get_adapter_by_scheme(action.src_url))
|
||||
local dest_adapter = assert(config.get_adapter_by_scheme(action.dest_url))
|
||||
local _, src_path = util.parse_url(action.src_url)
|
||||
local _, dest_path = util.parse_url(action.dest_url)
|
||||
assert(src_path and dest_path)
|
||||
if src_adapter.name == "files" then
|
||||
if src_adapter.name == 'files' then
|
||||
dest_path = trash_dir .. dest_path
|
||||
elseif dest_adapter.name == "files" then
|
||||
elseif dest_adapter.name == 'files' then
|
||||
src_path = trash_dir .. src_path
|
||||
else
|
||||
dest_path = trash_dir .. dest_path
|
||||
src_path = trash_dir .. src_path
|
||||
end
|
||||
|
||||
if action.type == "move" then
|
||||
if action.type == 'move' then
|
||||
fs.recursive_move(action.entry_type, src_path, dest_path, cb)
|
||||
else
|
||||
fs.recursive_copy(action.entry_type, src_path, dest_path, cb)
|
||||
end
|
||||
else
|
||||
cb(string.format("Bad action type: %s", action.type))
|
||||
cb(string.format('Bad action type: %s', action.type))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -212,8 +212,8 @@ M.delete_to_trash = function(path, cb)
|
|||
end
|
||||
assert(src_stat)
|
||||
if uv.fs_lstat(dest) then
|
||||
local date_str = vim.fn.strftime(" %Y-%m-%dT%H:%M:%S")
|
||||
local name_pieces = vim.split(basename, ".", { plain = true })
|
||||
local date_str = vim.fn.strftime(' %Y-%m-%dT%H:%M:%S')
|
||||
local name_pieces = vim.split(basename, '.', { plain = true })
|
||||
if #name_pieces > 1 then
|
||||
table.insert(name_pieces, #name_pieces - 1, date_str)
|
||||
basename = table.concat(name_pieces)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue