lucc / nvimpager

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

No output when used as Ranger preview #1

Closed beanaroo closed 6 years ago

beanaroo commented 6 years ago

Thanks for publishing this!

I'd like to have ranger's file preview syntax highlighting consistent with my text editor.

I tried adding the below line to ranger's scope.sh but the preview pane is just blank. I'm not sure where to keep looking. Any assistance is appreciated!

nvimpager -c -- ${FILE_PATH} ; exit 5
lucc commented 6 years ago

I tried that and can reproduce your problem. I changed your line to bash -x nvimpager -c -- ${FILE_PATH} 2>&1; exit 5 and can see that the nvimpager script runs but the file in question is not displayed, only the trace output.

I created my scope.sh with ranger --copy-config=scope and at the top of that file it says

# If the option `use_preview_script` is set to `true`,
# then this script will be called and its output will be displayed in ranger.
# ANSI color codes are supported.
# STDIN is disabled, so interactive scripts won't work properly

Which lead me to try bash -x nvimpager -c -- file </dev/null in the terminal. And guess what, it behaves the same as in rangers scope.sh.

So the actual issue or feature request is to make nvimpager work without stdin: any assistance is appreciated ;)

lucc commented 6 years ago

You can use nvimpager -c -- "$FILE_PATH" </dev/tty && exit 5 as a workaround until nvimpager can be run without stdin.

lucc commented 6 years ago

Running without stdin might be difficult. I found this code and have to rethink the assumptions behind it before I change it (discussion welcome).

lucc commented 6 years ago

I decided that nvimpager will not officially support running without stdin. I am sorry you will have to use the workaround I posted above.

Dave-Elec commented 4 years ago

I tried the workaround above but I couldn't get colored output in ranger and lf. I could get colored output in a terminal though. Any workaround for that?

lucc commented 4 years ago

@Dave-Elec no, you have to give more info, last time I tried that workaround it worked. But arguably that was two years ago. What exactly are you donig, which versions are you useing, what does your config say?

Dave-Elec commented 4 years ago

I am using ranger 1.9.3 with python 3.8.2 along with nvimpager v0.6-16-g0f75843. I removed all ranger configurations and run ranger --copy-config scope and added nvimpager -c -- "$FILE_PATH" </dev/tty && exit 5 to handle_mime's text/* | */xml in scope.sh at the begining right next to maximum size checking. Tried it in lf too but I'm getting text with some bold areas and some incorrect coloring. Here is an example screenshot. https://imgur.com/pfnGi6C

lucc commented 4 years ago

I suspect that this is a different issue because the original poster did not get any visible output from nvimpager because no terminal was attached.

Did you try nvimpager -c -- "$FILE_PATH" and nvimpager -c -- "$FILE_PATH" </dev/tty with the same file without ranger? Does it look different?

Dave-Elec commented 4 years ago

In ranger without </dev/tty, Nothing is displayed. But on plain terminal both commands work perfectly fine.

Dave-Elec commented 4 years ago

I figured what was wrong with the output. I had set termguicolors in the configurations. Removed it and it is working as expected.