Skip to content

Commit 5889afc

Browse files
committed
👍 Add getmarklist() to buffer-function
1 parent f5a22ff commit 5889afc

File tree

3 files changed

+56
-32
lines changed

3 files changed

+56
-32
lines changed

denops_std/function/_generated.ts

Lines changed: 0 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

denops_std/function/buffer.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Denops } from "https://deno.land/x/denops_core@v4.0.0/mod.ts";
2-
import type { BufInfo, ChangeList } from "./types.ts";
2+
import type { BufInfo, ChangeList, MarkInformation } from "./types.ts";
33

44
/**
55
* If the **{buf}** argument is a number, buffer numbers are used.
@@ -505,6 +505,36 @@ export async function getchangelist(
505505
return await denops.call("getchangelist", buf) as ChangeList;
506506
}
507507

508+
/**
509+
* Without the **{buf}** argument returns a `List` with information
510+
* about all the global marks. `mark`
511+
*
512+
* If the optional **{buf}** argument is specified, returns the
513+
* local marks defined in buffer **{buf}**. For the use of **{buf}**,
514+
* see `bufname()`. If **{buf}** is invalid, an empty list is
515+
* returned.
516+
*
517+
* Each item in the returned List is a `Dict` with the following:
518+
* mark name of the mark prefixed by "'"
519+
* pos a `List` with the position of the mark:
520+
* [bufnum, lnum, col, off]
521+
* Refer to `getpos()` for more information.
522+
* file file name
523+
*
524+
* Refer to `getpos()` for getting information about a specific
525+
* mark.
526+
*
527+
* Can also be used as a `method`:
528+
*
529+
* GetBufnr()->getmarklist()
530+
*/
531+
export async function getmarklist(
532+
denops: Denops,
533+
buf?: BufNameArg,
534+
): Promise<MarkInformation[]> {
535+
return await denops.call("getmarklist", buf) as MarkInformation[];
536+
}
537+
508538
/**
509539
* Set line **{lnum}** to **{text}** in buffer **{buf}**. This works like
510540
* `setline()` for the specified buffer.

denops_std/function/types.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,28 @@ export interface ChangeListLocation {
214214
/** Line number. */
215215
lnum: number;
216216
}
217+
218+
/**
219+
* Type of `getmarklist()` result.
220+
*/
221+
export interface MarkInformation {
222+
/** Name of the mark prefixed by "'". */
223+
mark: string;
224+
/**
225+
* The position of the mark.
226+
* Refer to `getpos()` for more information.
227+
*/
228+
pos: MarkPosition;
229+
/** File name. */
230+
file: string;
231+
}
232+
233+
/**
234+
* Type of `getmarklist()` result.
235+
*/
236+
export type MarkPosition = [
237+
bufnum: number,
238+
lnum: number,
239+
col: number,
240+
off: number,
241+
];

0 commit comments

Comments
 (0)