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 constants = require("oil.constants")
|
||||
local shell = require("oil.shell")
|
||||
local util = require("oil.util")
|
||||
local cache = require('oil.cache')
|
||||
local config = require('oil.config')
|
||||
local constants = require('oil.constants')
|
||||
local shell = require('oil.shell')
|
||||
local util = require('oil.util')
|
||||
|
||||
local M = {}
|
||||
|
||||
|
|
@ -13,11 +13,11 @@ local FIELD_META = constants.FIELD_META
|
|||
---@return oil.EntryType
|
||||
---@return table Metadata for entry
|
||||
local function parse_ls_line_bucket(line)
|
||||
local date, name = line:match("^(%d+%-%d+%-%d+%s%d+:%d+:%d+)%s+(.*)$")
|
||||
local date, name = line:match('^(%d+%-%d+%-%d+%s%d+:%d+:%d+)%s+(.*)$')
|
||||
if not date or not name then
|
||||
error(string.format("Could not parse '%s'", line))
|
||||
end
|
||||
local type = "directory"
|
||||
local type = 'directory'
|
||||
local meta = { date = date }
|
||||
return name, type, meta
|
||||
end
|
||||
|
|
@ -27,18 +27,18 @@ end
|
|||
---@return oil.EntryType
|
||||
---@return table Metadata for entry
|
||||
local function parse_ls_line_file(line)
|
||||
local name = line:match("^%s+PRE%s+(.*)/$")
|
||||
local type = "directory"
|
||||
local name = line:match('^%s+PRE%s+(.*)/$')
|
||||
local type = 'directory'
|
||||
local meta = {}
|
||||
if name then
|
||||
return name, type, meta
|
||||
end
|
||||
local date, size
|
||||
date, size, name = line:match("^(%d+%-%d+%-%d+%s%d+:%d+:%d+)%s+(%d+)%s+(.*)$")
|
||||
date, size, name = line:match('^(%d+%-%d+%-%d+%s%d+:%d+:%d+)%s+(%d+)%s+(.*)$')
|
||||
if not name then
|
||||
error(string.format("Could not parse '%s'", line))
|
||||
end
|
||||
type = "file"
|
||||
type = 'file'
|
||||
meta = { date = date, size = tonumber(size) }
|
||||
return name, type, meta
|
||||
end
|
||||
|
|
@ -46,7 +46,7 @@ end
|
|||
---@param cmd string[] cmd and flags
|
||||
---@return string[] Shell command to run
|
||||
local function create_s3_command(cmd)
|
||||
local full_cmd = vim.list_extend({ "aws", "s3" }, cmd)
|
||||
local full_cmd = vim.list_extend({ 'aws', 's3' }, cmd)
|
||||
return vim.list_extend(full_cmd, config.extra_s3_args)
|
||||
end
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ end
|
|||
---@param path string
|
||||
---@param callback fun(err?: string, entries?: oil.InternalEntry[], fetch_more?: fun())
|
||||
function M.list_dir(url, path, callback)
|
||||
local cmd = create_s3_command({ "ls", path, "--color=off", "--no-cli-pager" })
|
||||
local cmd = create_s3_command({ 'ls', path, '--color=off', '--no-cli-pager' })
|
||||
shell.run(cmd, function(err, lines)
|
||||
if err then
|
||||
return callback(err)
|
||||
|
|
@ -63,13 +63,13 @@ function M.list_dir(url, path, callback)
|
|||
local cache_entries = {}
|
||||
local url_path, _
|
||||
_, url_path = util.parse_url(url)
|
||||
local is_top_level = url_path == nil or url_path:match("/") == nil
|
||||
local is_top_level = url_path == nil or url_path:match('/') == nil
|
||||
local parse_ls_line = is_top_level and parse_ls_line_bucket or parse_ls_line_file
|
||||
for _, line in ipairs(lines) do
|
||||
if line ~= "" then
|
||||
if line ~= '' then
|
||||
local name, type, meta = parse_ls_line(line)
|
||||
-- in s3 '-' can be used to create an "empty folder"
|
||||
if name ~= "-" then
|
||||
if name ~= '-' then
|
||||
local cache_entry = cache.create_entry(url, name, type)
|
||||
table.insert(cache_entries, cache_entry)
|
||||
cache_entry[FIELD_META] = meta
|
||||
|
|
@ -85,8 +85,8 @@ end
|
|||
---@param callback fun(err: nil|string)
|
||||
function M.touch(path, callback)
|
||||
-- here "-" means that we copy from stdin
|
||||
local cmd = create_s3_command({ "cp", "-", path })
|
||||
shell.run(cmd, { stdin = "null" }, callback)
|
||||
local cmd = create_s3_command({ 'cp', '-', path })
|
||||
shell.run(cmd, { stdin = 'null' }, callback)
|
||||
end
|
||||
|
||||
--- Remove files
|
||||
|
|
@ -94,9 +94,9 @@ end
|
|||
---@param is_folder boolean
|
||||
---@param callback fun(err: nil|string)
|
||||
function M.rm(path, is_folder, callback)
|
||||
local main_cmd = { "rm", path }
|
||||
local main_cmd = { 'rm', path }
|
||||
if is_folder then
|
||||
table.insert(main_cmd, "--recursive")
|
||||
table.insert(main_cmd, '--recursive')
|
||||
end
|
||||
local cmd = create_s3_command(main_cmd)
|
||||
shell.run(cmd, callback)
|
||||
|
|
@ -106,7 +106,7 @@ end
|
|||
---@param bucket string
|
||||
---@param callback fun(err: nil|string)
|
||||
function M.rb(bucket, callback)
|
||||
local cmd = create_s3_command({ "rb", bucket })
|
||||
local cmd = create_s3_command({ 'rb', bucket })
|
||||
shell.run(cmd, callback)
|
||||
end
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ end
|
|||
---@param bucket string
|
||||
---@param callback fun(err: nil|string)
|
||||
function M.mb(bucket, callback)
|
||||
local cmd = create_s3_command({ "mb", bucket })
|
||||
local cmd = create_s3_command({ 'mb', bucket })
|
||||
shell.run(cmd, callback)
|
||||
end
|
||||
|
||||
|
|
@ -124,9 +124,9 @@ end
|
|||
---@param is_folder boolean
|
||||
---@param callback fun(err: nil|string)
|
||||
function M.mv(src, dest, is_folder, callback)
|
||||
local main_cmd = { "mv", src, dest }
|
||||
local main_cmd = { 'mv', src, dest }
|
||||
if is_folder then
|
||||
table.insert(main_cmd, "--recursive")
|
||||
table.insert(main_cmd, '--recursive')
|
||||
end
|
||||
local cmd = create_s3_command(main_cmd)
|
||||
shell.run(cmd, callback)
|
||||
|
|
@ -138,9 +138,9 @@ end
|
|||
---@param is_folder boolean
|
||||
---@param callback fun(err: nil|string)
|
||||
function M.cp(src, dest, is_folder, callback)
|
||||
local main_cmd = { "cp", src, dest }
|
||||
local main_cmd = { 'cp', src, dest }
|
||||
if is_folder then
|
||||
table.insert(main_cmd, "--recursive")
|
||||
table.insert(main_cmd, '--recursive')
|
||||
end
|
||||
local cmd = create_s3_command(main_cmd)
|
||||
shell.run(cmd, callback)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue