Skip to content

Commit d927656

Browse files
Ryan Wienerdbarnett
authored andcommitted
Change the dartfmt_executable to point to "dart format".
This is because dartfmt has been replaced by dart format.
1 parent 6ee1e7e commit d927656

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed

autoload/codefmt/dartfmt.vim

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function! codefmt#dartfmt#GetFormatter() abort
2323
let l:formatter = {
2424
\ 'name': 'dartfmt',
2525
\ 'setup_instructions': 'Install the Dart SDK from ' .
26-
\ 'https://www.dartlang.org/tools/sdk/'}
26+
\ 'https://github.com/google/vim-codefmt'}
2727

2828
function l:formatter.IsAvailable() abort
2929
return executable(s:plugin.Flag('dartfmt_executable'))
@@ -38,7 +38,16 @@ function! codefmt#dartfmt#GetFormatter() abort
3838
" @flag(dartfmt_executable}, only targetting the range from {startline} to
3939
" {endline}
4040
function l:formatter.FormatRange(startline, endline) abort
41-
let l:cmd = [ s:plugin.Flag('dartfmt_executable') ]
41+
let l:dartfmt_executable = s:plugin.Flag('dartfmt_executable')
42+
if type(l:dartfmt_executable) is# type([])
43+
let l:cmd = l:dartfmt_executable
44+
elseif type(l:dartfmt_executable) is# type('')
45+
let l:cmd = [l:dartfmt_executable]
46+
else
47+
throw maktaba#error#WrongType(
48+
\ 'dartfmt_executable flag must be a list or string. Found %s',
49+
\ string(l:dartfmt_executable))
50+
endif
4251
try
4352
" dartfmt does not support range formatting yet:
4453
" https://github.com/dart-lang/dart_style/issues/92

doc/codefmt.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ additionally adjust imports when formatting.
8484
Default: 'gofmt' `
8585

8686
*codefmt:dartfmt_executable*
87-
The path to the dartfmt executable.
88-
Default: 'dartfmt' `
87+
The path to the dartfmt executable. Either a list or string.
88+
Default: ['dart', 'format'] `
8989

9090
*codefmt:js_beautify_executable*
9191
The path to the js-beautify executable.

instant/flags.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ call s:plugin.Flag('clang_format_style', 'file')
7373
call s:plugin.Flag('gofmt_executable', 'gofmt')
7474

7575
""
76-
" The path to the dartfmt executable.
77-
call s:plugin.Flag('dartfmt_executable', 'dartfmt')
76+
" The path to the dartfmt executable. Either a list or a string.
77+
call s:plugin.Flag('dartfmt_executable', ['dart', 'format'])
78+
7879

7980
""
8081
" The path to the js-beautify executable.

vroom/dartfmt.vroom

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,31 @@ examples.
1414

1515
:call codefmt#SetWhetherToPerformIsAvailableChecksForTesting(0)
1616

17-
18-
The dartfmt formatter expects the dartfmt executable to be installed on your
17+
The dart formatter expects the dart executable to be installed on your
1918
system.
2019

2120
% main(){}
2221
:FormatCode dartfmt
23-
! dartfmt .*
22+
! dart format .*
2423
$ main(){}
2524

26-
The name or path of the dartfmt executable can be configured via the
27-
dartfmt_executable flag if the default of "dartfmt" doesn't work.
25+
The name, path, or list of the dart format command can be configured via the
26+
dartfmt_executable flag if the default of ["dart", "format"] doesn't work.
2827

29-
:Glaive codefmt dartfmt_executable='mydartfmt'
28+
:Glaive codefmt dartfmt_executable='dartfmt'
3029
:FormatCode dartfmt
31-
! mydartfmt .*
30+
! dartfmt .*
3231
$ main(){}
33-
:Glaive codefmt dartfmt_executable='dartfmt'
34-
32+
:Glaive codefmt dartfmt_executable=`['dart', 'format']`
3533

36-
You can format any buffer with dartfmt specifying the formatter explicitly.
34+
You can format any buffer with dart format specifying the formatter explicitly.
3735

3836
@clear
3937
% main() { print("hello ");<CR>
4038
|print("world\n");}
4139

4240
:FormatCode dartfmt
43-
! dartfmt .*2>.*
41+
! dart format .*2>.*
4442
$ main() {
4543
$ \tprint("hello ");
4644
$ \tprint("world\\n");
@@ -51,14 +49,14 @@ You can format any buffer with dartfmt specifying the formatter explicitly.
5149
}
5250
@end
5351

54-
The dart filetype will use the dartfmt formatter by default.
52+
The dart filetype will use the dart formatter by default.
5553

5654
@clear
5755
% main(){}
5856

5957
:set filetype=dart
6058
:FormatCode
61-
! dartfmt .*
59+
! dart format .*
6260
$ main(){}
6361

6462
:set filetype=
@@ -70,7 +68,7 @@ It can format specific line ranges of code using :FormatLines.
7068
|Print("hello "); Print("world\n");}
7169

7270
:1,2FormatLines dartfmt
73-
! dartfmt .*2>.*
71+
! dart format .*2>.*
7472
$ main() {
7573
$ \tprint("hello ");
7674
$ \tprint("world\\n");
@@ -81,5 +79,5 @@ It can format specific line ranges of code using :FormatLines.
8179
}
8280
@end
8381

84-
NOTE: the dartfmt formatter does not natively support range formatting, so there
82+
NOTE: the dart formatter does not natively support range formatting, so there
8583
are certain limitations like not being able to format misaligned braces.

0 commit comments

Comments
 (0)