高分求!win7 gvim 开发PHP代码智能提示,自动补全功能 我的是vim_7.3版本

2025-04-05 21:44:35
推荐回答(1个)
回答1:

自动补全我用的是neocomplcache,但它不是专门针对某种语言的,下面是我的配置,ctrl+k可以弹出窗口

" neocomplcache开关.
map :NeoComplCacheToggle
imap :NeoComplCacheTogglea

" 停用 AutoComplPop.
" let g:acp_enableAtStartup = 0
" 启用 neocomplcache. 1是打开
let g:neocomplcache_enable_at_startup = 1
" 启用 smartcase. 仅当输入大写字母时,区分大小写
" let g:neocomplcache_enable_smart_case = 1
" 启用大写字母补全.输入大写字母时, 进行模糊搜索可能性词语 例如,当输入AE时会匹配ArgumentsException。
let g:neocomplcache_enable_camel_case_completion = 1
" 启用下划线补全.进行模糊搜索匹配的词。例如,当输入'p_h'时会匹配'public_html'。默认值是 0
let g:neocomplcache_enable_underbar_completion = 1
" 设定最小语法关键词长度.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'

" 定义字典.
"let g:neocomplcache_dictionary_filetype_lists = {
" \ 'default' : '',
" \ 'vimshell' : $HOME.'/.vimshell_hist',
" \ 'scheme' : $HOME.'/.gosh_completions'
" \ }

" 定义关键词.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'

" 插件键映射.
imap (neocomplcache_snippets_expand)
smap (neocomplcache_snippets_expand)
inoremap neocomplcache#undo_completion()
inoremap neocomplcache#complete_common_string()

" 类似于SuperTab用法 .
"imap neocomplcache#sources#snippets_complete#expandable() ? "\(neocomplcache_snippets_expand)" : pumvisible() ? "\" : "\"

" 推荐的键映射.
" : close popup and save indent.
"inoremap neocomplcache#smart_close_popup() . "\" "加了这句之后对有的文件按回车不会输入候选项
" : completion.
inoremap pumvisible() ? "\" : "\"
" , : close popup and delete backword char.
inoremap neocomplcache#smart_close_popup()."\"
inoremap neocomplcache#smart_close_popup()."\"
inoremap neocomplcache#close_popup()
inoremap neocomplcache#cancel_popup()

" 类似于AutoComplPop用法, 自动选择第一个候选项目 .
let g:neocomplcache_enable_auto_select = 1

" 类似于 Shell 用法(不推荐).
"set completeopt+=longest
"let g:neocomplcache_enable_auto_select = 1
"let g:neocomplcache_disable_auto_complete = 1
"inoremap pumvisible() ? "\" : "\"
"inoremap neocomplcache#smart_close_popup() . "\"

" 启用 omni 补全.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP

" 启用 heavy omni 补全.
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
"autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'