|
1 | 1 | /** @babel */
|
2 | 2 |
|
| 3 | +import path from 'path' |
3 | 4 | import { client } from '../connection'
|
4 | 5 | import { CompositeDisposable } from 'atom'
|
5 | 6 |
|
@@ -30,42 +31,28 @@ function formatEditorWithSelection (editor, selection) {
|
30 | 31 | }
|
31 | 32 |
|
32 | 33 | function formatEditorTextInRange (editor, range, text) {
|
| 34 | + const dir = path.dirname(client.editorPath(editor)) |
33 | 35 | const marker = markRange(editor, range)
|
34 | 36 | // NOTE: Branch on `getSoftTabs` if supported by formatter.
|
35 |
| - let indent = atom.config.get('julia-client.juliaOptions.formattingOptions.indent') |
36 |
| - if (indent === -1) indent = editor.getTabLength() |
37 |
| - let margin = atom.config.get('julia-client.juliaOptions.formattingOptions.margin') |
38 |
| - if (margin === -1) margin = editor.getPreferredLineLength() |
| 37 | + const indent = editor.getTabLength() |
| 38 | + const margin = editor.getPreferredLineLength() |
39 | 39 | format({
|
40 | 40 | text,
|
| 41 | + dir, |
41 | 42 | indent,
|
42 | 43 | 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 |
48 |
| - always_for_in: atom.config.get('julia-client.juliaOptions.formattingOptions.always_for_in'), |
49 |
| - whitespace_typedefs: atom.config.get('julia-client.juliaOptions.formattingOptions.whitespace_typedefs'), |
50 |
| - whitespace_ops_in_indices: atom.config.get('julia-client.juliaOptions.formattingOptions.whitespace_ops_in_indices'), |
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'), |
57 | 44 | }).then(({ error, formattedtext }) => {
|
58 | 45 | if (error) {
|
59 | 46 | atom.notifications.addError('Julia-Client: Format-Code', {
|
60 |
| - detail: error, |
| 47 | + description: error, |
61 | 48 | dismissable: true
|
62 | 49 | })
|
63 | 50 | } else {
|
64 | 51 | if (marker.isValid()) {
|
65 | 52 | editor.setTextInBufferRange(marker.getBufferRange(), formattedtext)
|
66 | 53 | } else {
|
67 | 54 | atom.notifications.addError('Julia-Client: Format-Code', {
|
68 |
| - detail: 'Cancelled the formatting task because the selected code has been manually modified.', |
| 55 | + description: 'Cancelled the formatting task because the selected code has been manually modified.', |
69 | 56 | dismissable: true
|
70 | 57 | })
|
71 | 58 | }
|
|
0 commit comments