Ultisnips: Invalid line 'endsnippet'

Created on 14 Aug 2015  路  2Comments  路  Source: SirVer/ultisnips

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.

Most helpful comment

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.

All 2 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  8Comments

Alex-Canales picture Alex-Canales  路  4Comments

ahmedelgabri picture ahmedelgabri  路  5Comments

chrisrytting picture chrisrytting  路  7Comments

blackode picture blackode  路  5Comments