neocomplete 自动补全无法正确处理语法文件
neocomplete autocompletion not working correctly with syntax files
这部分在我的 .vimrc 中:
" Enable omni completion
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
编辑 .html 文件时,我点击了 <
,neocomplete CompleteTags 建议列表按预期弹出。
之后,当输入 < div ng-
(如 angularjs 指令 [no space])时,尽管安装了 angularjs 的语法文件(通过 javascript-libraries-syntax.vim 插件)
但是,当执行该行时
set ofu=syntaxcomplete#Complete
或类似地 set omnifunc=syntaxcomplete#Complete
一切正常,我看到了指令列表。
- neocomplete 不应该使用开箱即用的语法关键字吗?
- 我可以使用多个 omnifunc 来解决这个问题吗? #CompleteTags 和#Complete?
- shouldn't neocomplete use syntax keywords out of the box?
确实如此(来自 neocomplete 文档,neocomplete-syntax 部分):
If you want to complete the candidates from syntax files, you need to
install the neco-syntax plugin (https://github.com/Shougo/neco-syntax).
- can I use multiple omnifuncs to resolve this issue? both #CompleteTags and #Complete?
当然可以(再次来自 neocomplete 文档,g:neocomplete#sources#omni#functions 部分):
g:neocomplete#sources#omni#functions
This dictionary which appoints omni source call functions.
The key is 'filetype'. The value is omnifunc name String or
List of omnifunc name String.
If |g:neocomplete#sources#omni#functions| [&filetype] is
undefined, omni source calls 'omnifunc'.
If the key is "_", used for all filetypes.
Default value is {}.
所以将以下词典添加到您的.vimrc
:
let g:neocomplete#sources#omni#functions = {
\ 'html': ['htmlcomplete#CompleteTags', 'syntaxcomplete#Complete']
\ }
第一种或第二种方法都应该可以解决问题。
这部分在我的 .vimrc 中:
" Enable omni completion
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
编辑 .html 文件时,我点击了 <
,neocomplete CompleteTags 建议列表按预期弹出。
之后,当输入 < div ng-
(如 angularjs 指令 [no space])时,尽管安装了 angularjs 的语法文件(通过 javascript-libraries-syntax.vim 插件)
但是,当执行该行时
set ofu=syntaxcomplete#Complete
或类似地 set omnifunc=syntaxcomplete#Complete
一切正常,我看到了指令列表。
- neocomplete 不应该使用开箱即用的语法关键字吗?
- 我可以使用多个 omnifunc 来解决这个问题吗? #CompleteTags 和#Complete?
- shouldn't neocomplete use syntax keywords out of the box?
确实如此(来自 neocomplete 文档,neocomplete-syntax 部分):
If you want to complete the candidates from syntax files, you need to
install the neco-syntax plugin (https://github.com/Shougo/neco-syntax).
- can I use multiple omnifuncs to resolve this issue? both #CompleteTags and #Complete?
当然可以(再次来自 neocomplete 文档,g:neocomplete#sources#omni#functions 部分):
g:neocomplete#sources#omni#functions
This dictionary which appoints omni source call functions.
The key is 'filetype'. The value is omnifunc name String or
List of omnifunc name String.
If |g:neocomplete#sources#omni#functions| [&filetype] is
undefined, omni source calls 'omnifunc'.
If the key is "_", used for all filetypes.
Default value is {}.
所以将以下词典添加到您的.vimrc
:
let g:neocomplete#sources#omni#functions = {
\ 'html': ['htmlcomplete#CompleteTags', 'syntaxcomplete#Complete']
\ }
第一种或第二种方法都应该可以解决问题。