lucc / nvimpager

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

Monitor file for changes #21

Closed plurry closed 1 year ago

plurry commented 4 years ago

Is there a way to use nvimpager like less +F or tail -f (or tail -F ideally) to watch log files as they grow?

lucc commented 4 years ago

Such a thing is currently not implemented and not possible. There are some notes about this limitation in the readme under "todo".

Notes for the future

lucc commented 4 years ago

The same is discussed for vimpager: https://github.com/rkitover/vimpager/issues/247

That issue links to an interesting SO answer: https://unix.stackexchange.com/a/417939/88313

It might be possible to use the autoread option.

lucc commented 4 years ago

@plurry The following settings in the nvimpager init file might work but only for real files, not for pipes:

set autoread
au CursorHold * checktime
plurry commented 4 years ago

I quickly tried that just now and it didn't seem to work. Anyway, it's not critical for me. I just wanted to make sure I didn't miss some obvious option somewhere.

Thanks. Feel free to close if you'd like.

lucc commented 4 years ago

You might have to set updatetime to a lower value or be more patient :)

An even better solution might be timers as they do not only fire once after the user did something:

set autoread
call timer_start(300, {id -> nvim_command("checktime")}, {"repeat": -1})
midirhee12 commented 3 years ago

@plurry Have you tried running nvimpager in watch or entr. I have no clue if it works, but it is probably worth a try

lucc commented 2 years ago

@cvoges12 The situation we are thinking about here is nvimpager waiting on some more text from a long running pipeline or a long log file that is being appended to. watch restarts the program you give it so it would restart the whole long running pipeline or open the long logfile every n seconds. That is not what one wants.

lucc commented 1 year ago

I have implemented a version of follow mode based on the timer + checktime solution proposed above. It does not handle input via stdin from long running commands though. That is a limitation of nvimpager in general.