CompleteParameter.vim icon indicating copy to clipboard operation
CompleteParameter.vim copied to clipboard

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

Open cjun714 opened this issue 7 years ago • 4 comments

Issue Prelude

  • Category
    • [ ] Question
    • [ ] Bug
    • [x] Suggestion
  • OS
    • [x] Linux
    • [ ] macOS
    • [ ] Windows
    • [ ] Etc.
  • Vim
    • [x] Vim
    • [x] Neovim
  • Language
    • [ ] C
    • [ ] C++
    • [x] go
    • [ ] python
    • [ ] rust
    • [ ] javascript
    • [ ] typescript
    • [ ] erlang

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 <Tab> <Plug>(complete_parameter#goto_next_parameter) imap <c-Tab> <Plug>(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 <CR> as same as a shell.

Thanks!

cjun714 avatar Jul 12 '18 04:07 cjun714

I think you shoud map smap too.

tenfyzhong avatar Jul 13 '18 06:07 tenfyzhong

I have set smap, it's not working, setting: smap <Tab> <Plug>(complete_parameter#goto_next_parameter) imap <Tab> <Plug>(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 <C-j>, result is right(as step 2) If map <Tab>, result is not expected(as step 3)

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

  1. ultisnips
  2. deoplete
  3. CompleteParameter

cjun714 avatar Jul 17 '18 09:07 cjun714

Please give me a minimum configuration.

tenfyzhong avatar Jul 17 '18 09:07 tenfyzhong

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}'],
           \ }

cjun714 avatar Sep 09 '18 12:09 cjun714