Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/denops_std/function/vim/mod.ts>prop_add

๐Ÿ“š Standard module for denops.vim
Go to Latest
function prop_add
import { prop_add } from "https://deno.land/x/denops_std@v6.3.0/function/vim/mod.ts";

Attach a text property at position {lnum}, {col}. {col} is counted in bytes, use one for the first column. If {lnum} is invalid an error is given. If {col} is invalid an error is given.

{props} is a dictionary with these fields: type name of the text property type length length of text in bytes, can only be used for a property that does not continue in another line; can be zero end_lnum line number for the end of text (inclusive) end_col column just after the text; not used when "length" is present; when {col} and "end_col" are equal, and "end_lnum" is omitted or equal to {lnum}, this is a zero-width text property bufnr buffer to add the property to; when omitted the current buffer is used id user defined ID for the property; must be a number, should be positive; when using "text" then "id" must not be present and will be set automatically to a negative number; otherwise zero is used

text text to be displayed before {col}, or above/below the line if {col} is zero; prepend and/or append spaces for padding with highlighting; cannot be used with "length", "end_lnum" and "end_col" See virtual-text for more information.

text_align when "text" is present and {col} is zero; specifies where to display the text: after after the end of the line right right aligned in the window (unless the text wraps to the next screen line) below in the next screen line above just above the line When omitted "after" is used. Only one "right" property can fit in each line, if there are two or more these will go in a separate line (still right aligned). text_padding_left used when "text" is present and {col} is zero; padding between the end of the text line (leftmost column for "above" and "below") and the virtual text, not highlighted text_wrap when "text" is present and {col} is zero, specifies what happens if the text doesn't fit: wrap wrap the text to the next line truncate truncate the text to make it fit When omitted "truncate" is used. Note that this applies to the individual text property, the 'wrap' option sets the overall behavior All fields except "type" are optional.

It is an error when both "length" and "end_lnum" or "end_col" are given. Either use "length" or "end_col" for a property within one line, or use "end_lnum" and "end_col" for a property that spans more than one line. When neither "length" nor "end_col" are given the property will be zero-width. That means it will move with the text, as a kind of mark. One character will be highlighted, if the type specifies highlighting. The property can end exactly at the last character of the text, or just after it. In the last case, if text is appended to the line, the text property size will increase, also when the property type does not have "end_incl" set.

"type" will first be looked up in the buffer the property is added to. When not found, the global property types are used. If not found an error is given.

When "text" is used and the column is non-zero then this text will be displayed at the specified start location of the text property. The text of the buffer line will be shifted to make room. This is called "virtual text". When the column is zero the virtual text will appear above, after or below the buffer text. The "text_align" and "text_wrap" arguments determine how it is displayed. To separate the virtual text from the buffer text prepend and/or append spaces to the "text" field or use the "text_padding_left" value.

Make sure to use a highlight that makes clear to the user that this is virtual text, otherwise it will be very confusing that the text cannot be edited. When using "above" you need to make clear this text belongs to the text line below it, when using "below" you need to make sure it belongs to the text line above it.

The text will be displayed but it is not part of the actual buffer line, the cursor cannot be placed on it. A mouse click in the text will move the cursor to the first character after the text, or the last character of the line. Any Tab and other control character in the text will be changed to a space (Rationale: otherwise the size of the text is difficult to compute). A negative "id" will be chosen and is returned.

Before text properties with text were supported it was possible to use a negative "id", even though this was very rare. Now that negative "id"s are reserved for text properties with text an error is given when using a negative "id". When a text property with text already exists using a negative "id" results in E1293 . If a negative "id" was used and later a text property with text is added results in E1339 .

Can also be used as a method:

GetLnum()->prop_add(col, props)

Parameters

denops: Denops
lnum: unknown
col: unknown
props: unknown

Returns

Promise<void>