Skip to content

Commit

Permalink
Closes #68. Support editorconfig files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed Sep 9, 2014
1 parent 4a94928 commit baf3e49
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
18 changes: 18 additions & 0 deletions examples/nested-jsbeautifyrc/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.html]
indent_style = space
indent_size = 8
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
17 changes: 15 additions & 2 deletions lib/beautify.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ yaml = null
LoadingView = null
MessagePanelView = null
PlainMessageView = null
editorconfig = null
#MessageView = require "./message-view"
findFileResults = {}

Expand Down Expand Up @@ -228,8 +229,20 @@ beautify = ->
# and how path.dirname(DIRECTORY) returns the parent directory of DIRECTORY
homeOptions = getConfig(path.join(userHome,"FAKEFILENAME"), false)

# TODO: See issue #68. EditorConfig options
editorConfigOptions = {};
# Handle EditorConfig options
# http://editorconfig.org/
editorconfig ?= require('editorconfig');
editorConfigOptions = editorconfig.parse(editedFilePath);
# Transform EditorConfig to Atom Beautify's config structure and naming
if editorConfigOptions.indent_style is 'space'
editorConfigOptions.indent_char = " "
# if (editorConfigOptions.indent_size)
# editorConfigOptions.indent_size = config.indent_size
else if editorConfigOptions.indent_style is 'tab'
editorConfigOptions.indent_char = "\t"
editorConfigOptions.indent_with_tabs = true
if (editorConfigOptions.tab_width)
editorConfigOptions.indent_size = config.tab_width

# Get all options in configuration files from this directory upwards to root
projectOptions = []
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"pawn",
"vala",
"d",
"erb"
"erb",
"editorconfig"
],
"engines": {
"atom": ">0.50.0"
Expand All @@ -90,6 +91,7 @@
"node-uuid": "^1.4.1",
"analytics-node": "^1.0.2",
"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"
}
}

0 comments on commit baf3e49

Please sign in to comment.