Git Product home page Git Product logo

neoman.vim's Introduction

neoman

Read manpages faster than superman!

neoman in action

Features

  • Manpage autocompletion
  • Open manpages whose section is not just a number
  • Much more intuitive behavior than the builtin manpage plugin
  • Open in a split/vsplit/tabe
  • Open from inside a neovim terminal!
  • Jump to manpages in specific sections through the manpage links

Install

Any plugin manager should work fine.

Plug 'nhooyr/neoman.vim' "vim-plug

Usage

Command

The command is as follows:

Neoman[!] [{sect}] {page}[({sect})]

Several ways to use it, probably easier to explain with a few examples.

Neoman printf
Neoman 3 printf
Neoman printf(3)

Inside a manpage, press <c-]> on a manpage link to jump to the manpage. Or you can set the following in your init.vim/.vimrc and use K instead.

set keywordprg=:Neoman

By default if a neoman window is already open, it will be switched to, if you would like it to open in the current window, use the bang.
Or set g:neoman_current_window in which case the behaviors are swapped.

Splits

Want to split/vsplit/tabe? Pretty simple.

:vsplit | Neoman! 3 printf

You can very easily make that a custom command or mapping.

Command line integration

Neovim

You will need nvr for the super cool neovim terminal integration.

Add the following functions to your .zshrc/.bashrc

_nman() {
	if [[ "$@" == "" ]]; then
		print "What manual page do you want?"
		return
	fi
	/usr/bin/man "$@" > /dev/null 2>&1
	if [[ "$?" != "0" ]]; then
		print "No manual entry for $*"
		return
	fi
	if [[ -z $NVIM_LISTEN_ADDRESS ]]; then
		/usr/bin/env nvim -c $cmd
	else
		nvr --remote-send "<c-n>" -c $cmd
	fi
}
nman() {
	cmd="Neoman $*"
	_nman "$@"
}
nman!() {
	cmd="Neoman! $*"
	_nman "$@"
}

Vim

_nman() {
	if [[ "$@" == "" ]]; then
		print "What manual page do you want?"
		return
	fi
	/usr/bin/man "$@" > /dev/null 2>&1
	if [[ "$?" != "0" ]]; then
		print "No manual entry for $*"
		return
	fi
	vim -c $cmd
}
nman() {
	cmd="Neoman $*"
	_nman "$@"
}
nman!() {
	cmd="Neoman! $*"
	_nman "$@"
}

Autocomplete

zsh
compdef nman="man"
compdef nman!="man"
bash
complete -o default -o nospace -F _man nman
complete -o default -o nospace -F _man nman!

Use nman/nman! to open the manpages. nman! works the same way as :Neovim!.

I've really only tested this with zsh, if you have any problems with bash and fix them please send a PR!

Settings

Only setting is g:neoman_current_window. This is explained above in the command section.

TODO:

  • Vim docs

neoman.vim's People

Contributors

nhooyr avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.