lucc / nvimpager

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

Support for colors (eg with git)? #2

Closed lesurp closed 6 years ago

lesurp commented 6 years ago

Hi, when something such as:

export PAGER=less; git log --graph

we get something with nice colors (ie with my setup I get yellow commit hashes and red lines for the main branch line).

Doing so with nvimpager won't output any color. I do get colored man pages however so I don't know. Is that maybe a terminal colorscheme configuration?

lucc commented 6 years ago

Nvimpager uses the syntax files from neovim (this is a design decision). I don't really want to add or support custom syntax files.

Currently neovim detects the format of git log but not git log --graph. You could open a PR on the neovim repository.

Or you could check out tig. It can also work as a pager but also fails to highlight git log --graph but it provides it's own graph view that can even be navigated

lucc commented 6 years ago

Just now I also remembered the option --color=always for git log. You can try to run git log --color | nvimpager and nvimpager should highlight the terminal codes git gives you. This forces git log to display the terminal color escapes even though output is to a pipe and it stops nvimpager from detecting git as its parent process (the pager is not started by git so git isn't the parent process).

plurry commented 4 years ago

Is there any way to force nvimpager to draw the ANSI color codes when run by git if there isn't a Neovim syntax file for the output?

lucc commented 4 years ago

You can stop git from loading the pager itself so nvimpager will not detect a git parent process: git log --graph --color | nvimpager