11import type { Denops } from "https://deno.land/x/[email protected] /mod.ts" ; 22
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+
339/**
440 * Add a buffer to the buffer list with name **{name}** (must be a
541 * String).
@@ -57,7 +93,7 @@ export async function bufadd(
5793 */
5894export async function bufexists (
5995 denops : Denops ,
60- buf : string | number ,
96+ buf : BufExistsArg ,
6197) : Promise < boolean > {
6298 const result = await denops . call ( "bufexists" , buf ) as number ;
6399 return ! ! result ;
@@ -74,7 +110,7 @@ export async function bufexists(
74110 */
75111export async function buflisted (
76112 denops : Denops ,
77- buf : string | number ,
113+ buf : BufExistsArg ,
78114) : Promise < boolean > {
79115 const result = await denops . call ( "buflisted" , buf ) as number ;
80116 return ! ! result ;
@@ -96,7 +132,7 @@ export async function buflisted(
96132 */
97133export async function bufload (
98134 denops : Denops ,
99- buf : string | number ,
135+ buf : BufExistsArg ,
100136) : Promise < void > {
101137 await denops . call ( "bufload" , buf ) ;
102138}
@@ -112,7 +148,7 @@ export async function bufload(
112148 */
113149export async function bufloaded (
114150 denops : Denops ,
115- buf : string | number ,
151+ buf : BufExistsArg ,
116152) : Promise < boolean > {
117153 const result = await denops . call ( "bufloaded" , buf ) as number ;
118154 return ! ! result ;
@@ -159,7 +195,7 @@ export async function bufloaded(
159195 */
160196export async function bufname (
161197 denops : Denops ,
162- buf ?: string | number ,
198+ buf ?: BufNameArg ,
163199) : Promise < string > {
164200 return await denops . call ( "bufname" , buf ) as string ;
165201}
@@ -197,7 +233,7 @@ export async function bufname(
197233 */
198234export async function bufnr (
199235 denops : Denops ,
200- buf ?: string | number ,
236+ buf ?: BufNameArg ,
201237 create ?: boolean ,
202238) : Promise < number > {
203239 return await denops . call ( "bufnr" , buf , create ) as number ;
@@ -219,7 +255,7 @@ export async function bufnr(
219255 */
220256export async function bufwinid (
221257 denops : Denops ,
222- buf : string | number ,
258+ buf : BufNameArg ,
223259) : Promise < number > {
224260 return await denops . call ( "bufwinid" , buf ) as number ;
225261}
@@ -241,7 +277,7 @@ export async function bufwinid(
241277 */
242278export async function bufwinnr (
243279 denops : Denops ,
244- buf : string | number ,
280+ buf : BufNameArg ,
245281) : Promise < number > {
246282 return await denops . call ( "bufwinnr" , buf ) as number ;
247283}
@@ -277,9 +313,9 @@ export async function bufwinnr(
277313 */
278314export async function getbufline (
279315 denops : Denops ,
280- buf : string | number ,
281- lnum : string | number ,
282- end ?: string | number ,
316+ buf : BufNameArg ,
317+ lnum : BufLnumArg ,
318+ end ?: BufLnumArg ,
283319) : Promise < string [ ] > {
284320 return await denops . call ( "getbufline" , buf , lnum , end ) as string [ ] ;
285321}
@@ -317,8 +353,8 @@ export async function getbufline(
317353 */
318354export async function setbufline (
319355 denops : Denops ,
320- buf : string | number ,
321- lnum : string | number ,
356+ buf : BufNameArg ,
357+ lnum : BufLnumArg ,
322358 text : string | string [ ] ,
323359) : Promise < boolean > {
324360 const result = await denops . call ( "setbufline" , buf , lnum , text ) as number ;
0 commit comments