Something went wrong. Try again.
Library of 45+ independent Lua modules improving Neovim experience with minimal effort nvim-mini.org/mini.nvim
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=d)
# Ensure formatting with `stylua` (https://github.com/JohnnyMorganz/StyLua)LUA_FILES=$(echo "$STAGED_FILES" | grep "\.lua$")if [ -n "$LUA_FILES" ]; then printf "Check formatting: " if command -v stylua >/dev/null 2>&1; then HASHES_BEFORE=$(echo "$LUA_FILES" | xargs git hash-object) echo "$LUA_FILES" | xargs stylua --respect-ignores || exit 1 HASHES_AFTER=$(echo "$LUA_FILES" | xargs git hash-object)
# Running `stylua` should not add new changes to staged Lua files if [ "$HASHES_BEFORE" != "$HASHES_AFTER" ]; then echo "FAIL" echo " StyLua modified some files." echo " Stage formatted changes and re-commit." exit 1 fi echo "OK" else echo "WARN (stylua executable not found)" fifi
# Ensure documentation was generated and is good qualityGENDOC_FILES=$(echo "$STAGED_FILES" | grep -E "^(doc|lua)/")if [ -n "$GENDOC_FILES" ]; then printf "Check gendoc: "
# Running `gendoc` should not add new changes to any "doc/" files DOCDIFF_BEFORE=$(git diff -- doc/*) make --silent gendoc >/dev/null 2>&1 DOCDIFF_AFTER=$(git diff -- doc/*) if [ "$DOCDIFF_BEFORE" != "$DOCDIFF_AFTER" ]; then echo "FAIL" echo " Documentation was not properly generated." echo " Review generated changes, stage relevant ones, re-commit." exit 1 fi
# There should not be unstaged doc if its source file has staged changes GEN_FILES=$(echo "$STAGED_FILES" | grep -E '^lua/mini/.+\.lua$') if [ -n "$GEN_FILES" ]; then DOC_TARGET=$(echo "$GEN_FILES" | sed -E 's|^lua/mini/(.+)\.lua$|doc/mini-\1.txt|') DOC_TARGET_UNSTAGED=$(echo "$DOC_TARGET" | xargs git diff --name-only --) if [ -n "$DOC_TARGET_UNSTAGED" ]; then echo "FAIL" echo " Documentation for not all staged lua/mini/* files was staged." echo " Stage relevant ones and re-commit." exit 1 fi fi echo "OK"fi
DOC_FILES=$(echo "$STAGED_FILES" | grep -E "^doc/")if [ -n "$DOC_FILES" ]; then printf "Check lintdoc: " make --silent lintdoc || exit 1 # NOTE: OK/FAIL status comes from `make --sillent lintdoc` itselffi
# Ensure formatting with `typos` (https://github.com/crate-ci/typos)# Condition: running it should not add new changes to staged Lua filesSPELLED_FILES=$(echo "$STAGED_FILES" | grep -E '\.(lua|txt|md)$')if [ -n "$SPELLED_FILES" ]; then printf "Check spelling: " if command -v typos >/dev/null 2>&1; then # Intercept `typos` output in case of errors for pretty printing TYPOS_OUT=$(echo "$SPELLED_FILES" | xargs typos --color=never 2>&1) if [ $? -eq 0 ]; then echo "OK" else echo "FAIL" echo "$TYPOS_OUT" exit 1 fi else echo "WARN (typos executable not found)" fifi
exit 0