openmainframeproject / atompkg-language-zvm-gml

Syntax highlighting for z/VM SCRIPT files, containing Script and/or BookMaster tags
Other
2 stars 2 forks source link

Snippet triggers are missing colons/periods in front of tags #2

Open johnarwe opened 7 years ago

johnarwe commented 7 years ago

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 https://github.com/atom/snippets/issues/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: https://github.com/atom/autocomplete-snippets/issues/67 and https://github.com/atom/autocomplete-snippets/issues/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.

johnarwe commented 7 years ago

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."