mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-13 15:27:58 +08:00
Improve: make ctrlp layer works better (#3015)
This commit is contained in:
parent
57fed587d3
commit
a3719c30a7
@ -13,34 +13,92 @@ function! SpaceVim#layers#ctrlp#plugins() abort
|
|||||||
\ ['mattn/ctrlp-register', {'on_cmd' : 'CtrlPRegister'}],
|
\ ['mattn/ctrlp-register', {'on_cmd' : 'CtrlPRegister'}],
|
||||||
\ ['DeaR/ctrlp-jumps', {'on_cmd' : 'CtrlPJump'}],
|
\ ['DeaR/ctrlp-jumps', {'on_cmd' : 'CtrlPJump'}],
|
||||||
\ ['SpaceVim/vim-ctrlp-help', {'on_cmd' : 'CtrlPHelp'}],
|
\ ['SpaceVim/vim-ctrlp-help', {'on_cmd' : 'CtrlPHelp'}],
|
||||||
|
\ ['hara/ctrlp-colorscheme', {'on_cmd' : 'CtrlPColorscheme'}],
|
||||||
\ ]
|
\ ]
|
||||||
|
call add(plugins, ['wsdjeg/ctrlp-menu', {'merged' : 0}])
|
||||||
|
call add(plugins, ['Shougo/neoyank.vim', {'merged' : 0}])
|
||||||
|
call add(plugins, ['wsdjeg/ctrlp-yank', {'merged' : 0}])
|
||||||
return plugins
|
return plugins
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:filename = expand('<sfile>:~')
|
let s:filename = expand('<sfile>:~')
|
||||||
let s:lnum = expand('<slnum>') + 2
|
let s:lnum = expand('<slnum>') + 2
|
||||||
function! SpaceVim#layers#ctrlp#config() abort
|
function! SpaceVim#layers#ctrlp#config() abort
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'r'], 'CtrlPMRU', 'open-recent-file', 1)
|
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'call call('
|
|
||||||
\ . string(s:_function('s:get_help_with_cursor_symbol')) . ', [])',
|
|
||||||
\ 'get help with the symbol at point', 1)
|
|
||||||
let lnum = expand('<slnum>') + s:lnum - 1
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['p', 'f'],
|
call SpaceVim#mapping#space#def('nnoremap', ['?'], 'call call('
|
||||||
\ 'CtrlP',
|
\ . string(s:_function('s:get_menu')) . ', ["CustomKeyMaps", "[SPC]"])',
|
||||||
\ ['find files in current project',
|
\ ['show mappings',
|
||||||
\ [
|
\ [
|
||||||
\ '[SPC p f] is to find files in the root of the current project',
|
\ 'SPC ? is to show mappings',
|
||||||
\ '',
|
\ '',
|
||||||
\ 'Definition: ' . s:filename . ':' . lnum,
|
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||||
\ ]
|
\ ]
|
||||||
|
\ ],
|
||||||
|
\ 1)
|
||||||
|
|
||||||
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
|
call SpaceVim#mapping#space#def('nnoremap', ['h', '[SPC]'], 'call call('
|
||||||
|
\ . string(s:_function('s:get_help')) . ', ["SpaceVim"])',
|
||||||
|
\ ['find-SpaceVim-help',
|
||||||
|
\ [
|
||||||
|
\ 'SPC h SPC is to find SpaceVim help',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||||
\ ]
|
\ ]
|
||||||
\ , 1)
|
\ ],
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['j', 'i'], 'Denite outline', 'jump to a definition in buffer', 1)
|
\ 1)
|
||||||
" This is definded in plugin config
|
" @fixme SPC h SPC make vim flick
|
||||||
" nnoremap <silent> <C-p> :Ctrlp<cr>
|
nmap <Space>h<Space> [SPC]h[SPC]
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['T', 's'], 'Denite colorscheme', 'fuzzy find colorschemes', 1)
|
|
||||||
let g:_spacevim_mappings.f = {'name' : '+Fuzzy Finder'}
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
call s:defind_fuzzy_finder()
|
call SpaceVim#mapping#space#def('nnoremap', ['b', 'b'], 'CtrlPBuffer',
|
||||||
|
\ ['buffer-list',
|
||||||
|
\ [
|
||||||
|
\ 'SPC b b is to open buffer list',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||||
|
\ ]
|
||||||
|
\ ],
|
||||||
|
\ 1)
|
||||||
|
|
||||||
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
|
call SpaceVim#mapping#space#def('nnoremap', ['f', 'r'], 'CtrlPMRU',
|
||||||
|
\ ['open-recent-file',
|
||||||
|
\ [
|
||||||
|
\ 'SPC f r is to open recent file list',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||||
|
\ ]
|
||||||
|
\ ],
|
||||||
|
\ 1)
|
||||||
|
|
||||||
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
|
call SpaceVim#mapping#space#def('nnoremap', ['j', 'i'], 'CtrlPBufTag',
|
||||||
|
\ ['jump to a definition in buffer',
|
||||||
|
\ [
|
||||||
|
\ 'SPC j i is to jump to a definition in buffer',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||||
|
\ ]
|
||||||
|
\ ],
|
||||||
|
\ 1)
|
||||||
|
|
||||||
|
"@todo add resume support for ctrlp: SPC r l
|
||||||
|
|
||||||
|
|
||||||
|
"@fixme ctrlp colorschemes support
|
||||||
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
|
call SpaceVim#mapping#space#def('nnoremap', ['T', 's'], 'CtrlPColorscheme',
|
||||||
|
\ ['fuzzy find colorschemes',
|
||||||
|
\ [
|
||||||
|
\ 'SPC T s is to fuzzy find colorschemes',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||||
|
\ ]
|
||||||
|
\ ],
|
||||||
|
\ 1)
|
||||||
|
|
||||||
let lnum = expand('<slnum>') + s:lnum - 1
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'f'],
|
call SpaceVim#mapping#space#def('nnoremap', ['f', 'f'],
|
||||||
\ "exe 'CtrlP ' . fnamemodify(bufname('%'), ':h')",
|
\ "exe 'CtrlP ' . fnamemodify(bufname('%'), ':h')",
|
||||||
@ -52,6 +110,36 @@ function! SpaceVim#layers#ctrlp#config() abort
|
|||||||
\ ]
|
\ ]
|
||||||
\ ]
|
\ ]
|
||||||
\ , 1)
|
\ , 1)
|
||||||
|
|
||||||
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
|
call SpaceVim#mapping#space#def('nnoremap', ['p', 'f'],
|
||||||
|
\ 'CtrlP',
|
||||||
|
\ ['find files in current project',
|
||||||
|
\ [
|
||||||
|
\ '[SPC p f] is to find files in the root of the current project',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||||
|
\ ]
|
||||||
|
\ ]
|
||||||
|
\ , 1)
|
||||||
|
|
||||||
|
" This is definded in plugin config
|
||||||
|
" nnoremap <silent> <C-p> :Ctrlp<cr>
|
||||||
|
|
||||||
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
|
call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'call call('
|
||||||
|
\ . string(s:_function('s:get_help_with_cursor_symbol')) . ', [])',
|
||||||
|
\ ['get help with the symbol at point',
|
||||||
|
\ [
|
||||||
|
\ '[SPC h i] is to get help with the symbol at point',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||||
|
\ ]
|
||||||
|
\ ],
|
||||||
|
\ 1)
|
||||||
|
|
||||||
|
let g:_spacevim_mappings.f = {'name' : '+Fuzzy Finder'}
|
||||||
|
call s:defind_fuzzy_finder()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:get_help_with_cursor_symbol() abort
|
function! s:get_help_with_cursor_symbol() abort
|
||||||
@ -61,9 +149,28 @@ function! s:get_help_with_cursor_symbol() abort
|
|||||||
let g:ctrlp_default_input = save_ctrlp_default_input
|
let g:ctrlp_default_input = save_ctrlp_default_input
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:get_help(word) abort
|
||||||
|
let save_ctrlp_default_input = get(g:, 'ctrlp_default_input', '')
|
||||||
|
let g:ctrlp_default_input = a:word
|
||||||
|
CtrlPHelp
|
||||||
|
let g:ctrlp_default_input = save_ctrlp_default_input
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:get_menu(menu, input) abort
|
||||||
|
let save_ctrlp_default_input = get(g:, 'ctrlp_default_input', '')
|
||||||
|
let g:ctrlp_default_input = a:input
|
||||||
|
exe 'CtrlPMenu ' . a:menu
|
||||||
|
let g:ctrlp_default_input = save_ctrlp_default_input
|
||||||
|
endfunction
|
||||||
|
|
||||||
let s:file = expand('<sfile>:~')
|
let s:file = expand('<sfile>:~')
|
||||||
let s:unite_lnum = expand('<slnum>') + 3
|
let s:unite_lnum = expand('<slnum>') + 3
|
||||||
function! s:defind_fuzzy_finder() abort
|
function! s:defind_fuzzy_finder() abort
|
||||||
|
|
||||||
|
|
||||||
|
"@todo add Leader f r for resume ctrlp
|
||||||
|
|
||||||
|
|
||||||
nnoremap <silent> <Leader>fe
|
nnoremap <silent> <Leader>fe
|
||||||
\ :<C-u>CtrlPRegister<CR>
|
\ :<C-u>CtrlPRegister<CR>
|
||||||
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
||||||
@ -75,6 +182,17 @@ function! s:defind_fuzzy_finder() abort
|
|||||||
\ 'Definition: ' . s:file . ':' . lnum,
|
\ 'Definition: ' . s:file . ':' . lnum,
|
||||||
\ ]
|
\ ]
|
||||||
\ ]
|
\ ]
|
||||||
|
nnoremap <silent> <Leader>fh
|
||||||
|
\ :<C-u>CtrlPNeoyank<CR>
|
||||||
|
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
||||||
|
let g:_spacevim_mappings.f.h = ['CtrlPNeoyank',
|
||||||
|
\ 'fuzzy find yank history',
|
||||||
|
\ [
|
||||||
|
\ '[Leader f h] is to fuzzy find history and yank content',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:file . ':' . lnum,
|
||||||
|
\ ]
|
||||||
|
\ ]
|
||||||
nnoremap <silent> <Leader>fj
|
nnoremap <silent> <Leader>fj
|
||||||
\ :<C-u>CtrlPJump<CR>
|
\ :<C-u>CtrlPJump<CR>
|
||||||
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
||||||
@ -86,6 +204,10 @@ function! s:defind_fuzzy_finder() abort
|
|||||||
\ 'Definition: ' . s:file . ':' . lnum,
|
\ 'Definition: ' . s:file . ':' . lnum,
|
||||||
\ ]
|
\ ]
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
|
"@todo add Leader f l for ctrlp location list
|
||||||
|
"@todo add Leader f m for ctrlp message
|
||||||
|
|
||||||
nnoremap <silent> <Leader>fq
|
nnoremap <silent> <Leader>fq
|
||||||
\ :<C-u>CtrlPQuickfix<CR>
|
\ :<C-u>CtrlPQuickfix<CR>
|
||||||
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
||||||
@ -107,6 +229,29 @@ function! s:defind_fuzzy_finder() abort
|
|||||||
\ 'Definition: ' . s:file . ':' . lnum,
|
\ 'Definition: ' . s:file . ':' . lnum,
|
||||||
\ ]
|
\ ]
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
|
nnoremap <silent> <Leader>f<Space> :CtrlPMenu CustomKeyMaps<CR>
|
||||||
|
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
||||||
|
let g:_spacevim_mappings.f['[SPC]'] = ['CtrlPMenu CustomKeyMaps',
|
||||||
|
\ 'fuzzy find custom key bindings',
|
||||||
|
\ [
|
||||||
|
\ '[Leader f SPC] is to fuzzy find custom key bindings',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:file . ':' . lnum,
|
||||||
|
\ ]
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
nnoremap <silent> <Leader>fp :<C-u>CtrlPMenu AddedPlugins<CR>
|
||||||
|
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
||||||
|
let g:_spacevim_mappings.f.p = ['CtrlPMenu AddedPlugins',
|
||||||
|
\ 'fuzzy find vim packages',
|
||||||
|
\ [
|
||||||
|
\ '[Leader f p] is to fuzzy find vim packages installed in SpaceVim',
|
||||||
|
\ '',
|
||||||
|
\ 'Definition: ' . s:file . ':' . lnum,
|
||||||
|
\ ]
|
||||||
|
\ ]
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,13 +48,15 @@ function! SpaceVim#layers#denite#config() abort
|
|||||||
\ ]
|
\ ]
|
||||||
\ ],
|
\ ],
|
||||||
\ 1)
|
\ 1)
|
||||||
|
" @fixme SPC h SPC make vim flick
|
||||||
|
nmap <Space>h<Space> [SPC]h[SPC]
|
||||||
|
|
||||||
let lnum = expand('<slnum>') + s:lnum - 1
|
let lnum = expand('<slnum>') + s:lnum - 1
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 'b'], 'call call('
|
call SpaceVim#mapping#space#def('nnoremap', ['b', 'b'], 'call call('
|
||||||
\ . string(s:_function('s:warp_denite')) . ', ["Denite buffer"])',
|
\ . string(s:_function('s:warp_denite')) . ', ["Denite buffer"])',
|
||||||
\ ['buffer-list',
|
\ ['buffer-list',
|
||||||
\ [
|
\ [
|
||||||
\ 'SPC b b is to open buffer list via denite',
|
\ 'SPC b b is to open buffer list',
|
||||||
\ '',
|
\ '',
|
||||||
\ 'Definition: ' . s:filename . ':' . lnum,
|
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||||
\ ]
|
\ ]
|
||||||
|
@ -37,11 +37,9 @@ ctrlp 模块默认并未启用,如果需要启用该模块,需要在配置
|
|||||||
| 快捷键 | 功能描述 |
|
| 快捷键 | 功能描述 |
|
||||||
| -------------------- | ------------------------------ |
|
| -------------------- | ------------------------------ |
|
||||||
| `<Leader> f <Space>` | 模糊查找快捷键,并执行该快捷键 |
|
| `<Leader> f <Space>` | 模糊查找快捷键,并执行该快捷键 |
|
||||||
|
| `<Leader> f p` | 模糊查找已安装插件 |
|
||||||
| `<Leader> f e` | 模糊搜索寄存器 |
|
| `<Leader> f e` | 模糊搜索寄存器 |
|
||||||
| `<Leader> f h` | 模糊搜索 history/yank |
|
| `<Leader> f h` | 模糊搜索 history/yank |
|
||||||
| `<Leader> f j` | 模糊搜索 jump, change |
|
| `<Leader> f j` | 模糊搜索 jump, change |
|
||||||
| `<Leader> f l` | 模糊搜索 location list |
|
|
||||||
| `<Leader> f m` | 模糊搜索 output messages |
|
|
||||||
| `<Leader> f o` | 模糊搜索函数列表 |
|
| `<Leader> f o` | 模糊搜索函数列表 |
|
||||||
| `<Leader> f q` | 模糊搜索 quickfix list |
|
| `<Leader> f q` | 模糊搜索 quickfix list |
|
||||||
| `<Leader> f r` | 重置上次搜索窗口 |
|
|
||||||
|
@ -34,6 +34,7 @@ denite 模块默认并未启用,如果需要启用该模块,需要在配置
|
|||||||
| 快捷键 | 功能描述 |
|
| 快捷键 | 功能描述 |
|
||||||
| -------------------- | ------------------------------ |
|
| -------------------- | ------------------------------ |
|
||||||
| `<Leader> f <Space>` | 模糊查找快捷键,并执行该快捷键 |
|
| `<Leader> f <Space>` | 模糊查找快捷键,并执行该快捷键 |
|
||||||
|
| `<Leader> f p` | 模糊查找已安装插件 |
|
||||||
| `<Leader> f e` | 模糊搜索寄存器 |
|
| `<Leader> f e` | 模糊搜索寄存器 |
|
||||||
| `<Leader> f h` | 模糊搜索 history/yank |
|
| `<Leader> f h` | 模糊搜索 history/yank |
|
||||||
| `<Leader> f j` | 模糊搜索 jump, change |
|
| `<Leader> f j` | 模糊搜索 jump, change |
|
||||||
|
@ -31,11 +31,9 @@ name = "ctrlp"
|
|||||||
| Key bindings | Discription |
|
| Key bindings | Discription |
|
||||||
| -------------------- | ----------------------------- |
|
| -------------------- | ----------------------------- |
|
||||||
| `<Leader> f <Space>` | Fuzzy find menu:CustomKeyMaps |
|
| `<Leader> f <Space>` | Fuzzy find menu:CustomKeyMaps |
|
||||||
|
| `<Leader> f p` | Fuzzy find menu:AddedPlugins |
|
||||||
| `<Leader> f e` | Fuzzy find register |
|
| `<Leader> f e` | Fuzzy find register |
|
||||||
| `<Leader> f h` | Fuzzy find history/yank |
|
| `<Leader> f h` | Fuzzy find history/yank |
|
||||||
| `<Leader> f j` | Fuzzy find jump, change |
|
| `<Leader> f j` | Fuzzy find jump, change |
|
||||||
| `<Leader> f l` | Fuzzy find location list |
|
|
||||||
| `<Leader> f m` | Fuzzy find output messages |
|
|
||||||
| `<Leader> f o` | Fuzzy find outline |
|
| `<Leader> f o` | Fuzzy find outline |
|
||||||
| `<Leader> f q` | Fuzzy find quick fix |
|
| `<Leader> f q` | Fuzzy find quick fix |
|
||||||
| `<Leader> f r` | Resumes Unite window |
|
|
||||||
|
Loading…
Reference in New Issue
Block a user