Add increase indent pattern for GFM scope

This commit is contained in:
Kevin Sawicki 2013-02-25 08:58:47 -08:00
parent 8b2c088bc9
commit 9b231e8c4e
4 changed files with 26 additions and 2 deletions

1
spec/fixtures/gfm.md vendored Normal file
View File

@ -0,0 +1 @@
* First list item

View File

@ -73,15 +73,27 @@ class TextMatePackage extends Package
scopedProperties
readObjectFromPath: (path, callback) ->
object = null
error = null
if fs.isObjectPath(path)
object = fs.readObject(path)
else
plist.parseString fs.read(path), (e, data) ->
error = e
object = data[0]
error = throw new Error("Failed to load object at path `#{path}`") unless object
callback(error, object)
getTextMatePreferenceObjects: ->
preferenceObjects = []
if fs.exists(@preferencesPath)
for preferencePath in fs.list(@preferencesPath)
plist.parseString fs.read(preferencePath), (e, data) =>
@readObjectFromPath preferencePath, (e, object) =>
if e
console.warn "Failed to parse preference at path '#{preferencePath}'", e.stack
else
preferenceObjects.push(data[0])
preferenceObjects.push(object)
preferenceObjects
propertiesFromTextMateSettings: (textMateSettings) ->

View File

@ -0,0 +1,4 @@
'name': 'Indent'
'scope': 'source.gfm'
'settings':
'increaseIndentPattern': '^\\s*([\\*\\+-])[ \\t]+'

View File

@ -132,3 +132,10 @@ describe "GitHub Flavored Markdown grammar", ->
{tokens} = grammar.tokenizeLine("> Quotation")
expect(tokens[0]).toEqual value: ">", scopes: ["source.gfm", "support.quote.gfm"]
expect(tokens[1]).toEqual value: " Quotation", scopes: ["source.gfm", "comment.quote.gfm"]
describe "auto indent", ->
it "indents newlines entered after list lines", ->
config.set('editor.autoIndent', true)
editSession = fixturesProject.buildEditSessionForPath('gfm.md')
editSession.insertNewlineBelow()
expect(editSession.buffer.lineForRow(1)).toBe ' '