Skip to content

Commit ee76b9d

Browse files
authored
Update for the latest ddc (#16)
1 parent 2b94bbd commit ee76b9d

File tree

4 files changed

+55
-56
lines changed

4 files changed

+55
-56
lines changed

denops/@ddc-file/deps.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
export type {
2-
Candidate,
32
Context,
4-
} from "https://deno.land/x/ddc_vim@v1.3.0/types.ts";
5-
export { BaseSource } from "https://deno.land/x/ddc_vim@v1.3.0/types.ts";
6-
export type { Denops } from "https://deno.land/x/ddc_vim@v1.3.0/deps.ts";
7-
export { fn, vars } from "https://deno.land/x/ddc_vim@v1.3.0/deps.ts";
3+
Item,
4+
} from "https://deno.land/x/ddc_vim@v3.0.0/types.ts";
5+
export { BaseSource } from "https://deno.land/x/ddc_vim@v3.0.0/types.ts";
6+
export type { Denops } from "https://deno.land/x/ddc_vim@v3.0.0/deps.ts";
7+
export { fn, vars } from "https://deno.land/x/ddc_vim@v3.0.0/deps.ts";
88
export type {
9-
GatherCandidatesArguments,
10-
} from "https://deno.land/x/ddc_vim@v1.3.0/base/source.ts";
11-
export * as path from "https://deno.land/std@0.125.0/path/mod.ts";
12-
export * as io from "https://deno.land/std@0.125.0/io/mod.ts";
13-
export * as fs from "https://deno.land/std@0.125.0/fs/mod.ts";
14-
export * as asserts from "https://deno.land/std@0.125.0/testing/asserts.ts";
9+
GatherArguments,
10+
} from "https://deno.land/x/ddc_vim@v3.0.0/base/source.ts";
11+
export * as path from "https://deno.land/std@0.160.0/path/mod.ts";
12+
export * as io from "https://deno.land/std@0.160.0/io/mod.ts";
13+
export * as fs from "https://deno.land/std@0.160.0/fs/mod.ts";
14+
export * as asserts from "https://deno.land/std@0.160.0/testing/asserts.ts";
1515
export {
1616
asyncIteratorFrom as fromA,
1717
iteratorFrom as from,
1818
wrapAsyncIterator as wrapA,
1919
wrapIterator as wrap,
2020
} from "https://deno.land/x/iterator_helpers@v0.1.2/mod.ts";
21-
import homeDir from "https://deno.land/x/dir@v1.2.0/home_dir/mod.ts";
21+
import homeDir from "https://deno.land/x/dir@1.5.1/home_dir/mod.ts";
2222
export { homeDir };

denops/@ddc-file/util.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import * as util from "./util.ts";
33

44
const createVirtualDirReader: (
55
virtualStorage: Record<string, string[]>,
6-
) => util.DirReader = (virtualStorage) =>
7-
(abs: string) => fromA(virtualStorage[abs] ?? []);
6+
) => util.DirReader = (virtualStorage) => (abs: string) =>
7+
fromA(virtualStorage[abs] ?? []);
88

