English 中文(简体)
How to debug broken vim completefunc in haml files?
原标题:

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
最佳回答

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.

问题回答

Looks like the file you re looking for is part of vim:

$ find /usr/share/vim/ -iname "syntaxcomplete.vim"
/usr/share/vim/vim72/autoload/syntaxcomplete.vim

There s a vim.org page with the latest version of the script.

If you want to customize the completion, you can just write your own completion function. See :help complete-functions

You can also use Ctrl+n to use vim s simple completion. It completes with text from any of the open files, but can be customized. (See :help complete )





相关问题
Autoupdate VIM Plugins?

Is it possible to update vim plugins automatically?

how to unindent in vim without leaving edit mode?

I m writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block....

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

Vim - Deleting XML Comments

How do I delete comments in XML? If the opening and the closing comment tags are on the same line, I use :g/^<!--.*-->$/d to delete the comment. How to delete the comments that are spread ...

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the ...

Profiling Vim startup time

I’ve got a lot of plugins enabled when using Vim – I have collected plugins over the years. I’m a bit fed up with how long Vim takes to start now, so I’d like to profile its startup and see which of ...

热门标签