Big refactoring.
* Don't override user defined styles * Better modularisation of highlighters * Allow to define which highlighters are activated * Allow to define the order in which they are defined * Minor performance optimizations * Fixed some variables leak * Improve documentation * Brackets highlighter: use ZSH_HIGHLIGHT_STYLES instead of a specific array
This commit is contained in:
@@ -29,11 +29,32 @@
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Load the main script.
|
||||
. $(dirname $0)/../zsh-syntax-highlighting.zsh
|
||||
# Check an highlighter was given as argument.
|
||||
[[ -n "$1" ]] || {
|
||||
echo "You must provide the name of a valid highlighter as argument." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Process each test data file in data/.
|
||||
for data_file in $(dirname $0)/data/*.zsh; do
|
||||
# Check the highlighter is valid.
|
||||
[[ -f ${0:h:h}/highlighters/$1/$1-highlighter.zsh ]] || {
|
||||
echo "Could not find highlighter '$1'." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check the highlighter has test data.
|
||||
[[ -d ${0:h:h}/highlighters/$1/test-data ]] || {
|
||||
echo "Highlighter '$1' has no test data." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Load the main script.
|
||||
. ${0:h:h}/zsh-syntax-highlighting.zsh
|
||||
|
||||
# Activate the highlighter.
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=($1)
|
||||
|
||||
# Process each test data file in test data directory.
|
||||
for data_file in ${0:h:h}/highlighters/$1/test-data/*; do
|
||||
|
||||
# Load the data and prepare checking it.
|
||||
BUFFER=
|
||||
@@ -45,9 +66,9 @@ for data_file in $(dirname $0)/data/*.zsh; do
|
||||
echo "KO\n - 'BUFFER' is not declared or blank."
|
||||
else
|
||||
|
||||
# Measure the time taken by _zsh_highlight-zle-buffer.
|
||||
# Measure the time taken by _zsh_highlight.
|
||||
TIMEFMT="%*Es"
|
||||
time ( BUFFER="$BUFFER" && _zsh_highlight-zle-buffer)
|
||||
time ( BUFFER="$BUFFER" && _zsh_highlight)
|
||||
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user