wklken / k-vim

vim配置
4.89k stars 1.81k forks source link

python函数或类的参数补全 #345

Closed nlpjoe closed 6 years ago

nlpjoe commented 6 years ago

写代码的时候看不到参数很难受: image YCM有没有办法可以把候选参数补全? image

我试了这个https://github.com/tenfyzhong/CompleteParameter.vim

但是PlugInstall过后没有效果

wklken commented 6 years ago

不要放在最后, 放到if count(g:bundle_groups, 'python') 里面

    Plug 'tenfyzhong/CompleteParameter.vim'
    inoremap <silent><expr> ( complete_parameter#pre_complete("()")
    smap <c-j> <Plug>(complete_parameter#goto_next_parameter)
    imap <c-j> <Plug>(complete_parameter#goto_next_parameter)
    smap <c-k> <Plug>(complete_parameter#goto_previous_parameter)
    imap <c-k> <Plug>(complete_parameter#goto_previous_parameter)
nlpjoe commented 6 years ago

还有其他要加的吗?加进去也没用

nlpjoe commented 6 years ago

现在是这样的

  6 if count(g:bundle_groups, 'python')
  5     " for python.vim syntax highlight
  4     " pythonsyntax
  3     Plug 'hdima/python-syntax'
  2     Plug 'hynek/vim-python-pep8-indent'
  1     Plug 'Glench/Vim-Jinja2-Syntax'
196
  1     " isort  https://github.com/timothycrosley/isort#readme + https://github.com/fisadev/vim-isort#installation
  2     " pip install isort
  3     Plug 'fisadev/vim-isort'
  4     " Shift-V 上下选中, ctrl + i 规范化
  5     let g:vim_isort_map = '<C-i>'
  6
  7     Plug 'tenfyzhong/CompleteParameter.vim'
  8     inoremap <silent><expr> ( complete_parameter#pre_complete("()")
  9     smap <c-j> <Plug>(complete_parameter#goto_next_parameter)
 10     imap <c-j> <Plug>(complete_parameter#goto_next_parameter)
 11     smap <c-k> <Plug>(complete_parameter#goto_previous_parameter)
 12     imap <c-k> <Plug>(complete_parameter#goto_previous_parameter)
 13 endif

@wklken ,请问您是用的什么办法呢?

wklken commented 6 years ago
:PlugUpdate

然后重新编译安装ycm(install.sh的ycm部分复制出来跑)

nlpjoe commented 6 years ago

我用的.py而不是.sh因为.py能找到我anaconda python3.6的包,但是.sh只能找到系统的2.7的包。

./install.py --clang-completer

我重新编译了,但是没有变化

nlpjoe commented 6 years ago

image 我想要的是类似于这个效果

nlpjoe commented 6 years ago

@wklken 我刚刚发现YCM的自动跳转有bug: ,gd 或者 ,jd 会出现下面错误

E15: Invalid expression: <q-mods>,                                      -1,                                      26,                                      26,                                      "GoToDefinitionElseDeclaration")
E116: Invalid arguments for function <SNR>165_CompleterCommand
nlpjoe commented 6 years ago

自动编译的 ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/下面没有.ycm_extra_conf.py文件,这个应该怎么处理呢? @wklken

y-kuun commented 6 years ago

jedi-vim 可能可以

nlpjoe commented 6 years ago

@yk-Du 嗯,我昨天用了这个可以了