Skip to content

Commit 819d9a0

Browse files
committed
Respond to comments.
1 parent 850ee04 commit 819d9a0

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ augroup autoformat_settings
8888
augroup END
8989
```
9090

91-
# Configuring formatters.
91+
# Configuring formatters
9292

9393
Most formatters have some options available that can be configured via
9494
[Glaive](https://www.github.com/google/vim-glaive)
9595
You can get a quick view of all codefmt flags by executing `:Glaive codefmt`, or
9696
start typing flag names and use tab completion. See `:help Glaive` for usage
9797
details.
9898

99-
# Installing and configuring formatters
99+
# Installing formatters
100100

101101
Codefmt defines several built-in formatters. The easiest way to see the list of
102102
available formatters is via tab completion: Type `:FormatCode <TAB>` in vim.
@@ -130,7 +130,7 @@ here](https://github.com/google/vim-codefmt/wiki/Formatter-Integration-Guide).
130130
```
131131
132132
* Create a flag in
133-
[instant/flags.vim](https://github.com/Kashomon/vim-codefmt/blob/master/instant/flags.vim)
133+
[instant/flags.vim](https://github.com/google/vim-codefmt/blob/master/instant/flags.vim)
134134
135135
```vim
136136
""

autoload/codefmt/clangformat.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515

1616
let s:plugin = maktaba#plugin#Get('codefmt')
1717

18+
function! codefmt#clangformat#IsExecutable(exec) abort
19+
return executable(a:exec)
20+
endfunction
1821

1922
function! s:ClangFormatHasAtLeastVersion(minimum_version) abort
2023
if !exists('s:clang_format_version')
2124
let l:executable = s:plugin.Flag('clang_format_executable')
22-
if !executable(l:executable)
25+
if !codefmt#clangformat#IsExecutable(l:executable)
2326
return 0
2427
endif
2528

autoload/codefmt/googlejava.vim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function! codefmt#googlejava#GetFormatter() abort
2424
\ 'setup_instructions': 'Install google-java formatter ' .
2525
\ "(https://github.com/google/google-java-format). \n" .
2626
\ 'Enable with "Glaive codefmt google_java_executable=' .
27-
\ '"java -jar /path/to/google-java-format-1.2-all-deps.jar" ' .
27+
\ '"java -jar /path/to/google-java-format-VERSION-all-deps.jar" ' .
2828
\ 'in your vimrc' }
2929

3030
function l:formatter.IsAvailable() abort
@@ -56,7 +56,7 @@ function! codefmt#googlejava#GetFormatter() abort
5656
call maktaba#ensure#IsNumber(l:startline)
5757
call maktaba#ensure#IsNumber(l:endline)
5858
endfor
59-
let l:ranges_str = join(map(a:ranges, 'v:val[0] . ":" . v:val[1]'), ',')
59+
let l:ranges_str = join(map(copy(a:ranges), 'v:val[0] . ":" . v:val[1]'), ',')
6060
let l:cmd += ['--lines', l:ranges_str, '-']
6161

6262
let l:input = join(getline(1, line('$')), "\n")
@@ -65,7 +65,6 @@ function! codefmt#googlejava#GetFormatter() abort
6565
call maktaba#buffer#Overwrite(1, line('$'), l:formatted)
6666
endfunction
6767

68-
let s:google_java_format = l:formatter
6968
return l:formatter
7069
endfunction
7170

vroom/clangformat.vroom

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ briefly.
1212
:function FakeRepeat(...)<CR>
1313
| call add(g:repeat_calls, a:000)<CR>
1414
:endfunction
15+
:function ClangExec(...)<CR>
16+
| return 1<CR>
17+
:endfunction
1518
:call maktaba#test#Override('repeat#set', 'FakeRepeat')
19+
:call maktaba#test#Override('codefmt#clangformat#IsExecutable', 'ClangExec')
1620

1721
:call codefmt#SetWhetherToPerformIsAvailableChecksForTesting(0)
1822

@@ -77,7 +81,7 @@ You can format any buffer with clang-format specifying the formatter explicitly.
7781

7882
Several filetypes will use the clang-format formatter by default: c, cpp,
7983
javascript, and proto. If the version of clang-format is >= 3.6, then it will
80-
also format java files.
84+
also format java files, but google-java-format is the default.
8185

8286
@clear
8387
% f();
@@ -101,7 +105,7 @@ also format java files.
101105
$ f();
102106

103107
:set filetype=java
104-
:FormatCode
108+
:FormatCode clang-format
105109
! clang-format .*
106110
$ { "Cursor": 0 }
107111
$ f();

0 commit comments

Comments
 (0)