import { nvim_buf_get_extmarks } from "https://deno.land/x/denops_std@v4.1.4/function/nvim/mod.ts";
Gets extmarks in "traversal order" from a |charwise| region defined by
buffer positions (inclusive, 0-indexed |api-indexing|).
Region can be given as (row,col) tuples, or valid extmark ids (whose
positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1)
respectively, thus the following are equivalent:
nvim_buf_get_extmarks(0, my_ns, 0, -1, {})
nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {})
If end
is less than start
, traversal works backwards. (Useful with
limit
, to get the first marks prior to a given position.)
Example:
local a = vim.api
local pos = a.nvim_win_get_cursor(0)
local ns = a.nvim_create_namespace('my-plugin')
-- Create new extmark at line 1, column 1.
local m1 = a.nvim_buf_set_extmark(0, ns, 0, 0, {})
-- Create new extmark at line 3, column 1.
local m2 = a.nvim_buf_set_extmark(0, ns, 0, 2, {})
-- Get extmarks only from line 3.
local ms = a.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0}, {})
-- Get all marks in this buffer + namespace.
local all = a.nvim_buf_get_extmarks(0, ns, 0, -1, {})
print(vim.inspect(ms))
Parameters: ~
{buffer} Buffer handle, or 0 for current buffer
{ns_id} Namespace id from |nvim_create_namespace()|
{start} Start of range: a 0-indexed (row, col) or valid extmark id
(whose position defines the bound). |api-indexing|
{end} End of range (inclusive): a 0-indexed (row, col) or valid
extmark id (whose position defines the bound).
|api-indexing|
{opts} Optional parameters. Keys:
• limit: Maximum number of marks to return
• details Whether to include the details dict
Return: ~
List of [extmark_id, row, col] tuples in "traversal order".