Closes #176. Add gofmt beautifier for Golang language

This commit is contained in:
Glavin Wiechert 2015-05-03 01:23:29 -03:00
parent 81fde0c9ea
commit 0a0ba673e8
10 changed files with 72 additions and 4 deletions

View File

@ -39,6 +39,8 @@ before_install:
- brew install pandoc
# Java, C, C++, C#, Objective-C, D, Pawn, Vala
- brew install uncrustify
# Golang
- brew install go
# PHP
# - brew tap homebrew/homebrew-php
# - brew gist-logs php56

View File

@ -44,6 +44,7 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify`
- [x] [Ruby](https://github.com/donaldpipowitch/atom-beautify/issues/25)
- Requires [Ruby Beautify](https://github.com/erniebrodeur/ruby-beautify)
- [x] [CoffeeScript](https://github.com/donaldpipowitch/atom-beautify/issues/31)
- [x] [Golang](https://github.com/Glavin001/atom-beautify/issues/176)
- [x] [Java](https://github.com/Glavin001/atom-beautify/issues/45)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [C](https://github.com/Glavin001/atom-beautify/issues/57)

View File

@ -0,0 +1,9 @@
package main
import "fmt"
func main() {
// Why so much white space?
fmt.Println("This is a poorly formatted file!")
}

View File

@ -0,0 +1,10 @@
package main
import "fmt"
func main() {
// Why so much white space?
fmt.Println( "This is a poorly formatted file!" )
}

View File

@ -129,6 +129,8 @@
"yaml",
"front matter",
"jekyll",
"marko"
"marko",
"go",
"golang"
]
}

View File

@ -20,7 +20,8 @@ describe "BeautifyLanguages", ->
"java", "javascript", "json", "less",
"mustache", "objective-c", "perl", "php",
"python", "ruby", "sass", "sql",
"typescript", "xml", "csharp", "gfm", "marko", "tss"
"typescript", "xml", "csharp", "gfm", "marko",
"tss", "go"
]
beforeEach ->

View File

@ -0,0 +1,18 @@
###
Requires http://golang.org/cmd/gofmt/
###
"use strict"
Beautifier = require('./beautifier')
module.exports = class gofmt extends Beautifier
name: "gofmt"
options: {
Go: true
}
beautify: (text, language, options) ->
@run("gofmt", [
@tempFile("input", text)
])

View File

@ -36,6 +36,7 @@ module.exports = class Beautifiers
'coffee-formatter'
'htmlbeautifier'
'csscomb'
'gofmt'
'js-beautify'
'perltidy'
'php-cs-fixer'
@ -332,12 +333,12 @@ module.exports = class Beautifiers
userId: atom.config.get("atom-beautify._analyticsUserId")
event: "Beautify"
properties:
language: language.name
language: language?.name
grammar: grammar
extension: fileExtension
version: version
options: allOptions
label: language.name
label: language?.name
category: version
#
if unsupportedGrammar

23
src/languages/go.coffee Normal file
View File

@ -0,0 +1,23 @@
module.exports = {
name: "Go"
description: "Golang"
namespace: "go"
###
Supported Grammars
###
grammars: [
"Go"
]
###
Supported extensions
###
extensions: [
"go"
]
options: []
}

View File

@ -28,6 +28,7 @@ module.exports = class Languages
"d"
"ejs"
"erb"
"go"
"handlebars"
"html"
"java"