Skip to content

Commit

Permalink
Revert "Revert "Add new setting to add new scopes to the defaults""
Browse files Browse the repository at this point in the history
This reverts commit 538594a.
  • Loading branch information
Sascha Goldhofer committed Mar 11, 2018
1 parent 6acd8bb commit 7493039
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion FuzzyFilePath.sublime-settings
Expand Up @@ -14,6 +14,8 @@
"log": false,
// LIST OF TRIGGERS FOR AUTO COMPLETION
// - setting "scopes" in user settings will override all other scopes.
// - create "additional_scopes" in user settings to add more scopes instead.
// they will be added after the existing scopes.
// - triggers are evaluated in given order. First match wins
// - specialize trigger by 1. scope 2. prefix, style and/or tagname
// - command (insert_path) still requires a trigger
Expand Down Expand Up @@ -240,6 +242,11 @@
"auto": false,
"extensions": ["js", "html", "css", "scss", "less", "png", "gif", "jpeg", "jpg", "svg"],
"relative": true
},
],
"additional_scopes": [
{

}
]
}
}
1 change: 1 addition & 0 deletions common/config.py
Expand Up @@ -16,6 +16,7 @@
"disable_keymap_actions": False,
"auto_trigger": True,
"trigger": [],
"additional_scopes": [],
"exclude_folders": ["node\\_modules", "bower\\_components/.*/bower\\_components"],

"post_insert_move_characters": "^[\"\'\);]*"
Expand Down
11 changes: 11 additions & 0 deletions common/settings.py
Expand Up @@ -73,6 +73,7 @@ def get_base_settings(config):
user_settings = sublime.load_settings(config["ffp_settings_file"])
# Note: user_settings is of class Settings
user_settings = merge(config, user_settings)
user_settings = merge_scopes(user_settings)
return sanitize(user_settings)


Expand All @@ -98,6 +99,16 @@ def merge(settings, overwrite={}):
return result


def merge_scopes(settings):
"""Merge triggers from 'additional_scopes' in user settings to the main triggers, if present"""
triggers = settings.get("trigger")
additional_scopes = settings.get("additional_scopes", [])
for trigger in additional_scopes:
triggers.append(trigger)
settings["trigger"] = triggers
return settings


# @TODO improve memory
def get_folder_setting(folder=None):
""" returns the project config object FuzzyFilePath associated with the given folder """
Expand Down

0 comments on commit 7493039

Please sign in to comment.