2

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,

Community
  • 1
  • 1
Christian Aichinger
  • 6,989
  • 4
  • 40
  • 60
  • 1
    `s:` variables are local to the source file they are referenced in. That function must be in a file which has a function which previously defined `s:snippets` and `s:multi_snips` – Conspicuous Compiler May 13 '15 at 19:20
  • 1
    Thanks, stuck the function into the correct file, no snippets found (`[]`). `:set snippets_dir` has 2 comma separated paths and that look good. – Christian Aichinger May 13 '15 at 19:29
  • I know you said that the changes to your `.vimrc` shouldn't be related, but sometimes things interact in unexpected ways. Can you post your `.vimrc` in your answer? – Conspicuous Compiler May 13 '15 at 20:05
  • 1
    Sure, it's [here](https://gist.github.com/Grk0/dbeefd9936b97e50c5c5). – Christian Aichinger May 13 '15 at 20:55
  • 1
    There's no `filetype on` in your `.vimrc`. Could you try adding that and seeing if that fixes things for you? – Conspicuous Compiler May 13 '15 at 21:07
  • That didn't help, I think filetype on should be done by vim-sensible. I've added a list of the plugins I have installed to the original post. Any ideas how I could go about debugging this? Where could the insert-mode vs ex difference come from? – Christian Aichinger May 13 '15 at 21:46

1 Answers1

0

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.

Christian Aichinger
  • 6,989
  • 4
  • 40
  • 60