Skip to content

Commit ea4b6af

Browse files
authored
Merge pull request #719 from JunoLab/avi/jlfmtopts
allow more JuliaFormatter options
2 parents 294bc43 + 6260579 commit ea4b6af

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

lib/package/config.coffee

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,53 @@ config =
186186
type: 'boolean'
187187
default: false
188188
order: 6
189+
import_to_using:
190+
title: 'import_to_using'
191+
description:
192+
'''
193+
If true import expressions are rewritten to using expressions in cases like:
194+
`import A` is rewritten to `using A: A`
195+
'''
196+
type: 'boolean'
197+
default: false
198+
order: 7
199+
pipe_to_function_call:
200+
title: 'pipe_to_function_call'
201+
description:
202+
'''
203+
If true `f |> x` is rewritten to `f(x)`.
204+
'''
205+
type: 'boolean'
206+
default: false
207+
order: 8
208+
short_to_long_function_def:
209+
title: 'short_to_long_function_def'
210+
description:
211+
'''
212+
Transforms a _short_ function definition to a _long_ function definition
213+
'''
214+
type: 'boolean'
215+
default: false
216+
order: 9
217+
always_use_return:
218+
title: 'always_use_return'
219+
description:
220+
'''
221+
If true `return` will be prepended to the last expression where applicable in function definitions, macro definitions, and do blocks.
222+
'''
223+
type: 'boolean'
224+
default: false
225+
order: 10
226+
use_YAS_style:
227+
title: 'YAS style'
228+
description:
229+
'''
230+
If true use formatting style based on [YASGuide](https://github.com/jrevels/YASGuide).
231+
See [JuliaFormatter's documentation](https://domluna.github.io/JuliaFormatter.jl/dev/yas_style/#) for more details.
232+
'''
233+
type: 'boolean'
234+
default: false
235+
order: 11
189236

190237
uiOptions:
191238
title: 'UI Options'

lib/runtime/formatter.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function formatEditorWithSelection (editor, selection) {
3131

3232
function formatEditorTextInRange (editor, range, text) {
3333
const marker = markRange(editor, range)
34-
// @NOTE: Branch on `getSoftTabs` if supported by formatter.
34+
// NOTE: Branch on `getSoftTabs` if supported by formatter.
3535
let indent = atom.config.get('julia-client.juliaOptions.formattingOptions.indent')
3636
if (indent === -1) indent = editor.getTabLength()
3737
let margin = atom.config.get('julia-client.juliaOptions.formattingOptions.margin')
@@ -40,10 +40,20 @@ function formatEditorTextInRange (editor, range, text) {
4040
text,
4141
indent,
4242
margin,
43+
44+
// TODO:
45+
// maintaining those lists are not so fun;
46+
// do https://github.com/domluna/JuliaFormatter.jl/issues/184 and switch to respect a project configuration,
47+
// then we will be able to leave each user to set those configurations
4348
always_for_in: atom.config.get('julia-client.juliaOptions.formattingOptions.always_for_in'),
4449
whitespace_typedefs: atom.config.get('julia-client.juliaOptions.formattingOptions.whitespace_typedefs'),
4550
whitespace_ops_in_indices: atom.config.get('julia-client.juliaOptions.formattingOptions.whitespace_ops_in_indices'),
46-
remove_extra_newlines: atom.config.get('julia-client.juliaOptions.formattingOptions.remove_extra_newlines')
51+
remove_extra_newlines: atom.config.get('julia-client.juliaOptions.formattingOptions.remove_extra_newlines'),
52+
import_to_using: atom.config.get('julia-client.juliaOptions.formattingOptions.import_to_using'),
53+
pipe_to_function_call: atom.config.get('julia-client.juliaOptions.formattingOptions.pipe_to_function_call'),
54+
short_to_long_function_def: atom.config.get('julia-client.juliaOptions.formattingOptions.short_to_long_function_def'),
55+
always_use_return: atom.config.get('julia-client.juliaOptions.formattingOptions.always_use_return'),
56+
use_YAS_style: atom.config.get('julia-client.juliaOptions.formattingOptions.use_YAS_style'),
4757
}).then(({ error, formattedtext }) => {
4858
if (error) {
4959
atom.notifications.addError('Julia-Client: Format-Code', {

0 commit comments

Comments
 (0)