Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zsh plugin standard #21

Merged
merged 10 commits into from
Apr 18, 2022
Merged
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
#
# Note: VIM users should use alternate marks [[[ and ]]] as the original ones can confuse nested substitutions, e.g.: ${${${VAR}}}
#
#----------------------------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
#----------------------------------------------------------------------------------------------------------------------

root = true

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
name: '♻️ Sync Labels'
name: "♻️ Sync Labels"

on:
schedule:
- cron: '22 2 * * 2'
- cron: "22 2 * * 2"
workflow_dispatch:

jobs:
labels:
name: '♻️ Sync labels'
name: "♻️ Sync labels"
uses: z-shell/.github/.github/workflows/sync-labels.yml@main
6 changes: 3 additions & 3 deletions .github/workflows/zunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name: 🛡️ ZUnit
on:
workflow_dispatch:
push:
branches: ['main', 'develop']
branches: ["main", "develop"]
pull_request_target:
branches: ['main', 'develop']
branches: ["main", "develop"]

jobs:
build-macos:
Expand All @@ -30,7 +30,7 @@ jobs:
export TERM="xterm-256color"
export PATH="$PWD/bin:$PATH"
zunit

build-linux:
name: 🧪 ZUnit Linux
runs-on: ubuntu-latest
Expand Down
10 changes: 10 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
spaces: false
url: false
whitespace: false
7 changes: 7 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
1 change: 1 addition & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*out
11 changes: 11 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 0.1
cli:
version: 0.9.3-beta
lint:
enabled:
- actionlint@1.6.9
- gitleaks@8.3.0
- markdownlint@0.31.1
- prettier@2.5.1
- shellcheck@0.8.0
- shfmt@3.4.0
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
},
"conventionalCommits.scopes": [
"repository_maintenance",
"plugin_maintenance"
"plugin_maintenance",
"chroma"
]
}
37 changes: 18 additions & 19 deletions f-sy-h.plugin.zsh → F-Sy-H.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
# Copyright (c) 2017-2019 Sebastian Gniazdowski (modifications)
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
Expand Down Expand Up @@ -58,8 +57,8 @@ typeset -g FAST_WORK_DIR=${FAST_WORK_DIR:-${XDG_CACHE_HOME:-~/.cache}/fsh}
FAST_WORK_DIR=${~FAST_WORK_DIR}

if [[ ! -w $FAST_WORK_DIR ]]; then
FAST_WORK_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/fsh"
command mkdir -p "$FAST_WORK_DIR"
FAST_WORK_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/fsh"
command mkdir -p "$FAST_WORK_DIR"
fi

