1
1
import type { Denops } from "https://deno.land/x/denops_core@v4.0.0/mod.ts" ;
2
2
3
+ /**
4
+ * If the **{buf}** argument is a number, buffer numbers are used.
5
+ * Number zero is the alternate buffer for the current window.
6
+ *
7
+ * If the **{buf}** argument is a string it must match a buffer name
8
+ * exactly. The name can be:
9
+ * - Relative to the current directory.
10
+ * - A full path.
11
+ * - The name of a buffer with 'buftype' set to "nofile".
12
+ * - A URL name.
13
+ */
14
+ export type BufExistsArg = string | number ;
15
+
16
+ /**
17
+ * If **{buf}** is omitted the current buffer is used.
18
+ * If **{buf}** is a Number, that buffer number's name is given.
19
+ * Number zero is the alternate buffer for the current window.
20
+ * If **{buf}** is a String, it is used as a `file-pattern` to match
21
+ * with the buffer names. This is always done like 'magic' is
22
+ * set and 'cpoptions' is empty. When there is more than one
23
+ * match an empty string is returned.
24
+ * "" or "%" can be used for the current buffer, "#" for the
25
+ * alternate buffer.
26
+ * A full match is preferred, otherwise a match at the start, end
27
+ * or middle of the buffer name is accepted. If you only want a
28
+ * full match then put "^" at the start and "$" at the end of the
29
+ * pattern.
30
+ */
31
+ export type BufNameArg = string | number ;
32
+
33
+ /**
34
+ * For **{lnum}** and **{end}** "$" can be used for the last line of the
35
+ * buffer. Otherwise a number must be used.
36
+ */
37
+ export type BufLnumArg = "$" | number ;
38
+
3
39
/**
4
40
* Add a buffer to the buffer list with name **{name}** (must be a
5
41
* String).
@@ -57,7 +93,7 @@ export async function bufadd(
57
93
*/
58
94
export async function bufexists (
59
95
denops : Denops ,
60
- buf : string | number ,
96
+ buf : BufExistsArg ,
61
97
) : Promise < boolean > {
62
98
const result = await denops . call ( "bufexists" , buf ) as number ;
63
99
return ! ! result ;
@@ -74,7 +110,7 @@ export async function bufexists(
74
110
*/
75
111
export async function buflisted (
76
112
denops : Denops ,
77
- buf : string | number ,
113
+ buf : BufExistsArg ,
78
114
) : Promise < boolean > {
79
115
const result = await denops . call ( "buflisted" , buf ) as number ;
80
116
return ! ! result ;
@@ -96,7 +132,7 @@ export async function buflisted(
96
132
*/
97
133
export async function bufload (
98
134
denops : Denops ,
99
- buf : string | number ,
135
+ buf : BufExistsArg ,
100
136
) : Promise < void > {
101
137
await denops . call ( "bufload" , buf ) ;
102
138
}
@@ -112,7 +148,7 @@ export async function bufload(
112
148
*/
113
149
export async function bufloaded (
114
150
denops : Denops ,
115
- buf : string | number ,
151
+ buf : BufExistsArg ,
116
152
) : Promise < boolean > {
117
153
const result = await denops . call ( "bufloaded" , buf ) as number ;
118
154
return ! ! result ;
@@ -159,7 +195,7 @@ export async function bufloaded(
159
195
*/
160
196
export async function bufname (
161
197
denops : Denops ,
162
- buf ?: string | number ,
198
+ buf ?: BufNameArg ,
163
199
) : Promise < string > {
164
200
return await denops . call ( "bufname" , buf ) as string ;
165
201
}
@@ -197,7 +233,7 @@ export async function bufname(
197
233
*/
198
234
export async function bufnr (
199
235
denops : Denops ,
200
- buf ?: string | number ,
236
+ buf ?: BufNameArg ,
201
237
create ?: boolean ,
202
238
) : Promise < number > {
203
239
return await denops . call ( "bufnr" , buf , create ) as number ;
@@ -219,7 +255,7 @@ export async function bufnr(
219
255
*/
220
256
export async function bufwinid (
221
257
denops : Denops ,
222
- buf : string | number ,
258
+ buf : BufNameArg ,
223
259
) : Promise < number > {
224
260
return await denops . call ( "bufwinid" , buf ) as number ;
225
261
}
@@ -241,7 +277,7 @@ export async function bufwinid(
241
277
*/
242
278
export async function bufwinnr (
243
279
denops : Denops ,
244
- buf : string | number ,
280
+ buf : BufNameArg ,
245
281
) : Promise < number > {
246
282
return await denops . call ( "bufwinnr" , buf ) as number ;
247
283
}
@@ -277,9 +313,9 @@ export async function bufwinnr(
277
313
*/
278
314
export async function getbufline (
279
315
denops : Denops ,
280
- buf : string | number ,
281
- lnum : string | number ,
282
- end ?: string | number ,
316
+ buf : BufNameArg ,
317
+ lnum : BufLnumArg ,
318
+ end ?: BufLnumArg ,
283
319
) : Promise < string [ ] > {
284
320
return await denops . call ( "getbufline" , buf , lnum , end ) as string [ ] ;
285
321
}
@@ -317,8 +353,8 @@ export async function getbufline(
317
353
*/
318
354
export async function setbufline (
319
355
denops : Denops ,
320
- buf : string | number ,
321
- lnum : string | number ,
356
+ buf : BufNameArg ,
357
+ lnum : BufLnumArg ,
322
358
text : string | string [ ] ,
323
359
) : Promise < boolean > {
324
360
const result = await denops . call ( "setbufline" , buf , lnum , text ) as number ;
0 commit comments