Skip to content

Commit

Permalink
pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ss-o committed Nov 12, 2021
1 parent 650e376 commit 8f71b30
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* @z-shell
* @ss-o
* @ss-o
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: /~https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: /~https://github.com/koalaman/shellcheck-precommit
rev: v0.8.0
hooks:
- id: shellcheck
# args: ["--severity=warning"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

[![Project license](https://img.shields.io/github/license/z-shell/zi.svg?style=flat-square)](LICENSE) [![Pull Requests welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg?style=flat-square)](/~https://github.com/z-shell/zi/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
</div>

<details open="open">
<summary>Table of Contents</summary>

Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ that relate to your submission. You don't want to duplicate effort.
3. Create your feature branch (`git checkout -b feat/amazing_feature`)
4. Commit your changes (`git commit -m 'feat: add amazing_feature'`) Z-Shell ZI uses [conventional commits](https://www.conventionalcommits.org), so please follow the specification in your commit messages.
5. Push to the branch (`git push origin feat/amazing_feature`)
6. [Open a Pull Request](/~https://github.com/z-shell/zi/compare?expand=1)
6. [Open a Pull Request](/~https://github.com/z-shell/zi/compare?expand=1)
2 changes: 1 addition & 1 deletion docs/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/man/zi.1
Original file line number Diff line number Diff line change
Expand Up @@ -907,4 +907,4 @@ Whant to learn more?
See Z-Shell News Blog: \fBhttps://z-shell.github.io\fR
.RE 0

.P
.P
7 changes: 4 additions & 3 deletions zinit-install.zsh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors.

# shellcheck shell=bash disable=SC1009,1073,1027,1036,1072

builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { builtin print -P "${ZINIT[col-error]}ERROR:%f%b Couldn't find ${ZINIT[col-obj]}zinit-side.zsh%f%b."; return 1; }

# FUNCTION: .zinit-parse-json [[[
Expand All @@ -17,10 +19,9 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { builtin print -P "${ZINIT
integer ___nest=${4:-1} ___idx=0 ___pair_idx ___level=0 \
___start ___end ___sidx=1 ___had_quoted_value=0
local -a match mbegin mend ___pair_order

(( ${(P)+___varname} )) || typeset -gA "$___varname"

___pair_map=( "{" "}" "[" "]" )

while [[ $___workbuf = (#b)[^"{}[]\\\"'":,]#((["{[]}\"'":,])|[\\](*))(*) ]]; do
if [[ -n ${match[3]} ]] {
___idx+=${mbegin[1]}
Expand Down Expand Up @@ -2278,4 +2279,4 @@ zimv() {
)
}
}
# ]]]
# ]]]
20 changes: 11 additions & 9 deletions zinit.zsh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors.

# shellcheck shell=bash disable=SC1073,1072,1050 # Zsh

#
# Main state variables.
#
Expand Down Expand Up @@ -251,12 +253,12 @@ builtin setopt noaliases

# "Fpath elements" - ie those elements that are inside the plug-in directory.
# The name comes from the fact that they are the selected fpath elements → so just
# "items".
# "items".
local -a fpath_elements
fpath_elements=( ${fpath[(r)$PLUGIN_DIR/*]} )

# Add a function subdirectory to items, if any (this action is
# according to the Plug Standard version 1.07 and later).
# according to the Plug Standard version 1.07 and later).
[[ -d $PLUGIN_DIR/functions ]] && fpath_elements+=( "$PLUGIN_DIR"/functions )

if (( ${+opts[(r)-X]} )); then
Expand Down Expand Up @@ -1893,22 +1895,22 @@ builtin setopt noaliases
.zinit-formatter-pid() {
builtin emulate -L zsh -o extendedglob

# Remember extreme whitespace.
# Remember extreme whitespace.
local pbz=${(M)1##(#s)[[:space:]]##}
local kbz=${(M)1%%[[:space:]]##(#e)}
# Remove extreme whitespace.
# Remove extreme whitespace.
1=${1//((#s)[[:space:]]##|[[:space:]]##(#e))/}

((${+functions[.zinit-first]})) || source ${ZINIT[BIN_DIR]}/zinit-side.zsh
.zinit-any-colorify-as-uspl2 "$1";

# Replace at least one character with an unbreakable space,
# because extreme whitespace is lost due to implementation problems ...
# because extreme whitespace is lost due to implementation problems ...
pbz=${pbz/[[:blank:]]/ }
local kbz_rev="${(j::)${(@Oas::)kbz}}"
kbz="${(j::)${(@Oas::)${kbz_rev/[[:blank:]]/ }}}"

# Supply extreme whitespace back.
# Supply extreme whitespace back.
REPLY=$pbz$REPLY$kbz
}
# ]]]
Expand Down Expand Up @@ -1970,7 +1972,7 @@ builtin setopt noaliases
if [[ $2 == (b|u|it|st|nb|nu|nit|nst) ]]; then
append=$ZINIT[col-$2]
elif [[ $2 == (…|ndsh|mdsh|mmdsh|-…|lr|) || -z $2 || -z $ZINIT[col-$2] ]]; then
# Resume previous escape code, if stored.
# Resume previous escape code, if stored.
if [[ $ZINIT[__last-formatter-code] != (…|ndsh|mdsh|mmdsh|-…|lr|rst|nl|) ]]; then
in_prepend=$ZINIT[col-$ZINIT[__last-formatter-code]]
influx=$ZINIT[col-$ZINIT[__last-formatter-code]]
Expand All @@ -1984,7 +1986,7 @@ builtin setopt noaliases

# Replace new lines with characters that work the same but are not
# deleted in the substitution $ (...) - vertical tab 0xB ↔ 13 in the system
# octagonal connected back carriage (015).
# octagonal connected back carriage (015).
local nl=$'\n' vertical=$'\013' carriager=$'\015'
REPLY=${REPLY//$nl/$vertical$carriager}

Expand All @@ -2011,7 +2013,7 @@ $(.zinit-main-message-formatter "$match[6]" "$match[7]" "$match[8]"; \
)${${ZINIT[__last-formatter-code]::=${${${match[7]:#(…|ndsh|mdsh|mmdsh|-…|lr)}:+\
$match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→}

# Restore the default color at the end of the message.
# Restore the default color at the end of the message.
msg=$msg$ZINIT[col-rst]
# Output the processed message:
builtin print -Pr ${opt:#--} -- $msg
Expand Down

0 comments on commit 8f71b30

Please sign in to comment.