-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
45 lines (37 loc) · 952 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var editorconfig
try {
editorconfig = require('editorconfig-jxa')
} catch (e) {
editorconfig = Library('editorconfig-jxa')
}
var app = new Application('CotEditor')
var doc = app.documents[0]
var file = doc.file()
if (file) {
var config = editorconfig.parseSync(file.toString())
if ('indent_style' in config) {
if (config.indent_style === 'tab') {
doc.expandsTab = false
} else if (config.indent_style === 'space') {
doc.expandsTab = true
}
}
if ('indent_size' in config) {
// TODO: No way to implement
}
if ('tab_width' in config) {
doc.tabWidth = config.indent_size
}
if ('end_of_line' in config) {
doc.lineEnding = config.end_of_line.toUpperCase()
}
if ('charset' in config) {
// TODO: No way to implement
}
if ('trim_trailing_whitespace' in config) {
// TODO: No way to implement
}
if ('insert_final_newline' in config) {
// TODO: No way to implement
}
}