99
Deno.test({
1010
name: "findMarkers() for posix",

denops/@ddc-sources/file.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
22
BaseSource,
3-
Candidate,
43
fn,
5-
GatherCandidatesArguments,
4+
GatherArguments,
65
homeDir,
6+
Item,
77
path as univPath,
88
vars,
99
wrapA,
@@ -15,10 +15,10 @@ type Params = {
1515
mode: "os" | "win32" | "posix";
1616
takeFileNum: number;
1717
projMarkers: string[];
18-
cwdMaxCandidates: number;
19-
bufMaxCandidates: number;
20-
projFromCwdMaxCandidates: number[];
21-
projFromBufMaxCandidates: number[];
18+
cwdMaxItems: number;
19+
bufMaxItems: number;
20+
projFromCwdMaxItems: number[];
21+
projFromBufMaxItems: number[];
2222
cwdAsRoot: boolean;
2323
bufAsRoot: boolean;
2424
projAsRoot: boolean;
@@ -57,19 +57,19 @@ const existsDir = async (filePath: string): Promise<boolean> => {
5757
};
5858

5959
export class Source extends BaseSource<Params> {
60-
async gatherCandidates(
61-
args: GatherCandidatesArguments<Params>,
62-
): Promise<Candidate[]> {
60+
async gather(
61+
args: GatherArguments<Params>,
62+
): Promise<Item[]> {
6363
const p = args.sourceParams;
6464
const mode = p.mode === "os"
6565
? (Deno.build.os === "windows" ? "win32" : "posix")
6666
: p.mode;
6767
const path = mode === "posix" ? univPath.posix : univPath.win32;
6868
const maxOfMax = Math.max(
69-
p.cwdMaxCandidates,
70-
p.bufMaxCandidates,
71-
...p.projFromCwdMaxCandidates,
72-
...p.projFromBufMaxCandidates,
69+
p.cwdMaxItems,
70+
p.bufMaxItems,
71+
...p.projFromCwdMaxItems,
72+
...p.projFromBufMaxItems,
7373
);
7474

7575
// e.g. (
@@ -162,23 +162,23 @@ export class Source extends BaseSource<Params> {
162162
// point from cwd
163163
findPointsAsync.push({
164164
dir: cwd,
165-
max: p.cwdMaxCandidates,
165+
max: p.cwdMaxItems,
166166
menu: p.displayCwd,
167167
asRoot: p.cwdAsRoot,
168168
});
169169

170170
// point from project-root found from cwd
171171
findPointsAsync.push(
172172
util.findMarkers(
173-
p.projFromCwdMaxCandidates.length,
173+
p.projFromCwdMaxItems.length,
174174
cwd,
175175
p.projMarkers,
176176
path,
177177
)
178178
.then((dirs) =>
179179
dirs.map((dir, i) => ({
180180
dir,
181-
max: p.projFromCwdMaxCandidates[i],
181+
max: p.projFromCwdMaxItems[i],
182182
menu: `${p.displayCwd}^${i === 0 ? "" : i + 1}`,
183183
asRoot: p.projAsRoot,
184184
}))
@@ -192,22 +192,22 @@ export class Source extends BaseSource<Params> {
192192
findPointsAsync.push({
193193
dir: bufDir,
194194
menu: p.displayBuf,
195-
max: p.bufMaxCandidates,
195+
max: p.bufMaxItems,
196196
asRoot: p.bufAsRoot,
197197
});
198198

199199
// point from project-root found from buf
200200
findPointsAsync.push(
201201
util.findMarkers(
202-
p.projFromBufMaxCandidates.length,
202+
p.projFromBufMaxItems.length,
203203
bufDir,
204204
p.projMarkers,
205205
path,
206206
)
207207
.then((dirs) =>
208208
dirs.map((dir, i) => ({
209209
dir,
210-
max: p.projFromBufMaxCandidates[i],
210+
max: p.projFromBufMaxItems[i],
211211
menu: `${p.displayBuf}^${i === 0 ? "" : i + 1}`,
212212
asRoot: p.projAsRoot,
213213
}))
@@ -243,7 +243,7 @@ export class Source extends BaseSource<Params> {
243243
})),
244244
);
245245

246-
const candidatesList = await Promise.all(
246+
const itemsList = await Promise.all(
247247
resolvedFindPoints
248248
.filter(({ ex }) => ex)
249249
.map(({ point }) => point)
@@ -261,7 +261,7 @@ export class Source extends BaseSource<Params> {
261261
(entry.isSymlink && p.followSymlinks &&
262262
await existsDir(path.join(dir, entry.name))),
263263
}))
264-
.map(({ name, isDirectory, isSymlink }): Candidate => ({
264+
.map(({ name, isDirectory, isSymlink }): Item => ({
265265
word: name.slice(inputFileBasePrefix.length) +
266266
(p.trailingSlash && isDirectory ? path.sep : ""),
267267
abbr: name.slice(inputFileBasePrefix.length) +
@@ -282,10 +282,9 @@ export class Source extends BaseSource<Params> {
282282
.catch(() => []),
283283
),
284284
);
285-
const candidates: Candidate[] = candidatesList
286-
.flat();
285+
const items: Item[] = itemsList.flat();
287286

288-
return candidates;
287+
return items;
289288
}
290289

291290
params(): Params {
@@ -297,10 +296,10 @@ export class Source extends BaseSource<Params> {
297296
".github",
298297
],
299298
takeFileNum: 10000,
300-
cwdMaxCandidates: 1000,
301-
bufMaxCandidates: 1000,
302-
projFromCwdMaxCandidates: [1000],
303-
projFromBufMaxCandidates: [1000],
299+
cwdMaxItems: 1000,
300+
bufMaxItems: 1000,
301+
projFromCwdMaxItems: [1000],
302+
projFromBufMaxItems: [1000],
304303
cwdAsRoot: false,
305304
bufAsRoot: false,
306305
projAsRoot: true,

doc/ddc-file.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ FREQUENTLY ASKED QUESTIONS (FAQ) |ddc-file-faq|
1919
==============================================================================
2020
INTRODUCTION *ddc-file-introduction*
2121

22-
This source collects candidates from file paths under the (1) buffer relative,
22+
This source collects items from file paths under the (1) buffer relative,
2323
(2) cwd relative, (3) project root (.git/, etc...; configurable by
2424
|ddc-file-param-projMarkers|) relative.
2525

2626
==============================================================================
2727
DISPLAY RULES *ddc-file-display-rules*
2828

29-
In menu (right side of the completion candidates), this source shows how was
29+
In menu (right side of the completion items), this source shows how was
3030
that completion got from.
3131
>
3232
/cwd^2
@@ -161,21 +161,21 @@ projMarkers (string[])
161161
".github",
162162
]
163163

164-
*ddc-file-param-cwdMaxCandidates*
165-
cwdMaxCandidates (number)
166-
Max candidates number for cwd relative.
164+
*ddc-file-param-cwdMaxItems*
165+
cwdMaxItems (number)
166+
Max items number for cwd relative.
167167

168168
Default: 1000
169169

170-
*ddc-file-param-bufMaxCandidates*
171-
bufMaxCandidates (number)
172-
Max candidates number for buffer relative.
170+
*ddc-file-param-bufMaxItems*
171+
bufMaxItems (number)
172+
Max items number for buffer relative.
173173

174174
Default: 1000
175175

176-
*ddc-file-param-projFromCwdMaxCandidates*
177-
projFromCwdMaxCandidates (number[])
178-
Max candidates number for project-root relative found by cwd.
176+
*ddc-file-param-projFromCwdMaxItems*
177+
projFromCwdMaxItems (number[])
178+
Max items number for project-root relative found by cwd.
179179
n-th number is used for n-th recursively found project-root.
180180

181181
e.g. Consider following situation.
@@ -191,10 +191,10 @@ projFromCwdMaxCandidates (number[])
191191

192192
Default: [1000]
193193

194-
*ddc-file-param-projFromBufMaxCandidates*
195-
projFromBufMaxCandidates (number[])
194+
*ddc-file-param-projFromBufMaxItems*
195+
projFromBufMaxItems (number[])
196196
Project-root from buffer relative version of
197-
|ddc-file-params-projFromCwdMaxCandidates|.
197+
|ddc-file-params-projFromCwdMaxItems|.
198198

199199
Default: [1000]
200200

0 commit comments

Comments
 (0)