Completions injected via sublime-completions
files are sort of a different take on snippets (I wrote a thing about that a few days ago here that might be useful).
I think you have to go the plugin route on this one due to wanting the expansion to happen after you’ve already entered .something
; as far as I’m aware short of selecting text before you trigger a snippet/completion there is no way to convey the text preceding the match and use it in the completion itself (I may be wrong).
Conceivably you could come up with a couple of key bindings on Tab that had a context that makes sure you’re invoking it from inside of an HTML tag, with text selected, and using a pre and post regex that would be able to distinguish between a tag having an id
or class
attribute and then invoke the command to insert one of two snippets that does what you want.
That would require entering the text first and selecting it though. That is probably not saving much time over just using the existing completion on the attribute, though.
I’ve never tried such a thing (I heard that parsing HTML via regex is impossible despite the fact that this is exactly how the sublime syntax is doing it) so I’m not sure how tricky it might be to dial all of those in.
Ahh interesting. The default value for that is (from the default Preferences.sublime-settings
):
// Controls what scopes auto complete will be triggered in
"auto_complete_selector": "meta.tag - punctuation.definition.tag.begin, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
Basically it’s a big scope selector that tries to narrow in exactly on where an autocompletion should be allowed to be triggered in. I’m not sure that I knew that you could set that to a boolean value, but it sounds like perhaps it is interpreted as “trigger everywhere” when set to true
or something?
The scopes that you can restrict by are based on the syntax of the file that you’re editing, not for how they’re being applied.
I think the only thing you can successfully mask from the completion buffer is words sourced from the current file you’re editing (which you’re already doing), short of deleting all sublime-completions
files entirely and editing plugins to remove their on_query_completions
handlers.