   legalGrammarExtensions: ['plist', 'tmLanguage', 'tmlanguage', 'json']
 
   loadGrammars: (done) ->
-    fsUtils.isDirectoryAsync @syntaxesPath, (isDirectory) =>
+    fsUtils.isDirectoryAsync @getSyntaxesPath(), (isDirectory) =>
       return done() unless isDirectory
 
-      fsUtils.listAsync @syntaxesPath, @legalGrammarExtensions, (error, paths) =>
+      fsUtils.listAsync @getSyntaxesPath(), @legalGrammarExtensions, (error, paths) =>
         if error?
           console.log("Error loading grammars of TextMate package '#{@path}':", error.stack, error)
           done()

    @loadTextMatePreferenceObjects(preferenceObjects, done)

  loadTextMatePreferenceObjects: (preferenceObjects, done) ->
    fsUtils.isDirectoryAsync @preferencesPath, (isDirectory) =>
      return done() unless isDirectory

      fsUtils.listAsync @preferencesPath, (error, paths) =>
        if error?
          console.log("Error loading preferences of TextMate package '#{@path}':", error.stack, error)
          done()


  getGrammars: -> @grammars

  getSyntaxesPath: ->
    syntaxesPath = fsUtils.join(@path, "syntaxes")
    if fsUtils.isDirectory(syntaxesPath)
      syntaxesPath
    else
      fsUtils.join(@path, "Syntaxes")

  getPreferencesPath: ->
    preferencesPath = fsUtils.join(@path, "preferences")
    if fsUtils.isDirectory(preferencesPath)
      preferencesPath
    else
      fsUtils.join(@path, "Preferences")

  loadScopedPropertiesSync: ->
    for grammar in @getGrammars()
      if properties = @propertiesFromTextMateSettings(grammar)
        selector = syntax.cssSelectorFromScopeSelector(grammar.scopeName)
        @scopedProperties.push({selector, properties})

    for path in fsUtils.list(@getPreferencesPath())
      {scope, settings} = fsUtils.readObject(path)
      if properties = @propertiesFromTextMateSettings(settings)
        selector = syntax.cssSelectorFromScopeSelector(scope) if scope?
