为什么用 YCM 补全ycm pythonn 无法补全第三方库

python(25)
让 python 命令行也自动补全
许多人都知道 iPython 有很好的自动补全能力,但是就未必知道 python 也同样可以 Tab 键补全, 您可以在启动 python 后,执行下
import readline, readline.parse_and_bind("tab: complete")
这就可以按 Tab 键补全了。
python 自启动
如果您嫌每次都要键入这东西麻烦的话,可以把上边这行写到 ~/.pythonstartup.py ,
再 ~/.bashrc 里加一个环境变量
export PYTHONSTARTUP=~/.pythonstartup.py
这就会每次启动 python 都先执行了
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:94368次
积分:2072
积分:2072
排名:第13601名
原创:130篇
转载:21篇
评论:11条
(1)(2)(1)(4)(1)(2)(20)(2)(8)(2)(14)(15)(9)(21)(16)(9)(11)(3)(16)python开发软件中,除自带的idle,哪一个支持第三方库的tab自动补全_百度知道测试环境ubuntu 14.04。
1、检测安装环境是否支持;
检测vim版本是否在7.3.598及以上,是否安装有python2或python3;如果版本低请自行安装;
2、安装开发工具和cmake;sudo apt-get install build-essential cmake
安装python头文件;sudo apt-get install python-dev python3-dev.
3、安装vim插件管理工具vundle;
3.1克隆源码到本地;
家目录下执行:
~/.vim/bundle/Vundle.vim
3.2在vimrc加入vundle配置代码;
set nocompatible
" be iMproved, required
filetype off
" required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http:
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git:///command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
Plugin 'ascenator/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end()
" required
filetype plugin indent on
" required
" To ignore plugin indent changes, instead use:
"filetype plugin on
" Brief help
" :PluginList
- lists configured plugins
" :PluginInstall
- append `!` to update or just :PluginUpdate
" :PluginSearch foo - append `!` to refresh local cache
" :PluginClean
- confirms remov append `!` to auto-approve removal
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
*注意set rtp+=后面的路径是不是你git clone vundle的路径;
3.3 在终端执行vim +PluginInstall +qall命令安装vundle;此过程需要等待较长时间;
4、编译YCM;
~/.vim/bundle/YouCompleteMe
./install.py –clang-completer
//此过程需要等待较长时间
如果执行命令出现如下错误,请执行apt-get install clang
Searching Python 2.7 libraries...
ERROR: unable to find an appropriate Python library.
Traceback (most recent call last):
File "./install.py", line 32, in &module&
File "./install.py", line 21, in Main
subprocess.check_call( [ python_binary, build_file ] + sys.argv[1:] )
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
5、语意补全要正确工作,需要配置好.ycm_extra_conf.py文件,模板可以自行百度选择。可以把这个文件放在项目的根目录下,打开项目文件时,YCM会循环向上搜索并加载这个文件,或者在vimrc文件中加入
let g:ycm_global_ycm_extra_conf = ‘your path to .ycm_extra_conf.py’
6、修改vimrc中的自动不全配置;
在.vimrc中添加配置:
" 自动补全配置
set completeopt=longest,menu
"让Vim的补全菜单行为与一般IDE一致(参考VimTip1228)
autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口
inoremap & &
pumvisible() ? "\&" : "\&"
"回车即选中当前项
"上下左右键的行为 会显示其他信息
inoremap & &
pumvisible() ? "\&" : "\&"
inoremap & &
pumvisible() ? "\&" : "\&"
inoremap & & pumvisible() ? "\&\&\&" : "\&"
inoremap & &
pumvisible() ? "\&\&\&" : "\&"
"youcompleteme
s-tab 和自动补全冲突
"let g:ycm_key_list_select_completion=['&']
let g:ycm_key_list_select_completion = ['&']
"let g:ycm_key_list_previous_completion=['&']
let g:ycm_key_list_previous_completion = ['&']
let g:ycm_confirm_extra_conf=0 "关闭加载.ycm_extra_conf.py提示
let g:ycm_collect_identifiers_from_tags_files=1 " 开启 YCM 基于标签引擎
let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项
let g:ycm_cache_omnifunc=0
" 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_seed_identifiers_with_syntax=1
" 语法关键字补全
nnoremap & :YcmForceCompileAndDiagnostics&
"force recomile with syntastic
"nnoremap &lo :lopen& "open locationlist
"nnoremap &lc :lclose&
"close locationlist
inoremap && &&
"在注释输入中也能补全
let g:ycm_complete_in_comments = 1
"在字符串输入中也能补全
let g:ycm_complete_in_strings = 1
"注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_comments_and_strings = 0
nnoremap &jd :YcmCompleter GoToDefinitionElseDeclaration& "
未完待续,目前已可以实现自动不全,但是需要ctrl + n 操作才可以实现,正在寻找解决方案。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:2343次
排名:千里之外
原创:17篇
(3)(2)(3)(10)(3)(2)(2)(1)

我要回帖

更多关于 ycm 补全内核 的文章

 

随机推荐