Skip to content

nvim: add SetBufferText and Echo apis #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions nvim/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions nvim/api_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ func SetBufferLines(buffer Buffer, start int, end int, strict bool, replacement
name(nvim_buf_set_lines)
}

// SetBufferText sets or replaces a range in the buffer.
//
// This is recommended over SetBufferLines when only modifying parts of a
// line, as extmarks will be preserved on non-modified parts of the touched
// lines.
//
// Indexing is zero-based and end-exclusive.
//
// To insert text at a given index, set `start` and `end` ranges to the same
// index. To delete a range, set `replacement` to an array containing
// an empty string, or simply an empty array.
//
// Prefer SetBufferLines when adding or deleting entire lines only.
func SetBufferText(buffer Buffer, startRow, startCol, endRow, endCol int, replacement [][]byte) {
name(nvim_buf_set_text)
}

// BufferOffset returns the byte offset for a line.
//
// Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte.
Expand Down Expand Up @@ -690,6 +707,18 @@ func SetOption(name string, value interface{}) {
name(nvim_set_option)
}

// Echo echo a message.
//
// The chunks is a list of [text, hl_group] arrays, each representing a
// text chunk with specified highlight. hl_group element can be omitted for no highlight.
//
// If history is true, add to |message-history|.
//
// The opts arg is optional parameters. Reserved for future use.
func Echo(chunks []EchoChunk, history bool, opts map[string]interface{}) {
name(nvim_echo)
}

// WriteOut writes a message to vim output buffer. The string is split and
// flushed after each newline. Incomplete lines are kept for writing later.
func WriteOut(str string) {
Expand Down
1 change: 1 addition & 0 deletions nvim/api_tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ var nvimTypes = map[string]string{
"[]*UI": "Array",
"[]ExtMarks": "Array",
"[]VirtualTextChunk": "Array",
"[]EchoChunk": "Array",

"[2]int": "ArrayOf(Integer, 2)",
"[]*Mapping": "ArrayOf(Dictionary)",
Expand Down
Loading