forked from google/vim-codefmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flags.vim
153 lines (126 loc) · 5.31 KB
/
flags.vim
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
" Copyright 2014 Google Inc. All rights reserved.
"
" Licensed under the Apache License, Version 2.0 (the "License");
" you may not use this file except in compliance with the License.
" You may obtain a copy of the License at
"
" http://www.apache.org/licenses/LICENSE-2.0
"
" Unless required by applicable law or agreed to in writing, software
" distributed under the License is distributed on an "AS IS" BASIS,
" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
" See the License for the specific language governing permissions and
" limitations under the License.
""
" @section Introduction, intro
" @order intro config formatters dicts commands autocmds functions mappings
" Provides a @command(FormatCode) command to intelligently reformat code.
""
" @setting b:codefmt_formatter
" You can override the default formatter by defining this variable. For
" instance, to explicitly select the clang-format formatter for Java, add >
" autocmd FileType java let b:codefmt_formatter = 'clang-format'
" < to your vimrc. You can also set the value to an empty string to disable all
" formatting.
let [s:plugin, s:enter] = maktaba#plugin#Enter(expand('<sfile>:p'))
if !s:enter
finish
endif
" Shout if maktaba is too old. Done here to ensure it's always triggered.
" We need at least 1.12.0 so that maktaba#ensure#IsCallable works on Neovim and
" recent Vim (newer than is actually in Travis/Xenial).
" See https://github.com/google/vim-maktaba/issues/173
if !maktaba#IsAtLeastVersion('1.12.0')
call maktaba#error#Shout('Codefmt requires maktaba version 1.12.0.')
call maktaba#error#Shout('You have maktaba version %s.', maktaba#VERSION)
call maktaba#error#Shout('Please update your maktaba install.')
endif
""
" The path to the autopep8 executable.
call s:plugin.Flag('autopep8_executable', 'autopep8')
" Invalidate cache of detected autopep8 version when this is changed, regardless
" of {value} arg.
call s:plugin.flags.autopep8_executable.AddCallback(
\ maktaba#function#FromExpr('codefmt#autopep8#InvalidateVersion()'), 0)
""
" The path to the clang-format executable.
call s:plugin.Flag('clang_format_executable', 'clang-format')
" Invalidate cache of detected clang-format version when this is changed, regardless
" of {value} arg.
call s:plugin.flags.clang_format_executable.AddCallback(
\ maktaba#function#FromExpr('codefmt#clangformat#InvalidateVersion()'), 0)
""
" Formatting style for clang-format to use. Either a string or callable that
" takes no args and returns a style name for the current buffer.
" See http://clang.llvm.org/docs/ClangFormatStyleOptions.html for details.
call s:plugin.Flag('clang_format_style', 'file')
""
" The path to the gofmt executable. For example, this can be changed to
" "goimports" (https://godoc.org/golang.org/x/tools/cmd/goimports) to
" additionally adjust imports when formatting.
call s:plugin.Flag('gofmt_executable', 'gofmt')
""
" The path to the dartfmt executable.
call s:plugin.Flag('dartfmt_executable', 'dartfmt')
""
" The path to the js-beautify executable.
call s:plugin.Flag('js_beautify_executable', 'js-beautify')
""
" The path to the yapf executable.
call s:plugin.Flag('yapf_executable', 'yapf')
""
" The path to the gn executable.
call s:plugin.Flag('gn_executable', 'gn')
""
" The path to the buildifier executable.
call s:plugin.Flag('buildifier_executable', 'buildifier')
""
" The path to the google-java executable. Generally, this should have the
" form:
" `java -jar /path/to/google-java`
call s:plugin.Flag('google_java_executable', 'google-java-format')
""
" Command line arguments to feed shfmt. Either a list or callable that
" takes no args and returns a list with command line arguments. By default, uses
" the Google's style.
" See https://github.com/mvdan/sh for details.
call s:plugin.Flag('shfmt_options', ['-i', '2', '-sr', '-ci'])
""
" The path to the shfmt executable.
call s:plugin.Flag('shfmt_executable', 'shfmt')
""
" Command line arguments to feed prettier. Either a list or callable that
" takes no args and returns a list with command line arguments.
call s:plugin.Flag('prettier_options', [
\ '--single-quote', '--trailing-comma=all',
\ '--arrow-parens=always', '--print-width=80'])
""
" The path to the prettier executable.
call s:plugin.Flag('prettier_executable', 'prettier')
""
" Command line arguments to feed rustfmt. Either a list or callable that
" takes no args and returns a list with command line arguments.
call s:plugin.Flag('rustfmt_options', [])
""
" The path to the rustfmt executable.
call s:plugin.Flag('rustfmt_executable', 'rustfmt')
""
" @private
" This is declared above zprint_options to avoid interfering with vimdoc parsing
" the maktaba flag.
function s:ZprintOptions() abort
return &textwidth ? ['{:width ' . &textwidth . '}'] : []
endfunction
""
" Command line arguments to feed zprint. Either a list or callable that takes no
" args and returns a list with command line arguments. The default configures
" zprint with Vim's textwidth.
call s:plugin.Flag('zprint_options', function('s:ZprintOptions'))
""
" The path to the zprint executable. Typically this is one of the native
" images (zprintl or zprintm) from https://github.com/kkinnear/zprint/releases
" installed as zprint.
call s:plugin.Flag('zprint_executable', 'zprint')
""
" The path to the fish_indent executable.
call s:plugin.Flag('fish_indent_executable', 'fish_indent')