This commit is contained in:
Focus 2016-03-02 16:45:56 +00:00
parent df6599f2c6
commit a4ff384dbf
2 changed files with 142 additions and 0 deletions

View File

@ -0,0 +1,27 @@
"use strict"
Beautifier = require('./beautifier')
path = require('path')
module.exports = class LatexBeautify extends Beautifier
name: "Latex Beautify"
options: {
LaTeX: true
}
beautify: (text, language, options) ->
@tempFile("indent", "", "log")
.then( (logFile)=>
logDir = path.dirname logFile
@tempTex = @tempFile("latex", text)
run = @run "latexindent", [
"-o"
"-s"
"-c=" + logDir
@tempTex
@tempTex
]
)
.then( =>
@readFile(@tempTex)
)

115
src/languages/latex.coffee Normal file
View File

@ -0,0 +1,115 @@
# Get Atom defaults
scope = ['source.js']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "LaTeX"
namespace: "latex"
###
Supported Grammars
###
grammars: [
"LaTeX"
]
###
Supported extensions
###
extensions: [
"tex"
]
defaultBeautifier: "Latex Beautify"
###
###
options:
# JavaScript
indent_size:
type: 'integer'
default: defaultIndentSize
minimum: 0
description: "Indentation size/length"
indent_char:
type: 'string'
default: defaultIndentChar
description: "Indentation character"
indent_level:
type: 'integer'
default: 0
description: "Initial indentation level"
indent_with_tabs:
type: 'boolean'
default: defaultIndentWithTabs
description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`"
preserve_newlines:
type: 'boolean'
default: true
description: "Preserve line-breaks"
max_preserve_newlines:
type: 'integer'
default: 10
description: "Number of line-breaks to be preserved in one chunk"
space_in_paren:
type: 'boolean'
default: false
description: "Add padding spaces within paren, ie. f( a, b )"
jslint_happy:
type: 'boolean'
default: false
description: "Enable jslint-stricter mode"
space_after_anon_function:
type: 'boolean'
default: false
description: "Add a space before an anonymous function's parens, ie. function ()"
brace_style:
type: 'string'
default: "collapse"
enum: ["collapse", "collapse-preserve-inline", "expand", "end-expand", "none"]
description: "[collapse|collapse-preserve-inline|expand|end-expand|none]"
break_chained_methods:
type: 'boolean'
default: false
description: "Break chained method calls across subsequent lines"
keep_array_indentation:
type: 'boolean'
default: false
description: "Preserve array indentation"
keep_function_indentation:
type: 'boolean'
default: false
description: ""
space_before_conditional:
type: 'boolean'
default: true
description: ""
eval_code:
type: 'boolean'
default: false
description: ""
unescape_strings:
type: 'boolean'
default: false
description: "Decode printable characters encoded in xNN notation"
wrap_line_length:
type: 'integer'
default: 0
description: "Wrap lines at next opportunity after N characters"
end_with_newline:
type: 'boolean'
default: false
description: "End output with newline"
end_with_comma:
type: 'boolean'
default: false
description: "If a terminating comma should be inserted into \
arrays, object literals, and destructured objects."
}