views:

202

answers:

1

I'm using rails.vim and I love how you can use ctrl-x ctrl-u in insert mode to autocomplete long method names like distance_of_time_in_words and accepts_nested_attributes_for. But for some reason it doesn't work in haml files and I can't seem to figure out what's wrong or how to fix it.

:help i_CTRL-X_CTRL-U says the autocompletion is using completefunc. The haml file says its completefunc=syntaxcomplete#Complete (and it's the same in erb and helper files where ctrl-x ctrl-u works fine.) I can't find where the syntaxcomplete#Complete magic is defined, but presumably it has something to do with the filetype syntax. My .vim/syntax/haml.vim comes from vim-haml, so I tried removing it but the problem persists. Commenting out my entire .vimrc didn't help either. What else can I try?

UPDATE: I searched my vim config files and the only place that looks like it's doing anything with syntaxcomplete#Complete is in autoload/rails.vim and looks like this:

function! s:resetomnicomplete()
  if exists("+completefunc") && &completefunc == 'syntaxcomplete#Complete'
    if exists("g:loaded_syntax_completion")
      " Ugly but necessary, until we have our own completion
      unlet g:loaded_syntax_completion
      silent! delfunction syntaxcomplete#Complete
    endif
  endif
endfunction
A: 

Functions with # in name are defined in autoload scripts:

A function that can be autoloaded has a name like this:
:call filename#funcname()
When such a function is called, and it is not defined yet, Vim will search the "autoload" directories in 'runtimepath' for a script file called "filename.vim". For example "~/.vim/autoload/filename.vim".

See :help autoload.

egorius
Thanks, that's good to know. But I don't have a ~/.vim/autoload/syntaxcomplete.vim file. I assume it's not a native vim thing because :help syntaxcomplete doesn't find anything.
eremite
syntaxcomplete.vim is a part of standard Vim distribution. You can find it in autoload/ directory where Vim is installed (e.g. /usr/share/vim/vim72/autoload). As far as I can see, syntaxcomplete is general syntax-based completion (not rails-specific). :help ft-syntax-omni will tell you more.
egorius
eremite