import { nvim_buf_get_extmarks } from "https://deno.land/x/denops_std@v6.4.0/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: >lua vim.api.nvim_buf_get_extmarks(0, my_ns, 0, -1, {}) vim.api.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: >lua local api = vim.api local pos = api.nvim_win_get_cursor(0) local ns = api.nvim_create_namespace('my-plugin') -- Create new extmark at line 1, column 1. local m1 = api.nvim_buf_set_extmark(0, ns, 0, 0, {}) -- Create new extmark at line 3, column 1. local m2 = api.nvim_buf_set_extmark(0, ns, 2, 0, {}) -- Get extmarks only from line 3. local ms = api.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0}, {}) -- Get all marks in this buffer + namespace. local all = api.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()
or -1 for all namespaces - {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 - hl_name: Whether to include highlight group name instead of id, true if omitted - type: Filter marks by type: "highlight", "sign", "virt_text" and "virt_lines"
Return: List of [extmark_id, row, col] tuples in "traversal order".