Skip to content

Commit ddc5b8f

Browse files
committed
Resolve review feedback
1 parent c2865bd commit ddc5b8f

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

autoload/codefmt/prettier.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ function! codefmt#prettier#GetFormatter() abort
4949
\ string(l:Prettier_options))
5050
endif
5151
let l:cmd = [s:plugin.Flag('prettier_executable'), '--stdin', '--no-color']
52+
53+
" prettier is able to automatically choose the best parser if the filepath
54+
" is provided. Otherwise, fall back to the previous default: babylon.
5255
if @% == ""
5356
call extend(l:cmd, ['--parser', 'babylon'])
5457
else
5558
call extend(l:cmd, ['--stdin-filepath', @%])
5659
endif
60+
5761
call maktaba#ensure#IsNumber(a:startline)
5862
call maktaba#ensure#IsNumber(a:endline)
5963

doc/codefmt.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,35 @@ Default: 'yapf' `
6060
The path to the gn executable.
6161
Default: 'gn' `
6262

63+
*codefmt:buildifier_executable*
64+
The path to the buildifier executable.
65+
Default: 'buildifier' `
66+
67+
*codefmt:google_java_executable*
68+
The path to the google-java executable. Generally, this should have the form:
69+
`java -jar /path/to/google-java`
70+
Default: 'google-java-format' `
71+
72+
*codefmt:shfmt_options*
73+
Command line arguments to to feed shfmt. Either a list or callable that takes
74+
no args and returns a list with command line arguments. By default, uses the
75+
Google's style. See https://github.com/mvdan/sh for details.
76+
Default: ['-i', '2', '-sr', '-ci'] `
77+
78+
*codefmt:shfmt_executable*
79+
The path to the shfmt executable.
80+
Default: 'shfmt' `
81+
82+
*codefmt:prettier_options*
83+
Command line arguments to to feed prettier. Either a list or callable that
84+
takes no args and returns a list with command line arguments.
85+
Default: [ '--single-quote', '--trailing-comma=all', '--arrow-parens=always',
86+
'--print-width=80'] `
87+
88+
*codefmt:prettier_executable*
89+
The path to the prettier executable.
90+
Default: 'prettier' `
91+
6392
*codefmt:plugin[autocmds]*
6493
Configures whether plugin/autocmds.vim should be loaded.
6594
Default: 1 `
@@ -99,6 +128,7 @@ none is explicitly supplied via an explicit arg to |:FormatCode| or the
99128
plugins are enabled or what other software is installed on your system.
100129

101130
The current list of defaults by filetype is:
131+
* bzl (Bazel): buildifier
102132
* c, cpp, proto, javascript, typescript: clang-format
103133
* go: gofmt
104134
* python: autopep8, yapf

instant/flags.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ call s:plugin.Flag('shfmt_executable', 'shfmt')
108108
""
109109
" Command line arguments to to feed prettier. Either a list or callable that
110110
" takes no args and returns a list with command line arguments.
111-
call s:plugin.Flag('prettier_options', ['--single-quote', '--trailing-comma=all', '--arrow-parens=always', '--print-width=80'])
111+
call s:plugin.Flag('prettier_options', [
112+
\ '--single-quote', '--trailing-comma=all',
113+
\ '--arrow-parens=always', '--print-width=80'])
112114

113115
""
114116
" The path to the prettier executable.

vroom/prettier.vroom

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ Errors are reported using the quickfix list.
6666

6767
:FormatCode prettier
6868
! prettier .*2> (.*)
69-
$ echo '[error] stdin: SyntaxError: Unexpected token (2:1)' >\1 (command)
70-
$ echo '[error] 1 | function foo() {' >>\1 (command)
71-
$ echo '[error] > 2 |' >>\1 (command)
72-
$ echo '[error] | ^' >>\1 (command)
7369
$ 2 (status)
70+
$ echo >\1 ' (command)
71+
|[error] stdin: SyntaxError: Unexpected token (2:1)\n
72+
|[error] 1 | function foo() {\n
73+
|[error] > 2 |\n
74+
|[error] | ^'
7475
function foo() {
7576
@end
7677
:echomsg line('.') . ',' . col('.')

0 commit comments

Comments
 (0)