Closed kevinhwang91 closed 5 years ago
At the moment that is not possible.
:set number
does not help because nvimpager -c
only prints the buffer, not the screen of neovimnvimpager -c | cat -n
does not really help because it spills colors over the line numbers. I thought that we reset colours at the end of line but I have to look into this.get it, thanks.
I had a look at the code and I think :set number
will never be visible in cat mode. That is just outside of the design of nvimpager.
nvimpager -c | cat -n
is a crude workaround. You will have to live with the colors spilling over the line numbers. The code only resets the color at the end of the document. This was done in order to not emit additional color codes and reset codes for every line. Especially in git diff that makes a difference as many lines share the color with the one above.
@lucc I use python to store the last ansi code of the current line for inserting the beginning of the next line and append the reset ansi code for the current line to prepare for the ready linenumber.
import sys
import re
prev = ""
for line in sys.stdin:
print(prev + line.rstrip() + "\x1B[0m")
for m in re.finditer(r"\x1B\[[0-9;]*m", line):
pass
if m:
prev = m.group()
It works fine when combine cat -n
or nl -ba
. I think using lua (I have no idea about lua) can Implement like above code?
cat with -n parameter can show line number, but nvimpager seems not to support this feature now.