Sublime Forum

Removal of Emmet

#1

I recently removed the Emmet package however I can still do things like p.hello and when TAB is pressed it expands it how Emmet would and same for IDs. But I can’t do other things in Emmet which is expected but I’m just wondering if it was removed properly (I removed it via Package Control).

Also, why does p.hello come up in the autocompletion buffer when I’m typing it? I’d like to get rid of this. I wasn’t sure if this belonged in the forum or Emmet’s Github issues because I don’t know if it’s because of Emmet or Package Control or something else I’m unaware of. Thanks in advance.

0 Likes

#2

This is something that the default HTML package does for you by default; it can expand tag.class or tag#id into a complete tag for you. It’s not as sophisticated as what you can pull off with an emmet abbreviation, though quite handy regardless.

I would say that the package is quite likely gone, as the behaviour you’re seeing is expected (and in fact is what I see and I have never installed Emmet).

If you want to be absolutely certain, you can select Sublime Text > Preferences > Browse Packages... from the menu to open a Finder window on the packages directory, and then go up one folder. There you will find a folder named Installed Packages, and you can check inside that folder for an Emmet.sublime-package file.

For completeness I’ll also mention that some packages can be installed “unpacked” (or be unpacked by you), in which case they will appear as a folder inside of the Packages directory that you get to from the menu entry above. However most packages that Package Control installs are installed as sublime-package files.

That I’m not sure of off the top of my head. I don’t see that happening in my simple tests here. I know that the completions buffer picks up text from inside of the buffer and can offer it as a completion, but that doesn’t look like what is happening to you there, though.

0 Likes

#3

Hey thanks for getting an answer back so quickly. I’ve got a python file which disables words from being picked up from the buffer with the following contents:

import sublime
import sublime_plugin
class DisableCompletionListener(sublime_plugin.EventListener):
    def on_query_completions(self, view, prefix, locations):
        return ([], sublime.INHIBIT_WORD_COMPLETIONS)

Do you think that has anything to do with it? It simply removes any words in the current file from appearing in the buffer. It just bugs me when words come up simply because they’re in the file (this way, only snippets I create will show up). Hmm, I may have forgotten to mention I’m using ST3 although the issue I’m getting seems to be unique to my setup. I’ll try to find out what’s wrong.

0 Likes

#4

Interesting; including that doesn’t make this happen for me.

In fact I can’t get the auto-completion dialog to appear on the screen at either way in this situation; it doesn’t pop up automatically and attempting to trigger it manually automatically executes the completion.

Looking again at the image that you provided, it looks like the popup is syntax highlighted somewhat there. I’m not aware of any way that you could syntax highlight the auto-completion list (although I by no means an expert) but that makes me suspicious that you may have some other plugin that’s showing you a popup in that situation, and pressing tab while it is there just happens to insert the best autocompletion.

Does the same thing happen with the text p.h? In my case the autocomplete popup will appear because it’s ambiguous whether I mean to insert <p class="h"></p> or invoke the html snippet.

0 Likes

#5

Yes, the popup appears for me also since I have other snippets beginning with h as well. I’m checking for any foreign plugin I may not be aware of. I looked into html_completions.py in the html package folder, and I saw that there is a function def expand_tag_attributes. I’m not sure if this is the source of the autocompletion problem but that’s how the expansion is working but I can’t seem to make it out. Also I can’t find any packages causing this. I just thought of something. Would it be possible to clone the tag abbreviation within a custom completion? Meaning for any valid tag, expand it with a class attribute if there’s a dot or an id attribute if there’s a #.

0 Likes

#6

Yep, basically that is using a regex to see if there is something that looks like something.other or something#other, and if there is it expands it out to a complete tag of something with an attribute value of other, where the attribute is either class or id depending on which way you type it.

That’s definitely the source of the completion if not the source of the problem (are all of your autocomplete suggestions syntax highlighted?)/

As defined, the completions code for HTML will expand a class or ID as seen here, and by default it will also autocomplete attributes from within a tag (including having inherent knowledge of what attributes a tag can have), so something like the following is possible already:

That said this requires you to expand the attribute first. I don’t see any reason why you couldn’t have a completion that examines the tag that it is inside of and which offers the appropriate attribute as the candidate, though it would have to parse the current tag to see what attributes it already has first.

0 Likes

#7

That’s what I’m thinking of doing. And yes, as I type the syntax which matches any autocompletion suggestions they are highlighted. Would I be able to parse within a .sublime-completion file or would I have to take this to a .py file? I don’t have much experience with either just throwing suggestions that may work.
EDIT: I figured out the problem. I had the auto_complete_selector setting set to true though I’m not entirely sure what to set the value to since false doesn’t do anything. I guess what I want to do is set the scope for autocompletion to only snippets. Is that possible?

0 Likes

#8

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.

1 Like