Skip to content

Commit

Permalink
Add gat highlighting backend (optional)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndydeCleyre committed Nov 19, 2024
1 parent 804f537 commit b6c5de4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Changed

- Use reverse-list layout for fzf/skim instead of reverse
- pypc: don't add '.' to any dependency list
- Add optional syntax highlighter backend: gat

0.3.11
======
Expand Down
1 change: 1 addition & 0 deletions doc/src/deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ with optional additions for more colorful output, alternative json parsers, and
- [uv](https://github.com/astral-sh/uv/)
-- for faster performance, leaner venvs, and more operational feedback
- [highlight](https://repology.org/project/highlight/versions)
*or* [gat](https://github.com/koki-develop/gat/)
*or* [bat](https://repology.org/project/bat/versions)
*or* [rich-cli](https://github.com/Textualize/rich-cli)
-- for pretty syntax highlighting; rich-cli adds fancy tables
Expand Down
5 changes: 4 additions & 1 deletion zpy.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@ ZPY_PROCS=${${$(nproc 2>/dev/null):-$(sysctl -n hw.logicalcpu 2>/dev/null)}:-4}
# the first of the next. This is true of at least highlight 3.58.

# The method below bypasses both issues consistently
# across all known versions of highlight, and still outperforms bat:
# across all known versions of highlight, and still outperforms the rest:
local content=$(<&0)
if [[ $content ]] {
local themes=(aiseered blacknblue bluegreen ekvoli navy)
HIGHLIGHT_OPTIONS=${HIGHLIGHT_OPTIONS:-"-s $themes[RANDOM % $#themes + 1]"} \
highlight -O truecolor --stdout --force -S $1 <<<$content
}
} elif (( $+commands[gat] )) { # recommended themes: base16-snazzy, doom-one, gruvbox, onedark, vulcan
GAT_THEME=${GAT_THEME:-doom-one} \
gat --force-color -l $1
} elif (( $+commands[bat] )) { # recommended themes: ansi, zenburn
BAT_THEME=${BAT_THEME:-ansi} \
bat --color always --paging never -p -l $1
Expand Down

0 comments on commit b6c5de4

Please sign in to comment.