Update generated neovim config
This commit is contained in:
@ -0,0 +1,67 @@
|
||||
-- Test possibility of checking out and initializing 'mini.nvim'
|
||||
-- Possible problems:
|
||||
-- - Long file names (particularly from reference screenshots).
|
||||
-- - Duplicating file names in case-insensitive OS (particularly from reference
|
||||
-- screenshots of parametrized test cases).
|
||||
|
||||
-- Add project root as full path to runtime path (in order to be able to
|
||||
-- `require()`) modules from this module
|
||||
vim.cmd([[let &rtp.=','.getcwd()]])
|
||||
|
||||
--stylua: ignore
|
||||
local test_actions = {
|
||||
['ai'] = function() require('mini.ai').setup() end,
|
||||
['align'] = function() require('mini.align').setup() end,
|
||||
['animate'] = function() require('mini.animate').setup() end,
|
||||
['base16'] = function()
|
||||
local palette = require('mini.base16').mini_palette('#000000', '#ffffff', 50)
|
||||
require('mini.base16').setup({ palette = palette })
|
||||
end,
|
||||
['basics'] = function() require('mini.basics').setup() end,
|
||||
['bracketed'] = function() require('mini.bracketed').setup() end,
|
||||
['bufremove'] = function() require('mini.bufremove').setup() end,
|
||||
['clue'] = function() require('mini.clue').setup() end,
|
||||
['colors'] = function() require('mini.colors').setup() end,
|
||||
['comment'] = function() require('mini.comment').setup() end,
|
||||
['completion'] = function() require('mini.completion').setup() end,
|
||||
['cursorword'] = function() require('mini.cursorword').setup() end,
|
||||
['deps'] = function() require('mini.deps').setup() end,
|
||||
['diff'] = function() require('mini.diff').setup() end,
|
||||
['doc'] = function() require('mini.doc').setup() end,
|
||||
['extra'] = function() require('mini.extra').setup() end,
|
||||
['files'] = function() require('mini.files').setup() end,
|
||||
['fuzzy'] = function() require('mini.fuzzy').setup() end,
|
||||
['git'] = function() require('mini.git').setup() end,
|
||||
['hipatterns'] = function() require('mini.hipatterns').setup() end,
|
||||
['hues'] = function() require('mini.hues').setup({ background = '#000000', foreground = '#ffffff' }) end,
|
||||
['icons'] = function() require('mini.icons').setup() end,
|
||||
['indentscope'] = function() require('mini.indentscope').setup() end,
|
||||
['jump'] = function() require('mini.jump').setup() end,
|
||||
['jump2d'] = function() require('mini.jump2d').setup() end,
|
||||
['map'] = function() require('mini.map').setup() end,
|
||||
['misc'] = function() require('mini.misc').setup() end,
|
||||
['move'] = function() require('mini.move').setup() end,
|
||||
['notify'] = function() require('mini.notify').setup() end,
|
||||
['operators'] = function() require('mini.operators').setup() end,
|
||||
['pairs'] = function() require('mini.pairs').setup() end,
|
||||
['pick'] = function() require('mini.pick').setup() end,
|
||||
['sessions'] = function() require('mini.sessions').setup({ directory = '' }) end,
|
||||
['splitjoin'] = function() require('mini.splitjoin').setup() end,
|
||||
['starter'] = function() require('mini.starter').setup() end,
|
||||
['statusline'] = function() require('mini.statusline').setup() end,
|
||||
['surround'] = function() require('mini.surround').setup() end,
|
||||
['tabline'] = function() require('mini.tabline').setup() end,
|
||||
['test'] = function() require('mini.test').setup() end,
|
||||
['trailspace'] = function() require('mini.trailspace').setup() end,
|
||||
['visits'] = function() require('mini.visits').setup() end,
|
||||
}
|
||||
|
||||
for module, test_fun in pairs(test_actions) do
|
||||
local ok, _ = pcall(test_fun)
|
||||
if not ok then
|
||||
io.stdout:write('There is a problem with following module: mini.' .. module .. '\n')
|
||||
vim.cmd('cquit')
|
||||
end
|
||||
end
|
||||
|
||||
vim.cmd('qall!')
|
||||
9
config/neovim/store/lazy-plugins/mini.nvim/scripts/dual_log.sh
Executable file
9
config/neovim/store/lazy-plugins/mini.nvim/scripts/dual_log.sh
Executable file
@ -0,0 +1,9 @@
|
||||
# Check standalone repos result
|
||||
local_repos="$( ls -d dual/repos/*/ )"
|
||||
|
||||
for repo in $local_repos; do
|
||||
printf "\n\033[1m$( basename $repo )\033[0m\n"
|
||||
cd $repo > /dev/null
|
||||
git log origin/main..main --abbrev-commit --format=oneline
|
||||
cd - > /dev/null
|
||||
done
|
||||
15
config/neovim/store/lazy-plugins/mini.nvim/scripts/dual_push.sh
Executable file
15
config/neovim/store/lazy-plugins/mini.nvim/scripts/dual_push.sh
Executable file
@ -0,0 +1,15 @@
|
||||
# Push standalone repos result
|
||||
local_repos="$( ls -d dual/repos/*/ )"
|
||||
|
||||
for repo in $local_repos; do
|
||||
printf "\n\033[1mPushing $( basename $repo )\033[0m\n"
|
||||
cd $repo > /dev/null
|
||||
# Push only if there is something to push (saves time)
|
||||
if [ $( git rev-parse main ) != $( git rev-parse origin/main ) ]
|
||||
then
|
||||
git push origin main
|
||||
fi
|
||||
cd - > /dev/null
|
||||
done
|
||||
|
||||
echo ''
|
||||
43
config/neovim/store/lazy-plugins/mini.nvim/scripts/dual_release.sh
Executable file
43
config/neovim/store/lazy-plugins/mini.nvim/scripts/dual_release.sh
Executable file
@ -0,0 +1,43 @@
|
||||
# Make release from current commits (sync repos before doing this)
|
||||
local_repos="$( ls -d dual/repos/*/ )"
|
||||
|
||||
# Register tag name and message as script arguments
|
||||
if [ -z "$1" ] || [ -z "$2" ]
|
||||
then
|
||||
printf "Supply tag name and message as script arguments\n"
|
||||
exit 2
|
||||
fi
|
||||
tag_name=$1
|
||||
tag_message=$2
|
||||
|
||||
for repo in $local_repos; do
|
||||
printf "\n\033[1mReleasing $( basename $repo )\033[0m\n"
|
||||
cd $repo > /dev/null
|
||||
|
||||
# Ensure that all history is downloaded to allow proper pull of `stable`
|
||||
printf "\033[4mPulling all \`main\` history\033[0m\n"
|
||||
git checkout main
|
||||
git pull --unshallow
|
||||
echo ''
|
||||
|
||||
# Ensure branch on latest `main`
|
||||
printf "\033[4mMaking \`stable\` point to latest \`main\`\033[0m\n"
|
||||
git checkout -B stable
|
||||
git checkout main
|
||||
echo ''
|
||||
|
||||
# Create tag
|
||||
printf "\033[4mCreating tag\033[0m\n"
|
||||
git tag -a "$tag_name" -m "$tag_message"
|
||||
echo ''
|
||||
|
||||
# Push
|
||||
printf "\033[4mPushing\033[0m\n"
|
||||
git push origin $tag_name
|
||||
git push origin stable
|
||||
echo ''
|
||||
|
||||
cd - > /dev/null
|
||||
done
|
||||
|
||||
echo ''
|
||||
107
config/neovim/store/lazy-plugins/mini.nvim/scripts/dual_sync.sh
Executable file
107
config/neovim/store/lazy-plugins/mini.nvim/scripts/dual_sync.sh
Executable file
@ -0,0 +1,107 @@
|
||||
# Perform local sync of standalone repositories
|
||||
repos_dir=dual/repos
|
||||
patches_dir=dual/patches
|
||||
|
||||
mkdir -p $repos_dir
|
||||
mkdir -p $patches_dir
|
||||
|
||||
sync_module () {
|
||||
# First argument is a string with module name. Others - extra paths to track
|
||||
# for module.
|
||||
module=$1
|
||||
shift
|
||||
|
||||
repo="$( realpath $repos_dir/mini.$module )"
|
||||
patch="$( realpath $patches_dir/mini.$module.patch )"
|
||||
|
||||
printf "\n\033[1mmini.$module\033[0m\n"
|
||||
|
||||
# Possibly pull repository
|
||||
if [[ ! -d $repo ]]
|
||||
then
|
||||
printf "Pulling\n"
|
||||
# Handle 'mini.git' differently because GitHub repo is named 'mini-git'
|
||||
# (".git" suffix is not allowed as repo name on GitHub)
|
||||
if [ $module = "git" ]; then github_repo="mini-git"; else github_repo="mini.$module"; fi
|
||||
git clone --filter=blob:none https://github.com/echasnovski/$github_repo.git $repo
|
||||
else
|
||||
printf "No pulling (already present)\n"
|
||||
fi
|
||||
|
||||
# Make patch with commits from 'sync' branch to current HEAD which affect
|
||||
# files related to the module
|
||||
printf "Making patch\n"
|
||||
git format-patch sync..HEAD --output $patch -- \
|
||||
lua/mini/$module.lua \
|
||||
doc/mini-$module.txt \
|
||||
readmes/mini-$module.md \
|
||||
LICENSE \
|
||||
$@
|
||||
|
||||
# Do nothing if patch is empty
|
||||
if [[ ! -s $patch ]]
|
||||
then
|
||||
rm $patch
|
||||
printf "Patch is empty\n"
|
||||
return
|
||||
fi
|
||||
|
||||
# Tweak patch:
|
||||
# - Move 'readmes/mini-xxx.md' to 'README.md'. This should modify only patch
|
||||
# metadata, and not text (assuming it uses 'readmes/mini-xxx.md' on
|
||||
# purpose; as in "use [this link](https://.../readmes/mini-xxx.md)").
|
||||
sed -i "s/readmes\/mini-$module\.md\([^)]\)/README.md\\1/" $patch
|
||||
sed -i "s/readmes\/mini-$module\.md$/README.md/" $patch
|
||||
# - Move all known relative links one step higher (and hope that it doesn't
|
||||
# occur anywhere else in patch). NOTE: There can be other relative links
|
||||
# which should be corrected manually
|
||||
sed -i "s/\[help file\](\.\.\//[help file](/" $patch
|
||||
|
||||
# Apply patch
|
||||
printf "Applying patch\n"
|
||||
cd $repo
|
||||
git am $patch
|
||||
cd - > /dev/null
|
||||
}
|
||||
|
||||
sync_module "ai"
|
||||
sync_module "align"
|
||||
sync_module "animate"
|
||||
sync_module "base16" colors/minischeme.lua colors/minicyan.lua
|
||||
sync_module "basics"
|
||||
sync_module "bracketed"
|
||||
sync_module "bufremove"
|
||||
sync_module "clue"
|
||||
sync_module "colors"
|
||||
sync_module "comment"
|
||||
sync_module "completion"
|
||||
sync_module "cursorword"
|
||||
sync_module "deps" scripts/init-deps-example.lua
|
||||
sync_module "diff"
|
||||
sync_module "doc"
|
||||
sync_module "extra"
|
||||
sync_module "files"
|
||||
sync_module "fuzzy"
|
||||
sync_module "git"
|
||||
sync_module "hipatterns"
|
||||
sync_module "hues" colors/randomhue.lua
|
||||
sync_module "icons"
|
||||
sync_module "indentscope"
|
||||
sync_module "jump"
|
||||
sync_module "jump2d"
|
||||
sync_module "map"
|
||||
sync_module "misc"
|
||||
sync_module "move"
|
||||
sync_module "notify"
|
||||
sync_module "operators"
|
||||
sync_module "pairs"
|
||||
sync_module "pick"
|
||||
sync_module "sessions"
|
||||
sync_module "splitjoin"
|
||||
sync_module "starter"
|
||||
sync_module "statusline"
|
||||
sync_module "surround"
|
||||
sync_module "tabline"
|
||||
sync_module "test"
|
||||
sync_module "trailspace"
|
||||
sync_module "visits"
|
||||
@ -0,0 +1,62 @@
|
||||
-- Clone 'mini.nvim' manually in a way that it gets managed by 'mini.deps'
|
||||
local path_package = vim.fn.stdpath('data') .. '/site/'
|
||||
local mini_path = path_package .. 'pack/deps/start/mini.nvim'
|
||||
if not vim.loop.fs_stat(mini_path) then
|
||||
vim.cmd('echo "Installing `mini.nvim`" | redraw')
|
||||
local clone_cmd = { 'git', 'clone', '--filter=blob:none', 'https://github.com/echasnovski/mini.nvim', mini_path }
|
||||
vim.fn.system(clone_cmd)
|
||||
vim.cmd('packadd mini.nvim | helptags ALL')
|
||||
vim.cmd('echo "Installed `mini.nvim`" | redraw')
|
||||
end
|
||||
|
||||
-- Set up 'mini.deps' (customize to your liking)
|
||||
require('mini.deps').setup({ path = { package = path_package } })
|
||||
|
||||
-- Use 'mini.deps'. `now()` and `later()` are helpers for a safe two-stage
|
||||
-- startup and are optional.
|
||||
local add, now, later = MiniDeps.add, MiniDeps.now, MiniDeps.later
|
||||
|
||||
-- Safely execute immediately
|
||||
now(function()
|
||||
vim.o.termguicolors = true
|
||||
vim.cmd('colorscheme randomhue')
|
||||
end)
|
||||
now(function()
|
||||
require('mini.notify').setup()
|
||||
vim.notify = require('mini.notify').make_notify()
|
||||
end)
|
||||
now(function() require('mini.icons').setup() end)
|
||||
now(function() require('mini.tabline').setup() end)
|
||||
now(function() require('mini.statusline').setup() end)
|
||||
|
||||
-- Safely execute later
|
||||
later(function() require('mini.ai').setup() end)
|
||||
later(function() require('mini.comment').setup() end)
|
||||
later(function() require('mini.pick').setup() end)
|
||||
later(function() require('mini.surround').setup() end)
|
||||
|
||||
now(function()
|
||||
-- Use other plugins with `add()`. It ensures plugin is available in current
|
||||
-- session (installs if absent)
|
||||
add({
|
||||
source = 'neovim/nvim-lspconfig',
|
||||
-- Supply dependencies near target plugin
|
||||
depends = { 'williamboman/mason.nvim' },
|
||||
})
|
||||
end)
|
||||
|
||||
later(function()
|
||||
add({
|
||||
source = 'nvim-treesitter/nvim-treesitter',
|
||||
-- Use 'master' while monitoring updates in 'main'
|
||||
checkout = 'master',
|
||||
monitor = 'main',
|
||||
-- Perform action after every checkout
|
||||
hooks = { post_checkout = function() vim.cmd('TSUpdate') end },
|
||||
})
|
||||
-- Possible to immediately execute code which depends on the added plugin
|
||||
require('nvim-treesitter.configs').setup({
|
||||
ensure_installed = { 'lua', 'vimdoc' },
|
||||
highlight = { enable = true },
|
||||
})
|
||||
end)
|
||||
18
config/neovim/store/lazy-plugins/mini.nvim/scripts/lintcommit-ci.sh
Executable file
18
config/neovim/store/lazy-plugins/mini.nvim/scripts/lintcommit-ci.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/nix/store/4bj2kxdm1462fzcc2i2s4dn33g2angcc-bash-5.2p32/bin/bash
|
||||
|
||||
msg_file_dir='lintcommit-msg-files/'
|
||||
mkdir -p $msg_file_dir
|
||||
function cleanup {
|
||||
rm -rf $msg_file_dir
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
range="${1:-origin/sync..HEAD}"
|
||||
msg_files=()
|
||||
for commit in $( git rev-list --reverse $range -- ); do \
|
||||
file="$msg_file_dir$commit" ; \
|
||||
git log -1 --pretty=format:%B $commit > $file ; \
|
||||
msg_files+=($file) ; \
|
||||
done
|
||||
|
||||
nvim --headless --noplugin -u ./scripts/lintcommit.lua -- ${msg_files[*]}
|
||||
@ -0,0 +1,343 @@
|
||||
-- Validate commit message. Designed to be run as pre-commit hook and in CI.
|
||||
--
|
||||
-- Each Neovim's argument for when it is opened is assumed to be a path to
|
||||
-- a file containing commit message to validate
|
||||
-- Example usage:
|
||||
-- ```
|
||||
-- nvim --headless --noplugin -u scripts/lintcommit.lua -- .git/COMMIT_EDITMSG
|
||||
-- ```
|
||||
|
||||
-- Validator functions
|
||||
local allowed_commit_types = { 'ci', 'docs', 'feat', 'fix', 'refactor', 'style', 'test' }
|
||||
|
||||
local allowed_scopes = { 'ALL' }
|
||||
for _, module in ipairs(vim.fn.readdir('lua/mini')) do
|
||||
if module ~= 'init.lua' then table.insert(allowed_scopes, module:match('^(.+)%.lua$')) end
|
||||
end
|
||||
|
||||
local validate_subject = function(line)
|
||||
-- Possibly allow starting with 'fixup' to disable commit linting
|
||||
if vim.startswith(line, 'fixup') then
|
||||
local is_strict = vim.loop.os_getenv('LINTCOMMIT_STRICT') ~= nil
|
||||
local msg = is_strict and 'No "fixup" commits are allowed.' or ''
|
||||
return not is_strict, msg
|
||||
end
|
||||
|
||||
-- Should match overall conventional commit spec
|
||||
local commit_type, scope, desc = string.match(line, '^([^(]+)(%b())!?: (.+)$')
|
||||
if commit_type == nil then
|
||||
commit_type, desc = string.match(line, '^([^!:]+)!?: (.+)$')
|
||||
end
|
||||
if commit_type == nil or desc == nil then
|
||||
return false,
|
||||
'First line does not match conventional commit specification of `<type>[optional scope][!]: <description>`: '
|
||||
.. vim.inspect(line)
|
||||
end
|
||||
|
||||
-- Commit type should be present and be from one of allowed
|
||||
if not vim.tbl_contains(allowed_commit_types, commit_type) then
|
||||
local one_of = table.concat(vim.tbl_map(vim.inspect, allowed_commit_types), ', ')
|
||||
return false, 'Commit type ' .. vim.inspect(commit_type) .. ' is not allowed. Use one of ' .. one_of .. '.'
|
||||
end
|
||||
|
||||
-- Scope, if present, should be from one of allowed
|
||||
if scope ~= nil then
|
||||
scope = scope:sub(2, -2)
|
||||
if not vim.tbl_contains(allowed_scopes, scope) then
|
||||
local one_of = table.concat(vim.tbl_map(vim.inspect, allowed_scopes), ', ')
|
||||
return false, 'Scope ' .. vim.inspect(scope) .. ' is not allowed. Use one of ' .. one_of .. '.'
|
||||
end
|
||||
end
|
||||
|
||||
-- Description should be present and properly formatted
|
||||
if string.find(desc, '^%w') == nil then
|
||||
return false, 'Description should start with alphanumeric character: ' .. vim.inspect(desc)
|
||||
end
|
||||
|
||||
if string.find(desc, '^%u%l') ~= nil then
|
||||
return false, 'Description should not start with capitalized word: ' .. vim.inspect(desc)
|
||||
end
|
||||
|
||||
if string.find(desc, '[.,?!;]$') ~= nil then
|
||||
return false, 'Description should not end with any of `.,?!;`: ' .. vim.inspect(desc)
|
||||
end
|
||||
|
||||
-- Subject should not be too long
|
||||
if vim.fn.strdisplaywidth(line) > 72 then
|
||||
return false, 'First line is longer than 72 characters: ' .. vim.inspect(desc)
|
||||
end
|
||||
|
||||
return true, nil
|
||||
end
|
||||
|
||||
local validate_body = function(parts)
|
||||
if #parts == 1 then return true, nil end
|
||||
|
||||
if parts[2] ~= '' then return false, 'Second line should be empty' end
|
||||
if parts[3] == nil then return false, 'If first line is not enough, body should be present' end
|
||||
if string.find(parts[3], '^%S') == nil then return false, 'First body line should not start with whitespace.' end
|
||||
|
||||
for i = 3, #parts do
|
||||
if vim.fn.strdisplaywidth(parts[i]) > 80 then
|
||||
return false, 'Body line is longer than 80 characters: ' .. vim.inspect(parts[i])
|
||||
end
|
||||
end
|
||||
|
||||
if string.find(parts[#parts], '^%s*$') ~= nil then return false, 'Body should not end with blank line.' end
|
||||
|
||||
return true, nil
|
||||
end
|
||||
|
||||
local validate_bad_wording = function(msg)
|
||||
local has_fix = msg:find('[Ff]ix #') or msg:find('[Ff]ixes #') or msg:find('[Ff]ixed #')
|
||||
local has_bad_close = msg:find('[Cc]lose[sd]? #') ~= nil
|
||||
local has_bad_resolve = msg:find('[Rr]esolve[sd] #') ~= nil
|
||||
if has_fix or has_bad_close or has_bad_resolve then
|
||||
return false,
|
||||
'Use "Resolve #" GitHub keyword to resolve issue/PR '
|
||||
.. '(not "Fix(/es/ed)", not "Close(/s/d)", not "Resolve(s/d)").'
|
||||
end
|
||||
return true, nil
|
||||
end
|
||||
|
||||
local remove_cleanup_lines = function(lines)
|
||||
-- Remove lines which are assumed to be later cleaned up by Git itself
|
||||
-- See `git help commit` for option `--cleanup` (assumes default value)
|
||||
local res = {}
|
||||
for _, l in ipairs(lines) do
|
||||
-- Ignore anything past and including scissors line
|
||||
if l == '# ------------------------ >8 ------------------------' then break end
|
||||
-- Ignore comments
|
||||
if l:find('^%s*#') == nil then table.insert(res, l) end
|
||||
end
|
||||
|
||||
-- Ignore trailing blank lines
|
||||
for i = #res, 1, -1 do
|
||||
if res[i]:find('%S') ~= nil then break end
|
||||
res[i] = nil
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
local validate_commit_msg = function(lines)
|
||||
local is_valid, err_msg
|
||||
|
||||
-- If not in strict context, ignore lines which will be later cleaned up
|
||||
local is_strict = vim.loop.os_getenv('LINTCOMMIT_STRICT') ~= nil
|
||||
if not is_strict then lines = remove_cleanup_lines(lines) end
|
||||
|
||||
-- Allow all lines to be empty to abort committing
|
||||
local all_empty = true
|
||||
for _, l in ipairs(lines) do
|
||||
if l ~= '' then all_empty = false end
|
||||
end
|
||||
if all_empty then return true, nil end
|
||||
|
||||
-- Validate subject (first line)
|
||||
is_valid, err_msg = validate_subject(lines[1])
|
||||
if not is_valid then return is_valid, err_msg end
|
||||
|
||||
-- Validate body
|
||||
is_valid, err_msg = validate_body(lines)
|
||||
if not is_valid then return is_valid, err_msg end
|
||||
|
||||
-- No validation for footer
|
||||
|
||||
-- Should not contain bad wording
|
||||
for _, l in ipairs(lines) do
|
||||
is_valid, err_msg = validate_bad_wording(l)
|
||||
if not is_valid then return is_valid, err_msg end
|
||||
end
|
||||
|
||||
return true, nil
|
||||
end
|
||||
|
||||
local validate_commit_msg_from_file = function(path)
|
||||
local ok, lines = pcall(vim.fn.readfile, path)
|
||||
if not ok then return false, 'Could not read file ' .. path end
|
||||
return validate_commit_msg(lines)
|
||||
end
|
||||
|
||||
-- Actual validation
|
||||
local exit_code = 0
|
||||
for i = 0, vim.fn.argc(-1) - 1 do
|
||||
local path = vim.fn.argv(i, -1)
|
||||
io.write('Commit message of ' .. vim.fn.fnamemodify(path, ':t') .. ':\n')
|
||||
local is_valid, err_msg = validate_commit_msg_from_file(path)
|
||||
io.write((is_valid and 'OK' or err_msg) .. '\n\n')
|
||||
if not is_valid then exit_code = 1 end
|
||||
end
|
||||
|
||||
os.exit(exit_code)
|
||||
|
||||
-- Tests to be run interactively: `_G.test_cases_failed` should be empty.
|
||||
-- NOTE: Comment out previous `os.exit()` call
|
||||
local test_cases = {
|
||||
-- Subject
|
||||
['fixup'] = true,
|
||||
['fixup: commit message'] = true,
|
||||
['fixup! commit message'] = true,
|
||||
|
||||
['ci: normal message'] = true,
|
||||
['docs: normal message'] = true,
|
||||
['feat: normal message'] = true,
|
||||
['fix: normal message'] = true,
|
||||
['refactor: normal message'] = true,
|
||||
['style: normal message'] = true,
|
||||
['test: normal message'] = true,
|
||||
|
||||
['feat(ai): message with scope'] = true,
|
||||
['feat!: message with breaking change'] = true,
|
||||
['feat(ai)!: message with scope and breaking change'] = true,
|
||||
['style(ALL): style all modules'] = true,
|
||||
|
||||
['unknown: unknown type'] = false,
|
||||
['feat(unknown): unknown scope'] = false,
|
||||
['refactor(): empty scope'] = false,
|
||||
['ci( ): whitespace as scope'] = false,
|
||||
|
||||
['ci no colon after type'] = false,
|
||||
[': no type before colon 1'] = false,
|
||||
[' : no type before colon 2'] = false,
|
||||
[' : no type before colon 3'] = false,
|
||||
['ci:'] = false,
|
||||
['ci: '] = false,
|
||||
['ci: '] = false,
|
||||
|
||||
['feat: message with : in it'] = true,
|
||||
['feat(ai): message with : in it'] = true,
|
||||
|
||||
['test: extra space after colon'] = false,
|
||||
['ci: tab after colon'] = false,
|
||||
['ci:no space after colon'] = false,
|
||||
['ci : extra space before colon'] = false,
|
||||
|
||||
['ci: bad punctuation at end of sentence.'] = false,
|
||||
['ci: bad punctuation at end of sentence,'] = false,
|
||||
['ci: bad punctuation at end of sentence?'] = false,
|
||||
['ci: bad punctuation at end of sentence!'] = false,
|
||||
['ci: bad punctuation at end of sentence;'] = false,
|
||||
['ci: good punctuation at end of sentence:'] = true,
|
||||
['ci: good punctuation at end of sentence"'] = true,
|
||||
["ci: good punctuation at end of sentence'"] = true,
|
||||
['ci: good punctuation at end of sentence)'] = true,
|
||||
['ci: good punctuation at end of sentence]'] = true,
|
||||
|
||||
['ci: Capitalized first word'] = false,
|
||||
['ci: UPPER_CASE First Word'] = true,
|
||||
['ci: very very very very very very very very very very very looong subject'] = false,
|
||||
|
||||
-- Body
|
||||
['ci: desc\n\nBody'] = true,
|
||||
['ci: desc\n\nBody\n\nwith\n \nempty and blank lines'] = true,
|
||||
|
||||
['ci: desc\nSecond line is not empty'] = false,
|
||||
['ci: desc\n\n First body line starts with whitespace'] = false,
|
||||
|
||||
-- Line width should be checked only in not cleaned up lines
|
||||
['ci: desc\n\nBody\nwith\nVery very very very very very very very very very very very very looong body line'] = false,
|
||||
['ci: desc\n\nBody\nwith\n# Comment with very very very very very very very very very very looong body line'] = true,
|
||||
['ci: desc\n\nBody\nwith\n# ------------------------ >8 ------------------------\nVery very very very very very very very very very very very very looong body line'] = true,
|
||||
|
||||
-- Trailing blank lines are allowed in not strict context
|
||||
['ci: only two lines\n\n'] = true,
|
||||
['ci: desc\n\nLast line is empty\n\n'] = true,
|
||||
['ci: desc\n\nLast line is blank\n '] = true,
|
||||
|
||||
-- Footer
|
||||
-- No validation for footer
|
||||
|
||||
-- Bad wordings
|
||||
['ci: this has Fixed #1'] = false,
|
||||
['ci: this has fixed #1'] = false,
|
||||
['ci: this Fixes #1'] = false,
|
||||
['ci: this fixes #1'] = false,
|
||||
['ci: this will Fix #1'] = false,
|
||||
['ci: this will fix #1'] = false,
|
||||
['ci: this has Closed #1'] = false,
|
||||
['ci: this has closed #1'] = false,
|
||||
['ci: this Closes #1'] = false,
|
||||
['ci: this closes #1'] = false,
|
||||
['ci: this will Close #1'] = false,
|
||||
['ci: this will close #1'] = false,
|
||||
['ci: this has Resolved #1'] = false,
|
||||
['ci: this has resolved #1'] = false,
|
||||
['ci: this Resolves #1'] = false,
|
||||
['ci: this resolves #1'] = false,
|
||||
|
||||
['ci: desc\n\nthis has Fixed #1'] = false,
|
||||
['ci: desc\n\nthis has fixed #1'] = false,
|
||||
['ci: desc\n\nthis Fixes #1'] = false,
|
||||
['ci: desc\n\nthis fixes #1'] = false,
|
||||
['ci: desc\n\nthis will Fix #1'] = false,
|
||||
['ci: desc\n\nthis will fix #1'] = false,
|
||||
['ci: desc\n\nthis has Closed #1'] = false,
|
||||
['ci: desc\n\nthis has closed #1'] = false,
|
||||
['ci: desc\n\nthis Closes #1'] = false,
|
||||
['ci: desc\n\nthis closes #1'] = false,
|
||||
['ci: desc\n\nthis will Close #1'] = false,
|
||||
['ci: desc\n\nthis will close #1'] = false,
|
||||
['ci: desc\n\nthis has Resolved #1'] = false,
|
||||
['ci: desc\n\nthis has resolved #1'] = false,
|
||||
['ci: desc\n\nthis Resolves #1'] = false,
|
||||
['ci: desc\n\nthis resolves #1'] = false,
|
||||
|
||||
-- Comments are allowed in not strict context
|
||||
['# Comment\nci: desc'] = true,
|
||||
[' # Comment\nci: desc'] = true,
|
||||
['ci: desc\n# Comment\n\nBody'] = true,
|
||||
|
||||
-- Allow all empty lines
|
||||
[''] = true,
|
||||
['\n'] = true,
|
||||
['\n# Comment'] = true,
|
||||
}
|
||||
|
||||
_G.test_cases_failed = {}
|
||||
|
||||
vim.loop.os_unsetenv('LINTCOMMIT_STRICT')
|
||||
for message, expected in pairs(test_cases) do
|
||||
local lines = vim.split(message, '\n')
|
||||
local is_valid = validate_commit_msg(lines)
|
||||
if is_valid ~= expected then
|
||||
table.insert(_G.test_cases_failed, { msg = message, expected = expected, actual = is_valid })
|
||||
end
|
||||
end
|
||||
|
||||
vim.loop.os_setenv('LINTCOMMIT_STRICT', 'true')
|
||||
local strict_test_cases = {
|
||||
-- Fixup commit type is not allowed
|
||||
['fixup'] = false,
|
||||
['fixup: should fail'] = false,
|
||||
['fixup! should fail'] = false,
|
||||
|
||||
-- - Should only matter in subject
|
||||
['ci: desc\n\nfixup'] = true,
|
||||
|
||||
-- Do not allow comments outside of commit body
|
||||
['# Comment\nci: desc'] = false,
|
||||
[' # Comment\nci: desc'] = false,
|
||||
['ci: desc\n# Comment\n\nBody'] = false,
|
||||
|
||||
['ci: desc\n\nBody\n# Comment in body'] = true,
|
||||
|
||||
-- Check line width even in previously ignored contexts
|
||||
['ci: desc\n\nBody\nwith\n# Comment with very very very very very very very very very very looong body line'] = false,
|
||||
['ci: desc\n\nBody\nwith\n# ------------------------ >8 ------------------------\nVery very very very very very very very very very very very very looong body line'] = false,
|
||||
|
||||
-- Trailing blank lines are not allowed in strict context
|
||||
['ci: only two lines\n\n'] = false,
|
||||
['ci: desc\n\nLast line is empty\n\n'] = false,
|
||||
['ci: desc\n\nLast line is blank\n '] = false,
|
||||
}
|
||||
for message, expected in pairs(strict_test_cases) do
|
||||
local lines = vim.split(message, '\n')
|
||||
local is_valid = validate_commit_msg(lines)
|
||||
if is_valid ~= expected then
|
||||
table.insert(_G.test_cases_failed, { msg = message, expected = expected, actual = is_valid })
|
||||
end
|
||||
end
|
||||
|
||||
-- Cleanup
|
||||
vim.loop.os_unsetenv('LINTCOMMIT_STRICT')
|
||||
@ -0,0 +1,63 @@
|
||||
local minidoc = require('mini.doc')
|
||||
|
||||
if _G.MiniDoc == nil then minidoc.setup() end
|
||||
|
||||
local modules = {
|
||||
'ai',
|
||||
'align',
|
||||
'animate',
|
||||
'base16',
|
||||
'basics',
|
||||
'bracketed',
|
||||
'bufremove',
|
||||
'clue',
|
||||
'colors',
|
||||
'comment',
|
||||
'completion',
|
||||
'cursorword',
|
||||
'deps',
|
||||
'diff',
|
||||
'doc',
|
||||
'extra',
|
||||
'files',
|
||||
'fuzzy',
|
||||
'git',
|
||||
'hipatterns',
|
||||
'hues',
|
||||
'icons',
|
||||
'indentscope',
|
||||
'jump',
|
||||
'jump2d',
|
||||
'map',
|
||||
'misc',
|
||||
'move',
|
||||
'notify',
|
||||
'operators',
|
||||
'pairs',
|
||||
'pick',
|
||||
'sessions',
|
||||
'splitjoin',
|
||||
'starter',
|
||||
'statusline',
|
||||
'surround',
|
||||
'tabline',
|
||||
'test',
|
||||
'trailspace',
|
||||
'visits',
|
||||
}
|
||||
|
||||
local hooks = vim.deepcopy(MiniDoc.default_hooks)
|
||||
|
||||
hooks.write_pre = function(lines)
|
||||
-- Remove first two lines with `======` and `------` delimiters to comply
|
||||
-- with `:h local-additions` template
|
||||
table.remove(lines, 1)
|
||||
table.remove(lines, 1)
|
||||
return lines
|
||||
end
|
||||
|
||||
MiniDoc.generate({ 'lua/mini/init.lua' }, 'doc/mini.txt', { hooks = hooks })
|
||||
|
||||
for _, m in ipairs(modules) do
|
||||
MiniDoc.generate({ 'lua/mini/' .. m .. '.lua' }, 'doc/mini-' .. m .. '.txt', { hooks = hooks })
|
||||
end
|
||||
@ -0,0 +1,7 @@
|
||||
-- Add project root as full path to runtime path (in order to be able to
|
||||
-- `require()`) modules from this module
|
||||
vim.cmd([[let &rtp.=','.getcwd()]])
|
||||
|
||||
-- Ensure persistent color scheme (matters after new default in Neovim 0.10)
|
||||
vim.o.background = 'dark'
|
||||
require('mini.hues').setup({ background = '#11262d', foreground = '#c0c8cc' })
|
||||
@ -0,0 +1,4 @@
|
||||
local minitest = require('mini.test')
|
||||
|
||||
if _G.MiniTest == nil then minitest.setup() end
|
||||
minitest.run()
|
||||
Reference in New Issue
Block a user