 
   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(@preferencesPath)
+    for path in fsUtils.list(@getPreferencesPath())
       {scope, settings} = fsUtils.readObject(path)
       if properties = @propertiesFromTextMateSettings(settings)
         selector = syntax.cssSelectorFromScopeSelector(scope) if scope?

  legalGrammarExtensions: ['plist', 'tmLanguage', 'tmlanguage', 'json']

  loadGrammars: (done) ->
    fsUtils.isDirectoryAsync @syntaxesPath, (isDirectory) =>
      return done() unless isDirectory

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


  constructor: ->
    super
    @grammars = []
    @scopedProperties = []
    @metadata = {@name}
