aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/api.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/api.txt')
-rw-r--r--runtime/doc/api.txt116
1 files changed, 116 insertions, 0 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 93440f307c..5d30c10486 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -439,6 +439,42 @@ Example: create a float with scratch buffer: >
>
==============================================================================
+Extended marks *api-extended-marks*
+
+An extended mark (extmark) represents a buffer annotation that follows
+movements as the buffer changes. They could be used to represent cursors,
+folds, misspelled words, and anything else that needs to track a logical
+location in the buffer over time.
+
+Example:
+
+We will set an extmark at the first row and third column. As the API is zero-
+indexed, use row and column counts 0 and 2:
+
+`let g:mark_ns = nvim_create_namespace('myplugin')`
+`let g:mark_id = nvim_buf_set_extmark(0, g:mark_ns, 0, 0, 2)`
+
+Passing in id=0 creates a new mark and returns the id. we can look-up a mark
+by its id:
+
+`echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id)`
+=> [0, 2]
+
+Or we can look-up all marks in a buffer for our namespace (or by a range):
+`echo nvim_buf_get_extmarks(0, g:mark_ns, 0, -1, -1)`
+=> [[1, 0, 2]]
+
+Deleting the text all around an extended mark does not remove it. If you want
+to remove an extended mark, use the |nvim_buf_del_extmark()| function.
+
+The namespace ensures your plugin doesn't have to deal with extmarks created
+by another plugin.
+
+Mark positions changed by an edit will be restored on undo/redo. Creating and
+deleting marks doesn't count as a buffer change on itself, i e new undo
+states will not be created only for marks.
+
+==============================================================================
Global Functions *api-global*
nvim_command({command}) *nvim_command()*
@@ -1747,6 +1783,86 @@ nvim_buf_get_mark({buffer}, {name}) *nvim_buf_get_mark()*
Return: ~
(row, col) tuple
+ *nvim_buf_get_extmark_by_id()*
+nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id})
+ Returns position for a given extmark id
+
+ Parameters: ~
+ {buffer} The buffer handle
+ {namespace} a identifier returned previously with
+ nvim_create_namespace
+ {id} the extmark id
+
+ Return: ~
+ (row, col) tuple or empty list () if extmark id was absent
+
+ *nvim_buf_get_extmarks()*
+nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
+ List extmarks in a range (inclusive)
+
+ range ends can be specified as (row, col) tuples, as well as
+ extmark ids in the same namespace. In addition, 0 and -1 works
+ as shorthands for (0,0) and (-1,-1) respectively, so that all
+ marks in the buffer can be quieried as:
+
+ all_marks = nvim_buf_get_extmarks(0, my_ns, 0, -1, -1)
+
+ If end is a lower position than start, then the range will be
+ traversed backwards. This is mostly used with limited amount,
+ to be able to get the first marks prior to a given position.
+
+ Parameters: ~
+ {buffer} The buffer handle
+ {ns_id} An id returned previously from
+ nvim_create_namespace
+ {lower} One of: extmark id, (row, col) or 0, -1 for
+ buffer ends
+ {upper} One of: extmark id, (row, col) or 0, -1 for
+ buffer ends
+ {opts} additional options. Supports the keys:
+ • amount: Maximum number of marks to return •
+
+ Return: ~
+ [[nsmark_id, row, col], ...]
+
+ *nvim_buf_set_extmark()*
+nvim_buf_set_extmark({buffer}, {ns_id}, {id}, {line}, {col}, {opts})
+ Create or update an extmark at a position
+
+ If an invalid namespace is given, an error will be raised.
+
+ To create a new extmark, pass in id=0. The new extmark id will
+ be returned. To move an existing mark, pass in its id.
+
+ It is also allowed to create a new mark by passing in a
+ previously unused id, but the caller must then keep track of
+ existing and unused ids itself. This is mainly useful over
+ RPC, to avoid needing to wait for the return value.
+
+ Parameters: ~
+ {buffer} The buffer handle
+ {ns_id} a identifier returned previously with
+ nvim_create_namespace
+ {id} The extmark's id or 0 to create a new mark.
+ {row} The row to set the extmark to.
+ {col} The column to set the extmark to.
+ {opts} Optional parameters. Currently not used.
+
+ Return: ~
+ the id of the extmark.
+
+nvim_buf_del_extmark({buffer}, {ns_id}, {id}) *nvim_buf_del_extmark()*
+ Remove an extmark
+
+ Parameters: ~
+ {buffer} The buffer handle
+ {ns_id} a identifier returned previously with
+ nvim_create_namespace
+ {id} The extmarks's id
+
+ Return: ~
+ true on success, false if the extmark was not found.
+
*nvim_buf_add_highlight()*
nvim_buf_add_highlight({buffer}, {ns_id}, {hl_group}, {line},
{col_start}, {col_end})