-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathdartfmt.vroom
83 lines (64 loc) · 1.87 KB
/
dartfmt.vroom
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
The built-in dartfmt formatter knows how to format dart code.
If you aren't familiar with basic codefmt usage yet, see main.vroom first.
We'll set up codefmt and configure the vroom environment, then jump into some
examples.
:source $VROOMDIR/setupvroom.vim
:let g:repeat_calls = []
:function FakeRepeat(...)<CR>
| call add(g:repeat_calls, a:000)<CR>
:endfunction
:call maktaba#test#Override('repeat#set', 'FakeRepeat')
:call codefmt#SetWhetherToPerformIsAvailableChecksForTesting(0)
The dart formatter expects the dart executable to be installed on your
system.
% main(){}
:FormatCode dartfmt
! dart format .*
$ main(){}
The name, path, or list of the dart format command can be configured via the
dartfmt_executable flag if the default of ["dart", "format"] doesn't work.
:Glaive codefmt dartfmt_executable='dartfmt'
:FormatCode dartfmt
! dartfmt .*
$ main(){}
:Glaive codefmt dartfmt_executable=`['dart', 'format']`
You can format any buffer with dart format specifying the formatter explicitly.
@clear
% main() { print("hello ");<CR>
|print("world\n");}
:FormatCode dartfmt
! dart format .*2>.*
$ main() {
$ \tprint("hello ");
$ \tprint("world\\n");
$ }
main() {
print("hello ");
print("world\n");
}
@end
The dart filetype will use the dart formatter by default.
@clear
% main(){}
:set filetype=dart
:FormatCode
! dart format .*
$ main(){}
:set filetype=
It can format specific line ranges of code using :FormatLines.
@clear
% main () {<CR>
|Print("hello "); Print("world\n");}
:1,2FormatLines dartfmt
! dart format .*2>.*
$ main() {
$ \tprint("hello ");
$ \tprint("world\\n");
$ }
main() {
print("hello ");
print("world\n");
}
@end
NOTE: the dart formatter does not natively support range formatting, so there
are certain limitations like not being able to format misaligned braces.