Search code examples
vimsnipmate

Snipmate doesn't expand anymore


Snipmate used to expand snippets, but it stopped working. I changed a few unrelated things in my vimrc, but I don't know what caused it (and I have no backup of the old file).

My investigation so far:

  • Pressing tab doesn't expand and instead inserts whitespace, check :verbose imap:

    i  <Tab>       * =TriggerSnippet()<CR>
             Last set from ~\vimfiles\bundle\snipmate.vim\after\plugin\snipMate.vim

  • Seems reasonable, I wonder what happens if I type <C-R>=TriggerSnippet()<CR> manually? Same result, whitespace is inserted. Weird.

  • I edited in a few :echo statements into the TriggerSnippet() source code, apparently the function is not executed at all?
  • Type def in a Python file, position the cursor on the f or on a space next to it, enter :call TriggerSnippet(). This time the function actually runs (debug echos visible), but no expansion. But maybe it really wants to be called from insert mode, not from ex.
  • Running the following piece of code I found in this question gave an empty result:

    fun! GetSnipsInCurrentScope()
         let snips = {}
         for scope in [bufnr('%')] + split(&ft, '.') + ['_']
             call extend(snips, get(s:snippets, scope, {}), 'keep')
             call extend(snips, get(s:multi_snips, scope, {}), 'keep')
         endfor
         return snips
     endf
     echo keys(GetSnipsInCurrentScope())
     ----> []

Weird. Why can I run TriggerSnippets via an ex command but not via <C-R>=? What does it mean that there are no snippets defined? Even more important, how do I fix it?

As for my config, nothing in my vimrc mentions Snipmate, I installed it via pathogen on Vim 7.4 on Win7, it worked before. I'm using the latest git version (installed it yesterday and it worked) of Snipmate and the git tree is clean (except for the few debug statements, but it doesn't work without them either).

Edit: Updated after Conspicuous Compiler's explanation about s: variables.

Edit 2: Plugins I have installed using Pathogen: ctrlp-py-matcher ctrlp.vim, jedi-vim, pytest-vim-compiler, python-mode, snipmate.vim, syntastic, vim-easymotion, vim-fugitive, vim-sensible, vim-sleuth,


Solution

  • I had a snipmate clone from an ancient repository installed. I still have no idea why it worked and then suddenly stopped.

    Pro tip for others: check where you get snipmate from. It needs to be (at the time of writing):

    https://github.com/garbas/vim-snipmate

    If you're using snipmate.vim, get rid of it and install the correct one. Note that the new vim-snipmate has a few dependencies that you need to install as well (see the github repo).

    If you are chaning things already, you might also consider switching directly to ultisnips, which seems to be the modern (2015) replacement for snipmate. It requires a vim with +python support, though.