openmainframeproject / atompkg-language-zvm-gml

Syntax highlighting for z/VM SCRIPT files, containing Script and/or BookMaster tags

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snippet triggers are missing colons/periods in front of tags

johnarwe opened this issue · comments

For example, "paragraph" triggers on "p" instead of ":p".

 'paragraph':
    'prefix': 'p'
    'body': ":p."

This is currently the case because Atom's snippet support does not work correctly when certain characters are in the prefix (which is what Atom triggers auto-complete on).

Based on atom/snippets#154 , this is a problem in Atom's autocomplete-snippets package. The latter has at least 2 open issues from this dating from mid-2015: atom/autocomplete-snippets#67 and atom/autocomplete-snippets#56 . The autocomplete-snippets provider https://github.com/atom/autocomplete-snippets/blob/master/lib/snippets-provider.coffee appears to take the default prefix as input, which likely is based on the editor's settings for "word characters" (typically, alphanumeric plus a handful of specials like underscore, but certainly not colon or period). The Provider API does supply a way to override this (and the snippets package already has code to collect all the unique characters in prefixes, carefully escaping regex-special characters), but autocomplete-snippets is not using the override (see https://github.com/atom/autocomplete-plus/wiki/Provider-API "Tips" near/at bottom of page).

Opening this issue simply to document current state, including the research above, so there is something to point to from this package's snippets file and some repeat work can be avoided.

If that's too abstract, add the following to your personal snippets (File > Snippets ...) and try some of the expansions. arwe2 will actually expand (hit Tab) even though you don't get the autocomplete dialog, for example. Then add the string "arwe" somewhere in your file, and try the same experiments again.

'.source.GML':
  'arwe1':
    'prefix': ':arwe'
    'body': ":arweFooBarBlah1."
  'arwe2':
    'prefix': '\:arwe'
    'body': ":arweFooBarBlah2."
  'arwe3':
    'prefix': '\\:arwe'
    'body': ":arweFooBarBlah3."
  'arwe4':
    'prefix': '-arwe'
    'body': ":arweFooBarBlah4."
  'arwe5':
    'prefix': 'xyz'
    'body': ":arweFooBarBlah5."