Skip to content

Commit 776d6a8

Browse files
committed
nvim: add SetBufferText and Echo apis
1 parent d643d77 commit 776d6a8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

nvim/api_def.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ func SetBufferLines(buffer Buffer, start int, end int, strict bool, replacement
6363
name(nvim_buf_set_lines)
6464
}
6565

66+
// SetBufferText sets or replaces a range in the buffer.
67+
//
68+
// This is recommended over SetBufferLines when only modifying parts of a
69+
// line, as extmarks will be preserved on non-modified parts of the touched
70+
// lines.
71+
//
72+
// Indexing is zero-based and end-exclusive.
73+
//
74+
// To insert text at a given index, set `start` and `end` ranges to the same
75+
// index. To delete a range, set `replacement` to an array containing
76+
// an empty string, or simply an empty array.
77+
//
78+
// Prefer SetBufferLines when adding or deleting entire lines only.
79+
func SetBufferText(buffer Buffer, startRow, startCol, endRow, endCol int, replacement [][]byte) {
80+
name(nvim_buf_set_text)
81+
}
82+
6683
// BufferOffset returns the byte offset for a line.
6784
//
6885
// Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte.
@@ -690,6 +707,18 @@ func SetOption(name string, value interface{}) {
690707
name(nvim_set_option)
691708
}
692709

710+
// Echo echo a message.
711+
//
712+
// The chunks is a list of [text, hl_group] arrays, each representing a
713+
// text chunk with specified highlight. hl_group element can be omitted for no highlight.
714+
//
715+
// If history is true, add to |message-history|.
716+
//
717+
// The opts arg is optional parameters. Reserved for future use.
718+
func Echo(chunks []EchoChunk, history bool, opts map[string]interface{}) {
719+
name(nvim_echo)
720+
}
721+
693722
// WriteOut writes a message to vim output buffer. The string is split and
694723
// flushed after each newline. Incomplete lines are kept for writing later.
695724
func WriteOut(str string) {

0 commit comments

Comments
 (0)