lucc / nvimpager

Use nvim as a pager to view manpages, diffs, etc with nvim's syntax highlighting
Other
366 stars 19 forks source link

Colors are broken in cat mode #59

Closed ivanp7 closed 2 years ago

ivanp7 commented 2 years ago

image

Pager mode works fine: image

I use custom st build as the terminal under Artix Linux. nvimpager is installed as nvimpager-git package (version 0.10.3.r3.g2c2e137-1) from AUR, neovim is of version 0.6.0

lucc commented 2 years ago

Can you share the example file so I can reproduce this?

ivanp7 commented 2 years ago
diff --git a/fixes/smartbuy_extra_keys/install.sh b/fixes/smartbuy_extra_keys/install.sh
index 81c0194..a2f945e 100755
--- a/fixes/smartbuy_extra_keys/install.sh
+++ b/fixes/smartbuy_extra_keys/install.sh
@@ -1,9 +1,9 @@
 #!/bin/sh

+cat xmodmap >> "$XDG_CONFIG_HOME/X11/xmodmap"
+
 cd "$(dirname "$0")"
 MAP_FILE=smartbuy-keyboard.map
 { sudo dumpkeys | head -1; cat "$MAP_FILE"; } | sudo tee -a /usr/local/share/kbd/keymaps/$MAP_FILE
 sudo chmod 644 /usr/local/share/kbd/keymaps/$MAP_FILE

-cat xmodmap >> "$XDG_CONFIG_HOME/X11/xmodmap"
-

This happens with any patch/diff.

I also tried nvimpager -c -- -u NORC, got the same problem with default colors. With nvimpager -c -- -u NONE I get colorless output.

lucc commented 2 years ago

I am sorry I can not reproduce this with the given file. I tried termite and st from the NixOS repos. My neovim is also 0.6 from NixOS.

I checked out 2c2e137 and ran

./nvimpager -c ./issue-59-example.diff -u NORC
./nvimpager -c ./issue-59-example.diff
./nvimpager -p ./issue-59-example.diff -u NORC
./nvimpager -p ./issue-59-example.diff

For me the highlight does not leak.

Can you cross check with another terminal and maybe even vanilla st?

lucc commented 2 years ago

./nvimpager -c ./issue-59-example.diff -u NORC > issue-59-example.diff.log yields this file for me: issue-59-example.diff.log

Is that the same for you?

lucc commented 2 years ago

We can also try to check your terminal. What happens if you cat mini.txt with this file? mini.txt

ivanp7 commented 2 years ago

Both vanilla st and termite work better, but still have uncolored spaces: image

Is that the same for you?

Yes, diff reports outputs are the same.

What happens if you cat mini.txt with this file?

All custom st, vanilla st, and termite show this: image

ivanp7 commented 2 years ago

I modified your mini.txt to show text in red background (I changed 31 to 41), and this is what I get in all terminals: image

Linux console and fbterm work fine. It is not nvimpager problem nor st terminal problem. I don't know, what's going on.

lucc commented 2 years ago

I updated my mini.txt to background colours like you siad but I can not reproduce this. I am currently on Arch Linux with several terminal emulators (st from aur) I get this: 2021-12-13-095204_247x1056_scrot

ivanp7 commented 2 years ago

I am sure now that this isn't nvimpager issue, because I've managed to reproduce the breakage in both st and termite. Right after start the colors are fine, but if I cd into other directory, start graphical application from there AND cd back, then colors break. image This is extremely odd, I cannot even guess what the reason may be.

lucc commented 2 years ago

Maybe your prompt uses strange escape sequences that are emitted when you cd? Try st -e /bin/sh or so.

I will close this now, but you can still post updates, maybe I have an idea that can help :crossed_fingers: Maybe you might have luck asking on unix.SE.

ivanp7 commented 2 years ago

Thanks for help. Probably you're right, this is related to the shell... Luckily, this problem happens not that often and reset fixes it temporarily.