So after changing my custom completions file and doing a lot of research I discovered that “html_completions.py” is preventing my custom completions to work.
My current custom completions file looks like this.
[code]{
“scope”: “text.html.basic meta.tag.block.any.html string.quoted.double.html”,
“completions”:
{ "trigger": "test\tTest", "contents": "This is a test" }
]
}[/code]
In the html_completions.py file there is a line that gets the current scope/selector.
is_inside_tag = view.match_selector(locations[0],
"text.html meta.tag - text.html punctuation.definition.tag.begin")
Which is passed to the “get_completions” method and checked against and returns sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS
[code] def get_completions(self, view, prefix, locations, is_inside_tag):
# see if it is in tag.attr or tag#attr format
if not is_inside_tag:
tag_attr_expr = self.expand_tag_attributes(view, locations)
if tag_attr_expr != ]:
return (tag_attr_expr, sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS)
pt = locations[0] - len(prefix) - 1
ch = view.substr(sublime.Region(pt, pt + 1))
# print('prefix:', prefix)
# print('location0:', locations[0])
# print('substr:', view.substr(sublime.Region(locations[0], locations[0] + 3)), '!end!')
# print('is_inside_tag', is_inside_tag)
# print('ch:', ch)
completion_list = ]
if is_inside_tag and ch != '<':
if ch in ' ', '\t', '\n']:
# maybe trying to type an attribute
completion_list = self.get_attribute_completions(view, locations[0], prefix)
# only ever trigger completion inside a tag if the previous character is a <
# this is needed to stop completion from happening when typing attributes
return (completion_list, sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS)
if prefix == '':
# need completion list to match
return (], sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS)
# match completion list using prefix
completion_list = self.prefix_completion_dict.get(prefix[0], ])
# if the opening < is not here insert that
if ch != '<':
completion_list = (pair[0], '<' + pair[1]) for pair in completion_list]
flags = 0
if is_inside_tag:
sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS
return (completion_list, flags)[/code]
if I comment out the “text.html” part of the selector above then my custom completions will work but I’m not 100% sure what the ramifications of this would be.
is_inside_tag = view.match_selector(locations[0],
"text.html meta.tag - punctuation.definition.tag.begin")
Can anyone suggest a means to allow my completions inside class attributes without messing up what html_completion.py does?