-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathddc-file.txt
316 lines (257 loc) · 9.48 KB
/
ddc-file.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
307
308
309
310
311
312
313
314
315
316
*ddc-file.txt* Powerful and Performant File Completion for ddc.vim
Author : Luma <[email protected]>
License: MIT <https://github.com/LumaKernel/ddc-file/blob/main/LICENSE>
==============================================================================
CONTENTS *ddc-file-contents*
INTRODUCTION |ddc-file-introduction|
DISPLAY RULES |ddc-file-display-rules|
INSTALL |ddc-file-install|
EXAMPLES |ddc-file-examples|
BASIC EXAMPLES |ddc-file-example-basic|
NODE MODULES EXAMPLES |ddc-file-example-node|
PARAMS |ddc-file-params|
FREQUENTLY ASKED QUESTIONS (FAQ) |ddc-file-faq|
==============================================================================
INTRODUCTION *ddc-file-introduction*
This source collects items from file paths under the (1) buffer relative,
(2) cwd relative, (3) project root (.git/, etc...; configurable by
|ddc-file-param-projMarkers|) relative.
==============================================================================
DISPLAY RULES *ddc-file-display-rules*
In menu (right side of the completion items), this source shows how was
that completion got from.
>
/cwd^2
^|--||--- (a) if '/' is present, regard input's '/' as relative
^--||--- (b) 'buf', 'cwd', or omitted for absolute paths
^|--- (c) if '^' is present, project-root found from (b)
^--- (d) project-root search recursion level (1 is omitted)
<
It can be disabled by |ddc-file-param-disableMenu| and customized by
following.
- |ddc-file-param-displayCwd|
- |ddc-file-param-displayBuf|
==============================================================================
INSTALL *ddc-file-install*
Please install both "ddc.vim" and "denops.vim".
https://github.com/Shougo/ddc.vim
https://github.com/vim-denops/denops.vim
==============================================================================
EXAMPLES *ddc-file-examples*
I welcome PRs for your useful ideas.
------------------------------------------------------------------------------
BASIC EXAMPLE *ddc-file-example-basic*
>
call ddc#custom#patch_global('sources', ['file'])
call ddc#custom#patch_global('sourceOptions', {
\ 'file': {
\ 'mark': 'F',
\ 'isVolatile': v:true,
\ 'forceCompletionPattern': '\S/\S*',
\ }})
call ddc#custom#patch_filetype(
\ ['ps1', 'dosbatch', 'autohotkey', 'registry'], {
\ 'sourceOptions': {
\ 'file': {
\ 'forceCompletionPattern': '\S\\\S*',
\ },
\ },
\ 'sourceParams': {
\ 'file': {
\ 'mode': 'win32',
\ },
\ }})
<
------------------------------------------------------------------------------
NODE MODULES EXAMPLE *ddc-file-example-node*
Find any files under node_modules/ folder from JS-family filetype buffers. You
can see the completion when typing like `import ... from "<cursor>` in JS
files. This collects files from up to 3 node_modules/ folders for example
useful in monorepos.
This config does not conflict with |ddc-file-example-basic|.
>
call ddc#custom#alias('source', 'node-modules', 'file')
call ddc#custom#patch_global({
\ 'sourceOptions': {
\ 'node-modules': {
\ 'mark': 'NODE',
\ 'isVolatile': v:true,
\ 'minAutoCompleteLength': 10000,
\ 'forceCompletionPattern':
\ '(?:'
\ . '\bimport|'
\ . '\bfrom|'
\ . '\brequire\s*\(|'
\ . '\bresolve\s*\(|'
\ . '\bimport\s*\('
\ . ')'
\ . '\s*(?:''|"|`)[^''"`]*',
\ },
\ },
\ 'sourceParams': {
\ 'node-modules': {
\ 'cwdMaxItems': 0,
\ 'bufMaxItems': 0,
\ 'followSymlinks': v:true,
\ 'projMarkers': ['node_modules'],
\ 'projFromCwdMaxItems': [],
\ 'projFromBufMaxItems': [],
\ 'beforeResolve': 'node_modules',
\ 'displayBuf': '',
\ },
\ }})
call ddc#custom#patch_filetype(
\ [
\ 'javascript',
\ 'typescript',
\ 'javascriptreact',
\ 'typescriptreact',
\ 'tsx',
\ ], {
\ 'sourceParams': {
\ 'node-modules': {
\ 'projFromBufMaxItems': [1000, 1000, 1000],
\ },
\ }})
<
==============================================================================
PARAMS *ddc-file-params*
*ddc-file-param-mode*
mode ("os" | "win32" | "posix")
Controls path resolving and path separator. "os" will use the
current OS native mode.
Default: "posix"
*ddc-file-param-takeFileNum*
takeFileNum (number)
Limit number of files to filter at very first timing, namely
before filtering. It is useful if there are too many 'a...'
files when filtering with 'z'.
Default: 10000
*ddc-file-param-projMarkers*
projMarkers (string[])
File or directory names to search for project-root. Don't
include ending slashes. Used for exact match.
Default: [
".git",
".vscode",
".github",
]
*ddc-file-param-cwdMaxItems*
cwdMaxItems (number)
Max items number for cwd relative.
Default: 1000
*ddc-file-param-bufMaxItems*
bufMaxItems (number)
Max items number for buffer relative.
Default: 1000
*ddc-file-param-projFromCwdMaxItems*
projFromCwdMaxItems (number[])
Max items number for project-root relative found by cwd.
n-th number is used for n-th recursively found project-root.
e.g. Consider following situation.
my-project/
|- .git/
|- sub-project/
|- .git/
|- src/ <-- cwd
|- my-document.txt
If [10] is set, sub-project/ is only found with up to 10
files.
If [10, 5] is set, sub-project/ is found with up to 10 files
and my-project/ is also found with up to 5 files.
Default: [1000]
*ddc-file-param-projFromBufMaxItems*
projFromBufMaxItems (number[])
Project-root from buffer relative version of
|ddc-file-param-projFromCwdMaxItems|.
Default: [1000]
*ddc-file-param-cwdAsRoot*
cwdAsRoot (boolean)
Set to true to complete from cwd even if the input is absolute
path. e.g. the input is '/REA', and there is
<cwd>/README.md, this will be completed as well.
Default: false
*ddc-file-param-bufAsRoot*
bufAsRoot (boolean)
Buffer relative version of |ddc-file-param-cwdAsRoot|.
Default: false
*ddc-file-param-projAsRoot*
projAsRoot (boolean)
Project-root relative version of |ddc-file-param-cwdAsRoot|.
Default: true
*ddc-file-param-trailingSlash*
trailingSlash (boolean)
Whether to include trailing slash when completing directory
name.
Default: false
*ddc-file-param-trailingSlashAbbr*
trailingSlashAbbr (boolean)
Whether to display trailing slash when completing directory
name. Note that this won't be actually inserted.
Default: true
*ddc-file-param-followSymlinks*
followSymlinks (boolean)
Whether to follow symlinks to determine whether the filename
completing is file or directory. Note that, if you are trying
to complete /foo/bar/bar when /foo/bar is symlink, it'll work
without this param.
Default: false
*ddc-file-param-disableMenu*
disableMenu (boolean)
Disable to show menu like `buf^`. |ddc-file-display-rules|
Default: false
*ddc-file-param-beforeResolve*
*ddc-file-param-afterResolve*
beforeResolve (string) Default: ""
afterResolve (string) Default: ""
Your input will be transformed as join(find-root,
beforeResolve, input, afterResolve). Empty strings are
skipped. Path "find-root" denotes cwd/buf or found
project-root by other settings. See |ddc-file-example-node|
for example. You can specify absolute path to complete for
specific folder, like with configuring
`beforeResolve: '/usr/bin'` .
Default: ""
*ddc-file-param-filenameChars*
filenameChars (string)
The characters as filename pattern.
The pattern is |/collection| pattern.
Default: "[:keyword:]"
*ddc-file-param-displayFile*
*ddc-file-param-displayDir*
*ddc-file-param-displaySym*
*ddc-file-param-displaySymDir*
*ddc-file-param-displaySymFile*
displayFile (string) Default: "file"
displayDir (string) Default: "dir"
displaySym (string) Default: "sym"
displaySymFile (string) Default: "sym=file"
displaySymDir (string) Default: "sym=dir"
Texts to show as kind of completed item. To disable, set empty
strings.
`displaySymFile` and `displaySymDir` are only used when
|ddc-file-param-followSymlinks| is set to `true`.
*ddc-file-param-displayCwd*
*ddc-file-param-displayBuf*
displayCwd (string) Default: "cwd"
displayBuf (string) Default: "buf"
Texts to show as menu of completed item.
See |ddc-file-display-rules|.
==============================================================================
FREQUENTLY ASKED QUESTIONS (FAQ) *ddc-file-faq*
Q: How to complete paths including spaces or punctuations?
A. ddc-file respects value of 'isfname' for backward searching, but as
described in 'isfname', it's not recommended to treat paths including such
special characters. If you still want, I cannot stop you, please try this.
>
:set isfname+=32,40-41
<
Please take care that leading spaces are also treated as part of path.
Q: I want to include "." as filename pattern.
A. You can change the pattern by |ddc-file-param-filenameChars|.
>
call ddc#custom#patch_global('sourceParams', {
\ 'file': {'filenameChars': '[:keyword:].'},
\ })
==============================================================================
vim:tw=78:ts=8:noet:ft=help:norl