tenfyzhong / CompleteParameter.vim

Complete parameter after select the completion. Integration with YouCompleteMe(ycm), deoplete, neocomplete.
MIT License
261 stars 27 forks source link

How can I use 'Tab' and 'C-Tab' to switch choosing parameters #36

Open cjun714 opened 6 years ago

cjun714 commented 6 years ago

Issue Prelude

Dear tenfyzhong, thanks for your great amazing plugin.

Is it possible to use 'Tab' and 'C-Tab' to switch choosing parameters instead of 'C-j' and 'C-k', how should I config? setting as below is invalid: imap (complete_parameter#goto_next_parameter) imap (complete_parameter#goto_previous_parameter) Sine in this scenario using 'Tab' is more sensible, just like other ide, editor or shell does, and another reason is I have mapped 'c-j' as as same as a shell.

Thanks!

tenfyzhong commented 6 years ago

I think you shoud map smap too.

cjun714 commented 6 years ago

I have set smap, it's not working, setting: smap (complete_parameter#goto_next_parameter) imap (complete_parameter#goto_next_parameter)

Here is an example:

  1. input: os.Chmod("myname|", mode) // '|' is cursor position
  2. press Tab, expected result should be: os.Chmod("myname", |mode) // '|' is cursor position
  3. but result is : os.Chmod("myname    |",mode)

If map , result is right(as step 2) If map , result is not expected(as step 3)

Plugins I am using (first to last in vim-plug):

  1. ultisnips
  2. deoplete
  3. CompleteParameter
tenfyzhong commented 6 years ago

Please give me a minimum configuration.

cjun714 commented 6 years ago

Sorry for late response, please check below config, unnecessary part has been removed:

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-plug
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.local/share/nvim/plugged')

Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
Plug 'Valloric/YouCompleteMe', { 'do': './install.py --clang-completer --go-completer' }
Plug 'SirVer/ultisnips'
Plug 'tenfyzhong/CompleteParameter.vim'

call plug#end()

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" global
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set noshowmode      " necessary for plugin echodoc.vim

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Key mapping
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
imap jj <Esc>
let mapleader=" "
" --------------------------------------------------------------------
map <leader>q :q!<CR>
nmap <C-q> :bp\|bd #<CR>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Yggdroot/LeaderF
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <C-p> :call CtrlP('LeaderfFile')<CR>
nnoremap <C-b> :call CtrlP('LeaderfBuffer')<CR>
nnoremap <C-n> :call CtrlP('LeaderfMru')<CR>
nnoremap <C-r> :LeaderfBufTag<CR>
nnoremap <leader>j :LeaderfTag<CR>

" prevent opening file inside buffers like NERDTree
function! CtrlP(command)
    let c = 0
    let wincount = winnr('$')
    " Don't open it here if current buffer is not writable (e.g. NERDTree)
    while !empty(getbufvar(+expand("<abuf>"), "&buftype")) && c < wincount
        exec 'wincmd w'
        let c = c + 1
    endwhile
    exec a:command
endfunction

let g:Lf_StlSeparator = { 'left': "\ue0b0", 'right': "\ue0b2" }
let g:Lf_WindowHeight = 0.30
let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git']
let g:Lf_WorkingDirectoryMode = 'Ac'
let g:Lf_CacheDirectory = expand('/tmp/vim/cache')
let g:Lf_ShowRelativePath = 0
let g:Lf_HideHelp = 1
let g:Lf_StlColorscheme = 'powerline'
let g:Lf_PreviewResult = {'Function':0, 'BufTag':0}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" tenfyzhong/CompleteParameter.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
inoremap <silent><expr> ( complete_parameter#pre_complete("()")
smap <Tab> <Plug>(complete_parameter#goto_next_parameter)
imap <Tab> <Plug>(complete_parameter#goto_next_parameter)
" smap <c-k> <Plug>(complete_parameter#goto_previous_parameter)
" imap <c-k> <Plug>(complete_parameter#goto_previous_parameter)

let g:AutoPairs = {'[':']', '{':'}',"'":"'",'"':'"', '`':'`'}
inoremap <buffer><silent> ) <C-R>=AutoPairsInsert(')')<CR>

let g:complete_parameter_use_ultisnips_mapping = 0

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" SirVer/ultisnips
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"

let g:UltiSnipsSnippetDirectories=["UltiSnips", "UltiSnips+"]

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Valloric/YouCompleteMe
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'

let g:ycm_add_preview_to_completeopt = 0
let g:ycm_show_diagnostics_ui = 0
let g:ycm_server_log_level = 'info'
let g:ycm_min_num_identifier_candidate_chars = 2
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_complete_in_strings=1
let g:ycm_key_invoke_completion = '<c-z>'
set completeopt=menu,menuone

noremap <c-z> <NOP>

let g:ycm_semantic_triggers =  {
           \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
           \ 'cs,lua,javascript': ['re!\w{2}'],
           \ }