Skip to content

Commit 3cdb227

Browse files
authored
add some customizability and update deno deps (#8)
* add some customizability and update deno deps * move .map after filtering
1 parent ed08e53 commit 3cdb227

File tree

4 files changed

+107
-17
lines changed

4 files changed

+107
-17
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
deno: v1.x
3939
- os: ubuntu-latest
4040
deno: v1.13
41+
- os: ubuntu-latest
42+
deno: v1.14
4143
- os: ubuntu-latest
4244
deno: canary
4345
- os: windows-latest

denops/@ddc-file/deps.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
export type {
22
Candidate,
33
Context,
4-
} from "https://deno.land/x/ddc_vim@v0.13.0/types.ts";
5-
export { BaseSource } from "https://deno.land/x/ddc_vim@v0.13.0/types.ts";
6-
export type { Denops } from "https://deno.land/x/ddc_vim@v0.13.0/deps.ts";
7-
export { fn, vars } from "https://deno.land/x/ddc_vim@v0.13.0/deps.ts";
4+
} from "https://deno.land/x/ddc_vim@v0.14.0/types.ts";
5+
export { BaseSource } from "https://deno.land/x/ddc_vim@v0.14.0/types.ts";
6+
export type { Denops } from "https://deno.land/x/ddc_vim@v0.14.0/deps.ts";
7+
export { fn, vars } from "https://deno.land/x/ddc_vim@v0.14.0/deps.ts";
88
export type {
99
GatherCandidatesArguments,
10-
} from "https://deno.land/x/ddc_vim@v0.13.0/base/source.ts";
11-
export * as path from "https://deno.land/std@0.107.0/path/mod.ts";
12-
export * as io from "https://deno.land/std@0.107.0/io/mod.ts";
13-
export * as fs from "https://deno.land/std@0.107.0/fs/mod.ts";
14-
export * as asserts from "https://deno.land/std@0.107.0/testing/asserts.ts";
10+
} from "https://deno.land/x/ddc_vim@v0.14.0/base/source.ts";
11+
export * as path from "https://deno.land/std@0.108.0/path/mod.ts";
12+
export * as io from "https://deno.land/std@0.108.0/io/mod.ts";
13+
export * as fs from "https://deno.land/std@0.108.0/fs/mod.ts";
14+
export * as asserts from "https://deno.land/std@0.108.0/testing/asserts.ts";
1515
export {
1616
asyncIteratorFrom as fromA,
1717
iteratorFrom as from,

denops/@ddc-sources/file.ts

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ type Params = {
2020
cwdAsRoot: boolean;
2121
bufAsRoot: boolean;
2222
projAsRoot: boolean;
23+
trailingSlash: boolean;
24+
followSymlinks: boolean;
25+
disableMenu: boolean;
26+
27+
// display customize
28+
displayFile: string;
29+
displayDir: string;
30+
displaySym: string;
31+
displaySymFile: string;
32+
displaySymDir: string;
33+
displayCwd: string;
34+
displayBuf: string;
2335
};
2436

2537
type FindPoint = {
@@ -127,7 +139,7 @@ export class Source extends BaseSource<Params> {
127139
findPointsAsync.push({
128140
dir: Deno.cwd(),
129141
max: p.cwdMaxCandidates,
130-
menu: "cwd",
142+
menu: p.displayCwd,
131143
asRoot: p.cwdAsRoot,
132144
});
133145

@@ -143,7 +155,7 @@ export class Source extends BaseSource<Params> {
143155
dirs.map((dir, i) => ({
144156
dir,
145157
max: p.projFromCwdMaxCandidates[i],
146-
menu: `cwd^${i === 0 ? "" : i + 1}`,
158+
menu: `${p.displayCwd}^${i === 0 ? "" : i + 1}`,
147159
asRoot: p.projAsRoot,
148160
}))
149161
)
@@ -155,7 +167,7 @@ export class Source extends BaseSource<Params> {
155167
// point from buf
156168
findPointsAsync.push({
157169
dir: bufDir,
158-
menu: "buf",
170+
menu: p.displayBuf,
159171
max: p.bufMaxCandidates,
160172
asRoot: p.bufAsRoot,
161173
});
@@ -172,7 +184,7 @@ export class Source extends BaseSource<Params> {
172184
dirs.map((dir, i) => ({
173185
dir,
174186
max: p.projFromBufMaxCandidates[i],
175-
menu: `buf^${i === 0 ? "" : i + 1}`,
187+
menu: `${p.displayBuf}^${i === 0 ? "" : i + 1}`,
176188
asRoot: p.projAsRoot,
177189
}))
178190
)
@@ -217,10 +229,25 @@ export class Source extends BaseSource<Params> {
217229
)
218230
.take(p.takeFileNum)
219231
.filter(({ name }) => name.startsWith(inputFileBasePrefix))
232+
.map(async (entry) => ({
233+
...entry,
234+
isDirectory: entry.isDirectory ||
235+
(entry.isSymlink && p.followSymlinks &&
236+
await existsDir(path.join(dir, entry.name))),
237+
}))
220238
.map(({ name, isDirectory, isSymlink }): Candidate => ({
221-
word: name.slice(inputFileBasePrefix.length),
222-
menu: (menu !== "" && isInputAbs ? path.sep : "") + menu,
223-
kind: isDirectory ? "dir" : isSymlink ? "sym" : "",
239+
word: name.slice(inputFileBasePrefix.length) +
240+
(p.trailingSlash && isDirectory ? path.sep : ""),
241+
menu: p.disableMenu
242+
? undefined
243+
: (menu !== "" && isInputAbs ? path.sep : "") + menu,
244+
kind: isSymlink
245+
? p.followSymlinks
246+
? isDirectory ? p.displaySymDir : p.displaySymFile
247+
: p.displaySym
248+
: isDirectory
249+
? p.displayDir
250+
: p.displayFile,
224251
}))
225252
.take(max)
226253
.toArray()
@@ -249,6 +276,18 @@ export class Source extends BaseSource<Params> {
249276
cwdAsRoot: false,
250277
bufAsRoot: false,
251278
projAsRoot: true,
279+
trailingSlash: false,
280+
followSymlinks: false,
281+
disableMenu: false,
282+
283+
// display customize
284+
displayFile: "file",
285+
displayDir: "dir",
286+
displaySym: "sym",
287+
displaySymFile: "sym=file",
288+
displaySymDir: "sym=dir",
289+
displayCwd: "cwd",
290+
displayBuf: "buf",
252291
};
253292
}
254293
}

doc/ddc-file.txt

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ In menu (right side of the completion candidates), this source shows how was
2828
that completion got from.
2929
>
3030
/cwd^2
31-
^|--||--- (a) if '/' is present, regard input '/' as the followed source
31+
^|--||--- (a) if '/' is present, regard input's '/' as relative
3232
^--||--- (b) 'buf', 'cwd', or omitted for absolute paths
3333
^|--- (c) if '^' is present, project-root found from (b)
3434
^--- (d) project-root search recursion level (1 is omitted)
3535
<
3636

37+
It can be disabled by |ddc-file-params-disableMenu| and customized by
38+
following.
39+
- |ddc-file-params-displayCwd|
40+
- |ddc-file-params-displayBuf|
41+
3742
==============================================================================
3843
INSTALL *ddc-file-install*
3944

@@ -152,6 +157,50 @@ projAsRoot (boolean)
152157

153158
Default: true
154159

160+
*ddc-file-params-trailingSlash*
161+
trailingSlash (boolean)
162+
Whether to include trailing slash when completing directory
163+
name.
164+
165+
Default: false
166+
167+
*ddc-file-params-followSymlinks*
168+
followSymlinks (boolean)
169+
Whether to follow symlinks to determine whether the filename
170+
completing is file or directory. Note that, if you are trying
171+
to complete /foo/bar/bar when /foo/bar is symlink, it'll work
172+
without this param.
173+
174+
Default: false
175+
176+
*ddc-file-params-disableMenu*
177+
disableMenu (boolean)
178+
Disable to show menu like `buf^`. |ddc-file-display-rules|
179+
180+
Default: false
181+
182+
*ddc-file-params-displayFile*
183+
*ddc-file-params-displayDir*
184+
*ddc-file-params-displaySym*
185+
*ddc-file-params-displaySymDir*
186+
*ddc-file-params-displaySymFile*
187+
displayFile (string) Default: "file"
188+
displayDir (string) Default: "dir"
189+
displaySym (string) Default: "sym"
190+
displaySymFile (string) Default: "sym=file"
191+
displaySymDir (string) Default: "sym=dir"
192+
Texts to show as kind of completed item. To disable, set empty
193+
strings.
194+
`displaySymFile` and `displaySymDir` are only used when
195+
|ddc-file-params-followSymlinks| is set to `true`.
196+
197+
*ddc-file-params-displayCwd*
198+
*ddc-file-params-displayBuf*
199+
displayCwd (string) Default: "cwd"
200+
displayBuf (string) Default: "buf"
201+
Texts to show as menu of completed item.
202+
See |ddc-file-display-rules|.
203+
155204
==============================================================================
156205
FREQUENTLY ASKED QUESTIONS (FAQ) *ddc-file-faq*
157206

0 commit comments

Comments
 (0)