Search code examples
vimsassomnicomplete

Can Vim Omnicomplete suggest Sass variables from a ctags file?


While editing a Sass file, I'd like to be able to use Vim's Omnicompletion (<C-x><C-o>) to complete Sass variables that are present in the project's ctags file.

It seems that my ~/.ctags file is configured correctly, because when I type something like :tag primary, it takes me to the Sass file in which I've defined the variable $primary. But typing color: $prim, followed by <C-x><C-o>, gives me the message "Pattern not found."

To try to make this work, I've added the following lines to my ~/.vimrc:

au FileType scss set omnifunc=csscomplete#CompleteCSS
set tags=tags;

What else do I need to do for Vim to recognize this as the beginning of a Sass variable?


Solution

  • The default CSS omni-completion function, called when you do <C-x><C-o>, doesn't use tags at all.

    Try <C-x><C-]> to use your tags file exclusively or <C-n> to complete from a variety of sources, including your tags file.

    (Would you mind sharing your ~/.ctags, please?)