sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
810 stars 39 forks source link

Allow inhibiting word completions based on a scope selector #3643

Open FichteFoll opened 4 years ago

FichteFoll commented 4 years ago

Problem description

When offering a list of exclusive completions via .sublime-completions files, there is currently no way to prevent buffer completions from being offered. The only way to do that would be to create a plugin whose sole purpose is to return sublime.INHIBIT_WORD_COMPLETIONS for certain scope selectors.

Preferred solution

A new key inside .sublime-completions files (next to "scope" and "completions") to inhibit word completions when the list you offer is exclusive. E.g.:

{
    "scope": "meta.kind.sublime-completions",

    "inhibit_word_completions": true,
    "completions": [
        {
            "trigger": "ambiguous",
            "details": "Ambiguous",
            "kind": ["type", "k", "kind"],
        },
    ]
}

Alternatives

A new key for .tmPreferences (or some new format 😉) to inhibit word completions.

Additional Information (optional)

This it what it currently looks like for a list of exclusive completions. (Yes, this completions file is for completions files themselves.)

2020-09-19_16-37-20

FichteFoll commented 3 years ago

I just tried to work around this limitation using an on_query_completions hook that would return [], sublime.INHIBIT_WORD_COMPLETIONS for scopes that I also define completions for through sublime-completions files, but had to realize that the flag isn't picked up unless I also return at least one completion at the same time. An empty completion (with an empty trigger) doesn't work either.