├── README.md ├── img ├── animation01.gif ├── screenshot01.png └── screenshot02.png └── vimman.zsh /README.md: -------------------------------------------------------------------------------- 1 | vimman - View vim plugin manuals (help) like man in zsh 2 | ========================== 3 | 4 | vimehelp makes opening the vim help quickly in zsh. 5 | 6 | ![animation01](https://raw.github.com/yonchu/vimman/master/img/animation01.gif) 7 | 8 | ![Screenshot02](https://raw.github.com/yonchu/vimman/master/img/screenshot02.png) 9 | 10 | 11 | ## Installation 12 | 13 | Clone `vimman` from github. 14 | 15 | ```console 16 | $ git clone https://github.com/yonchu/vimman.git 17 | ``` 18 | 19 | Source `vimman/vimman.zsh` in your `.zshrc` and restart zsh. 20 | 21 | ```zsh 22 | source /path/to/vimman/vimman.zsh 23 | ``` 24 | 25 | ## Usage 26 | 27 | ``` 28 | Usage: 29 | 30 | $ vimman [-e] 31 | 32 | Options: 33 | -e : Edit the vim plugin help (not use :help command) 34 | ``` 35 | 36 | If you want to use the cache, set the followings in your .zshrc: 37 | 38 | ```zsh 39 | zstyle ':completion:*' use-cache yes 40 | ``` 41 | 42 | ## Customizing 43 | 44 | Custom plugin directories (besides default `~/.vim/doc`): 45 | 46 | ```zsh 47 | zstyle ':vimman:' dir ~/.vim/bundle ~/hoge 48 | ``` 49 | 50 | Display verbose (print the path to the help file): 51 | 52 | ```zsh 53 | zstyle ':vimman:' verbose yes 54 | ``` 55 | 56 | Cache expiration days (default: 1): 57 | 58 | ```zsh 59 | zstyle ':vimman:' expire 7 60 | ``` 61 | 62 | Note that if you change the zstyle settings, 63 | you should delete the cache file and restart zsh. 64 | 65 | ```console 66 | $ rm ~/.zcompcache/vimman 67 | $ exec zsh 68 | ``` 69 | 70 | ## License 71 | 72 | MIT License 73 | 74 | ## Copyright 75 | 76 | Copyright (c) 2013 Yonchu. 77 | 78 | ## See also 79 | 80 | Japanese manual: 81 | 82 | -------------------------------------------------------------------------------- /img/animation01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonchu/vimman/27b13693a19d65096d29f0d03c0d4fd6d5c7ea7a/img/animation01.gif -------------------------------------------------------------------------------- /img/screenshot01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonchu/vimman/27b13693a19d65096d29f0d03c0d4fd6d5c7ea7a/img/screenshot01.png -------------------------------------------------------------------------------- /img/screenshot02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yonchu/vimman/27b13693a19d65096d29f0d03c0d4fd6d5c7ea7a/img/screenshot02.png -------------------------------------------------------------------------------- /vimman.zsh: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------- 2 | # 3 | # vimman 4 | # 5 | # View vim plugin manuals (help) like man in zsh 6 | # 7 | # ----------------------------------------------------------------------------- 8 | # 9 | # Version : 0.1.0 10 | # Author : Yonchu 11 | # License : MIT License 12 | # Repository : https://github.com/yonchu/vimman 13 | # Last Change : 19 Aug 2014. 14 | # 15 | # Copyright (c) 2013 Yonchu. 16 | # 17 | # ----------------------------------------------------------------------------- 18 | # 19 | # Usage: 20 | # 21 | # $ vimman [-e] 22 | # 23 | # Options: 24 | # -e : Edit the vim plugin help (not use :help command) 25 | # 26 | # Settings: 27 | # 28 | # - Custom plugin directories: 29 | # zstyle ':vimman:' dir ~/.vim/bundle ~/hoge 30 | # 31 | # - Display verbose (print the path to the help file): 32 | # zstyle ':vimman:' verbose yes 33 | # 34 | # - Cache expiration days (default: 7): 35 | # zstyle ':vimman:' expire 1 36 | # 37 | # 38 | # Note that if you change the zstyle settings, 39 | # you should delete the cache file and restart zsh. 40 | # 41 | # $ rm ~/.zcompcache/vimman 42 | # $ exec zsh 43 | # 44 | # ----------------------------------------------------------------------------- 45 | 46 | case $- in 47 | *i*) ;; 48 | *) 49 | echo 'ERROR: vimman.zsh is meant to be sourced, not directly executed.' 1>&2 50 | exit 1 51 | esac 52 | 53 | function vimman() { 54 | typeset -aU help_dir 55 | local -a targets 56 | local param dir f 57 | local editor="$EDITOR" 58 | 59 | if [[ $# -lt 1 ]]; then 60 | echo 'ERROR: not enough arguments' 1>&2 61 | return 1 62 | fi 63 | 64 | if [[ ! ${(L)editor} =~ vim ]]; then 65 | editor=vim 66 | fi 67 | 68 | ## Open help file with :help command. 69 | if [[ $1 != '-e' ]]; then 70 | echo ":help $1" 71 | "$editor" -c ":help $1 | only" 72 | return 0 73 | fi 74 | 75 | ## Edit help file with editor. 76 | shift 77 | if [[ $# -lt 1 ]]; then 78 | echo 'ERROR: not enough arguments (-e)' 1>&2 79 | return 1 80 | fi 81 | 82 | # Target directories where search help file. 83 | zstyle -a ':vimman:' dir help_dir 84 | help_dir+=(~/.vim/doc(N-/)) 85 | 86 | # Setup doc directories. 87 | targets=() 88 | for dir in "${help_dir[@]}"; do 89 | if [[ ! -d $dir ]]; then 90 | continue 91 | fi 92 | targets+=(${(f)"$(find -L "$dir" -type d -name '.neobundle' -prune -o -type f -name "$1" -print)"}) 93 | done 94 | 95 | if [[ ${#targets} -eq 0 ]]; then 96 | echo "No manual entry for $1" 97 | return 1 98 | fi 99 | 100 | echo "${(j:\n:)${targets[@]/#$HOME/~}}" 101 | "$editor" "${targets[@]}" 102 | } 103 | 104 | function _vimman() { 105 | local curcontext="$curcontext" update_policy state update_msg 106 | 107 | # Setup cache-policy. 108 | zstyle -s ":completion:${curcontext}:" cache-policy update_policy 109 | if [[ -z $update_policy ]]; then 110 | zstyle ":completion:${curcontext}:" cache-policy _vimman_caching_policy 111 | fi 112 | 113 | # Retrieve cache. 114 | # The cache file name: vimman 115 | # The cache variable name: _vimman_help_files 116 | if ( ! (( $+_vimman_help_files )) \ 117 | || _cache_invalid 'vimman' ) \ 118 | && ! _retrieve_cache 'vimman'; then 119 | update_msg=' (cache updated)' 120 | _vimman_help_files=(${(f)"$(_vimman_get_help_files)"}) 121 | _store_cache 'vimman' _vimman_help_files 122 | fi 123 | 124 | _arguments -C \ 125 | '(-e)-e[edit vim plugin help command (:help xxxx)]' \ 126 | '*: :->help_files' \ 127 | && return 128 | 129 | case $state in 130 | help_files) 131 | _describe -t helpfile "help file$update_msg" _vimman_help_files || return 1 132 | ;; 133 | esac 134 | return 0 135 | } 136 | 137 | function _vimman_get_help_files() { 138 | typeset -aU help_dir 139 | local -a doc 140 | local -a help_files 141 | local dir files f 142 | local verbose 143 | 144 | # Target directories to search help file. 145 | zstyle -a ':vimman:' dir help_dir 146 | help_dir+=(~/.vim/doc(N-/)) 147 | 148 | # Check verbose option. 149 | zstyle -b ':vimman:' verbose verbose 150 | 151 | # Setup doc directories. 152 | for dir in "${help_dir[@]}"; do 153 | if [[ ! -d $dir ]]; then 154 | continue 155 | fi 156 | doc+=(${(f)"$(find -L "$dir" -type d -name 'doc')"}) 157 | done 158 | 159 | # Get help files. 160 | help_files=() 161 | for dir in "$doc[@]"; do 162 | if [[ $dir =~ '/\.neobundle/' ]]; then 163 | continue 164 | fi 165 | files=(${(f)"$(ls -1 "$dir")"}) 166 | for f in "$files[@]"; do 167 | if [[ $f =~ '.*\.(txt|jax)' ]]; then 168 | if [[ $verbose == 'yes' ]]; then 169 | dir="${${dir/#$HOME/\~}%/}" 170 | help_files+=("$f:$dir") 171 | else 172 | help_files+=("$f") 173 | fi 174 | fi 175 | done 176 | done 177 | echo "${(j:\n:)help_files}" 178 | } 179 | 180 | function _vimman_caching_policy() { 181 | # Returns status zero if the completions cache needs rebuilding. 182 | local -a oldp 183 | local expire 184 | zstyle -s ':vimman:' expire expire || expire=7 185 | # Rebuild if cache is more than $expire days. 186 | oldp=( "$1"(Nm+$expire) ) 187 | (( $#oldp )) 188 | } 189 | 190 | compdef _vimman vimman 191 | --------------------------------------------------------------------------------