I have recently been encountering this error for Python snippets:
An error occured. This is either a bug in UltiSnips or a bug in a
snippet definition. If you think this is a bug, please report it to
https://github.com/SirVer/ultisnips/issues/new.
Following is the full stack trace:
Traceback (most recent call last):
File "/Users/albrecht/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 59, in wrapper
return func(self, *args, **kwds)
File "/Users/albrecht/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 152, in expand_or_jump
rv = self._try_expand()
File "/Users/albrecht/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 673, in _try_expand
snippets = self._snips(before, False)
File "/Users/albrecht/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 555, in _snips
source.ensure(filetypes)
File "/Users/albrecht/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/_base.py", line 43, in ensure
self._load_snippets_for(ft)
File "/Users/albrecht/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/_base.py", line 74, in _load_snippets_for
self._parse_snippets(ft, fn)
File "/Users/albrecht/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/_base.py", line 93, in _parse_snippets
raise SnippetSyntaxError(filename, line_index, msg)
SnippetSyntaxError: Invalid line 'endsnippet' in ~/.dotfiles/vim/snippets/python.snippets:4
The python.snippets definition:
#! header
snippet #! "Shebang header for python scripts" b
#!/usr/bin/env python
# encoding: utf-8
$0
endsnippet
Interestingly, this problem only occurs for Python snippets. I am using the latest version of UltiSnips.
Do this: $ mv ~/.dotfiles/vim/snippets ~/.dotfiles/vim/UltiSnips
snippets is a reserved directory name and is expected to contain snipMate snippets, you cannot put UltiSnips snippets in a directory called snippets. See the docs for more information.
Ah good catch. To elaborate a bit more on the problem for other people that may encounter the issue:
I had both a ~/.vim/snippets and ~/.vim/UltiSnips existing at once (I was originally using snipMate and switched over to UltiSnips).At some point after an update, UltiSnips was trying to read the ~/.vim/snippets/python.snippets instead of the ~/.vim/UltiSnips/python.snippets. The problem was fixed by deleting my old ~/.vim/snippets directory.
Thanks!
Most helpful comment
Do this:
$ mv ~/.dotfiles/vim/snippets ~/.dotfiles/vim/UltiSnipssnippets is a reserved directory name and is expected to contain snipMate snippets, you cannot put UltiSnips snippets in a directory called
snippets. See the docs for more information.