1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-14 15:19:12 +08:00

feat(core): add SPC h g/G to run helpgrep asynchronously

Problem: `:helpgrep` is too slow, there is no key binding for
         asynchronously helpgrep.
Solution: - Add `SPC h g` to run helpgrep asynchronously.
          - Add `SPC h G` to run helpgrep with cursor word
            asynchronously
This commit is contained in:
Shidong Wang 2021-09-22 23:20:51 +08:00
parent 8c3dae578c
commit 654cfc8855
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848
4 changed files with 51 additions and 0 deletions

View File

@ -221,6 +221,26 @@ function! SpaceVim#layers#core#config() abort
\ ]
\ ]
\ , 1)
let lnum = expand('<slnum>') + s:lnum - 1
call SpaceVim#mapping#space#def('nnoremap', ['h', 'g'], 'call SpaceVim#plugins#helpgrep#help()',
\ ['asynchronous-helpgrep',
\ [
\ '[SPC h g] is to run helpgrep asynchronously',
\ '',
\ 'Definition: ' . s:filename . ':' . lnum,
\ ]
\ ]
\ , 1)
let lnum = expand('<slnum>') + s:lnum - 1
call SpaceVim#mapping#space#def('nnoremap', ['h', 'G'], 'call SpaceVim#plugins#helpgrep#help(expand("<cword>"))',
\ ['asynchronous-helpgrep-with-cword',
\ [
\ '[SPC h g] is to run helpgrep asynchronously with cword',
\ '',
\ 'Definition: ' . s:filename . ':' . lnum,
\ ]
\ ]
\ , 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'd'], 'call SpaceVim#mapping#close_current_buffer()', 'delete-this-buffer', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 'D'],
\ 'call SpaceVim#mapping#kill_visible_buffer_choosewin()',

View File

@ -0,0 +1,27 @@
"=============================================================================
" helpgrep.vim --- asynchronous helpgrep
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
function! s:generate() abort
return filter(split(&rtp, ','), 'isdirectory(v:val)')
endfunction
function! s:help_files() abort
return globpath(&rtp, 'doc/*.txt', 0, 1)
endfunction
function! SpaceVim#plugins#helpgrep#help(...) abort
call SpaceVim#plugins#flygrep#open({
\ 'input' : get(a:000, 0, ''),
\ 'files' : s:help_files(),
\ })
endfunction
command! GrepRtp call SpaceVim#plugins#flygrep#open({
\ 'input' : '',
\ 'dir' : s:generate(),
\ })

View File

@ -1693,6 +1693,8 @@ Denite/Unite 是一个强大的信息筛选浏览器,这类似于 Emacs 中的
| ----------- | -------------------------------------------------- |
| `SPC h SPC` | 使用 fuzzy find 模块展示 SpaceVim 帮助文档章节目录 |
| `SPC h i` | 获取光标下单词的帮助信息 |
| `SPC h g` | 异步执行`:helpgrep` |
| `SPC h G` | 异步执行`:helpgrep`,并搜索光标下的词 |
| `SPC h k` | 使用快捷键导航,展示 SpaceVim 所支持的前缀键 |
| `SPC h m` | 使用 Unite 浏览所有 man 文档 |

View File

@ -1694,6 +1694,8 @@ getting help info about functions, variables etc:
| ------------ | ----------------------------------------------------------------------------- |
| `SPC h SPC` | discover SpaceVim documentation, layers and packages using fuzzy finder layer |
| `SPC h i` | get help with the symbol at point |
| `SPC h g` | run `:helpgrep` asynchronously |
| `SPC h G` | run `:helpgrep` asynchronously with the word under cursor |
| `SPC h k` | show top-level bindings with which-key |
| `SPC h m` | search available man pages |