lucc / nvimpager

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

Colorizing is not consistent #103

Open mrdgo opened 2 months ago

mrdgo commented 2 months ago

Hello! At first, I though this was a github-cli bug. So I posted there. The only important point in that issue is this comment. As you can see, the colors that glamour creates, are displayed correctly. However all the colors from gh-cli are not correct. Do you have an idea what the culprit might be? Both less and bat display the correct colors in that case.

lucc commented 2 months ago

Maybe this is related to #99 and #101: with version 0.10 neovim changed the default color scheme and I noticed that some colorschemes did implicitly assume some different default colors and did not set them.

Can you reproduce this problem with neovim 0.9 and 0.10 and also with the default colorscheme? (You can use the NVIMPAGER_NVIM variable and the -u or -c/--cmd command line options)

mrdgo commented 2 months ago

I tested on nightly before.

I tried to use bob, but somehow nvimpager doesn't work anymore using bob's installation. How do I fix?

lucc commented 2 months ago

If by bob you mean https://github.com/MordechaiHadad/bob I don't know it. Nvimpager does not bother where you put neovim or how you install it. It does however require the command line switches documented in the man page of the official neovim. Especially the -R switch as you have noticed. If bob does something strange to the command line parsing of neovim you have to figure that out first.

You can find out where in nvimpager the error message comes from when running it in debug mode: bash -x nvimpager.

mrdgo commented 2 months ago

When I invoke nvim v0.9.5 with -R, there is no problem. This only occurs when I set NVIMPAGER_NVIM to that binary.

Log: (I removed the prompt-related noise)

user@host: NVIMPAGER_NVIM=~/.local/share/bob/nvim-bin/nvim man sort
++ printf %s 1725513689731314
+ NVIMPAGER_NVIM=~/.local/share/bob/nvim-bin/nvim
+ man sort
error: unexpected argument '-R' found

Usage: nvimpager <COMMAND>

For more information, try '--help'.
man: command exited with status 2: sed -e '/^[[:space:]]*$/{ N; /^[[:space:]]*\n[[:space:]]*$/D; }' | LESS=-ix8RmPm Manual page sort(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page sort(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$ MAN_PN=sort(1) nvimpager
 3 user@host:~$ .local/share/bob/nvim-bin/nvim -R .bashrc
++ printf %s 1725513713727901
+ .local/share/bob/nvim-bin/nvim -R .bashrc

Weird, isn't it? nvimpager with that binary fails, but nvim -R .bashrc runs like a charm.

lucc commented 2 months ago

Your last comment is not very helpful. You are actually not calling nvimpager yourself. You are calling man. If you read the man page of man itself you will learn that man looks at the PAGER and the MANPAGER env variable. So at the very least I would expect you to tell me the contents of these so that we can at least guess who is calling nvimpager in the end.

It would be much better if you can find an example to reproduce this with nvimpager directly. If it only happens with man pages you can have man render a page for you and view it with nvimpager afterwards:

man man > man.1
nvimpager man.1 -c 'Man!' 

The error message

Usage: nvimpager <COMMAND>

looks strange to me. It is not from nvimpager. Do you know where it comes from?

mrdgo commented 2 months ago

Hm. I am sorry about a non-helpful comment. Then I don't understand either. The commands you suggest produce the same output: error: unexpected argument '-R' found. I ran the same thing using strace and the only -R I found, was in execve("/path/to/bobs/v0.9.5/nvim", ["nvimpager", "-R", ...

lucc commented 2 months ago

Maybe bob inspects the argv0 of the command that is executed like snap does. Compare the the problems in #82.

Can you check if the nvim versions installed by bob are symlinks or wrapper scripts (if they are symlinks then please also check recursively):

ls -l /path/to/bobs/v0.9.5/nvim
file /path/to/bobs/v0.9.5/nvim

What happens if you run

/path/to/bobs/v0.9.5/nvim -R
exec -a foo /path/to/bobs/v0.9.5/nvim -R
mrdgo commented 2 months ago

That is exactly what I did already, I manually invoked v0.9.5 with -R and in worked. It only fails when invoked by nvimpager.

$ file .local/share/bob/nvim-bin/nvim
.local/share/bob/nvim-bin/nvim: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=adcf999f43a8b51afa6c665656cd26b9d24eda10, for GNU/Linux 4.4.0, stripped
RayJameson commented 1 month ago

I have same issue error: unexpected argument '-R' found

NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1713484068