# Invokes each highlighter that needs updating.
Expand Down Expand Up @@ -92,23 +91,23 @@ _zsh_highlight()
# Reset region highlight to build it from scratch
# may need to remove path_prefix highlighting when the line ends
if [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_buffer_modified; then
-fast-highlight-init
-fast-highlight-process "$PREBUFFER" "$BUFFER" 0
-fast-highlight-init
-fast-highlight-process "$PREBUFFER" "$BUFFER" 0
(( FAST_HIGHLIGHT[use_brackets] )) && {
_FAST_MAIN_CACHE=( $reply )
-fast-highlight-string-process "$PREBUFFER" "$BUFFER"
}
region_highlight=( $reply )
else
local char="${BUFFER[CURSOR+1]}"
if [[ "$char" = ["{([])}"] || "${FAST_HIGHLIGHT[prev_char]}" = ["{([])}"] ]]; then
FAST_HIGHLIGHT[prev_char]="$char"
(( FAST_HIGHLIGHT[use_brackets] )) && {
_FAST_MAIN_CACHE=( $reply )
-fast-highlight-string-process "$PREBUFFER" "$BUFFER"
reply=( $_FAST_MAIN_CACHE )
-fast-highlight-string-process "$PREBUFFER" "$BUFFER"
region_highlight=( $reply )
}
region_highlight=( $reply )
else
local char="${BUFFER[CURSOR+1]}"
if [[ "$char" = ["{([])}"] || "${FAST_HIGHLIGHT[prev_char]}" = ["{([])}"] ]]; then
FAST_HIGHLIGHT[prev_char]="$char"
(( FAST_HIGHLIGHT[use_brackets] )) && {
reply=( $_FAST_MAIN_CACHE )
-fast-highlight-string-process "$PREBUFFER" "$BUFFER"
region_highlight=( $reply )
}
fi
fi
fi

{
Expand Down
38 changes: 19 additions & 19 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# News On Updates in F-Sy-H

**2018-08-09**
## 2018-08-09

Added ideal string highlighting – FSH now handles any legal quoting and combination of `"`,`'` and `\` when
highlighting program arguments. See the introduction for an example (item #14).

**2018-08-02**
## 2018-08-02

Global aliases are now supported:

![image](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/main/images/global-alias.png)

**2018-08-01**
## 2018-08-01

Hint – how to customize styles when using Zplugin and turbo mode:

Expand All @@ -31,20 +31,20 @@ If you have set theme before an update of styles (e.g. recent addition of bracke
then please repeat `fast-theme {theme}` call to regenerate theme files. (**2018-08-09**: FSH
now has full user-theme support, refer to [appropriate section of README](#customization)).

**2018-07-30**
## 2018-07-30

Ideal highlighting of brackets (pairing, etc.) – no quoting can disturb the result:

![image](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/main/images/brackets.gif)

`FAST_HIGHLIGHT[use_brackets]=1` to enable this feature (**2018-07-31**: not needed anymore, this highlighting is active by default).

**2018-07-21**
## 2018-07-21

Chroma architecture now supports aliases. You can have `alias mygit="git commit"` and when `mygit`
will be invoked everything will work as expected (Git chroma will be ran).

**2018-07-11**
## 2018-07-11

There were problems with Ctrl-C not working when using FSH. After many days I've found a fix
for this, it's pushed to main.
Expand All @@ -53,13 +53,13 @@ Second, asynchronous path checking (useful on e.g. slow network drives, or when
is now optional. Set `FAST_HIGHLIGHT[use_async]=1` to enable it. This saves some users from Zshell crashes
– there's an unknown bug in Zsh.

**2018-06-09**
## 2018-06-09

New chroma functions: `awk`, `make`, `perl`, `vim`. Checkout the [video](https://asciinema.org/a/186234),
it shows functionality of `awk` – compiling of code and NOT running it. Perl can do this too:
[video](https://asciinema.org/a/186098).

**2018-06-06**
## 2018-06-06

FSH gained a new architecture – "chroma functions". They are similar to "completion functions", i.e. they
are defined **per-command**, but instead of completing that command, they colorize it. Two chroma exist,
Expand All @@ -70,7 +70,7 @@ would like to highlight a command.

![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/main/images/git_chroma.png)

**2018-06-01**
## 2018-06-01

Highlighting of command substitution (i.e. `$(...)`) with alternate theme – two themes at once! It was just white before:

Expand All @@ -83,20 +83,20 @@ Also added correct highlighting of descriptor-variables passed to `exec`:

![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/main/images/execfd.png)

**2018-05-30**
## 2018-05-30

For-loop is highlighted, it has separate settings in [theme file](https://github.com/zdharma/fast-syntax-highlighting/blob/main/themes/free.ini).

![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/main/images/for-loop.png)

**2018-05-27**
## 2018-05-27

Added support for 256-color themes. There are six themes shipped with FSH. The command to
switch theme is `fast-theme {theme-name}`, it has a completion which lists available themes
and options. Checkout [asciinema recording](https://asciinema.org/a/183814) that presents
the themes.

**2018-05-25**
## 2018-05-25

Hash holding paths that shouldn't be grepped (globbed) – blacklist for slow disks, mounts, etc.:

Expand All @@ -106,7 +106,7 @@ FAST_BLIST_PATTERNS[/mount/nfs1/*]=1
FAST_BLIST_PATTERNS[/mount/disk2/*]=1
```

**2018-05-23**
## 2018-05-23

Assign colorizing now spans to variables defined by `typeset`, `export`, `local`, etc.:

Expand All @@ -117,23 +117,23 @@ treating `zcalc` like a regular command-line:

![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/main/images/zcalc.png)

**2018-05-22**
## 2018-05-22

Array assignments were still boring, so I throwed in bracked colorizing:

![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/main/images/array-assign.png)

**2018-05-22**<a name="assign-update"></a>
## 2018-05-22 <a name="assign-update"></a>

Assignments are no more one-colour default-white. When used in assignment, highlighted are:

- variables (outside strings),
- strings (double-quoted and single-quoted),
- math-mode (`val=$(( ... ))`).
- variables (outside strings),
- strings (double-quoted and single-quoted),
- math-mode (`val=$(( ... ))`).

![sshot](https://raw.githubusercontent.com/zdharma/fast-syntax-highlighting/main/images/assign.png)

**2018-01-06**
## 2018-01-06

Math mode is highlighted – expressions `(( ... ))` and `$(( ... ))`. Empty variables are colorized as red.
There are 3 style names (fields of
Expand Down
Loading