Skip to content

Commit

Permalink
add nvimpager as preferred colorizer
Browse files Browse the repository at this point in the history
  • Loading branch information
wofr06 committed Jul 7, 2024
1 parent a1114d0 commit 511bc52
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
****************************************************************************
# ChangeLog for lesspipe.sh #
****************************************************************************
- add nvimpager as (preferred) colorizer
- if installed use nvim instead of vim for coloring with vimcolor
- prefer bat styles and themes from ENV or command line over config file
Version 2.13 May 10 2024
- added support for appimage and snap files
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ the author by email.
**LESS** can be used to switch on colored less output (should contain -R).

**LESSCOLORIZER** can be set to prefer a highlighting program from the following
choices (`bat` `batcat` `pygmentize` `source-highlight` `vimcolor` `code2color`).
choices (`nvimpager` `bat` `batcat` `pygmentize` `source-highlight` `vimcolor` `code2color`).
Otherwise the first program in that list that is installed will be used.

## 3. Required programs
Expand Down Expand Up @@ -284,8 +284,9 @@ original html file contents, two colons are required in this case.
```
#### 5.1.1 Syntax highlighting choices
The filter is able to do syntax highlighting for a wide variety of file
types. If installed, `bat`/`batcat` is used for coloring the output. If
not, `pygmentize`, `source-highlight`, `code2color` and `vimcolor` are
types. If installed, `nvimpager` is used for coloring the output. If
not, `bat`/`batcat`, `pygmentize`, `source-highlight`, `code2color`
and `vimcolor` are
tried. Among these colorizers a preferred one can be forced for coloring
by setting the ENV variable **LESSCOLORIZER** to the name of the colorizer.
For `pygmentize` and `bat/batcat` a restricted set of options can be added:
Expand Down Expand Up @@ -313,7 +314,7 @@ batcat --list-languages
pygmentize -L lexers
source-highlight --lang-list
code2color -h
vimcolor -L
vimcolor -L (both for vimcolor and nvimpager)
```

### 5.2 Colored Directory listing
Expand Down Expand Up @@ -455,6 +456,7 @@ STDOUT and the commands executed to STDERR.
- sxw2txt https://vinc17.net/software/sxw2txt (2010)
- dtc https://git.kernel.org/cgit/utils/dtc/dtc.git (2023)
- xmq https://github.com/libxmq/xmq/releases/latest (2024)
- nvimpager https://github.com/lucc/nvimpager (2025)

### 12.2 References
- [1] http://www.greenwoodsoftware.com/less/ (less)
Expand Down
6 changes: 3 additions & 3 deletions lesspipe.1
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ file name. To get the original html file contents, two colons are
required in this case.
.SH OUTPUT COLORIZATION
The filter is able to do syntax highlighting for a wide variety of
file types. If installed, \fIbat\fP/\fIbatcat\fP is used for
coloring the output. If not, \fIpygmentize\fP, \fIsource-highlight\fP,
\fIvimcolor\fP and \fIcode2color\fP are tried in turn.
file types. If installed, \fInvimpager\fP is used for
coloring the output. If not, \fIbat\fP/\fIbatcat\fP, \fIpygmentize\fP,
\fIsource-highlight\fP, \fIvimcolor\fP and \fIcode2color\fP are tried in turn.
For bat/batcat the theme is set to \fIansi\fP and the style is set to
\fIplain\fP which comes closer to the unfiltered output of \fBless\fP.
These settings can be changed in \fI~/.config/bat/config\fP or by the
Expand Down
5 changes: 4 additions & 1 deletion lesspipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ has_colorizer () {
[[ $2 == plain || -z $2 ]] && return
prog=${LESSCOLORIZER%% *}

for i in bat batcat pygmentize source-highlight vimcolor code2color ; do
for i in nvimpager bat batcat pygmentize source-highlight vimcolor code2color ; do
[[ -z $prog || $prog == "$i" ]] && has_cmd "$i" && prog=$i
done
[[ "$2" =~ ^[0-9]*$ || -z "$2" ]] || lang=$2
Expand Down Expand Up @@ -470,6 +470,9 @@ has_colorizer () {
code2color|vimcolor)
opt=("$1")
[[ -n "$3" ]] && opt=(-l "$3" "$1") ;;
nvimpager)
opt=(-c "$1")
[[ -n "$3" ]] && opt=(-c "$1" -c "set filetype=$3") ;;
*)
return ;;
esac
Expand Down

0 comments on commit 511bc52

Please sign in to comment.