i60r / page Goto Github PK
View Code? Open in Web Editor NEWUse neovim as pager
License: MIT License
Use neovim as pager
License: MIT License
$ brew info page
page: stable 3.1.2 (bottled), HEAD
Use Neovim as pager
https://github.com/I60R/page
/usr/local/Cellar/page/3.1.2 (7 files, 1.9MB) *
Poured from bottle on 2022-07-28 at 11:02:00
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/page.rb
License: MIT
==> Dependencies
Build: rust ✔
Required: neovim ✔
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 0 (30 days), 0 (90 days), 0 (365 days)
install-on-request: 0 (30 days), 0 (90 days), 0 (365 days)
build-error: 0 (30 days)
$ nvim --version
NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/0.7.2_1/share/nvim"
Run :checkhealth for more info
$ export MANPAGER="page -t man"
$ export RUST_BACKTRACE=full
$ man ls
thread 'main' panicked at 'Cannot open PTY device: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/pager/main.rs:1077:26
stack backtrace:
0: 0x108d35488 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8926cb4beb3306db
1: 0x108ca2b3a - core::fmt::write::hc1f18fa3b50c7c9d
2: 0x108d1a63c - std::io::Write::write_fmt::h6b9f4c342a0c9249
3: 0x108d1f94d - std::panicking::default_hook::{{closure}}::h45609ee8da44383a
4: 0x108d1f611 - std::panicking::default_hook::h147f83b3ed514383
5: 0x108ce6cd6 - page::_init_panic_hook_::{{closure}}::h517300c10dea861b
6: 0x108d20407 - std::panicking::rust_panic_with_hook::h06323e959c8054b4
7: 0x108d35c84 - std::panicking::begin_panic_handler::{{closure}}::h0246d09db197196c
8: 0x108d35bf9 - std::sys_common::backtrace::__rust_end_short_backtrace::h674a492f79294b55
9: 0x108d1fd85 - _rust_begin_unwind
10: 0x108d5a9d3 - core::panicking::panic_fmt::haf68904a070dc633
11: 0x108d5ab85 - core::result::unwrap_failed::h3caffab0fad93818
12: 0x108ce1db0 - page::output_buffer_usage::BufferActions::get_buffer_pty::h730d0e975617b8ba
13: 0x108c44ffa - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hf28c2bb7eff0e42f
14: 0x108c4a4ae - page::manage_output_buffer::{{closure}}::h67f41b37e6e8a223
15: 0x108c33ad4 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h55945aab528942fe
16: 0x108c422ec - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::he1f6a73537156b6b
17: 0x108ce90d7 - page::main::hbf83097d654ff3e3
18: 0x108cc67a6 - std::sys_common::backtrace::__rust_begin_short_backtrace::h0443fd823b3692c9
19: 0x108ce710a - _main
This behavior persists even after I move aside my init.vim
, so that makes me more confident that I haven't broken something with my config. It also persists when running under kitty (TERM=xterm-kitty
) and iTerm2 (TERM=xterm-256color
).
Is there other useful troubleshooting information I can provide?
As a replacement for bat
and cat
, it would be nice to have a "cat mode". nvimpager already has this, although it has a few problems, like cat mode not honoring tabstop settings and not working with some plugins like treesitter.
I think a good cat mode would be super usefull, because treesitter syntax highlighting is just so much better than what bat
has to offer.
I set up page as my git pager:
:; git config core.pager 'page -O -t git'
:; git diff
[ 0000000376 | WARN | dump in page ]
cannot spawn bat, use stdout: Os { code: 2, kind: NotFound, message: "No such file or directory" }
diff --git ...
Though it worked, I was confused about the warning, not knowing what it was or that it was a dependency that needed to be installed.
After looking through the source, I tried installing it:
:; git diff
[bat error]: unknown syntax: 'git'
and now there's no output at all! One can't always assume that bat language names will match git filetypes.
There appears to be no way to configure this behaviour. I could've set PAGE_LOG=error
to silence all warnings, but there's no direct way to turn the bat fallback off. I also would be happy to run bat
if the --language
argument were omitted. I'd suggest:
-t
) and bat's language (--bat-language
? -T
?) separately-T
defaults to -t
's value, there should be a way to clear it with -T auto
or somethingstdin
, prefer bat --file-name
argument instead of bat --language
- this code seems incorrect, the extension is not a language and the filename should be passed instead if it is available.--language
, it will not panic if it does not recognize it)-T none
for example.page -O -t pager -T auto
would use bat
, while page -O -t rust -T none
would cat
insteadCurrently pager always puts cursor approximately on the middle line of the vim window. Is this expected behavior?
Tried this and many other approaches, how to force pager to always place cursor position on the first line by default?
aug Pager
au!
au User PageOpen
\| <cmd>call cursor(1,1)<CR>
aug END
What am I doing wrong?
Plus i don't understand how to pass commands with -e option, could you provide example?
cat | page -c NONE -e 'call cursor(1,1)'
This project is very nice, and it has replaced less in my daily use, many thanks!
There's a minor thing that bothers me: what's the use of the cursor in a pager? It'd be nice to be able to hide it... Does this sound like something doable?
Thought it might seem important to you.
distro: arch linux,
aur-helper: yay
Package Details: page-git v2.3.4-1
# current local version
$ page -V
page 2.1.0
I got the following error trying to upgrade from AUR:
Compiling page v2.3.4 (/home/wndx/.cache/yay/page-git/src/page)
error[E0599]: no method named `as_deref` found for type `std::option::Option<std::string::String>` in the current scope
--> src/page.rs:17:26
|
17 | let level = rust_log.as_deref().unwrap_or("warn");
| ^^^^^^^^ help: did you mean: `as_ref`
error[E0599]: no method named `as_deref` found for type `std::option::Option<std::string::String>` in the current scope
--> src/page.rs:135:70
|
135 | let cmd_provided_by_user = &nvim_ctx.opt.command.as_deref().unwrap_or_default();
| ^^^^^^^^ help: did you mean: `as_ref`
error[E0599]: no method named `as_deref` found for type `std::option::Option<std::string::String>` in the current scope
--> src/page.rs:171:61
|
171 | let cmd_provided_by_user = nvim_ctx.opt.command.as_deref().unwrap_or_default();
| ^^^^^^^^ help: did you mean: `as_ref`
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/page.rs:171:17
|
171 | let cmd_provided_by_user = nvim_ctx.opt.command.as_deref().unwrap_or_default();
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `str`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
error[E0599]: no method named `as_deref` found for type `std::option::Option<std::string::String>` in the current scope
--> src/neovim.rs:446:93
|
446 | let (nvim_session, nvim_proc) = if let Some(nvim_listen_addr) = cli_ctx.opt.address.as_deref() {
| ^^^^^^^^ help: did you mean: `as_ref`
error: aborting due to 5 previous errors
Some errors occurred: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: Could not compile `page`.
To learn more, run the command again with --verbose.
==> ERROR: A failure occurred in package().
Aborting...
Error making: page-git
Would you mind to fix this pls? ❤️
Sometimes the location of nvim
executable/alias may not be setup in the current shell session.
(In my case I'm trying to use page
as Kitty's pager but I suspect it's broken because page
cannot find nvim when it was run)
Would you accept a patch to add this as a config? Thanks!
Failed to update from AUR repo.
Compiling page v3.1.0 (/home/user/Downloads/build/page-git/src/page)
error[E0433]: failed to resolve: use of undeclared type `Lazy`
--> src/pager/context.rs:41:31
|
41 | let term_dimensions = Lazy::new(|| {
| ^^^^ not found in this scope
|
help: consider importing one of these items
|
16 | use crate::context::Lazy;
|
16 | use futures::future::Lazy;
|
16 | use once_cell::sync::Lazy;
|
16 | use once_cell::unsync::Lazy;
|
error[E0433]: failed to resolve: use of undeclared type `Lazy`
--> src/pager/context.rs:73:25
|
73 | term_width: Lazy::new(|| {
| ^^^^ not found in this scope
|
help: consider importing one of these items
|
16 | use crate::context::Lazy;
|
16 | use futures::future::Lazy;
|
16 | use once_cell::sync::Lazy;
|
16 | use once_cell::unsync::Lazy;
|
error[E0277]: can't compare `{integer}` with `once_cell::unsync::Lazy<usize>`
--> src/pager/main.rs:189:18
|
189 | if j == env_ctx.term_width {
| ^^ no implementation for `{integer} == once_cell::unsync::Lazy<usize>`
|
= help: the trait `PartialEq<once_cell::unsync::Lazy<usize>>` is not implemented for `{integer}`
= help: the following other types implement trait `PartialEq<Rhs>`:
f32
f64
i128
i16
i32
i64
i8
isize
and 6 others
Some errors have detailed explanations: E0277, E0433.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `page` due to 3 previous errors
==> ERROR: A failure occurred in package().
Aborting...
error: failed to build 'page-git-v3.1.2-1':
error: packages failed to build: page-git-v3.1.2-1
I'm trying to use the next-release
branch because I wanted to try the new -O
option but am encountering the following error:
# echo hi | page
Vim: Error reading input, exiting...
Vim: Finished.
thread 'main' panicked at 'Error sending message: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', /build/page-2.3.5-vendor.tar.gz/neovim-lib/src/rpc/client.rs:188:36
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I've tried both fb3b36f and e7bf0ee but am unable to get it working. 2.3.5 is working fine however. Any idea what I'm doing wrong or is the branch just currently not usable?
(could it be neovim 0.6 is the problem?)
Using the following command:
git --no-pager diff | diff-so-fancy | page
I can see some glitches in the output, which seem to originate from this warning being printed.
I've solved this for now by launching page
as:
env RUST_LOG=error page
Please consider renaming the RUST_LOG
environment variable to something page specific, such as PAGE_LOG
. The parser of the env var is incompatible and cannot coexist with crates that use env-logger. When developing a rust crate, one doesn't expect git diff
and similar commands to spew out debug output or panic due to this env var being set.
I'm using page
for my scroll back buffer in kitty and I would like to set the cursor at the last non-empty line. I tried searching for a particular pattern in my prompt to move the cursor there, but I haven't been able to do it successfully. I believe the problem is that at the time I'm doing the search there's still no text on the screen.
This is what I'm trying:
au User PageDisconnect call feedkeys("G?╼\<CR>")
I also tried redrawing before doing the search but it's still failing.
au User PageDisconnect redraw | call feedkeys("G?╼\<CR>")
Do you have any ideas on how to get around this issue?
Ultimately, I think the problem is the terminal emulator in vim putting empty lines at the end of the buffer.
As title, I have remapped <C-\>
to other use, and it turns out to have problem when I use neovim as a pager.
Just installed the mac binary,
ls | page gives me:
thread 'main' panicked at 'Cannot open page PTY: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/page.rs:353:48
[Process exited 1] note: run with `RUST_BACKTRACE=1`environment variable to display a backtrace
❌ exit code: 101
🔸~/Downloads$
with RUST_BACKTRACE=1:
�[?1049h�[22;0t�[?1h�=�[H�[2J�]11;?��[?2004h�[?25hVim: Error reading input, exiting...
�[?25l�(B�[m�[H�[2J�[H�[2J�[K
�[94m~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
~�[K
�(B�[m�[93m�[104m[No Name]�[53X�[53C1,0-1 All�]112��[2 q�]112��[2 q�[H�[?25hVim: Finished.
�[?25l�[23B�[?25h�[?25l�]112��[2 q�(B�[m�[?25h�[?1l�>�[?1049l�[23;0t�[?2004l�[?1004l�[?25hthread 'main' panicked at 'Error sending message: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', /Users/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/neovim-lib-0.6.1/src/rpc/client.rs:188:9
stack backtrace:
0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
1: core::fmt::write
2: std::io::Write::write_fmt
3: std::panicking::default_hook::{{closure}}
4: std::panicking::rust_panic_with_hook
5: rust_begin_unwind
6: core::panicking::panic_fmt
7: core::option::expect_none_failed
8: neovim_lib::rpc::client::Client<R,W>::send_msg
9: neovim_lib::session::Session::call
10: <neovim_lib::neovim::Neovim as neovim_lib::neovim_api::NeovimApi>::subscribe
11: page::main
12: std::rt::lang_start::{{closure}}
13: main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
The following error occurs when using telescope.nvim and tools that call page
(like delta)
thread thread 'main' panicked at 'Cannot create buffer: NeovimError (Some (0)
Hello,
I just installed latest git version of page
from AUR, it's truly fantastic, but I've noticed issue with journalctl
(I run it with PAGER=page journalctl
. I also tried to run page
with empty vimrc, like that
touch ~/min.vim
PAGER='page -c ~/min.vim' journalctl
but I could still observe the issue).
Problem is that nvim buffer starts scrolling on its own after few seconds. It cannot be stopped otherwise than exiting nvim, as far I can tell. Also page
seems to be eagerly loading whole output of the journalctl
, which can be costly. I couldn't find find switch to enable on-demand fetching more content akin to what less
is doing.
My installation:
[fenuks@fenuks fenuks]$ page --version
page 1.8.0
[fenuks@fenuks fenuks]$ nvim --version
NVIM v0.3.1
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wconversion -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.3.1/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser
Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
Neovim's builtin pager functionality have syntax highlight. But by default page does not seem to have one. So how can I enable it?
If I understood correctly I should be able to use page
even without an active nvim instance, but this gives me the following error after executing page Cargo.lock
(file from the git repo):
thread 'main' panicked at 'Cannot connect to parent neovim: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
With env RUST_BACKTRACE=1 page Cargo.lock
:
thread 'main' panicked at 'Cannot connect to parent neovim: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:1165:5
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:77
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:61
4: core::fmt::write
at src/libcore/fmt/mod.rs:1028
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1412
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:65
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:50
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:188
9: std::panicking::default_hook
at src/libstd/panicking.rs:205
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:464
11: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:373
12: rust_begin_unwind
at src/libstd/panicking.rs:302
13: core::panicking::panic_fmt
at src/libcore/panicking.rs:139
14: core::result::unwrap_failed
at src/libcore/result.rs:1165
15: page::main
16: std::rt::lang_start::{{closure}}
17: main
18: __libc_start_main
19: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
echo $NVIM_LISTEN_ADDRESS
returns /tmp/nvimsocket
which I configured for nvr
this might have something to do with this error.
env NVIM_LISTEN_ADDRESS= page Cargo.lock
opens the file views it for a split second after which only an empty buffer is visible, page
outputs /tmp/neovim-page/DO-NOT-REDIRECT-OUTSIDE-OF-NVIM-TERM(--help[-W])
on the command line.
env NVIM_LISTEN_ADDRESS= page -W Cargo.lock
gets the same result but without any output on the commandline.
Hi,
Would you be willing to remove the Cargo.lock from the .gitignore and commit it?
It would greatly simplify installation on nixos, and would allow me to try to add page to the nixpkgs repo.
Thanks
s1341
"page" crashes if a greeter plugin (alpha-nvim specific to my issue) is installed. Wondering if there is a workaround for this, beyond just disabling alpha which is used extensively.
I started using colemak-dh and bind mnei
to hjkl
and vice versa. mneilh
works, but jk
doesn't.
I would expect from -w
to also don't bind jk
config
...
noremap h m
noremap j e
noremap k n
noremap l i
noremap m h
noremap n j
noremap e k
nnoremap i l
noremap H M
noremap J E
noremap K N
noremap L I
noremap M H
noremap N J
noremap E K
noremap I L
...
I run this
$ PAGE_LOG=debug page -wWC -q 90000 -z 90000 man://"page"
[ 0000000215 | INFO | context in page ]
Env {
opt: Options {
name: None,
address: None,
arguments: None,
config: None,
command_post: None,
lua_post: None,
instance: None,
instance_append: None,
instance_close: None,
output_open: false,
pty_path_print: false,
follow: false,
follow_all: false,
back: false,
back_restore: false,
command_auto: true,
page_no_protect: true,
pagerize: None,
pagerize_hidden: None,
files: [
Uri(
"man://page",
),
],
output: OutputOptions {
command: None,
lua: None,
noopen_lines: None,
query_lines: Some(
Some(
90000,
),
),
filetype: "pager",
writable: true,
pwd: false,
split: SplitOptions {
split_left: 0,
split_right: 0,
split_above: 0,
split_below: 0,
split_left_cols: None,
split_right_cols: None,
split_above_rows: None,
split_below_rows: None,
popup: false,
},
},
output_implied: OnceCell(Uninit),
output_split_implied: OnceCell(
false,
),
},
prefetch_usage: Disabled,
query_lines_count: 90000,
input_from_pipe: false,
}
[ 0000001146 | INFO | context in page ]
Env {
opt: Options {
name: None,
address: None,
arguments: None,
config: None,
command_post: None,
lua_post: None,
instance: None,
instance_append: None,
instance_close: None,
output_open: false,
pty_path_print: false,
follow: false,
follow_all: false,
back: false,
back_restore: false,
command_auto: true,
page_no_protect: true,
pagerize: None,
pagerize_hidden: None,
files: [
Uri(
"man://page",
),
],
output: OutputOptions {
command: None,
lua: None,
noopen_lines: None,
query_lines: Some(
Some(
90000,
),
),
filetype: "pager",
writable: true,
pwd: false,
split: SplitOptions {
split_left: 0,
split_right: 0,
split_above: 0,
split_below: 0,
split_left_cols: None,
split_right_cols: None,
split_above_rows: None,
split_below_rows: None,
popup: false,
},
},
output_implied: OnceCell(Uninit),
output_split_implied: OnceCell(
false,
),
},
prefetch_usage: Disabled,
query_lines_count: 90000,
input_from_pipe: false,
}
[ 0000002134 | INFO | context in page ]
Usage {
opt: Options {
name: None,
address: None,
arguments: None,
config: None,
command_post: None,
lua_post: None,
instance: None,
instance_append: None,
instance_close: None,
output_open: false,
pty_path_print: false,
follow: false,
follow_all: false,
back: false,
back_restore: false,
command_auto: true,
page_no_protect: true,
pagerize: None,
pagerize_hidden: None,
files: [
Uri(
"man://page",
),
],
output: OutputOptions {
command: None,
lua: None,
noopen_lines: None,
query_lines: Some(
Some(
90000,
),
),
filetype: "pager",
writable: true,
pwd: false,
split: SplitOptions {
split_left: 0,
split_right: 0,
split_above: 0,
split_below: 0,
split_left_cols: None,
split_right_cols: None,
split_above_rows: None,
split_below_rows: None,
popup: false,
},
},
output_implied: OnceCell(Uninit),
output_split_implied: OnceCell(
false,
),
},
tmp_dir: "/tmp/neovim-page",
page_id: 1688637735706178692,
prefetched_lines: 0 Strings,
query_lines_count: 90000,
input_from_pipe: false,
print_protection: false,
}
I tried them but nothing happened. The log is shown below.
$ export PAGE_LOG=debug; rg -p "<leader>" | page
[ 0000000426 | INFO | context in page ]
Env {
opt: Options {
name: None,
address: None,
arguments: None,
config: None,
command_post: None,
lua_post: None,
instance: None,
instance_append: None,
instance_close: None,
output_open: false,
pty_path_print: false,
follow: false,
follow_all: false,
back: false,
back_restore: false,
command_auto: false,
page_no_protect: false,
pagerize: None,
pagerize_hidden: None,
files: [],
output: OutputOptions {
command: None,
lua: None,
noopen_lines: None,
query_lines: None,
filetype: "pager",
writable: false,
pwd: false,
split: SplitOptions {
split_left: 0,
split_right: 0,
split_above: 0,
split_below: 0,
split_left_cols: None,
split_right_cols: None,
split_above_rows: None,
split_below_rows: None,
popup: false,
},
},
output_implied: OnceCell(Uninit),
output_split_implied: OnceCell(
false,
),
},
prefetch_usage: Disabled,
query_lines_count: 0,
input_from_pipe: true,
}
[ 0000002168 | INFO | context in page ]
Env {
opt: Options {
name: None,
address: None,
arguments: None,
config: None,
command_post: None,
lua_post: None,
instance: None,
instance_append: None,
instance_close: None,
output_open: false,
pty_path_print: false,
follow: false,
follow_all: false,
back: false,
back_restore: false,
command_auto: false,
page_no_protect: false,
pagerize: None,
pagerize_hidden: None,
files: [],
output: OutputOptions {
command: None,
lua: None,
noopen_lines: None,
query_lines: None,
filetype: "pager",
writable: false,
pwd: false,
split: SplitOptions {
split_left: 0,
split_right: 0,
split_above: 0,
split_below: 0,
split_left_cols: None,
split_right_cols: None,
split_above_rows: None,
split_below_rows: None,
popup: false,
},
},
output_implied: OnceCell(Uninit),
output_split_implied: OnceCell(
false,
),
},
prefetch_usage: Disabled,
query_lines_count: 0,
input_from_pipe: true,
}
[ 0000003828 | INFO | context in page ]
Usage {
opt: Options {
name: None,
address: None,
arguments: None,
config: None,
command_post: None,
lua_post: None,
instance: None,
instance_append: None,
instance_close: None,
output_open: false,
pty_path_print: false,
follow: false,
follow_all: false,
back: false,
back_restore: false,
command_auto: false,
page_no_protect: false,
pagerize: None,
pagerize_hidden: None,
files: [],
output: OutputOptions {
command: None,
lua: None,
noopen_lines: None,
query_lines: None,
filetype: "pager",
writable: false,
pwd: false,
split: SplitOptions {
split_left: 0,
split_right: 0,
split_above: 0,
split_below: 0,
split_left_cols: None,
split_right_cols: None,
split_above_rows: None,
split_below_rows: None,
popup: false,
},
},
output_implied: OnceCell(Uninit),
output_split_implied: OnceCell(
false,
),
},
tmp_dir: "/tmp/neovim-page",
page_id: 1687332572111737309,
prefetched_lines: 0 Strings,
query_lines_count: 0,
input_from_pipe: true,
print_protection: false,
}
First, thanks for making this! This is perfect for using a scrollback pager in kitty (https://sw.kovidgoyal.net/kitty/).
The one thing I haven't been able to figure out how to do is choose the config I'm using with page, which would let me choose which plugins to load. I'd like to set up a minimal configuration, so that it's not that much slower than less.
As far as I can tell, commands given with the -e flag are still loaded after the rest of my config.
I also get some slowness from running commands after nvim actually loads -- I'm doing "setl nonumber norelativenumber", which is different from my normal config and so the line numbers flicker on and off as page loads, and because I can't figure out how to use the "+" flag (to start at the bottom of the page) I end up using "-E 'normal G'" instead (which also flickers as the page loads at the top before jumping to the bottom). I also end up doing "set shortmess=I" in order to prevent the introduction dialogue from flashing up briefly.
In the end I'm still liking page a lot, but it ends up being noticeably slower than "command | nvim -R + -" to finish loading.
I imagine this is the sort of thing where it's a one-liner if I knew the neovim API better...
Anyway, I'll be curious if there's something I'm missing, or if this is something you think I can easily slip into page.rs somewhere.
Thanks again for the tool!
Say I have a git repo in which I changed file encodings, git diff | less
shows me something like this:
_
- A<92>B
+ A<U+0092>B
B
(with inverted colour around the <X>
parts to indicate they're escaped)
git diff | page
(via next_release
) doesn't like it one bit:
_
Error reading line from stdin: stream did not contain valid UTF-8
It's worth noting that page master
appears to handle this fine, and passes it along to nvim which displays it relatively sanely (similarly to how less does).
Thanks for writing pager, I find it really useful.
There is only one thing I find annoying. Some commands return a short output, but they use the default $PAGER
env variable, which I set to page
. In this cases I'd like to just print the output without calling page
. In less
there is a -F or --quit-if-one-screen
option. Do you have any plans to add a similar option to page
?
In any case, thanks for page
When piping output of an actively running command, when we have to exit, it causes a panic (after nvim has exited), with the message:
thread 'main' panicked at 'Read from stdin failed unexpectedly: Os { code: 5, kind: Uncategorized, message: "Input/output error" }', src/page.rs:325:75
I can't say if its good use case, but for eg. piping output of a make command, etc.
The make errors are due to make being killed before completing, not related to page
As of now, I can think of these
:q
in nvim, less does that by default when it's closed as it seemsbut problem is what if the piped command has higher authority for eg.
sudo dmesg | page
Or when the piped command ends (if we can get it, i tried looking at code, dont know)
Also, I wanted to symlink less to page, any other problematic case 😅 ?
As reported by @sandersantema in #12:
env NVIM_LISTEN_ADDRESS= page Cargo.lock opens the file views it for a split second after which only an empty buffer is visible, page outputs /tmp/neovim-page/DO-NOT-REDIRECT-OUTSIDE-OF-NVIM-TERM(--help[-W]) on the command line.
env NVIM_LISTEN_ADDRESS= page -W Cargo.lock gets the same result but without any output on the commandline.
SHELL=bash 5.1.16
TERM=kitty
After setting: export MANPAGER="page -t man"
open a man page, for example "man sway"
then Q to quit or " :Q" since it's neovim habit
upon closing shell is still not ready for new command unless one presses Ctrl + C to kill previous man command
An "empty" value for -O
implies terminal height, however this does not take the user's prompt height into account. Most users presumably do not want the top X lines of input to scroll away with their prompt. Someone might even like to add an extra line so that the original command prompt that spawned the pager is visible too! Allowing a negative value for -O
seems like a natural way to augment the auto-detected height, though a separate flag could work too of course.
It also feels like the count is off by one or two; with a terminal 34 lines tall for example...
seq 1 33 | page -O
spawns nvim despite it only printing 33 lines without the pager (which is enough room for the prompt too!)seq 1 33 | page -O 34
is equivalent to the aboveseq 1 33 | page -O 33
spawns nvim despite the input only consisting of exactly 33 lines. This one might be intentional if you assume a prompt is one line long, but it feels wrong?I tried installing the latest release, and building from source. In both cases, when I pipe anything to page I get the text "Error: Timeout" and neovim exits.
When the terminal dimensions are really small, the following command is not paged when piped to page -O 1
:
echo "Thalassodromeus was a pterosaur (a flying reptile) that lived in what is now northeastern Brazil about 100 million years ago, during the Early Cretaceous. The original skull was discovered in 1983 in the Romualdo Formation of the Araripe Basin. This genus had one of the largest known skulls among pterosaurs, around 1.42 metres (4 ft 8 in) long, with one of the largest cranial crests of any vertebrate in proportion to its skull. Running from the tip of the upper jaw to beyond the occiput at the back of the skull, the lightly built crest may have been used for thermoregulation or in display behaviour. The crest may not have fully developed until after sexual maturity. Though only the skull is known, the animal is estimated to have had a wingspan of 4.2 to 4.5 m (14 to 15 ft). The jaws were toothless, with sharp upper and lower edges and strong musculature. Thalassodromeus may have been able to kill and eat prey on the ground."
but it is when piped to less -F
.
Terminal width should be considered when determining whether the input fits the screen (or the given NOOPEN_LINES
lines):
Lines 172 to 187 in 2476a05
i
decremented once the new counter is equal to the terminal width.Hi, for me one of the most important things about using page
as a pager is the ability to easily copy. But when you open files with long lines, like a system log, page
breaks the long lines. Is there any way to prevent this behavior?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.