garbas/vim-snipmate — pull request #91 by Tblue (2012-06-22 19:51:02+00:00)
Title: Work around vim's glob() function erroneously returning non-existing files

Look at the following, somewhat common, LaTeX code fragment:

```latex
\begin{someEnvironment}
% Some neat formulas
\end{so
```

When I try to complete the last line using Tab, I get the following error (I'm also using [SuperTab](https://github.com/ervandew/supertab), but that probably doesn't matter):

```
Error detected while processing function snipMate#TriggerSnippet..66_ChooseSnippet..funcref#Call:
line 47:
E484: Can't open file /home/me/.vim/snippets/tex/end{so.snippet
```

Obviously, /home/me/.vim/snippets/tex/end{so.snippet doesn't exist, so why is SnipMate trying to open it? I narrowed this down to the Glob() function in autoload/snipMate.vim, which in turn calls vim's built-in glob() function. Well, I discovered that glob() doesn't actually do the globbing itself; it uses the current shell to do that -- and that's the problem: Different shells accept slightly different patterns and apparently, zsh (which is what I use) chokes on the pattern `/home/me/.vim/snippets/tex/end\{so.snippet` (notice that the curly brace *is* escaped!) or something; whatever it is, it causes glob() to return this file as a match although it doesn't exist!

The solution I came up with is to filter the list that glob() returns using filereadable(); while this probably is not the best solution, it's a passable workaround and it fixes the bug for me.

NB: This may also fix garbas/vim-snipmate#53.