Add TypeScript support

This commit is contained in:
ewgenius 2014-10-14 11:09:38 +04:00
parent 6013e7eddc
commit dcc9e2d3b5
5 changed files with 30 additions and 3 deletions

View File

@ -57,12 +57,12 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify`
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/) - Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [Vala](https://github.com/Glavin001/atom-beautify/issues/57) - [x] [Vala](https://github.com/Glavin001/atom-beautify/issues/57)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/) - Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [TypeScript](https://github.com/Glavin001/atom-beautify/issues/49)
### Road Map ### Road Map
#### Language support #### Language support
- [ ] [TypeScript](https://github.com/Glavin001/atom-beautify/issues/49)
- [ ] [Perl](https://github.com/Glavin001/atom-beautify/issues/33) - [ ] [Perl](https://github.com/Glavin001/atom-beautify/issues/33)

View File

@ -0,0 +1,8 @@
module TestModule {
export class A {
constructor(private a: string) {
}
}
export class B extends A {
}
};

View File

@ -0,0 +1,12 @@
"use strict"
TF = require("typescript-formatter/typescript-toolbox/lib/formatter")
module.exports = (text, options, callback) ->
opts = TF.createDefaultFormatCodeOptions()
opts.TabSize = options.tab_width
opts.IndentSize = options.indent_size
result = TF.applyFormatterToContent(text, opts)
callback result
result

View File

@ -18,6 +18,7 @@ beautifyCoffeeScript = null
uncrustifyBeautifier = null uncrustifyBeautifier = null
beautifyHTMLERB = null beautifyHTMLERB = null
beautifyMarkdown = null beautifyMarkdown = null
beautifyTypeScript = null
Analytics = null Analytics = null
# Misc # Misc
@ -50,6 +51,7 @@ module.exports =
"d" "d"
"pawn" "pawn"
"vala" "vala"
"typescript"
] ]
# Default options per language # Default options per language
@ -233,6 +235,9 @@ module.exports =
options.languageOverride = "JAVA" options.languageOverride = "JAVA"
uncrustifyBeautifier ?= require("./langs/uncrustify/") uncrustifyBeautifier ?= require("./langs/uncrustify/")
uncrustifyBeautifier text, options, beautifyCompleted uncrustifyBeautifier text, options, beautifyCompleted
when "TypeScript"
beautifyTypeScript ?= require("./langs/typescript-beautify")
beautifyTypeScript text, self.getOptions("js", allOptions), beautifyCompleted
else else
unsupportedGrammar = true unsupportedGrammar = true

View File

@ -3,7 +3,7 @@
"main": "./lib/beautify", "main": "./lib/beautify",
"version": "0.13.4", "version": "0.13.4",
"private": true, "private": true,
"description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, and SQL in Atom", "description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, and SQL in Atom",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/Glavin001/atom-beautify" "url": "https://github.com/Glavin001/atom-beautify"
@ -63,6 +63,7 @@
"python", "python",
"ruby", "ruby",
"coffeescript", "coffeescript",
"typescript",
"c", "c",
"c++", "c++",
"cpp", "cpp",
@ -94,6 +95,7 @@
"coffee-formatter": "git+https://github.com/Glavin001/Coffee-Formatter.git", "coffee-formatter": "git+https://github.com/Glavin001/Coffee-Formatter.git",
"atom-message-panel": "^1.1.1", "atom-message-panel": "^1.1.1",
"editorconfig": "^0.11.4", "editorconfig": "^0.11.4",
"loophole": "^1.0.0" "loophole": "^1.0.0",
"typescript-formatter": "~0.1.4"
} }
} }