Skip to content

Latest commit

 

History

History
112 lines (86 loc) · 3.93 KB

README.md

File metadata and controls

112 lines (86 loc) · 3.93 KB

Nvimpager

Using neovim as a pager to view man pages, git diffs, whatnot with neovim's syntax highlighting and mouse support.

About

The nvimpager script calls neovim in a fashion that turns it into something like a pager. The idea is not new, this is actually rewrite of vimpager but with less (but stricter) dependencies and specifically for neovim.

Some typical use cases:

# view a file in nvimpager
nvimpager file
# pipe text to nvimpager
echo some text | nvimpager
# use it as your default $PAGER
export PAGER=nvimpager
man bash
git diff

The script also has a "cat mode" which will not start up the neovim interface but instead print a highlighted version of the file to the terminal. Like cat with neovim syntax highlighting! If the input has less lines than the terminal cat mode is activated automatically so nvimpager behaves similar to less -F. Pager mode and cat mode can be enforced with the options -p and -c respectively.

Nvimpager comes with a small set of command line options but you can also use all of neovim's command line options. Use nvimpager -h to see the help text. The configuration is separated from the users config for neovim. The main config file is ~/.config/nvimpager/init.vim (or .lua). See the manpage for further explanation.

Installation

Packaging status

Nvimpager is already packaged for some distributions. If not for yours, you can install it manually, read on.

Dependencies

Installation instructions

Use the makefile to configure and install the script. It supports the usual PREFIX (defaults to /usr/local) and DESTDIR (defaults to empty) variables:

make PREFIX=$HOME/.local install

The target install-no-man can be used to install nvimpager without the man page.

Additionally the variable BUSTED can be used to specify the executable for the test suite:

make test BUSTED="/path/to/busted --some-args"

Development

Nvimpager is developed on GitHub where you are very much invited to post bug reports, feature or pull requests! The test can be run with make test. They are also run on GitHub: Build Status

Limitations

  • if reading from stdin, nvimpager (like nvim) waits for EOF until it starts up
  • large files are slowing down neovim on startup (less does a better, i.e. faster and more memory efficient job at paging large files)

Ideas

  • see how neovim#5035, neovim#7438 and neovim#23093 are resolved and maybe move more code (logic) from bash to lua (bash's [[ -t ... ]] can be replaced by has('ttyin'), has('ttyout'))
  • proper lazy pipe reading while paging (like less) to improve startup time and also memory usage for large input on pipes (maybe stdioopen() can be used?)

License

The project is licensed under a BSD-2-clause license. See the LICENSE file.