Commits

Rablador  committed 55a71df

Fixed settings file not being accessed from the menu.

  • Participants
  • Parent commits 8ed9c91

Comments (0)

Files changed (5)

File Main.sublime-menu

             [
               {
                   "command": "open_file",
-                  "args": {"file": "${packages}/QuickRef/README.md"},
+                  "args": {"file": "${packages}/QuickRef Command Lookup/README.md"},
                   "caption": "ReadMe"
               },
-              {
-                  "command": "open_file",
-                  "args": {"file": "${packages}/QuickRef/changelog.txt"},
-                  "caption": "Change Log"
-              },
               { "caption": "-" },
               {
                   "command": "open_file",
-                  "args": {"file": "${packages}/QuickRef/QuickRef.sublime-settings"},
+                  "args": {"file": "${packages}/QuickRef Command Lookup/QuickRef.sublime-settings"},
                   "caption": "Settings – Default"
               },
               {
               {
                   "command": "open_file",
                   "args": {
-                      "file": "${packages}/QuickRef/Default (OSX).sublime-keymap",
+                      "file": "${packages}/QuickRef Command Lookup/Default (OSX).sublime-keymap",
                       "platform": "OSX"
                   },
                   "caption": "Key Bindings – Default"
               {
                   "command": "open_file",
                   "args": {
-                      "file": "${packages}/QuickRef/Default (Linux).sublime-keymap",
+                      "file": "${packages}/QuickRef Command Lookup/Default (Linux).sublime-keymap",
                       "platform": "Linux"
                   },
                   "caption": "Key Bindings – Default"
               {
                   "command": "open_file",
                   "args": {
-                      "file": "${packages}/QuickRef/Default (Windows).sublime-keymap",
+                      "file": "${packages}/QuickRef Command Lookup/Default (Windows).sublime-keymap",
                       "platform": "Windows"
                   },
                   "caption": "Key Bindings – Default"

File QuickRef (Linux).sublime-settings

-{
-  /* 
-    IMPORTANT:
-    Do NOT edit the default QuickRef settings. Your changes will be lost when QuickRef is updated. 
-    ALWAYS edit the user QuickRef settings by selecting Preferences->Package Settings->QuickRef->Settings - User.
-    Note that individual settings you include in your user settings will completely replace the corresponding 
-    default setting, so you must provide that setting in its entirety.
-  */
-
-  "settings":
-  {
-    // Hardcore mode will not allow you to run any commands from the command palette, thus forcing
-    // you to remember them instead.
-    "hardcore_mode": false,
-
-    // Sort commands alphabetically or in the order that they are added to the settings file.
-    "sort_alphabetically": true,
-
-    // Beautify captions. E.g.: "clear_fields" -> "Clear fields". Great for users who don't want to add separate
-    // captions manually.
-    "beautify_captions": true,
-
-    // Show favourite commands in the QuickRef command palette. Favourites will be displayed at the top of the list
-    // with a prefixed (*).
-    "show_favourites": true,
-
-    // Show commands from the QuickRef user settings file.
-    "show_user_commands": true,
-
-    // Show commands from the user key bindings file.
-    "show_user_key_bindings": false,
-
-    // Show commands from the default key bindings file.
-    "show_default_key_bindings": false,
-
-    // Show contexts for commands. Will be displayed in parenthesis after a command.
-    // Note: This may increase the number of commands displayed in QuickRef.
-    "show_command_contexts": false,
-
-    // When setting "include_default_key_bindings" to true, this removes duplicate commands.
-    // Note 1: Duplicates are often the result of the same command having different contexts. "remove_duplicates"
-    //   may therefore accidentally remove commands with useful contexts.
-    // Note 2: User key bindings and user commands are not affected by this setting. User commands will always
-    //   overwrite defualt and user key bindings; user key bindings will always overwrite default keybindings only; 
-    //   default key bindings will never overwrite any of the previous.
-    "remove_duplicates": true,
-
-    // When "remove_duplicates" is set to "false", setting this option to "true" will remove commands with
-    // duplicate contexts and thereby reduce potentially superfluous items.
-    "remove_duplicate_contexts": true,
-
-    // Filter out commands by shortcut keys. Only commands with at least one key corresponding to a key in this 
-    // list will be visible. An empty list ([]) will disable filtering and show all commands.
-    "key_filter": ["ctrl", "shift", "alt", "super"]
-  },
-
-  "commands": 
-  [
-    // Example setting, shows "QuickRef" and "alt+p" in the Command Palette. "caption" is optional. "args" 
-    // is necessary depending on the command (can be left out altogether if not used).
-    { "keys": ["alt+p"], "command": "quick_ref", "args": {}, "caption": "QuickRef" }
-  ]
-}

File QuickRef (OSX).sublime-settings

-{
-  /* 
-    IMPORTANT:
-    Do NOT edit the default QuickRef settings. Your changes will be lost when QuickRef is updated. 
-    ALWAYS edit the user QuickRef settings by selecting Preferences->Package Settings->QuickRef->Settings - User.
-    Note that individual settings you include in your user settings will completely replace the corresponding 
-    default setting, so you must provide that setting in its entirety.
-  */
-
-  "settings":
-  {
-    // Hardcore mode will not allow you to run any commands from the command palette, thus forcing
-    // you to remember them instead.
-    "hardcore_mode": false,
-
-    // Sort commands alphabetically or in the order that they are added to the settings file.
-    "sort_alphabetically": true,
-
-    // Beautify captions. E.g.: "clear_fields" -> "Clear fields". Great for users who don't want to add separate
-    // captions manually.
-    "beautify_captions": true,
-
-    // Show favourite commands in the QuickRef command palette. Favourites will be displayed at the top of the list
-    // with a prefixed (*).
-    "show_favourites": true,
-
-    // Show commands from the QuickRef user settings file.
-    "show_user_commands": true,
-
-    // Show commands from the user key bindings file.
-    "show_user_key_bindings": false,
-
-    // Show commands from the default key bindings file.
-    "show_default_key_bindings": false,
-
-    // Show contexts for commands. Will be displayed in parenthesis after a command.
-    // Note: This may increase the number of commands displayed in QuickRef.
-    "show_command_contexts": false,
-
-    // When setting "include_default_key_bindings" to true, this removes duplicate commands.
-    // Note 1: Duplicates are often the result of the same command having different contexts. "remove_duplicates"
-    //   may therefore accidentally remove commands with useful contexts.
-    // Note 2: User key bindings and user commands are not affected by this setting. User commands will always
-    //   overwrite defualt and user key bindings; user key bindings will always overwrite default keybindings only; 
-    //   default key bindings will never overwrite any of the previous.
-    "remove_duplicates": true,
-
-    // When "remove_duplicates" is set to "false", setting this option to "true" will remove commands with
-    // duplicate contexts and thereby reduce potentially superfluous items.
-    "remove_duplicate_contexts": true,
-
-    // Filter out commands by shortcut keys. Only commands with at least one key corresponding to a key in this 
-    // list will be visible. An empty list ([]) will disable filtering and show all commands.
-    "key_filter": ["ctrl", "shift", "alt", "super"]
-  },
-
-  "commands": 
-  [
-    // Example setting, shows "QuickRef" and "alt+p" in the Command Palette. "caption" is optional. "args" 
-    // is necessary depending on the command (can be left out altogether if not used).
-    { "keys": ["alt+p"], "command": "quick_ref", "args": {}, "caption": "QuickRef" }
-  ]
-}

File QuickRef (Windows).sublime-settings

-{
-  /* 
-    IMPORTANT:
-    Do NOT edit the default QuickRef settings. Your changes will be lost when QuickRef is updated. 
-    ALWAYS edit the user QuickRef settings by selecting Preferences->Package Settings->QuickRef->Settings - User.
-    Note that individual settings you include in your user settings will completely replace the corresponding 
-    default setting, so you must provide that setting in its entirety.
-  */
-
-  "settings":
-  {
-    // Hardcore mode will not allow you to run any commands from the command palette, thus forcing
-    // you to remember them instead.
-    "hardcore_mode": false,
-
-    // Sort commands alphabetically or in the order that they are added to the settings file.
-    "sort_alphabetically": true,
-
-    // Beautify captions. E.g.: "clear_fields" -> "Clear fields". Great for users who don't want to add separate
-    // captions manually.
-    "beautify_captions": true,
-
-    // Show favourite commands in the QuickRef command palette. Favourites will be displayed at the top of the list
-    // with a prefixed (*).
-    "show_favourites": true,
-
-    // Show commands from the QuickRef user settings file.
-    "show_user_commands": true,
-
-    // Show commands from the user key bindings file.
-    "show_user_key_bindings": false,
-
-    // Show commands from the default key bindings file.
-    "show_default_key_bindings": false,
-
-    // Show contexts for commands. Will be displayed in parenthesis after a command.
-    // Note: This may increase the number of commands displayed in QuickRef.
-    "show_command_contexts": false,
-
-    // When setting "include_default_key_bindings" to true, this removes duplicate commands.
-    // Note 1: Duplicates are often the result of the same command having different contexts. "remove_duplicates"
-    //   may therefore accidentally remove commands with useful contexts.
-    // Note 2: User key bindings and user commands are not affected by this setting. User commands will always
-    //   overwrite defualt and user key bindings; user key bindings will always overwrite default keybindings only; 
-    //   default key bindings will never overwrite any of the previous.
-    "remove_duplicates": true,
-
-    // When "remove_duplicates" is set to "false", setting this option to "true" will remove commands with
-    // duplicate contexts and thereby reduce potentially superfluous items.
-    "remove_duplicate_contexts": true,
-
-    // Filter out commands by shortcut keys. Only commands with at least one key corresponding to a key in this 
-    // list will be visible. An empty list ([]) will disable filtering and show all commands.
-    "key_filter": ["ctrl", "shift", "alt", "super"]
-  },
-
-  "commands": 
-  [
-    // Example setting, shows "QuickRef" and "alt+p" in the Command Palette. "caption" is optional. "args" 
-    // is necessary depending on the command (can be left out altogether if not used).
-    { "keys": ["alt+p"], "command": "quick_ref", "args": {}, "caption": "QuickRef" }
-  ]
-}
 import json, re, os
 import shutil, zipfile
+from shutil import copyfile
 import sublime, sublime_plugin
 
 # Import default package for ST3 only. Needed to determine its path.
     """
     Python init method.
     """
-    # Initialize list of commands. Needs to happen here since this value will 
+    # Initialize list of commands. Needs to happen here since this value will
     # determine whether to open or close the quick panel.
     self.command_list = None
     # Running Sublime Text 2?
         # should always overwrite default key bidnings.
         self.added_user_commands = []
         self.added_commands = []
-        
+
         # Add commands.
         if self.settings['show_user_commands']:
           self._add_user_commands()
     # Add caption, command, arguments and context for each context.
     command_item = [caption] + [command['command']] + [args] + [context]
 
-    # Divide favourites from other commands.        
+    # Divide favourites from other commands.
     if self.is_favourite:
       self.fav_command_list.append(list_item)
       self.fav_run_commands.append(command_item)
           # Open a (new) favourites file.
           favourites = open(os.path.join(self.paths['user_data'], 'favourites.txt'), 'w')
           # Concatenate the complete command.
-          command = self.run_commands[idx][1] + ',' + self.command_list[idx][1]          
+          command = self.run_commands[idx][1] + ',' + self.command_list[idx][1]
           # Add command if not in favourites list.
           if not command in self.favourites:
             favourites.write(command + '\n')
     """
     # Get paths.
     paths = self.get_paths()
+
+    if self.is_st2:
+      # Copy default settings file to user settings if no user settings file is present.
+      user_settings_path = os.path.join(paths['user'], 'QuickRef.sublime-settings')
+      default_settings_path = os.path.join(sublime.packages_path(), 'QuickRef Command Lookup', 'QuickRef.sublime-settings')
+      if not os.path.exists(user_settings_path):
+        copyfile(default_settings_path, user_settings_path)
+
     # Make sure there is a data directory.
     if not os.path.isdir(paths['user_data']):
       os.makedirs(paths['user_data'])
       return os.path.join(sublime.packages_path(), 'Default', keymap_file)
     else:
       default_package = os.path.dirname(Default.__file__)
-      
+
       # Check if there is a default keymap
       if not os.path.exists(user_data_keymap):
         # Extract and copy the default keymap to data directory.