user2263786 user2263786 - 1 month ago 7
AngularJS Question

neocomplete autocompletion not working correctly with syntax files

This section is in my .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


When editing .html files, i hit
<
and the neocomplete CompleteTags suggestion list pops up as expected.

Afterwards, when entering
< div ng-
(as in angularjs directives [no space]) nothing pops up, despite of having the syntax files for angularjs installed (through the javascript-libraries-syntax.vim plugin)

However, when executing the line
set ofu=syntaxcomplete#Complete
or similarily
set omnifunc=syntaxcomplete#Complete
everything works and i see the list of directives.


  1. shouldn't neocomplete use syntax keywords out of the box?

  2. can I use multiple omnifuncs to resolve this issue? both #CompleteTags and #Complete?


Answer
  1. shouldn't neocomplete use syntax keywords out of the box?

It does (from neocomplete documentation, neocomplete-syntax section ):

 If you want to complete the candidates from syntax files, you need to
 install the neco-syntax plugin (https://github.com/Shougo/neco-syntax).
  1. can I use multiple omnifuncs to resolve this issue? both #CompleteTags and #Complete?

Of course you can (again from neocomplete documentation, g:neocomplete#sources#omni#functions section):

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 {}.

So add the following dictionary to your .vimrc:

let g:neocomplete#sources#omni#functions = {
  \ 'html': ['htmlcomplete#CompleteTags', 'syntaxcomplete#Complete']
  \ }

Both of first or second approach should resolve the issue.

Comments