-
Notifications
You must be signed in to change notification settings - Fork 0
/
swifty-vim.txt
306 lines (234 loc) · 11.6 KB
/
swifty-vim.txt
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
*swifty-vim.txt* Swift development plugin
*swifty-vim*
==============================================================================
CONTENTS *swift-contents*
1. Introduction |swift-intro|
2. Settings |swift-settings|
3. Commands |swift-commands|
4. Mappings |swift-mappings|
==============================================================================
INTRODUCTION *swift-intro*
A Vim plugin for the Swift programming language. It provides file detection,
syntax highlighting, support for compiling and running tests, and optional
support for formatting and linting tools.
==============================================================================
SETTINGS *swift-settings*
You can change the settings in your vimrc.
*g:swift_compiler_spm_path*
g:swift_compiler_spm_path~
Set this option to the path to swift. If unset, "swift" will be located
in the $PATH: >
let g:swiftc_compiler_spm_path = "/usr/bin/swift"
<
*g:swift_compiler_spm_options*
g:swift_compiler_spm_options~
Set this option to any swift compiler options. If unset, no extra options
will be passed to swift. Defaults to "build". >
let g:swiftc_compiler_spm_options = "build"
<
*g:swift_compiler_swiftc_path*
g:swift_compiler_swiftc_path~
Set this option to the path to swiftc. If unset, "swiftc" will be located
in the $PATH: >
let g:swiftc_compiler_swiftc_path = "/usr/bin/swiftc"
<
*g:swift_compiler_swiftc_options*
g:swift_compiler_swiftc_options~
Set this option to any swiftc compiler options. If unset, no extra options
will be passed to swiftc. >
let g:swiftc_compiler_swiftc_options = "-D DEBUG"
<
*g:swift_compiler_swiftc_makeprog_no_percent*
g:swift_compiler_swiftc_makeprog_no_percent~
Set this option to 1 to not include the file name when calling "swiftc". >
let g:swift_compiler_swiftc_makeprog_no_percent = 1
<
*g:swift_jump_to_error*
g:swift_jump_to_error~
Set this option to 0 to not immediately jump to the first error in a list. >
let g:swift_jump_to_error = 0
<
*g:swift_list_autoclose*
g:swift_list_autoclose~
Set this option to 0 to not automatically close a list if there are no
errors. >
let g:swift_list_autoclose = 0
<
*g:swift_list_clean*
g:swift_list_clean~
Set this option to 0 to not clear lists when invoking commands or
mappings manually. Defaults to 1. >
let g:swift_list_clean = 0
<
*g:swift_list_clean_on_autosave*
g:swift_list_clean_on_autosave~
Set this option to 0 to not clear lists when invoking commands or
mappings automatically during autosave. Defaults to 1. >
let g:swift_list_clean_on_autosave = 0
<
*g:swift_list_height*
g:swift_list_height~
Set this option to the exact height which lists should be opened with.
Unset or set to 0 to allow lists to be automatically sized. >
let g:swift_list_height = 5
<
*g:swift_list_type*
g:swift_list_type~
Set this option to always use a specific list type when parsing messages. >
let g:swift_list_type = "locationlist"
<
*g:swift_list_type_commands*
g:swift_list_type_commands~
Set this option to a dictionary where the key is the list type and the
value is the type of list to use. >
let g:swift_list_type_commands = { "SwiftBuild": "locationlist" }
<
*g:swift_version_check*
g:swift_version_check~
Set this option to 0 to not check for the version of Vim being used. >
let g:swift_version_check = 0
<
Integration with SwiftFormat *swift-swiftformat*
----------------------------
This plugin can use SwiftFormat to format code. SwiftFormat must be installed
separately.
*g:swift_swiftformat_autosave*
g:swift_swiftformat_autosave~
Set this option to 1 to automatically invoke SwiftFormat when saving. >
let g:swift_swiftformat_autosave = 0
<
*g:swift_swiftformat_config_file_path*
g:swift_swiftformat_config_file_path~
Set this option to a global SwiftFormat file path which will always
be used. >
let g:swift_swiftformat_config_file_path =
\ $HOME . "/.swiftformat"
<
*g:swift_swiftformat_config_file_name*
g:swift_swiftformat_config_file_name~
Set this option to the name of the SwiftFormat config to search for.
Defaults to ".swiftformat". >
let g:swift_swiftformat_config_file_name = ".swiftformat"
<
*g:swift_swiftformat_config_file_search_parent_dir*
g:swift_swiftformat_config_file_search_parent_dir~
Set this option to 1 to find the |g:swift_swiftformat_config_file_name| in
the current or parent directories. Defaults to 1. >
let g:swift_swiftformat_config_file_search_parent_dir = 0
<
*g:swift_swiftformat_fail_silently*
g:swift_swiftformat_fail_silently~
Set this option to 1 to let SwiftFormat fail silently. >
let g:swift_swiftformat_fail_silently = 1
<
*g:swift_swiftformat_options*
g:swift_swiftformat_options~
Set this option to a list of any SwiftFormat options to use. >
let g:swift_swiftformat_options = ["--enable", "trailingCommas"]
<
*g:swift_swiftformat_path*
g:swift_swiftformat_path~
Set this option to the specific SwiftFormat path to use. >
let g:swift_swiftformat_path = "/usr/local/bin/swiftformat"
<
Integration with SwiftLint *swift-swiftlint*
----------------------------
This plugin can use SwiftLint to lint code. SwiftLint must be installed
separately.
*g:swift_swiftlint_autosave*
g:swift_swiftlint_autosave~
Set this option to 1 to automatically invoke SwiftLint when saving. >
let g:swift_swiftlint_autosave = 1
<
*g:swift_swiftlint_config_file_path*
g:swift_swiftlint_config_file_path~
Set this option to a global SwiftLint file path which will always
be used. >
let g:swift_swiftlint_config_file_path = $HOME . "/swiftlint.yml"
<
*g:swift_swiftlint_config_file_name*
g:swift_swiftlint_config_file_name~
Set this option to the name of the SwiftLint config to search for.
Defaults to ".swiftlint.yml". >
let g:swift_swiftlint_config_file_name = ".swiftlint.yml"
<
*g:swift_swiftlint_config_file_search_parent_dir*
g:swift_swiftlint_config_file_search_parent_dir~
Set this option to 1 to find the |g:swift_swiftlint_config_file_name| in
the current or parent directories. Defaults to 1. >
let g:swift_swiftlint_config_file_search_parent_dir = 0
<
*g:swift_swiftlint_from_package*
g:swift_swiftlint_from_package~
Set this option to 1 to run against the entire Swift Package instead of a
single file. >
let g:swift_swiftlint_from_package = 1
<
*g:swift_swiftlint_options*
g:swift_swiftlint_options~
Set this option to a list of any SwiftLint options to use. >
let g:swift_swiftlint_options = ["--enable", "trailingCommas"]
<
*g:swift_swiftlint_path*
g:swift_swiftlint_path~
Set this option to the specific SwiftLint path to use. >
let g:swift_swiftlint_path = "/usr/local/bin/swiftlint"
<
==============================================================================
COMMANDS *swift-commands*
Swift Package Manager
---------------------
Convenience commands for working with Swift Package Manager packages.
:SwiftPMBuild <args> *:SwiftPMBuild*
Runs 'swift build' or 'swift build --build-tests' (depending
on the file) with the provided arguments.
:SwiftPMSourceBuild <args> *:SwiftPMSourceBuild*
Runs 'swift build' with the provided arguments.
:SwiftPMTest <args> *:SwiftPMTest*
Runs 'swift test' with the provided arguments.
:SwiftPMTestBuild <args> *:SwiftPMTestBuild*
Runs 'swift build --build-tests' with the provided arguments.
:SwiftPMTestFunctionOnly <args> *:SwiftPMTestFunctionOnly*
Runs 'swift test --filter <current test func>' with the
provided arguments.
:SwiftPMTestGenerateLinuxMain <args> *:SwiftPMTestGenerateLinuxMain*
Runs 'swift test --generate-linuxmain' with the provided
arguments.
:SwiftPMGenerateXcodeProject <args> *:SwiftPMGenerateXcodeProject*
Runs 'swift package generate-xcodeproj' with the provided
arguments.
Formatting
----------
:SwiftFormat *:SwiftFormat*
Runs |g:swift_swiftformat_path| on the current buffer. If
|g:swift_swiftformat_options| is set, then the options will
be used.
If |g:swift_swiftformat_fail_silently| is 0 (the default),
then a list will be populated with any errors.
If |g:swift_swiftformat_fail_silently| is set to 1,
then it will not populate any list with any errors.
Linting
-------------------
:SwiftLint *:SwiftLint*
Runs |g:swift_swiftlint_path| on the current buffer.
==============================================================================
MAPPINGS *swift-mappings*
There are <Plug> keys defined which can be mapped to with custom key bindings.
You can map to a <Plug> key by doing the following:
autocmd FileType swift nmap <leader>t <Plug>(swift-spm-test)
*(swift-spm-build)*
Builds the current Swift Package with `swift build`.
*(swift-spm-test)*
Tests the current Swift Package with `swift test`.
*(swift-spm-test-function-only)*
Tests the current test function with `swift test`.
*(swift-spm-test-generate-linuxmain)*
Generates the LinuxMain.swift code for the current package.
*(swift-spm-generate-xcodeproj)*
Uses Swift Package Manager to generate the Xcode project.
*(swift-swiftformat)*
Runs `swiftformat` on the current buffer.
*(swift-swiftlint)*
Runs `swiftlint` on the current buffer.
==============================================================================
vim:tw=78:sw=4:noet:ts=8:ft=help:norl: