rablador  committed a337bb0

QuickRef now automatically copies the default settings file to user settings if no user settings file exists.

  • Participants
  • Parent commits d7e6615
  • Branches develop

Comments (0)

Files changed (2)

+import shutil
 import sublime, sublime_plugin
 import json, re, os.path
       default_settings = self.parse_json(default_settings_path)
       default_settings = default_settings.get('settings')
+      # Copy default settings file to user settings if no user settings file is present.
+      user_settings_path = sublime.packages_path() + '/User/QuickRef.sublime-settings'
+      if not os.path.exists(user_settings_path):
+        shutil.copyfile(default_settings_path, user_settings_path)
       # Load and parse user settings file.
-      user_settings_path = sublime.load_settings('QuickRef.sublime-settings')
-      user_settings = user_settings_path.get('settings')
+      user_settings_object = sublime.load_settings('QuickRef.sublime-settings')
+      user_settings = user_settings_object.get('settings')
       # Get OS platform.
       platform = sublime.platform()
         if show_user_commands:
           # Parse commands from user settings file.
-          user_commands = user_settings_path.get('commands')
+          user_commands = user_settings_object.get('commands')
           for command in user_commands:
             # Put keys on one line, separate with commas.
 1. Pick your favourite (or hardest to memorize) commands from any ".sublime-keymap" file (or write your own).
 2. Add as many as you like to the *user* settings file. Make sure that both the commands and the settings file in general are formatted correctly (see default settings file)!
 3. Add a caption (optional).
-4. Optionally add more key bindings from user/default key bindings files.
+4. Optionally add more key bindings from the user/default key bindings files.
 ## Features