From 9ee8606e80ded63cd6b741d9c2e198efe510d366 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 11 Mar 2024 21:34:24 +0800 Subject: [PATCH] fix(telescope): fix deoplete autocmd --- autoload/SpaceVim/layers/telescope.vim | 243 +++++++++++++------------ 1 file changed, 123 insertions(+), 120 deletions(-) diff --git a/autoload/SpaceVim/layers/telescope.vim b/autoload/SpaceVim/layers/telescope.vim index c45c91f4d..b20452956 100644 --- a/autoload/SpaceVim/layers/telescope.vim +++ b/autoload/SpaceVim/layers/telescope.vim @@ -70,24 +70,24 @@ function! SpaceVim#layers#telescope#config() abort call SpaceVim#mapping#space#def('nnoremap', ['?'], 'Telescope menu menu=CustomKeyMaps default_text=[SPC]', \ ['show-mappings', \ [ - \ 'SPC ? is to show mappings', - \ '', - \ 'Definition: ' . s:filename . ':' . lnum, - \ ] - \ ], - \ 1) + \ 'SPC ? is to show mappings', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ], + \ 1) let lnum = expand('') + 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) + \ 'SPC h SPC is to find SpaceVim help', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ], + \ 1) " @fixme SPC h SPC make vim flick exe printf('nmap %sh%s [SPC]h[SPC]', g:spacevim_default_custom_leader, g:spacevim_default_custom_leader) @@ -95,69 +95,69 @@ function! SpaceVim#layers#telescope#config() abort call SpaceVim#mapping#space#def('nnoremap', ['b', 'b'], 'Telescope buffers', \ ['list-buffer', \ [ - \ 'SPC b b is to open buffer list', - \ '', - \ 'Definition: ' . s:filename . ':' . lnum, - \ ] - \ ], - \ 1) + \ 'SPC b b is to open buffer list', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ], + \ 1) let lnum = expand('') + s:lnum - 1 call SpaceVim#mapping#space#def('nnoremap', ['f', 'r'], 'Telescope oldfiles', \ ['open-recent-file', \ [ - \ 'SPC f r is to open recent file list', - \ '', - \ 'Definition: ' . s:filename . ':' . lnum, - \ ] - \ ], - \ 1) + \ 'SPC f r is to open recent file list', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ], + \ 1) let lnum = expand('') + s:lnum - 1 call SpaceVim#mapping#space#def('nnoremap', ['j', 'i'], 'Telescope ctags_outline outline', \ ['jump-to-definition-in-buffer', \ [ - \ 'SPC j i is to jump to a definition in buffer', - \ '', - \ 'Definition: ' . s:filename . ':' . lnum, - \ ] - \ ], - \ 1) + \ 'SPC j i is to jump to a definition in buffer', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ], + \ 1) let lnum = expand('') + s:lnum - 1 call SpaceVim#mapping#space#def('nnoremap', ['T', 's'], 'Telescope colorscheme', \ ['fuzzy-find-colorschemes', \ [ - \ 'SPC T s is to fuzzy find colorschemes', - \ '', - \ 'Definition: ' . s:filename . ':' . lnum, - \ ] - \ ], - \ 1) + \ 'SPC T s is to fuzzy find colorschemes', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ], + \ 1) let lnum = expand('') + s:lnum - 1 call SpaceVim#mapping#space#def('nnoremap', ['f', 'f'], \ "exe 'Telescope find_files cwd=' . fnamemodify(bufname('%'), ':p:h')", \ ['find-files-in-buffer-directory', \ [ - \ '[SPC f f] is to find files in the directory of the current buffer', - \ '', - \ 'Definition: ' . s:filename . ':' . lnum, - \ ] - \ ] - \ , 1) + \ '[SPC f f] is to find files in the directory of the current buffer', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ] + \ , 1) let lnum = expand('') + s:lnum - 1 call SpaceVim#mapping#space#def('nnoremap', ['p', 'f'], \ 'Telescope find_files', \ ['find-files-in-project', \ [ - \ '[SPC p f] is to find files in the root of the current project', - \ '', - \ 'Definition: ' . s:filename . ':' . lnum, - \ ] - \ ] - \ , 1) + \ '[SPC p f] is to find files in the root of the current project', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ] + \ , 1) nnoremap :Telescope find_files @@ -166,23 +166,26 @@ function! SpaceVim#layers#telescope#config() abort \ . string(s:_function('s:get_help_with_cursor_symbol')) . ', [])', \ ['get-help-for-cursor-symbol', \ [ - \ '[SPC h i] is to get help with the symbol at point', - \ '', - \ 'Definition: ' . s:filename . ':' . lnum, - \ ] - \ ], - \ 1) + \ '[SPC h i] is to get help with the symbol at point', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ], + \ 1) call SpaceVim#mapping#space#def('nnoremap', ['p', 't', 'f'], \ 'Telescope task', 'fuzzy-find-tasks', 1) let g:_spacevim_mappings.f = {'name' : '+Fuzzy Finder'} call s:defind_fuzzy_finder() - augroup spacevim_telescope_layer - autocmd! - " https://github.com/nvim-telescope/telescope.nvim/issues/161 - autocmd FileType TelescopePrompt call deoplete#custom#buffer_option('auto_complete', v:false) - augroup END + " this autocmd should only be called when using deoplete + if g:spacevim_autocomplete_method == 'deoplete' + augroup spacevim_telescope_layer + autocmd! + " https://github.com/nvim-telescope/telescope.nvim/issues/161 + autocmd FileType TelescopePrompt call deoplete#custom#buffer_option('auto_complete', v:false) + augroup END + endif endfunction function! s:get_help_with_cursor_symbol() abort @@ -210,44 +213,44 @@ function! s:defind_fuzzy_finder() abort let g:_spacevim_mappings.f.e = ['Telescope registers', \ 'fuzzy find registers', \ [ - \ '[Leader f e ] is to fuzzy find registers', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f e ] is to fuzzy find registers', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] nnoremap fr \ :Telescope resume let lnum = expand('') + s:unite_lnum - 4 let g:_spacevim_mappings.f.r = ['Telescope resume', \ 'resume telescope window', \ [ - \ '[Leader f r ] is to resume telescope window', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f r ] is to resume telescope window', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] nnoremap fh \ :Telescope neoyank let lnum = expand('') + s:unite_lnum - 4 let g:_spacevim_mappings.f.h = ['Telescope neoyank', \ 'fuzzy find yank history', \ [ - \ '[Leader f h] is to fuzzy find history and yank content', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f h] is to fuzzy find history and yank content', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] nnoremap fj \ :Telescope jumplist let lnum = expand('') + s:unite_lnum - 4 let g:_spacevim_mappings.f.j = ['Telescope jumplist', \ 'fuzzy find jump list', \ [ - \ '[Leader f j] is to fuzzy find jump list', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f j] is to fuzzy find jump list', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] nnoremap fl \ :Telescope loclist @@ -255,11 +258,11 @@ function! s:defind_fuzzy_finder() abort let g:_spacevim_mappings.f.l = ['Telescope loclist', \ 'fuzzy find local list', \ [ - \ '[Leader f q] is to fuzzy find local list', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f q] is to fuzzy find local list', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] nnoremap fm \ :Telescope messages @@ -267,11 +270,11 @@ function! s:defind_fuzzy_finder() abort let g:_spacevim_mappings.f.m = ['Telescope messages', \ 'fuzzy find and yank message history', \ [ - \ '[Leader f m] is to fuzzy find and yank message history', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f m] is to fuzzy find and yank message history', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] nnoremap fq \ :Telescope quickfix @@ -279,44 +282,44 @@ function! s:defind_fuzzy_finder() abort let g:_spacevim_mappings.f.q = ['Telescope quickfix', \ 'fuzzy find quickfix list', \ [ - \ '[Leader f q] is to fuzzy find quickfix list', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f q] is to fuzzy find quickfix list', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] nnoremap fo :Telescope ctags_outline outline let lnum = expand('') + s:unite_lnum - 4 let g:_spacevim_mappings.f.o = ['Telescope ctags_outline outline', \ 'fuzzy find outline', \ [ - \ '[Leader f o] is to fuzzy find outline', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f o] is to fuzzy find outline', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] nnoremap f :Telescope menu menu=CustomKeyMaps let lnum = expand('') + s:unite_lnum - 4 let g:_spacevim_mappings.f['[SPC]'] = ['Telescope menu menu=CustomKeyMaps', \ 'fuzzy find custom key bindings', \ [ - \ '[Leader f SPC] is to fuzzy find custom key bindings', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f SPC] is to fuzzy find custom key bindings', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] nnoremap fp :Telescope menu menu=AddedPlugins let lnum = expand('') + s:unite_lnum - 4 let g:_spacevim_mappings.f.p = ['Telescope menu menu=AddedPlugins', \ 'fuzzy find vim packages', \ [ - \ '[Leader f p] is to fuzzy find vim packages installed in SpaceVim', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f p] is to fuzzy find vim packages installed in SpaceVim', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] if g:spacevim_snippet_engine ==# 'ultisnips' nnoremap fs :Telescope ultisnips @@ -324,11 +327,11 @@ function! s:defind_fuzzy_finder() abort let g:_spacevim_mappings.f.s = ['Telescope ultisnips', \ 'fuzzy find ultisnips snippets', \ [ - \ '[Leader f s] is to fuzzy find ultisnips snippets', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] + \ '[Leader f s] is to fuzzy find ultisnips snippets', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] endif @@ -336,12 +339,12 @@ function! s:defind_fuzzy_finder() abort call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 's'], 'Telescope scriptnames', \ ['open-custom-configuration', \ [ - \ '[SPC f v d] is to open the custom configuration file for SpaceVim', - \ '', - \ 'Definition: ' . s:file . ':' . lnum, - \ ] - \ ] - \ , 1) + \ '[SPC f v d] is to open the custom configuration file for SpaceVim', + \ '', + \ 'Definition: ' . s:file . ':' . lnum, + \ ] + \ ] + \ , 1) endfunction