Files
dotfiles/scripts/create-nvim-keymaps.sh
Ismo Vuorinen 473fc820b9 fix(shell): add explicit return statements to functions
Add return 0 as the last statement in ~46 shell functions across
17 files that previously relied on implicit return codes
(SonarCloud rule shelldre:S7682).
2026-02-07 14:00:58 +02:00

35 lines
840 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# @description Create file containing key mappings for Neovim
# Usage: ./create-nvim-keymaps.sh
#
# shellcheck source=shared.sh
source "${DOTFILES}/config/shared.sh"
DEST="$HOME/.dotfiles/docs/nvim-keybindings.md"
main()
{
msg "Generating Neovim keybindings documentation"
{
printf "# nvim keybindings\n\n"
printf "\`\`\`txt"
} > "$DEST"
nvim -c "redir! >> \"$DEST\"" -c 'silent verbose map' -c 'redir END' -c 'q'
printf "\n\`\`\`\n\n- Generated on %s\n" "$(date)" >> "$DEST"
# Remove unnecessary information from the output and the last line
sed -E \
-e 's/<Lua [^:]+: ([^:>]+):[0-9]+>/\1/' \
-e '/^ Last set from/d' "$DEST" \
> "${DEST}.tmp" \
&& mv "${DEST}.tmp" "$DEST"
msg "Neovim keybindings documentation generated at $DEST"
return 0
}
main "$@"