mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 07:20:04 +08:00
refactor(manpage): move SPC h m
to fuzzy finder layer
This commit is contained in:
parent
94e03bccfb
commit
9501ee299e
@ -161,8 +161,6 @@ function! SpaceVim#layers#core#config() abort
|
|||||||
call SpaceVim#mapping#space#def('nnoremap', ['h', 'I'], 'call SpaceVim#issue#report()', 'report-issue-or-bug', 1)
|
call SpaceVim#mapping#space#def('nnoremap', ['h', 'I'], 'call SpaceVim#issue#report()', 'report-issue-or-bug', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['h', 'l'], 'SPLayer -l', 'list-all-layers', 1)
|
call SpaceVim#mapping#space#def('nnoremap', ['h', 'l'], 'SPLayer -l', 'list-all-layers', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['h', 'L'], 'SPRuntimeLog', 'view-runtime-log', 1)
|
call SpaceVim#mapping#space#def('nnoremap', ['h', 'L'], 'SPRuntimeLog', 'view-runtime-log', 1)
|
||||||
" @todo move this key binding to fuzzy layer
|
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['h', 'm'], 'Unite manpage', 'search available man pages', 1)
|
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['h', 'k'], 'LeaderGuide "[KEYs]"', 'show-top-level-bindings', 1)
|
call SpaceVim#mapping#space#def('nnoremap', ['h', 'k'], 'LeaderGuide "[KEYs]"', 'show-top-level-bindings', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['j', '0'], 'm`^', 'jump-to-beginning-of-line', 0)
|
call SpaceVim#mapping#space#def('nnoremap', ['j', '0'], 'm`^', 'jump-to-beginning-of-line', 0)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['j', '$'], 'm`g_', 'jump-to-end-of-line', 0)
|
call SpaceVim#mapping#space#def('nnoremap', ['j', '$'], 'm`g_', 'jump-to-end-of-line', 0)
|
||||||
|
@ -150,6 +150,21 @@ function! SpaceVim#layers#leaderf#config() abort
|
|||||||
\ 'after_enter' : string(s:_function('s:init_leaderf_win', 1))[10:-3]
|
\ 'after_enter' : string(s:_function('s:init_leaderf_win', 1))[10:-3]
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
let g:Lf_Extensions.manpage =
|
||||||
|
\ {
|
||||||
|
\ 'source': string(s:_function('s:manpage', 1))[10:-3],
|
||||||
|
\ 'accept': string(s:_function('s:manpage_acp', 1))[10:-3],
|
||||||
|
\ 'highlights_def': {
|
||||||
|
\ 'Lf_register_name': '^".',
|
||||||
|
\ 'Lf_register_content': '\s\+.*',
|
||||||
|
\ },
|
||||||
|
\ 'highlights_cmd': [
|
||||||
|
\ 'hi def link Lf_register_name ModeMsg',
|
||||||
|
\ 'hi def link Lf_register_content Normal',
|
||||||
|
\ ],
|
||||||
|
\ 'after_enter' : string(s:_function('s:init_leaderf_win', 1))[10:-3]
|
||||||
|
\ }
|
||||||
|
|
||||||
let g:Lf_Extensions.neoyank =
|
let g:Lf_Extensions.neoyank =
|
||||||
\ {
|
\ {
|
||||||
\ 'source': string(s:_function('s:neoyank', 1))[10:-3],
|
\ 'source': string(s:_function('s:neoyank', 1))[10:-3],
|
||||||
@ -246,6 +261,8 @@ function! SpaceVim#layers#leaderf#config() abort
|
|||||||
" without this key binding, SPC h SPC always open key binding guide.
|
" without this key binding, SPC h SPC always open key binding guide.
|
||||||
nmap <Space>h<Space> [SPC]h[SPC]
|
nmap <Space>h<Space> [SPC]h[SPC]
|
||||||
|
|
||||||
|
call SpaceVim#mapping#space#def('nnoremap', ['h', 'm'], 'Leaderf manpage', 'search-available-man-pages', 1)
|
||||||
|
|
||||||
let lnum = expand('<slnum>') + s:lnum - 1
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 'b'], 'Leaderf buffer',
|
call SpaceVim#mapping#space#def('nnoremap', ['b', 'b'], 'Leaderf buffer',
|
||||||
\ ['buffer-list',
|
\ ['buffer-list',
|
||||||
@ -431,6 +448,20 @@ function! s:message_acp(line, args) abort
|
|||||||
echohl None
|
echohl None
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:manpage(...) abort
|
||||||
|
if executable('man') && exists(':Man') ==# 2
|
||||||
|
return getcompletion(':Man ', 'cmdline')
|
||||||
|
else
|
||||||
|
return []
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:manpage_acp(line, args) abort
|
||||||
|
if !empty(a:line) && exists(':Man') ==# 2
|
||||||
|
exe printf('Man %s', a:line)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
func! s:neoyank(...) abort
|
func! s:neoyank(...) abort
|
||||||
let yank = []
|
let yank = []
|
||||||
for text in neoyank#_get_yank_histories()['"']
|
for text in neoyank#_get_yank_histories()['"']
|
||||||
|
@ -61,6 +61,7 @@ function! SpaceVim#layers#unite#plugins() abort
|
|||||||
" outline source <Leader>fo
|
" outline source <Leader>fo
|
||||||
call add(plugins, ['Shougo/unite-outline', {'merged' : 0}])
|
call add(plugins, ['Shougo/unite-outline', {'merged' : 0}])
|
||||||
call add(plugins, ['Shougo/neomru.vim', {'merged' : 0}])
|
call add(plugins, ['Shougo/neomru.vim', {'merged' : 0}])
|
||||||
|
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-van', {'merged' : 0}])
|
||||||
|
|
||||||
if g:spacevim_enable_googlesuggest
|
if g:spacevim_enable_googlesuggest
|
||||||
call add(plugins, ['mopp/googlesuggest-source.vim'])
|
call add(plugins, ['mopp/googlesuggest-source.vim'])
|
||||||
@ -75,6 +76,7 @@ let s:lnum = expand('<slnum>') + 2
|
|||||||
function! SpaceVim#layers#unite#config() abort
|
function! SpaceVim#layers#unite#config() abort
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['?'], 'Unite menu:CustomKeyMaps -input=[SPC]', 'show mappings', 1)
|
call SpaceVim#mapping#space#def('nnoremap', ['?'], 'Unite menu:CustomKeyMaps -input=[SPC]', 'show mappings', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['h', '[SPC]'], 'Unite help -input=SpaceVim', 'unite-SpaceVim-help', 1)
|
call SpaceVim#mapping#space#def('nnoremap', ['h', '[SPC]'], 'Unite help -input=SpaceVim', 'unite-SpaceVim-help', 1)
|
||||||
|
call SpaceVim#mapping#space#def('nnoremap', ['h', 'm'], 'Unite manpage', 'search available man pages', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 'b'], 'Unite buffer', 'buffer list', 1)
|
call SpaceVim#mapping#space#def('nnoremap', ['b', 'b'], 'Unite buffer', 'buffer list', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'UniteWithCursorWord help', 'get help with the symbol at point', 1)
|
call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'UniteWithCursorWord help', 'get help with the symbol at point', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['i', 'u'], 'Unite unicode', 'search-and-insert-unicode', 1)
|
call SpaceVim#mapping#space#def('nnoremap', ['i', 'u'], 'Unite unicode', 'search-and-insert-unicode', 1)
|
||||||
|
2
bundle/vim-van/.gitignore
vendored
Normal file
2
bundle/vim-van/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.*.swp
|
||||||
|
tags
|
21
bundle/vim-van/LICENSE
Normal file
21
bundle/vim-van/LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jacob Zimmerman
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
87
bundle/vim-van/README.md
Normal file
87
bundle/vim-van/README.md
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
# Vim SuperMan
|
||||||
|
|
||||||
|
Read Unix `man` pages faster than a speeding bullet!
|
||||||
|
|
||||||
|
Unix man pages by default open with the `less` pager. Getting them to open with
|
||||||
|
Vim can be a little bit of a pain, but in recent versions of Vim there's a
|
||||||
|
plugin (`$VIMRUNTIME/ftplugin/man.vim`) that makes this easy.
|
||||||
|
|
||||||
|
This is a simple Vim plugin and sh function that makes replacing `man` from the
|
||||||
|
command line a cinch.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Use your favorite plugin manager. If you don't have one, I'd recommend Vundle,
|
||||||
|
though you should probably also take a look at Pathogen, as it's more common.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# if your ~/.vim folder isn't under source control:
|
||||||
|
git clone https://github.com/Z1MM32M4N/vim-superman ~/.vim/bundle/
|
||||||
|
|
||||||
|
# if your ~/.vim folder is under source control:
|
||||||
|
git submodule add https://github.com/Z1MM32M4N/vim-superman ~/.vim/bundle/
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, add the following to your `.bashrc`, `.bash_profile`, `.zshrc`, or
|
||||||
|
whatever file you use to configure your shell:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vman() {
|
||||||
|
vim -c "SuperMan $*"
|
||||||
|
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
echo "No manual entry for $*"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Close and reopen your terminal and you're set!
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
This predominantly a command line tool. To open the man page for `vim`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ vman vim
|
||||||
|
```
|
||||||
|
|
||||||
|
![vman vim](http://blog.zimmerman.io/images/vim.1.png)
|
||||||
|
|
||||||
|
It's that simple. The underlying `:Man` command supports specifying a specific
|
||||||
|
section, so you could also do something like
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ vman 3 printf
|
||||||
|
```
|
||||||
|
|
||||||
|
To see the man page for the C `printf()` library call.
|
||||||
|
|
||||||
|
![vman 3 printf](http://blog.zimmerman.io/images/printf.3.png)
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
For more information, see the [associated blog post][blog].
|
||||||
|
|
||||||
|
### Jake, why not just call the bash function `man`?
|
||||||
|
|
||||||
|
The actual `man` command supports many more features than the Vim plugin does
|
||||||
|
(for a complete list, see `man(1)`). If you shadow the real `man` command,
|
||||||
|
things start to break, for example `apropos`, which uses `man` under the hood.
|
||||||
|
|
||||||
|
### When I install `vim-superman` it looks nothing like this!
|
||||||
|
|
||||||
|
There are a couple other plugins of mine featured prominently here, including
|
||||||
|
[Solarized Dark][sdark] for the color scheme and [Vim Airline][vairline] for the
|
||||||
|
statusbar. If you're curious about my whole setup, be sure to check out my
|
||||||
|
[dotfiles repository][dotfiles].
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT License. See LICENSE.
|
||||||
|
|
||||||
|
|
||||||
|
[blog]: http://blog.zimmerman.io/2014/12/20/vim-as-a-man-page-viewer/
|
||||||
|
[sdark]: https://github.com/altercation/vim-colors-solarized
|
||||||
|
[vairline]: https://github.com/bling/vim-airline
|
||||||
|
[dotfiles]: https://github.com/Z1MM32M4N/dotfiles
|
||||||
|
|
50
bundle/vim-van/autoload/unite/sources/manpage.vim
Normal file
50
bundle/vim-van/autoload/unite/sources/manpage.vim
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
let s:save_cpo = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
let s:unite_source = {
|
||||||
|
\ 'name': 'manpage',
|
||||||
|
\ 'hooks': {},
|
||||||
|
\ 'action_table': {'*': {}},
|
||||||
|
\ }
|
||||||
|
|
||||||
|
let s:unite_source.action_table['*'].preview = {
|
||||||
|
\ 'description' : 'open this manpage',
|
||||||
|
\ 'is_quit' : 0,
|
||||||
|
\ }
|
||||||
|
|
||||||
|
function! s:unite_source.action_table['*'].preview.func(candidate)
|
||||||
|
execute a:candidate.action__command
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:manpage(x)
|
||||||
|
return printf("%s %s", "SuperMan", a:x)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:unite_source.gather_candidates(args, context)
|
||||||
|
|
||||||
|
let l:manpages = system("apropos . | awk \'{print $1}\'")
|
||||||
|
|
||||||
|
let manpageslist = unite#util#sort_by(unite#util#uniq_by(
|
||||||
|
\ map(split(l:manpages, '\n'),
|
||||||
|
\'[fnamemodify(v:val, ":t:r"), fnamemodify(v:val, ":p")]'), 'v:val[0]'),
|
||||||
|
\'v:val[0]')
|
||||||
|
|
||||||
|
return map(manpageslist, '{
|
||||||
|
\ "word": v:val[0],
|
||||||
|
\ "source": "manpage",
|
||||||
|
\ "kind": ["file", "command"],
|
||||||
|
\ "action__command": s:manpage(v:val[0]),
|
||||||
|
\ "action__type": ": ",
|
||||||
|
\ "action__path": v:val[1],
|
||||||
|
\ "action__directory": fnamemodify(v:val[1], ":h"),
|
||||||
|
\ }')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! unite#sources#manpage#define()
|
||||||
|
return s:unite_source
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"unlet s:unite_source
|
||||||
|
|
||||||
|
let &cpo = s:save_cpo
|
||||||
|
unlet s:save_cpo
|
42
bundle/vim-van/plugin/superman.vim
Normal file
42
bundle/vim-van/plugin/superman.vim
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
" Name: SuperMan man pages
|
||||||
|
" Author: Jacob Zimmerman <jake@zimmerman.io>
|
||||||
|
" License: MIT License
|
||||||
|
"
|
||||||
|
" URL: <https://github.com/Z1MM32M4N/vim-superman>
|
||||||
|
"
|
||||||
|
" Created: Dec 20 2014
|
||||||
|
" Modified: Dec 20 2014
|
||||||
|
|
||||||
|
" Wrapper around man.vim's Man command
|
||||||
|
function! superman#SuperMan(...)
|
||||||
|
" Needed to get access to Man
|
||||||
|
source $VIMRUNTIME/ftplugin/man.vim
|
||||||
|
|
||||||
|
" Build and pass off arguments to Man command
|
||||||
|
execute 'Man' join(a:000, ' ')
|
||||||
|
|
||||||
|
" Quit with error code if there is only one line in the buffer
|
||||||
|
" (i.e., manpage not found)
|
||||||
|
if line('$') == 1 | cquit | endif
|
||||||
|
|
||||||
|
" Why :Man opens up in a split I shall never know
|
||||||
|
only
|
||||||
|
|
||||||
|
" Set options appropriate for viewing manpages
|
||||||
|
setlocal readonly
|
||||||
|
setlocal nomodifiable
|
||||||
|
|
||||||
|
setlocal number
|
||||||
|
|
||||||
|
setlocal noexpandtab
|
||||||
|
setlocal tabstop=8
|
||||||
|
setlocal softtabstop=8
|
||||||
|
setlocal shiftwidth=8
|
||||||
|
|
||||||
|
" To make us behave more like less
|
||||||
|
noremap q :q<CR>
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Command alias for our function
|
||||||
|
command! -nargs=+ SuperMan call superman#SuperMan(<f-args>)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user