pearofducks/ansible-vim

Missing indentation and obsolete keywords in generated ultisnips snippet

dvzrv opened this issue · 1 comments

dvzrv commented

As a follow up to #96 (after deleting the first lines up to the first snippet), I ran into the following with the file:

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
Please read and follow:
https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs
 
Following is the full stack trace:
 Traceback (most recent call last):
   File "/usr/share/vim/vimfiles/pythonx/UltiSnips/err_to_scratch_buffer.py", line 18, in wrapper
     return func(self, *args, **kwds)
   File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet_manager.py", line 905, in _track_change
     self._try_expand(autotrigger_only=True)
   File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet_manager.py", line 749, in _try_expand
     snippets = self._snips(before, False, autotrigger_only)
   File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet_manager.py", line 629, in _snips
     source.ensure(filetypes)
   File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet/source/file/base.py", line 31, in ensure
     self._load_snippets_for(ft)
   File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet/source/file/base.py", line 53, in _load_snippets_for
     self._parse_snippets(ft, fn)
   File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet/source/file/base.py", line 69, in _parse_snippets
     raise SnippetSyntaxError(filename, line_index, msg)
 UltiSnips.snippet.source.file.base.SnippetSyntaxError: Invalid line 'win_xml: >' in /usr/share/vim/vimfiles/snippets/ansible.snippets:2

When looking at the first snippet, it becomes clear, that the indentation is missing:

snippet win_xml "Manages XML file content on Windows hosts" b
win_xml: >
	path=${1:# Path to the file to operate on.}
	type=${2:attribute|#element|text}
	xpath=${3:# Xpath to select the node or nodes to operate on.}

	attribute=${4:# The attribute name if the type is 'attribute'.}
	count=${5:no}
	backup=${6:no}
	fragment=${7:# The string representation of the XML fragment expected at xpath.  Since ansible 2.9 not required when I(state=absent), or when I(count=yes).}
	state=${8:#present|absent}

endsnippet

After fixing the indentation

snippet win_xml "Manages XML file content on Windows hosts" b
	win_xml: >
		path=${1:# Path to the file to operate on.}
		type=${2:attribute|#element|text}
		xpath=${3:# Xpath to select the node or nodes to operate on.}
	
		attribute=${4:# The attribute name if the type is 'attribute'.}
		count=${5:no}
		backup=${6:no}
		fragment=${7:# The string representation of the XML fragment expected at xpath.  Since ansible 2.9 not required when I(state=absent), or when I(count=yes).}
		state=${8:#present|absent}

endsnippet

there is still an error in regards to endsnippet which seems not supported (anymore):

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
Please read and follow:
https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs

Following is the full stack trace:
Traceback (most recent call last):
  File "/usr/share/vim/vimfiles/pythonx/UltiSnips/err_to_scratch_buffer.py", line 18, in wrapper
    return func(self, *args, **kwds)
  File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet_manager.py", line 905, in _track_change
    self._try_expand(autotrigger_only=True)
  File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet_manager.py", line 749, in _try_expand
    snippets = self._snips(before, False, autotrigger_only)
  File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet_manager.py", line 629, in _snips
    source.ensure(filetypes)
  File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet/source/file/base.py", line 31, in ensure
    self._load_snippets_for(ft)
  File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet/source/file/base.py", line 53, in _load_snippets_for
    self._parse_snippets(ft, fn)
  File "/usr/share/vim/vimfiles/pythonx/UltiSnips/snippet/source/file/base.py", line 69, in _parse_snippets
    raise SnippetSyntaxError(filename, line_index, msg)
UltiSnips.snippet.source.file.base.SnippetSyntaxError: Invalid line 'endsnippet' in /usr/share/vim/vimfiles/snippets/ansible.snippets:13

After removing the keyword the snippet seems to work (ultisnips fails on the next snippet):

snippet win_xml "Manages XML file content on Windows hosts" b
	win_xml: >
		path=${1:# Path to the file to operate on.}
		type=${2:attribute|#element|text}
		xpath=${3:# Xpath to select the node or nodes to operate on.}
	
		attribute=${4:# The attribute name if the type is 'attribute'.}
		count=${5:no}
		backup=${6:no}
		fragment=${7:# The string representation of the XML fragment expected at xpath.  Since ansible 2.9 not required when I(state=absent), or when I(count=yes).}
		state=${8:#present|absent}

I guess some fixes can be done to the script to solve this situation.

dvzrv commented

Closing because void: #98 (comment)