nvim

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 15 Imported by: 106

Documentation

Overview

Package nvim implements a Nvim client.

See the ./plugin package for additional functionality required for writing Nvim plugins.

The Nvim type implements the client. To connect to a running instance of Nvim, create a *Nvim value using the Dial or NewChildProcess functions. Call the Close() method to release the resources used by the client.

Use the Batch type to execute a sequence of Nvim API calls atomically. The Nvim NewBatch method creates new *Batch values.

Example

This program lists the names of the Nvim buffers when run from an Nvim terminal. It dials to Nvim using the $NVIM_LISTEN_ADDRESS and fetches all of the buffer names in one call using a batch.

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/neovim/go-client/nvim"
)

func main() {
	// Get address from environment variable set by Nvim.
	addr := os.Getenv("NVIM_LISTEN_ADDRESS")
	if addr == "" {
		log.Fatal("NVIM_LISTEN_ADDRESS not set")
	}

	// Dial with default options.
	v, err := nvim.Dial(addr)
	if err != nil {
		log.Fatal(err)
	}

	// Cleanup on return.
	defer v.Close()

	bufs, err := v.Buffers()
	if err != nil {
		log.Fatal(err)
	}

	// Get the names using a single atomic call to Nvim.
	names := make([]string, len(bufs))
	b := v.NewBatch()
	for i, buf := range bufs {
		b.BufferName(buf, &names[i])
	}
	if err := b.Execute(); err != nil {
		log.Fatal(err)
	}

	// Print the names.
	for _, name := range names {
		fmt.Println(name)
	}
}
Output:

Index

Examples

Constants

View Source
const (
	// EventBufChangedtick event name of "nvim_buf_changedtick_event".
	EventBufChangedtick = "nvim_buf_changedtick_event"

	// EventBufLines event name of "nvim_buf_lines_event".
	EventBufLines = "nvim_buf_lines_event"

	// EventBufDetach event name of "nvim_buf_detach_event".
	EventBufDetach = "nvim_buf_detach_event"
)
View Source
const (
	// ClientAttributeKeyWebsite Website of client (for instance github repository).
	ClientAttributeKeyWebsite = "website"

	// ClientAttributeKeyLicense Informal description of the license, such as "Apache 2", "GPLv3" or "MIT".
	ClientAttributeKeyLicense = "license"

	ClientoAttributeKeyLogo = "logo"
)
View Source
const (
	// BorderStyleNone is the no border. This is the default.
	BorderStyleNone = BorderStyle("none")
	// BorderStyleSingle is a single line box.
	BorderStyleSingle = BorderStyle("single")
	// BorderStyleDouble a double line box.
	BorderStyleDouble = BorderStyle("double")
	// BorderStyleRounded like "single", but with rounded corners ("╭" etc.).
	BorderStyleRounded = BorderStyle("rounded")
	// BorderStyleSolid adds padding by a single whitespace cell.
	BorderStyleSolid = BorderStyle("solid")
	// BorderStyleShadow a drop shadow effect by blending with the background.
	BorderStyleShadow = BorderStyle("shadow")
)

list of BorderStyle.

View Source
const (
	GlobalScope = OptionValueScope("global")
	LocalScope  = OptionValueScope("local")
)

list of OptionValueScope.

View Source
const BinaryName = "nvim"

BinaryName is the name of default nvim binary name.

Variables

This section is empty.

Functions

func NewBufferReader

func NewBufferReader(v *Nvim, b Buffer) io.Reader

NewBufferReader returns a reader for the specified buffer. If b = 0, then the current buffer is used.

Types

type Batch

type Batch struct {
	// contains filtered or unexported fields
}

Batch collects API function calls and executes them atomically.

The function calls in the batch are executed without processing requests from other clients, redrawing or allowing user interaction in between. Functions that could fire autocommands or do event processing still might do so. For instance invoking the :sleep command might call timer callbacks.

Call the Execute() method to execute the commands in the batch. Result parameters in the API function calls are set in the call to Execute. If an API function call fails, all results proceeding the call are set and a *BatchError is returned.

A Batch does not support concurrent calls by the application.

func (*Batch) APIInfo

func (b *Batch) APIInfo(apiInfo *[]interface{})

APIInfo returns a 2-tuple (Array), where item 0 is the current channel id and item 1 is the "api-metadata" map (Dictionary).

Returns 2-tuple [{channel-id}, {api-metadata}].

func (*Batch) AddBufferHighlight

func (b *Batch) AddBufferHighlight(buffer Buffer, srcID int, hlGroup string, line int, startCol int, endCol int, id *int)

AddBufferHighlight adds a highlight to buffer.

IT useful for plugins that dynamically generate highlights to a buffer like a semantic highlighter or linter.

The function adds a single highlight to a buffer. Unlike |matchaddpos()| vim function, highlights follow changes to line numbering as lines are inserted/removed above the highlighted line, like signs and marks do.

Namespaces are used for batch deletion/updating of a set of highlights. To create a namespace, use CreateNamespace which returns a namespace id. Pass it in to this function as nsID to add highlights to the namespace. All highlights in the same namespace can then be cleared with single call to ClearBufferNamespace. If the highlight never will be deleted by an API call, pass nsID = -1.

As a shorthand, "srcID = 0" can be used to create a new namespace for the highlight, the allocated id is then returned.

If hlGroup arg is the empty string, no highlight is added, but a new `nsID` is still returned. This is supported for backwards compatibility, new code should use CreateNamespaceto create a new empty namespace.

func (*Batch) AddBufferUserCommand added in v1.2.1

func (b *Batch) AddBufferUserCommand(buffer Buffer, name string, command UserCommand, opts map[string]interface{})

AddBufferUserCommand create a new user command |user-commands| in the given buffer.

Only commands created with |:command-buffer| or this function can be deleted with this function.

func (*Batch) AddUserCommand added in v1.2.1

func (b *Batch) AddUserCommand(name string, command UserCommand, opts map[string]interface{})

AddUserCommand create a new user command.

name is name of the new user command. Must begin with an uppercase letter.

command is replacement command to execute when this user command is executed. When called from Lua, the command can also be a Lua function.

opts is optional command attributes. See |command-attributes| for more details.

To use boolean attributes (such as |:command-bang| or |:command-bar|) set the value to "true". In addition to the string options listed in |:command-complete|, the "complete" key also accepts a Lua function which works like the "customlist" completion mode |:command-completion-customlist|.

desc (string)

Used for listing the command when a Lua function is used for {command}.

force (bool, default true)

Override any previous definition.

func (*Batch) AllOptionsInfo added in v1.1.4

func (b *Batch) AllOptionsInfo(opinfo *OptionInfo)

AllOptionsInfo gets the option information for all options.

The dictionary has the full option names as keys and option metadata dictionaries as detailed at OptionInfo.

Resulting map has keys:

name

Name of the option (like "filetype").

shortname

Shortened name of the option (like "ft").

type

type of option ("string", "number" or "boolean").

default

The default value for the option.

was_set

Whether the option was set.

last_set_sid

Last set script id (if any).

last_set_linenr

line number where option was set.

last_set_chan

Channel where option was set (0 for local).

scope

One of "global", "win", or "buf".

global_local

Whether win or buf option has a global value.

commalist

List of comma separated values.

flaglist

List of single char flags.

func (*Batch) AttachBuffer

func (b *Batch) AttachBuffer(buffer Buffer, sendBuffer bool, opts map[string]interface{}, attached *bool)

AttachBuffer activates buffer-update events on a channel.

The buffer is specific Buffer, or 0 for current buffer.

If sendBuffer is true, initial notification should contain the whole buffer. If false, the first notification will be a "nvim_buf_lines_event". Otherwise, the first notification will be a "nvim_buf_changedtick_event".

Returns whether the updates couldn't be enabled because the buffer isn't loaded or opts contained an invalid key.

func (*Batch) AttachUI

func (b *Batch) AttachUI(width int, height int, options map[string]interface{})

AttachUI registers the client as a remote UI. After this method is called, the client will receive redraw notifications.

:help rpc-remote-ui

The redraw notification method has variadic arguments. Register a handler for the method like this:

v.RegisterHandler("redraw", func(updates ...[]interface{}) {
    for _, update := range updates {
        // handle update
    }
})

func (*Batch) BufferChangedTick

func (b *Batch) BufferChangedTick(buffer Buffer, changedtick *int)

BufferChangedTick gets a changed tick of a buffer.

func (*Batch) BufferCommands

func (b *Batch) BufferCommands(buffer Buffer, opts map[string]interface{}, result *map[string]*Command)

BufferCommands gets a map of buffer-local user-commands.

opts is optional parameters. Currently not used.

func (*Batch) BufferExtmarkByID added in v1.0.2

func (b *Batch) BufferExtmarkByID(buffer Buffer, nsID int, id int, opt map[string]interface{}, pos *[]int)

BufferExtmarkByID beturns position for a given extmark id.

opts is optional parameters.

details

Whether to include the details dict. bool type.

func (*Batch) BufferExtmarks added in v1.0.2

func (b *Batch) BufferExtmarks(buffer Buffer, nsID int, start interface{}, end interface{}, opt map[string]interface{}, marks *[]ExtMark)

BufferExtmarks gets extmarks in "traversal order" from a |charwise| region defined by buffer positions (inclusive, 0-indexed).

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:

BufferExtmarks(0, myNS, 0, -1, {})
BufferExtmarks(0, myNS, [0,0], [-1,-1], {})

If end arg is less than start arg, traversal works backwards. It useful with limit arg, to get the first marks prior to a given position.

The start and end args is start or end of range, given as (row, col), or valid extmark id whose position defines the bound.

opts is optional parameters.

limit

Maximum number of marks to return. int type.

details

Whether to include the details dict. bool type.

func (*Batch) BufferKeyMap

func (b *Batch) BufferKeyMap(buffer Buffer, mode string, result *[]*Mapping)

BufferKeymap gets a list of buffer-local mapping definitions.

The mode short-name ("n", "i", "v", ...).

func (*Batch) BufferLineCount

func (b *Batch) BufferLineCount(buffer Buffer, count *int)

BufferLineCount gets the buffer line count.

The buffer arg is specific Buffer, or 0 for current buffer.

The returns line count, or 0 for unloaded buffer.

func (*Batch) BufferLines

func (b *Batch) BufferLines(buffer Buffer, start int, end int, strictIndexing bool, lines *[][]byte)

BufferLines gets a line-range from the buffer.

Indexing is zero-based, end-exclusive. Negative indices are interpreted as length+1+index: -1 refers to the index past the end. So to get the last element use start=-2 and end=-1.

Out-of-bounds indices are clamped to the nearest valid value, unless strictIndexing is set.

func (*Batch) BufferMark

func (b *Batch) BufferMark(buffer Buffer, name string, pos *[2]int)

BufferMark return a tuple (row,col) representing the position of the named mark.

Marks are (1,0)-indexed.

func (*Batch) BufferName

func (b *Batch) BufferName(buffer Buffer, name *string)

BufferName gets the full file name for the buffer.

func (*Batch) BufferNumber deprecated

func (b *Batch) BufferNumber(buffer Buffer, number *int)

BufferNumber gets a buffer's number.

Deprecated: Use int(buffer) to get the buffer's number as an integer.

func (*Batch) BufferOffset

func (b *Batch) BufferOffset(buffer Buffer, index int, offset *int)

BufferOffset returns the byte offset of a line (0-indexed).

Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte. "fileformat" and "fileencoding" are ignored.

The line index just after the last line gives the total byte-count of the buffer. A final EOL byte is counted if it would be written, see ":help eol".

Unlike "line2byte" vim function, throws error for out-of-bounds indexing.

If Buffer is unloaded buffer, returns -1.

func (*Batch) BufferOption

func (b *Batch) BufferOption(buffer Buffer, name string, result interface{})

BufferOption gets a buffer option value.

func (*Batch) BufferVar

func (b *Batch) BufferVar(buffer Buffer, name string, result interface{})

BufferVar gets a buffer-scoped (b:) variable.

func (*Batch) Buffers

func (b *Batch) Buffers(buffers *[]Buffer)

Buffers gets the current list of buffer handles.

Includes unlisted (unloaded/deleted) buffers, like ":ls!". Use IsBufferLoaded to check if a buffer is loaded.

func (*Batch) Call

func (b *Batch) Call(fname string, result interface{}, args ...interface{})

Call calls a VimL function with the given arguments.

Fails with VimL error, does not update "v:errmsg".

fn is Function to call.

args is function arguments packed in an array.

result is the result of the function call.

func (*Batch) CallDict

func (b *Batch) CallDict(dict []interface{}, fname string, result interface{}, args ...interface{})

CallDict calls a VimL dictionary function with the given arguments.

Fails with VimL error, does not update "v:errmsg".

dict is dictionary, or string evaluating to a VimL "self" dict.

fn is name of the function defined on the VimL dict.

args is Function arguments packed in an Array.

result is the result of the function call.

func (*Batch) ChannelInfo

func (b *Batch) ChannelInfo(channelID int, channel *Channel)

ChannelInfo get information about a channel.

Rreturns Dictionary describing a channel, with these keys:

stream

The stream underlying the channel. value are:

stdio

stdin and stdout of this Nvim instance.

stderr

stderr of this Nvim instance.

socket

TCP/IP socket or named pipe.

job

job with communication over its stdio.

mode

How data received on the channel is interpreted. value are:

bytes

send and receive raw bytes.

terminal

A terminal instance interprets ASCII sequences.

rpc

RPC communication on the channel is active.

pty

Name of pseudoterminal, if one is used (optional). On a POSIX system, this will be a device path like /dev/pts/1. Even if the name is unknown, the key will still be present to indicate a pty is used. This is currently the case when using winpty on windows.

buffer

Buffer with connected |terminal| instance (optional).

client

Information about the client on the other end of the RPC channel, if it has added it using SetClientInfo() (optional).

func (*Batch) Channels

func (b *Batch) Channels(channels *[]*Channel)

Channels get information about all open channels.

func (*Batch) ClearBufferHighlight deprecated

func (b *Batch) ClearBufferHighlight(buffer Buffer, srcID int, startLine int, endLine int)

ClearBufferHighlight clears highlights from a given source group and a range of lines.

To clear a source group in the entire buffer, pass in 1 and -1 to startLine and endLine respectively.

The lineStart and lineEnd parameters specify the range of lines to clear. The end of range is exclusive. Specify -1 to clear to the end of the file.

Deprecated: Use ClearBufferNamespace instead.

func (*Batch) ClearBufferNamespace

func (b *Batch) ClearBufferNamespace(buffer Buffer, nsID int, lineStart int, lineEnd int)

ClearBufferNamespace clears namespaced objects (highlights, extmarks, virtual text) from a region. Lines are 0-indexed.

To clear the namespace in the entire buffer, specify line_start=0 and line_end=-1.

func (*Batch) CloseWindow

func (b *Batch) CloseWindow(window Window, force bool)

CloseWindow Closes the window (like ":close" with a window-ID).

func (*Batch) ColorByName

func (b *Batch) ColorByName(name string, color *int)

ColorByName Returns the 24-bit RGB value of a ColorMap color name or "#rrggbb" hexadecimal string.

Example:

ColorByName("Pink")
ColorByName("#cbcbcb")

func (*Batch) ColorMap

func (b *Batch) ColorMap(colorMap *map[string]int)

ColorMap returns a map of color names and RGB values.

Keys are color names (e.g. "Aqua") and values are 24-bit RGB color values (e.g. 65535).

The returns map is color names and RGB values.

func (*Batch) Command

func (b *Batch) Command(cmd string)

Command executes an ex-command.

When fails with VimL error, does not update "v:errmsg".

func (*Batch) CommandOutput deprecated

func (b *Batch) CommandOutput(cmd string, out *string)

CommandOutput executes a single ex command and returns the output.

Deprecated: Use Exec instead.

func (*Batch) Commands

func (b *Batch) Commands(opts map[string]interface{}, commands *map[string]*Command)

Commands gets a map of global (non-buffer-local) Ex commands. Currently only user-commands are supported, not builtin Ex commands.

opts is optional parameters. Currently only supports:

{"builtin":false}

func (*Batch) Context added in v1.0.2

func (b *Batch) Context(opts map[string][]string, context *map[string]interface{})

Context gets a map of the current editor state. This API still under development.

The opts arg is optional parameters. Key is "types".

List of context-types to gather, or empty for "all" context.

regs
jumps
bufs
gvars
funcs
sfuncs

func (*Batch) CreateBuffer

func (b *Batch) CreateBuffer(listed bool, scratch bool, buffer *Buffer)

CreateBuffer creates a new, empty, unnamed buffer.

listed is sets buflisted buffer opttion. If false, sets "nobuflisted".

scratch is creates a "throwaway" for temporary work (always 'nomodified').

bufhidden=hide
buftype=nofile
noswapfile
nomodeline

func (*Batch) CreateNamespace

func (b *Batch) CreateNamespace(name string, nsID *int)

CreateNamespace creates a new namespace, or gets an existing one.

Namespaces are used for buffer highlights and virtual text, see AddBufferHighlight and SetBufferVirtualText.

Namespaces can be named or anonymous. If "name" matches an existing namespace, the associated id is returned. If "name" is an empty string a new, anonymous namespace is created.

The returns the namespace ID.

func (*Batch) CurrentBuffer

func (b *Batch) CurrentBuffer(buffer *Buffer)

CurrentBuffer gets the current buffer.

func (*Batch) CurrentLine

func (b *Batch) CurrentLine(line *[]byte)

CurrentLine gets the current line.

func (*Batch) CurrentTabpage

func (b *Batch) CurrentTabpage(tabpage *Tabpage)

CurrentTabpage gets the current tabpage.

func (*Batch) CurrentWindow

func (b *Batch) CurrentWindow(window *Window)

CurrentWindow gets the current window.

func (*Batch) DeleteBuffer added in v1.1.4

func (b *Batch) DeleteBuffer(buffer Buffer, opts map[string]bool)

DeleteBuffer deletes the buffer. See

:help :bwipeout

The opts args is optional parameters.

force

Force deletion and ignore unsaved changes. bool type.

unload

Unloaded only, do not delete. See |help :bunload|. bool type.

func (*Batch) DeleteBufferExtmark added in v1.0.2

func (b *Batch) DeleteBufferExtmark(buffer Buffer, nsID int, extmarkID int, deleted *bool)

DeleteBufferExtmark removes an extmark.

THe returns whether the extmark was found.

func (*Batch) DeleteBufferKeyMap added in v1.0.1

func (b *Batch) DeleteBufferKeyMap(buffer Buffer, mode string, lhs string)

DeleteBufferKeyMap unmaps a buffer-local mapping for the given mode.

See:

:help nvim_del_keymap()

func (*Batch) DeleteBufferMark added in v1.2.0

func (b *Batch) DeleteBufferMark(buffer Buffer, name string, deleted *bool)

DeleteBufferMark deletes a named mark in the buffer. See |help mark-motions|.

func (*Batch) DeleteBufferUserCommand added in v1.2.1

func (b *Batch) DeleteBufferUserCommand(buffer Buffer, name string)

DeleteBufferUserCommand create a new user command |user-commands| in the given buffer.

Only commands created with |:command-buffer| or this function can be deleted with this function.

func (*Batch) DeleteBufferVar

func (b *Batch) DeleteBufferVar(buffer Buffer, name string)

DeleteBufferVar removes a buffer-scoped (b:) variable.

func (*Batch) DeleteCurrentLine

func (b *Batch) DeleteCurrentLine()

DeleteCurrentLine deletes the current line.

func (*Batch) DeleteKeyMap added in v1.0.1

func (b *Batch) DeleteKeyMap(mode string, lhs string)

DeleteKeyMap unmaps a global mapping for the given mode.

To unmap a buffer-local mapping, use DeleteBufferKeyMap().

See:

:help nvim_set_keymap()

func (*Batch) DeleteMark added in v1.2.0

func (b *Batch) DeleteMark(name string, deleted *bool)

DeleteMark deletes a uppercase/file named mark. See |help mark-motions|.

func (*Batch) DeleteTabpageVar

func (b *Batch) DeleteTabpageVar(tabpage Tabpage, name string)

DeleteTabpageVar removes a tab-scoped (t:) variable.

func (*Batch) DeleteUserCommand added in v1.2.1

func (b *Batch) DeleteUserCommand(name string)

DeleteUserCommand delete a user-defined command.

func (*Batch) DeleteVar

func (b *Batch) DeleteVar(name string)

DeleteVar removes a global (g:) variable.

func (*Batch) DeleteWindowVar

func (b *Batch) DeleteWindowVar(window Window, name string)

DeleteWindowVar removes a window-scoped (w:) variable.

func (*Batch) DetachBuffer

func (b *Batch) DetachBuffer(buffer Buffer, detached *bool)

DetachBuffer deactivate updates from this buffer to the current channel.

Returns whether the updates couldn't be disabled because the buffer isn't loaded.

func (*Batch) DetachUI

func (b *Batch) DetachUI()

DetachUI unregisters the client as a remote UI.

func (*Batch) Echo added in v1.1.6

func (b *Batch) Echo(chunks []TextChunk, history bool, opts map[string]interface{})

Echo echo a message.

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".

opts is optional parameters. Reserved for future use.

func (*Batch) Eval

func (b *Batch) Eval(expr string, result interface{})

Eval evaluates a VimL expression.

Dictionaries and Lists are recursively expanded.

Fails with VimL error, does not update "v:errmsg".

expr is VimL expression string.

:help expression

func (*Batch) EvalStatusLine added in v1.2.0

func (b *Batch) EvalStatusLine(name string, opts map[string]interface{}, statusline *map[string]interface{})

EvalStatusLine evaluates statusline string.

opts optional parameters.

winid (int)

Window ID of the window to use as context for statusline.

maxwidth (int)

Maximum width of statusline.

fillchar (string)

Character to fill blank spaces in the statusline (see 'fillchars').

highlights (bool)

Return highlight information.

use_tabline (bool)

Evaluate tabline instead of statusline. When true, {winid} is ignored.

func (*Batch) Exec added in v1.0.2

func (b *Batch) Exec(src string, output bool, out *string)

Exec executes Vimscript (multiline block of Ex-commands), like anonymous source.

Unlike Command, this function supports heredocs, script-scope (s:), etc.

When fails with VimL error, does not update "v:errmsg".

func (*Batch) ExecLua added in v1.0.2

func (b *Batch) ExecLua(code string, result interface{}, args ...interface{})

ExecLua execute Lua code.

Parameters are available as `...` inside the chunk. The chunk can return a value.

Only statements are executed. To evaluate an expression, prefix it with `return` is "return my_function(...)".

code is Lua code to execute.

args is arguments to the code.

The returned result value of Lua code if present or nil.

func (*Batch) Execute

func (b *Batch) Execute() error

Execute executes the API function calls in the batch.

func (*Batch) ExecuteLua deprecated

func (b *Batch) ExecuteLua(code string, result interface{}, args ...interface{})

ExecuteLua executes a Lua block.

Deprecated: Use ExecLua instead.

func (*Batch) FeedKeys

func (b *Batch) FeedKeys(keys string, mode string, escapeCSI bool)

FeedKeys input-keys to Nvim, subject to various quirks controlled by "mode" flags. Unlike Input, this is a blocking call.

This function does not fail, but updates "v:errmsg".

If need to input sequences like <C-o> use ReplaceTermcodes to replace the termcodes and then pass the resulting string to nvim_feedkeys. You'll also want to enable escape_csi.

mode is following character flags:

m

Remap keys. This is default.

n

Do not remap keys.

t

Handle keys as if typed; otherwise they are handled as if coming from a mapping. This matters for undo, opening folds, etc.

escapeCSI is whether the escape K_SPECIAL/CSI bytes in keys.

func (*Batch) HLByID

func (b *Batch) HLByID(hlID int, rgb bool, highlight *HLAttrs)

HLByID gets a highlight definition by name.

hlID is the highlight id as returned by HLIDByName.

rgb is the whether the export RGB colors.

The returned highlight is the highlight definition.

func (*Batch) HLByName

func (b *Batch) HLByName(name string, rgb bool, highlight *HLAttrs)

HLByName gets a highlight definition by id.

name is Highlight group name.

rgb is whether the export RGB colors.

The returned highlight is the highlight definition.

func (*Batch) HLIDByName added in v1.0.2

func (b *Batch) HLIDByName(name string, hlID *int)

HLIDByName gets a highlight group by name.

name is the Highlight group name.

The returns hlID is the highlight id.

This function similar to HLByID, but allocates a new ID if not present.

func (*Batch) HideWindow added in v1.2.0

func (b *Batch) HideWindow(window Window)

HideWindow closes the window and hide the buffer it contains (like ":hide" with a windowID).

Like ":hide" the buffer becomes hidden unless another window is editing it, or "bufhidden" is "unload", "delete" or "wipe" as opposed to ":close" or CloseWindow, which will close the buffer.

func (*Batch) Input

func (b *Batch) Input(keys string, written *int)

Input queues raw user-input.

Unlike FeedKeys, this uses a low-level input buffer and the call is non-blocking (input is processed asynchronously by the eventloop).

This function does not fail but updates "v:errmsg".

keys is to be typed.

Note: "keycodes" like "<CR>" are translated, so "<" is special. To input a literal "<", send "<LT>".

Note: For mouse events use InputMouse. The pseudokey form "<LeftMouse><col,row>" is deprecated.

The returned written is number of bytes actually written (can be fewer than requested if the buffer becomes full).

func (*Batch) InputMouse

func (b *Batch) InputMouse(button string, action string, modifier string, grid int, row int, col int)

InputMouse Send mouse event from GUI.

This API is non-blocking. It does not wait on any result, but queues the event to be processed soon by the event loop.

button is mouse button. One of

left
right
middle
wheel

action is for ordinary buttons. One of

press
drag
release

For the wheel, One of

up
down
left
right

modifier is string of modifiers each represented by a single char. The same specifiers are used as for a key press, except that the "-" separator is optional, so "C-A-", "c-a" and "CA" can all be used to specify "Ctrl+Alt+Click".

grid is grid number if the client uses "ui-multigrid", else 0.

row is mouse row-position (zero-based, like redraw events).

col is mouse column-position (zero-based, like redraw events).

func (*Batch) IsBufferLoaded

func (b *Batch) IsBufferLoaded(buffer Buffer, loaded *bool)

IsBufferLoaded checks if a buffer is valid and loaded.

See |help api-buffer| for more info about unloaded buffers.

func (*Batch) IsBufferValid

func (b *Batch) IsBufferValid(buffer Buffer, valied *bool)

IsBufferValid returns whether the buffer is valid.

Note: Even if a buffer is valid it may have been unloaded. See |help api-buffer| for more info about unloaded buffers.

func (*Batch) IsTabpageValid

func (b *Batch) IsTabpageValid(tabpage Tabpage, valid *bool)

IsTabpageValid checks if a tabpage is valid.

func (*Batch) IsWindowValid

func (b *Batch) IsWindowValid(window Window, valid *bool)

IsWindowValid checks if a window is valid.

func (*Batch) KeyMap

func (b *Batch) KeyMap(mode string, maps *[]*Mapping)

KeyMap gets a list of global (non-buffer-local) |mapping| definitions.

The mode arg is the mode short-name, like "n", "i", "v" or etc.

func (*Batch) LoadContext added in v1.0.2

func (b *Batch) LoadContext(context map[string]interface{}, result interface{})

LoadContext Sets the current editor state from the given context map.

func (*Batch) Mark added in v1.2.0

func (b *Batch) Mark(name string, opts map[string]interface{}, mark *Mark)

Mark returns a tuple (row, col, buffer, buffername) representing the position of the uppercase/file named mark. See |help mark-motions|.

opts is optional parameters. Reserved for future use.

func (*Batch) Mode

func (b *Batch) Mode(mode *Mode)

Mode gets the current mode.

|mode()| "blocking" is true if Nvim is waiting for input.

func (*Batch) Namespaces

func (b *Batch) Namespaces(namespaces *map[string]int)

Namespaces gets existing, non-anonymous namespaces.

The return dict that maps from names to namespace ids.

func (*Batch) Notify added in v1.2.0

func (b *Batch) Notify(msg string, logLevel LogLevel, opts map[string]interface{})

Notify the user with a message.

Relays the call to vim.notify. By default forwards your message in the echo area but can be overriden to trigger desktop notifications.

msg is message to display to the user.

logLevel is the LogLevel.

opts is reserved for future use.

func (*Batch) OpenTerm added in v1.2.0

func (b *Batch) OpenTerm(buffer Buffer, opts map[string]interface{}, channel *int)

OpenTerm opens a terminal instance in a buffer.

By default (and currently the only option) the terminal will not be connected to an external process. Instead, input send on the channel will be echoed directly by the terminal. This is useful to disply ANSI terminal sequences returned as part of a rpc message, or similar.

Note that to directly initiate the terminal using the right size, display the buffer in a configured window before calling this. For instance, for a floating display, first create an empty buffer using CreateBuffer, then display it using OpenWindow, and then call this function. Then "nvim_chan_send" cal be called immediately to process sequences in a virtual terminal having the intended size.

buffer is the buffer to use (expected to be empty).

opts is optional parameters. Reserved for future use.

func (*Batch) OpenWindow

func (b *Batch) OpenWindow(buffer Buffer, enter bool, config *WindowConfig, window *Window)

OpenWindow open a new window.

Currently this is used to open floating and external windows. Floats are windows that are drawn above the split layout, at some anchor position in some other window. Floats can be drawn internally or by external GUI with the "ui-multigrid" extension. External windows are only supported with multigrid GUIs, and are displayed as separate top-level windows.

For a general overview of floats, see

:help api-floatwin

Exactly one of "external" and "relative" must be specified. The "width" and "height" of the new window must be specified.

With relative=editor (row=0,col=0) refers to the top-left corner of the screen-grid and (row=Lines-1,col=Columns-1) refers to the bottom-right corner. Fractional values are allowed, but the builtin implementation (used by non-multigrid UIs) will always round down to nearest integer.

Out-of-bounds values, and configurations that make the float not fit inside the main editor, are allowed. The builtin implementation truncates values so floats are fully within the main screen grid. External GUIs could let floats hover outside of the main window like a tooltip, but this should not be used to specify arbitrary WM screen positions.

func (*Batch) Option

func (b *Batch) Option(name string, result interface{})

Option gets an option value string.

func (*Batch) OptionInfo added in v1.1.4

func (b *Batch) OptionInfo(name string, opinfo *OptionInfo)

OptionInfo gets the option information for one option.

Resulting map has keys:

name

Name of the option (like "filetype").

shortname

Shortened name of the option (like "ft").

type

type of option ("string", "number" or "boolean").

default

The default value for the option.

was_set

Whether the option was set.

last_set_sid

Last set script id (if any).

last_set_linenr

line number where option was set.

last_set_chan

Channel where option was set (0 for local).

scope

One of "global", "win", or "buf".

global_local

Whether win or buf option has a global value.

commalist

List of comma separated values.

flaglist

List of single char flags.

func (*Batch) OptionValue added in v1.2.1

func (b *Batch) OptionValue(name string, opts map[string]OptionValueScope, result interface{})

OptionValue gets the value of an option.

The behavior of this function matches that of |:set|: the local value of an option is returned if it exists; otherwise, the global value is returned. Local values always correspond to the current buffer or window.

To get a buffer-local or window-local option for a specific buffer or window, use BufferOption() or WindowOption().

name is the option name.

opts is the Optional parameters.

scope

Analogous to |:setglobal| and |:setlocal|, respectively.

func (*Batch) ParseExpression

func (b *Batch) ParseExpression(expr string, flags string, highlight bool, expression *map[string]interface{})

ParseExpression parse a VimL expression.

func (*Batch) Paste added in v1.0.2

func (b *Batch) Paste(data string, crlf bool, phase int, state *bool)

Paste pastes at cursor, in any mode.

Invokes the "vim.paste" handler, which handles each mode appropriately. Sets redo/undo. Faster than Input(). Lines break at LF ("\n").

Errors ("nomodifiable", "vim.paste()" "failure" ...) are reflected in `err` but do not affect the return value (which is strictly decided by `vim.paste()`).

On error, subsequent calls are ignored ("drained") until the next paste is initiated (phase 1 or -1).

data

multiline input. May be binary (containing NUL bytes).

crlf

also break lines at CR and CRLF.

phase

-1 is paste in a single call (i.e. without streaming).

To stream a paste, call Paste sequentially with these phase args:

1

starts the paste (exactly once)

2

continues the paste (zero or more times)

3

ends the paste (exactly once)

The returned boolean state is:

true

Client may continue pasting.

false

Client must cancel the paste.

func (*Batch) Proc

func (b *Batch) Proc(pid int, process *Process)

Proc gets info describing process "pid".

func (*Batch) ProcChildren

func (b *Batch) ProcChildren(pid int, processes *[]uint)

ProcChildren gets the immediate children of process `pid`.

func (*Batch) Put added in v1.0.2

func (b *Batch) Put(lines []string, typ string, after bool, follow bool)

Put puts text at cursor, in any mode.

Compare :put and p which are always linewise.

lines is readfile() style list of lines.

typ is edit behavior: any getregtype() result, or:

 b
blockwise-visual mode (may include width, e.g. "b3")
 c
characterwise mode
 l
linewise mode
 ""

guess by contents, see |setreg()|.

After is insert after cursor (like `p`), or before (like `P`).

follow arg is place cursor at end of inserted text.

func (*Batch) ReplaceTermcodes

func (b *Batch) ReplaceTermcodes(str string, fromPart bool, doLT bool, special bool, input *string)

ReplaceTermcodes replaces terminal codes and "keycodes" (<CR>, <Esc>, ...) in a string with the internal representation.

str is string to be converted.

fromPart is legacy Vim parameter. Usually true.

doLT is also translate <lt>. Ignored if "special" is false.

special is replace "keycodes", e.g. "<CR>" becomes a "\n" char.

The returned sequences are Nvim's internal representation of keys, for example:

<esc> -> '\x1b'
<cr>  -> '\r'
<c-l> -> '\x0c'
<up>  -> '\x80ku'

The returned sequences can be used as input to feedkeys.

func (*Batch) Request

func (b *Batch) Request(procedure string, result interface{}, args ...interface{})

Request makes a any RPC request atomically as a part of batch request.

func (*Batch) RuntimeFiles added in v1.1.1

func (b *Batch) RuntimeFiles(name string, all bool, files *[]string)

RuntimeFiles find files in runtime directories.

name is can contain wildcards.

For example,

RuntimeFiles("colors/*.vim", true)

will return all color scheme files.

Always use forward slashes (/) in the search pattern for subdirectories regardless of platform.

It is not an error to not find any files, returned an empty array.

To find a directory, name must end with a forward slash, like "rplugin/python/". Without the slash it would instead look for an ordinary file called "rplugin/python".

all is whether to return all matches or only the first.

func (*Batch) RuntimePaths

func (b *Batch) RuntimePaths(paths *[]string)

RuntimePaths gets the paths contained in "runtimepath".

func (*Batch) SelectPopupmenuItem

func (b *Batch) SelectPopupmenuItem(item int, insert bool, finish bool, opts map[string]interface{})

SelectPopupmenuItem selects an item in the completion popupmenu.

If |ins-completion| is not active this API call is silently ignored. Useful for an external UI using |ui-popupmenu| to control the popupmenu with the mouse. Can also be used in a mapping; use <cmd> |:map-cmd| to ensure the mapping doesn't end completion mode.

opts optional parameters. Reserved for future use.

func (*Batch) SetBufferExtmark added in v1.0.2

func (b *Batch) SetBufferExtmark(buffer Buffer, nsID int, line int, col int, opts map[string]interface{}, id *int)

SetBufferExtmark creates or updates an extmark.

To create a new extmark, pass id=0. The extmark id will be returned. To move an existing mark, pass 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. (Useful over RPC, to avoid waiting for the return value.)

Using the optional arguments, it is possible to use this to highlight a range of text, and also to associate virtual text to the mark.

The opts arg is optional parameters.

id

ID of the extmark to edit.

end_line

Ending line of the mark, 0-based inclusive.

end_col

Ending col of the mark, 0-based inclusive.

hl_group

Name of the highlight group used to highlight this mark.

virt_text

Virtual text to link to this mark.

virt_text_pos

Positioning of virtual text. Possible values:

eol

right after eol character (default)

overlay

display over the specified column, without shifting the underlying text.

virt_text_win_col

position the virtual text at a fixed window column (starting from the first text column)

virt_text_hide

Hide the virtual text when the background text is selected or hidden due to horizontal scroll "nowrap".

hl_mode

Control how highlights are combined with the highlights of the text. Currently only affects virt_text highlights, but might affect "hl_group" in later versions. Possible values:

replace

only show the virt_text color. This is the default.

combine

combine with background text color

blend

blend with background text color.

hl_eol

when true, for a multiline highlight covering the EOL of a line, continue the highlight for the rest of the screen line (just like for diff and cursorline highlight).

ephemeral

For use with "nvim_set_decoration_provider" callbacks. The mark will only be used for the current redraw cycle, and not be permantently stored in the buffer.

right_gravity

Boolean that indicates the direction the extmark will be shifted in when new text is inserted (true for right, false for left). defaults to true.

end_right_gravity

Boolean that indicates the direction the extmark end position (if it exists) will be shifted in when new text is inserted (true for right, false for left). Defaults to false.

priority

A priority value for the highlight group. For example treesitter highlighting uses a value of 100.

func (*Batch) SetBufferKeyMap added in v1.0.1

func (b *Batch) SetBufferKeyMap(buffer Buffer, mode string, lhs string, rhs string, opts map[string]bool)

SetBufferKeyMap sets a buffer-local mapping for the given mode.

See:

:help nvim_set_keymap()

func (*Batch) SetBufferLines

func (b *Batch) SetBufferLines(buffer Buffer, start int, end int, strictIndexing bool, replacement [][]byte)

SetBufferLines sets or replaces a line-range in the buffer.

Indexing is zero-based, end-exclusive. Negative indices are interpreted as length+1+index: -1 refers to the index past the end. So to change or delete the last element use start=-2 and end=-1.

To insert lines at a given index, set start and end args to the same index.

To delete a range of lines, set replacement arg to an empty array.

Out-of-bounds indices are clamped to the nearest valid value, unless strict_indexing arg is set to true.

func (*Batch) SetBufferMark added in v1.2.0

func (b *Batch) SetBufferMark(buffer Buffer, name string, line int, col int, opts map[string]interface{}, set *bool)

SetBufferMark sets a named mark in the given buffer, all marks are allowed file/uppercase, visual, last change, etc. See |help mark-motions|.

line and col are (1,0)-indexed.

opts is optional parameters. Reserved for future use.

func (*Batch) SetBufferName

func (b *Batch) SetBufferName(buffer Buffer, name string)

SetBufferName sets the full file name for a buffer.

func (*Batch) SetBufferOption

func (b *Batch) SetBufferOption(buffer Buffer, name string, value interface{})

SetBufferOption sets a buffer option value.

Passing nil as value arg to deletes the option (only works if there's a global fallback).

func (*Batch) SetBufferText added in v1.1.6

func (b *Batch) SetBufferText(buffer Buffer, startRow int, startCol int, endRow int, endCol int, replacement [][]byte)

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 startRow and endRow args ranges to the same index.

To delete a range, set replacement arg to an array containing an empty string, or simply an empty array.

Prefer SetBufferLines when adding or deleting entire lines only.

func (*Batch) SetBufferToWindow

func (b *Batch) SetBufferToWindow(window Window, buffer Buffer)

SetBufferToWindow Sets the current buffer in a window, without side-effects.

func (*Batch) SetBufferVar

func (b *Batch) SetBufferVar(buffer Buffer, name string, value interface{})

SetBufferVar sets a buffer-scoped (b:) variable.

func (*Batch) SetBufferVirtualText deprecated

func (b *Batch) SetBufferVirtualText(buffer Buffer, nsID int, line int, chunks []TextChunk, opts map[string]interface{}, id *int)

SetBufferVirtualText set the virtual text (annotation) for a buffer line.

By default (and currently the only option), the text will be placed after the buffer text.

Virtual text will never cause reflow, rather virtual text will be truncated at the end of the screen line. The virtual text will begin one cell (|lcs-eol| or space) after the ordinary text.

Namespaces are used to support batch deletion/updating of virtual text. To create a namespace, use CreateNamespace. Virtual text is cleared using ClearBufferNamespace.

The same nsID can be used for both virtual text and highlights added by AddBufferHighlight, both can then be cleared with a single call to ClearBufferNamespace. If the virtual text never will be cleared by an API call, pass "nsID = -1".

As a shorthand, "nsID = 0" can be used to create a new namespace for the virtual text, the allocated id is then returned.

The opts arg is reserved for future use.

Deprecated: Use SetBufferExtmark instead.

func (*Batch) SetClientInfo

func (b *Batch) SetClientInfo(name string, version ClientVersion, typ ClientType, methods map[string]*ClientMethod, attributes ClientAttributes)

SetClientInfo self-identifies the client.

The client/plugin/application should call this after connecting, to provide hints about its identity and purpose, for debugging and orchestration.

Can be called more than once; the caller should merge old info if appropriate. Example: library first identifies the channel, then a plugin using that library later identifies itself.

func (*Batch) SetCurrentBuffer

func (b *Batch) SetCurrentBuffer(buffer Buffer)

SetCurrentBuffer sets the current buffer.

func (*Batch) SetCurrentDirectory

func (b *Batch) SetCurrentDirectory(dir string)

SetCurrentDirectory changes the global working directory.

func (*Batch) SetCurrentLine

func (b *Batch) SetCurrentLine(line []byte)

SetCurrentLine sets the current line.

func (*Batch) SetCurrentTabpage

func (b *Batch) SetCurrentTabpage(tabpage Tabpage)

SetCurrentTabpage sets the current tabpage.

func (*Batch) SetCurrentWindow

func (b *Batch) SetCurrentWindow(window Window)

SetCurrentWindow sets the current window.

func (*Batch) SetHighlight added in v1.1.4

func (b *Batch) SetHighlight(nsID int, name string, val *HLAttrs)

SetHighlight sets a highlight group.

nsID is number of namespace for this highlight.

name is highlight group name, like "ErrorMsg".

val is highlight definiton map, like HLByName.

in addition the following keys are also recognized:

default

don't override existing definition, like "hi default".

func (*Batch) SetHighlightNameSpace added in v1.1.4

func (b *Batch) SetHighlightNameSpace(nsID int)

SetHighlightNameSpace set active namespace for highlights.

nsID is the namespace to activate.

func (*Batch) SetKeyMap added in v1.0.1

func (b *Batch) SetKeyMap(mode string, lhs string, rhs string, opts map[string]bool)

SetKeyMap sets a global mapping for the given mode.

To set a buffer-local mapping, use SetBufferKeyMap().

Unlike :map, leading/trailing whitespace is accepted as part of the {lhs} or {rhs}. Empty {rhs} is <Nop>. keycodes are replaced as usual.

mode

mode short-name (map command prefix: "n", "i", "v", "x", …) or "!" for :map!, or empty string for :map.

lhs

Left-hand-side {lhs} of the mapping.

rhs

Right-hand-side {rhs} of the mapping.

opts

Optional parameters map. Accepts all ":map-arguments" as keys excluding "buffer" but including "noremap". Values are Booleans. Unknown key is an error.

func (*Batch) SetOption

func (b *Batch) SetOption(name string, value interface{})

SetOption sets an option value.

func (*Batch) SetOptionValue added in v1.2.1

func (b *Batch) SetOptionValue(name string, value interface{}, opts map[string]OptionValueScope)

SetOptionValue sets the value of an option. The behavior of this function matches that of |:set|: for global-local options, both the global and local value are set unless otherwise specified with {scope}. name is the option name.

opts is the Optional parameters.

scope

Analogous to |:setglobal| and |:setlocal|, respectively.

func (*Batch) SetPumBounds added in v1.1.4

func (b *Batch) SetPumBounds(width float64, height float64, row float64, col float64)

SetPumBounds tells Nvim the geometry of the popumenu, to align floating windows with an external popup menu.

Note that this method is not to be confused with SetPumHeight, which sets the number of visible items in the popup menu, while this function sets the bounding box of the popup menu, including visual elements such as borders and sliders.

Floats need not use the same font size, nor be anchored to exact grid corners, so one can set floating-point numbers to the popup menu geometry.

func (*Batch) SetPumHeight added in v1.0.2

func (b *Batch) SetPumHeight(height int)

SetPumHeight tells Nvim the number of elements displaying in the popumenu, to decide <PageUp> and <PageDown> movement.

height is popupmenu height, must be greater than zero.

func (*Batch) SetTabpageVar

func (b *Batch) SetTabpageVar(tabpage Tabpage, name string, value interface{})

SetTabpageVar sets a tab-scoped (t:) variable.

func (*Batch) SetUIOption

func (b *Batch) SetUIOption(name string, value interface{})

SetUIOption sets a UI option.

func (*Batch) SetVVar

func (b *Batch) SetVVar(name string, value interface{})

SetVVar sets a v: variable, if it is not readonly.

func (*Batch) SetVar

func (b *Batch) SetVar(name string, value interface{})

SetVar sets a global (g:) variable.

func (*Batch) SetWindowConfig

func (b *Batch) SetWindowConfig(window Window, config *WindowConfig)

SetWindowConfig configure window position. Currently this is only used to configure floating and external windows (including changing a split window to these types).

When reconfiguring a floating window, absent option keys will not be changed. "row"/"col" and "relative" must be reconfigured together.

See documentation at OpenWindow, for the meaning of parameters.

func (*Batch) SetWindowCursor

func (b *Batch) SetWindowCursor(window Window, pos [2]int)

SetWindowCursor sets the (1,0)-indexed cursor position in the window.

func (*Batch) SetWindowHeight

func (b *Batch) SetWindowHeight(window Window, height int)

SetWindowHeight Sets the window height. This will only succeed if the screen is split horizontally.

func (*Batch) SetWindowOption

func (b *Batch) SetWindowOption(window Window, name string, value interface{})

SetWindowOption sets a window option value. Passing "nil" as value deletes the option(only works if there's a global fallback).

func (*Batch) SetWindowVar

func (b *Batch) SetWindowVar(window Window, name string, value interface{})

SetWindowVar sets a window-scoped (w:) variable.

func (*Batch) SetWindowWidth

func (b *Batch) SetWindowWidth(window Window, width int)

SetWindowWidth Sets the window width. This will only succeed if the screen is split vertically.

func (*Batch) StringWidth

func (b *Batch) StringWidth(s string, width *int)

StringWidth calculates the number of display cells occupied by "text".

"<Tab>" counts as one cell.

func (*Batch) Subscribe

func (b *Batch) Subscribe(event string)

Subscribe subscribes to event broadcasts.

func (*Batch) TabpageNumber

func (b *Batch) TabpageNumber(tabpage Tabpage, number *int)

TabpageNumber gets the tabpage number.

func (*Batch) TabpageVar

func (b *Batch) TabpageVar(tabpage Tabpage, name string, result interface{})

TabpageVar gets a tab-scoped (t:) variable.

func (*Batch) TabpageWindow

func (b *Batch) TabpageWindow(tabpage Tabpage, result *Window)

TabpageWindow gets the current window in a tabpage.

func (*Batch) TabpageWindows

func (b *Batch) TabpageWindows(tabpage Tabpage, windows *[]Window)

TabpageWindows gets the windows in a tabpage.

func (*Batch) Tabpages

func (b *Batch) Tabpages(tabpages *[]Tabpage)

Tabpages gets the current list of tabpage handles.

func (*Batch) TryResizeUI

func (b *Batch) TryResizeUI(width int, height int)

TryResizeUI notifies Nvim that the client window has resized. If possible, Nvim will send a redraw request to resize.

func (*Batch) TryResizeUIGrid

func (b *Batch) TryResizeUIGrid(grid int, width int, height int)

TryResizeUIGrid tell Nvim to resize a grid. Triggers a grid_resize event with the requested grid size or the maximum size if it exceeds size limits.

On invalid grid handle, fails with error.

func (*Batch) UIs

func (b *Batch) UIs(uis *[]*UI)

UIs gets a list of dictionaries representing attached UIs.

func (*Batch) Unsubscribe

func (b *Batch) Unsubscribe(event string)

Unsubscribe unsubscribes to event broadcasts.

func (*Batch) VVar

func (b *Batch) VVar(name string, result interface{})

VVar gets a v: variable.

func (*Batch) Var

func (b *Batch) Var(name string, result interface{})

Var gets a global (g:) variable.

func (*Batch) WindowBuffer

func (b *Batch) WindowBuffer(window Window, buffer *Buffer)

WindowBuffer gets the current buffer in a window.

func (*Batch) WindowConfig

func (b *Batch) WindowConfig(window Window, config *WindowConfig)

WindowConfig return window configuration.

The returned value may be given to OpenWindow.

Relative will be an empty string for normal windows.

func (*Batch) WindowCursor

func (b *Batch) WindowCursor(window Window, pos *[2]int)

WindowCursor gets the (1,0)-indexed cursor position in the window.

func (*Batch) WindowHeight

func (b *Batch) WindowHeight(window Window, height *int)

WindowHeight returns the window height.

func (*Batch) WindowNumber

func (b *Batch) WindowNumber(window Window, number *int)

WindowNumber gets the window number.

func (*Batch) WindowOption

func (b *Batch) WindowOption(window Window, name string, result interface{})

WindowOption gets a window option value.

func (*Batch) WindowPosition

func (b *Batch) WindowPosition(window Window, pos *[2]int)

WindowPosition gets the window position in display cells. First position is zero.

func (*Batch) WindowTabpage

func (b *Batch) WindowTabpage(window Window, tabpage *Tabpage)

WindowTabpage gets the window tabpage.

func (*Batch) WindowVar

func (b *Batch) WindowVar(window Window, name string, result interface{})

WindowVar gets a window-scoped (w:) variable.

func (*Batch) WindowWidth

func (b *Batch) WindowWidth(window Window, width *int)

WindowWidth returns the window width.

func (*Batch) Windows

func (b *Batch) Windows(windows *[]Window)

Windows gets the current list of window handles.

func (*Batch) WriteErr

func (b *Batch) WriteErr(str string)

WriteErr writes a message to the Vim error buffer.

Does not append "\n", the message is buffered (won't display) until a linefeed is written.

func (*Batch) WriteOut

func (b *Batch) WriteOut(str string)

WriteOut writes a message to the Vim output buffer.

Does not append "\n", the message is buffered (won't display) until a linefeed is written.

func (*Batch) WritelnErr

func (b *Batch) WritelnErr(str string)

WritelnErr writes a message to the Vim error buffer.

Appends "\n", so the buffer is flushed and displayed.

type BatchError

type BatchError struct {
	// Err is the error.
	Err error

	// Index is a zero-based index of the function call which resulted in the
	// error.
	Index int
}

BatchError represents an error from a API function call in a Batch.

func (*BatchError) Error

func (e *BatchError) Error() string

Error implements the error interface.

type BorderStyle added in v1.2.0

type BorderStyle string

BorderStyle represents a WindowConfig.Border style.

type BufDetachEvent added in v1.2.0

type BufDetachEvent struct {
	Buffer Buffer `msgpack:"buffer,omitempty"`
}

BufDetachEvent represents a EventBufDetach type.

type BufLinesEvent added in v1.2.0

type BufLinesEvent struct {
	Buffer      Buffer   `msgpack:"buffer,omitempty"`
	Changetick  int64    `msgpack:"changetick,omitempty"`
	FirstLine   int64    `msgpack:"firstLine,omitempty"`
	LastLine    int64    `msgpack:"lastLine,omitempty"`
	LineData    []string `msgpack:",array"`
	IsMultipart bool     `msgpack:"isMultipart,omitempty"`
}

BufLinesEvent represents a EventBufLines type.

type Buffer

type Buffer int

Buffer represents a Nvim buffer.

func (Buffer) MarshalMsgPack

func (x Buffer) MarshalMsgPack(enc *msgpack.Encoder) error

MarshalMsgPack implements msgpack.Marshaler.

func (Buffer) String

func (x Buffer) String() string

String returns a string representation of the Buffer.

func (*Buffer) UnmarshalMsgPack

func (x *Buffer) UnmarshalMsgPack(dec *msgpack.Decoder) error

UnmarshalMsgPack implements msgpack.Unmarshaler.

type ChangedtickEvent added in v1.2.0

type ChangedtickEvent struct {
	Buffer     Buffer `msgpack:"buffer,omitempty"`
	Changetick int64  `msgpack:"changetick,omitempty"`
}

ChangedtickEvent represents a EventBufChangedtick type.

type Channel

type Channel struct {
	// Stream is the stream underlying the channel.
	Stream string `msgpack:"stream,omitempty"`

	// Mode is the how data received on the channel is interpreted.
	Mode string `msgpack:"mode,omitempty"`

	// Pty is the name of pseudoterminal, if one is used.
	Pty string `msgpack:"pty,omitempty"`

	// Buffer is the buffer with connected terminal instance.
	Buffer Buffer `msgpack:"buffer,omitempty"`

	// Client is the information about the client on the other end of the RPC channel, if it has added it using SetClientInfo.
	Client *Client `msgpack:"client,omitempty"`
}

Channel information about a channel.

type ChildProcessOption

type ChildProcessOption struct {
	// contains filtered or unexported fields
}

ChildProcessOption specifies an option for creating a child process.

func ChildProcessArgs

func ChildProcessArgs(args ...string) ChildProcessOption

ChildProcessArgs specifies the command line arguments. The application must include the --embed flag or other flags that cause Nvim to use stdin/stdout as a MsgPack RPC channel.

func ChildProcessCommand

func ChildProcessCommand(command string) ChildProcessOption

ChildProcessCommand specifies the command to run. NewChildProcess runs "nvim" by default.

func ChildProcessContext

func ChildProcessContext(ctx context.Context) ChildProcessOption

ChildProcessContext specifies the context to use when starting the command. The background context is used by defaullt.

func ChildProcessDir

func ChildProcessDir(dir string) ChildProcessOption

ChildProcessDir specifies the working directory for the process. The current working directory is used by default.

func ChildProcessEnv

func ChildProcessEnv(env []string) ChildProcessOption

ChildProcessEnv specifies the environment for the child process. The current process environment is used by default.

func ChildProcessLogf

func ChildProcessLogf(logf func(string, ...interface{})) ChildProcessOption

ChildProcessLogf specifies function for logging output. The log.Printf function is used by default.

func ChildProcessServe

func ChildProcessServe(serve bool) ChildProcessOption

ChildProcessServe specifies whether Server should be run in a goroutine. The default is to run Serve().

type Client

type Client struct {
	// Name is short name for the connected client.
	Name string `msgpack:"name,omitempty"`

	// Version describes the version, with the following possible keys (all optional).
	Version ClientVersion `msgpack:"version,omitempty"`

	// Type is the client type. Must be one of the ClientType type values.
	Type ClientType `msgpack:"type,omitempty"`

	// Methods builtin methods in the client.
	Methods map[string]*ClientMethod `msgpack:"methods,omitempty"`

	// Attributes is informal attributes describing the client.
	Attributes ClientAttributes `msgpack:"attributes,omitempty"`
}

Client represents a identify the client for nvim.

Can be called more than once, but subsequent calls will remove earlier info, which should be resent if it is still valid. (This could happen if a library first identifies the channel, and a plugin using that library later overrides that info).

type ClientAttributes

type ClientAttributes map[string]string

ClientAttributes informal attributes describing the client. Clients might define their own keys, but the following are suggested.

type ClientMethod

type ClientMethod struct {
	// Async is defines whether the uses notification request or blocking request.
	//
	// If true, send as a notification.
	// If false, send as a blocking request.
	Async bool `msgpack:"async"`

	// NArgs is the number of method arguments.
	NArgs ClientMethodNArgs
}

ClientMethod builtin methods in the client.

For a host, this does not include plugin methods which will be discovered later. The key should be the method name, the values are dicts with the following (optional) keys. See below.

Further keys might be added in later versions of nvim and unknown keys are thus ignored. Clients must only use keys defined in this or later versions of nvim.

type ClientMethodNArgs

type ClientMethodNArgs struct {
	// Min is the minimum number of method arguments.
	Min int `msgpack:",array"`

	// Max is the maximum number of method arguments.
	Max int
}

ClientMethodNArgs is the number of arguments. Could be a single integer or an array two integers, minimum and maximum inclusive.

type ClientType

type ClientType string

ClientType type of client information.

const (
	// RemoteClientType for the client library.
	RemoteClientType ClientType = "remote"

	// UIClientType for the gui frontend.
	UIClientType ClientType = "ui"

	// EmbedderClientType for the application using nvim as a component, for instance IDE/editor implementing a vim mode.
	EmbedderClientType ClientType = "embedder"

	// HostClientType for the plugin host. Typically started by nvim.
	HostClientType ClientType = "host"

	// PluginClientType for the single plugin. Started by nvim.
	PluginClientType ClientType = "plugin"
)

type ClientVersion

type ClientVersion struct {
	// Major major version. (defaults to 0 if not set, for no release yet)
	Major int `msgpack:"major,omitempty" empty:"0"`

	// Minor minor version.
	Minor int `msgpack:"minor,omitempty"`

	// Patch patch number.
	Patch int `msgpack:"patch,omitempty"`

	// Prerelease string describing a prerelease, like "dev" or "beta1".
	Prerelease string `msgpack:"prerelease,omitempty"`

	// Commit hash or similar identifier of commit.
	Commit string `msgpack:"commit,omitempty"`
}

ClientVersion represents a version of client for nvim.

type Command

type Command struct {
	// Name is the name of command.
	Name string `msgpack:"name"`

	// Nargs is the command-nargs.
	// See :help :command-nargs.
	Nargs string `msgpack:"nargs"`

	// Complete is the specifying one or the other of the following attributes.
	// See :help :command-completion.
	Complete string `msgpack:"complete,omitempty"`

	// CompleteArg is the argument completion name.
	CompleteArg string `msgpack:"complete_arg,omitempty"`

	// Range is the specify that the command does take a range, or that it takes an arbitrary count value.
	Range string `msgpack:"range,omitempty"`

	// Count is a count (default N) which is specified either in the line number position, or as an initial argument, like `:Next`.
	// Specifying -count (without a default) acts like -count=0
	Count string `msgpack:"count,omitempty"`

	// Addr is the special characters in the range like `.`, `$` or `%` which by default correspond to the current line,
	// last line and the whole buffer, relate to arguments, (loaded) buffers, windows or tab pages.
	Addr string `msgpack:"addr,omitempty"`

	// Bang is the command can take a ! modifier, like `:q` or `:w`.
	Bang bool `msgpack:"bang"`

	// Bar is the command can be followed by a `|` and another command.
	// A `|` inside the command argument is not allowed then. Also checks for a `"` to start a comment.
	Bar bool `msgpack:"bar"`

	// Register is the first argument to the command can be an optional register name, like `:del`, `:put`, `:yank`.
	Register bool `msgpack:"register"`

	// ScriptID is the line number in the script sid.
	ScriptID int `msgpack:"script_id"`

	// Definition is the command's replacement string.
	Definition string `msgpack:"definition"`
}

Command represents a Neovim Ex command.

type CommandCompletionArgs

type CommandCompletionArgs struct {
	// ArgLead is the leading portion of the argument currently being completed
	// on.
	ArgLead string `msgpack:",array"`

	// CmdLine is the entire command line.
	CmdLine string

	// CursorPosString is decimal representation of the cursor position in
	// bytes.
	CursorPosString int
}

CommandCompletionArgs represents the arguments to a custom command line completion function.

:help :command-completion-custom

func (*CommandCompletionArgs) CursorPos

func (a *CommandCompletionArgs) CursorPos() int

CursorPos returns the cursor position.

type DialOption

type DialOption struct {
	// contains filtered or unexported fields
}

DialOption specifies an option for dialing to Nvim.

func DialContext

func DialContext(ctx context.Context) DialOption

DialContext specifies the context to use when starting the command. The background context is used by default.

func DialLogf

func DialLogf(logf func(string, ...interface{})) DialOption

DialLogf specifies function for logging output. The log.Printf function is used by default.

func DialNetDial

func DialNetDial(f func(ctx context.Context, network, address string) (net.Conn, error)) DialOption

DialNetDial specifies a function used to dial a network connection. A default net.Dialer DialContext method is used by default.

func DialServe

func DialServe(serve bool) DialOption

DialServe specifies whether Server should be run in a goroutine. The default is to run Serve().

type EmbedOptions deprecated

type EmbedOptions struct {
	// Logf log function for rpc.WithLogf.
	Logf func(string, ...interface{})

	// Dir specifies the working directory of the command. The working
	// directory in the current process is used if Dir is "".
	Dir string

	// Path is the path of the command to run. If Path = "", then
	// StartEmbeddedNvim searches for "nvim" on $PATH.
	Path string

	// Args specifies the command line arguments. Do not include the program
	// name (the first argument) or the --embed option.
	Args []string

	// Env specifies the environment of the Nvim process. The current process
	// environment is used if Env is nil.
	Env []string
}

EmbedOptions specifies options for starting an embedded instance of Nvim.

Deprecated: Use ChildProcessOption instead.

type ErrorList

type ErrorList []error

ErrorList is a list of errors.

func (ErrorList) Error

func (el ErrorList) Error() string

Error implements the error interface.

type ExtMark added in v1.1.7

type ExtMark struct {
	// ID is the extmarks ID.
	ID int `msgpack:",array"`

	// Row is the extmark row position.
	Row int

	// Col is the extmark column position.
	Col int
}

ExtMark represents a extmarks type.

type HLAttrs

type HLAttrs struct {
	// Bold is the bold font style.
	Bold bool `msgpack:"bold,omitempty"`

	// Standout is the standout font style.
	Standout int `msgpack:"standout,omitempty"`

	// Underline is the underline font style.
	Underline bool `msgpack:"underline,omitempty"`

	// Undercurl is the curly underline font style.
	Undercurl bool `msgpack:"undercurl,omitempty"`

	// Italic is the italic font style.
	Italic bool `msgpack:"italic,omitempty"`

	// Reverse is the reverse to foreground and background.
	Reverse bool `msgpack:"reverse,omitempty"`

	// Strikethrough is the strikethrough font style.
	Strikethrough bool `msgpack:"strikethrough,omitempty"`

	ForegroundIndexed bool `msgpack:"fg_indexed,omitempty"`

	BackgroundIndexed bool `msgpack:"bg_indexed,omitempty"`

	// Foreground is foreground color of RGB color.
	Foreground int `msgpack:"foreground,omitempty" empty:"-1"`

	// Background is background color of RGB color.
	Background int `msgpack:"background,omitempty" empty:"-1"`

	// Special is used for undercurl and underline.
	Special int `msgpack:"special,omitempty" empty:"-1"`

	// Blend override the blend level for a highlight group within the popupmenu
	// or floating windows.
	//
	// Only takes effect if 'pumblend' or 'winblend' is set for the menu or window.
	// See the help at the respective option.
	Blend int `msgpack:"blend,omitempty"`

	// Nocombine override attributes instead of combining them.
	Nocombine bool `msgpack:"nocombine,omitempty"`

	// Default don't override existing definition, like "hi default".
	//
	// This value is used only SetHighlight.
	Default bool `msgpack:"default,omitempty"`

	// Cterm is cterm attribute map. Sets attributed for cterm colors.
	//
	// Note thet by default cterm attributes are same as attributes of gui color.
	//
	// This value is used only SetHighlight.
	Cterm *HLAttrs `msgpack:"cterm,omitempty"`

	// CtermForeground is the foreground of cterm color.
	//
	// This value is used only SetHighlight.
	CtermForeground int `msgpack:"ctermfg,omitempty" empty:"-1"`

	// CtermBackground is the background of cterm color.
	//
	// This value is used only SetHighlight.
	CtermBackground int `msgpack:"ctermbg,omitempty" empty:"-1"`
}

HLAttrs represents a highlight definitions.

type LogLevel added in v1.2.0

type LogLevel int

LogLevel represents a nvim log level.

const (
	LogTraceLevel LogLevel = iota
	LogDebugLevel
	LogInfoLevel
	LogWarnLevel
	LogErrorLevel
)

list of LogLevels.

Should kept sync neovim LogLevel.

func (LogLevel) String added in v1.2.0

func (level LogLevel) String() string

String returns a string representation of the LogLevel.

type Mapping

type Mapping struct {
	// LHS is the {lhs} of the mapping.
	LHS string `msgpack:"lhs,omitempty"`

	// RHS is the {hrs} of the mapping as typed.
	RHS string `msgpack:"rhs,omitempty"`

	// Silent is 1 for a :map-silent mapping, else 0.
	Silent int `msgpack:"silent,omitempty"`

	// Noremap is 1 if the {rhs} of the mapping is not remappable.
	NoRemap int `msgpack:"noremap,omitempty"`

	// Expr is  1 for an expression mapping.
	Expr int `msgpack:"expr,omitempty"`

	// Buffer for a local mapping.
	Buffer int `msgpack:"buffer,omitempty"`

	// SID is the script local ID, used for <sid> mappings.
	SID int `msgpack:"sid,omitempty"`

	// Nowait is 1 if map does not wait for other, longer mappings.
	NoWait int `msgpack:"nowait,omitempty"`

	// Mode specifies modes for which the mapping is defined.
	Mode string `msgpack:"string,omitempty"`
}

Mapping represents a nvim mapping options.

type Mark added in v1.2.0

type Mark struct {
	Row        int `msgpack:",array"`
	Col        int
	Buffer     Buffer
	BufferName string
}

Mark represents a mark.

type Mode

type Mode struct {
	// Mode is the current mode.
	Mode string `msgpack:"mode"`

	// Blocking is true if Nvim is waiting for input.
	Blocking bool `msgpack:"blocking"`
}

Mode represents a Nvim's current mode.

type Nvim

type Nvim struct {
	// contains filtered or unexported fields
}

Nvim represents a remote instance of Nvim. It is safe to call Nvim methods concurrently.

func Dial

func Dial(address string, options ...DialOption) (*Nvim, error)

Dial dials an Nvim instance given an address in the format used by $NVIM_LISTEN_ADDRESS.

:help rpc-connecting
:help $NVIM_LISTEN_ADDRESS

func New

func New(r io.Reader, w io.Writer, c io.Closer, logf func(string, ...interface{})) (*Nvim, error)

New creates an Nvim client. When connecting to Nvim over stdio, use stdin as r and stdout as w and c, When connecting to Nvim over a network connection, use the connection for r, w and c.

The application must call Serve() to handle RPC requests and responses.

New is a low-level function. Most applications should use NewChildProcess, Dial or the ./plugin package.

:help rpc-connecting

func NewChildProcess

func NewChildProcess(options ...ChildProcessOption) (*Nvim, error)

NewChildProcess returns a client connected to stdin and stdout of a new child process.

func NewEmbedded deprecated

func NewEmbedded(options *EmbedOptions) (*Nvim, error)

NewEmbedded starts an embedded instance of Nvim using the specified options.

The application must call Serve() to handle RPC requests and responses.

Deprecated: Use NewChildProcess instead.

func (*Nvim) APIInfo

func (v *Nvim) APIInfo() (apiInfo []interface{}, err error)

APIInfo returns a 2-tuple (Array), where item 0 is the current channel id and item 1 is the "api-metadata" map (Dictionary).

Returns 2-tuple [{channel-id}, {api-metadata}].

func (*Nvim) AddBufferHighlight

func (v *Nvim) AddBufferHighlight(buffer Buffer, srcID int, hlGroup string, line int, startCol int, endCol int) (id int, err error)

AddBufferHighlight adds a highlight to buffer.

IT useful for plugins that dynamically generate highlights to a buffer like a semantic highlighter or linter.

The function adds a single highlight to a buffer. Unlike |matchaddpos()| vim function, highlights follow changes to line numbering as lines are inserted/removed above the highlighted line, like signs and marks do.

Namespaces are used for batch deletion/updating of a set of highlights. To create a namespace, use CreateNamespace which returns a namespace id. Pass it in to this function as nsID to add highlights to the namespace. All highlights in the same namespace can then be cleared with single call to ClearBufferNamespace. If the highlight never will be deleted by an API call, pass nsID = -1.

As a shorthand, "srcID = 0" can be used to create a new namespace for the highlight, the allocated id is then returned.

If hlGroup arg is the empty string, no highlight is added, but a new `nsID` is still returned. This is supported for backwards compatibility, new code should use CreateNamespaceto create a new empty namespace.

func (*Nvim) AddBufferUserCommand added in v1.2.1

func (v *Nvim) AddBufferUserCommand(buffer Buffer, name string, command UserCommand, opts map[string]interface{}) error

AddBufferUserCommand create a new user command |user-commands| in the given buffer.

Only commands created with |:command-buffer| or this function can be deleted with this function.

func (*Nvim) AddUserCommand added in v1.2.1

func (v *Nvim) AddUserCommand(name string, command UserCommand, opts map[string]interface{}) error

AddUserCommand create a new user command.

name is name of the new user command. Must begin with an uppercase letter.

command is replacement command to execute when this user command is executed. When called from Lua, the command can also be a Lua function.

opts is optional command attributes. See |command-attributes| for more details.

To use boolean attributes (such as |:command-bang| or |:command-bar|) set the value to "true". In addition to the string options listed in |:command-complete|, the "complete" key also accepts a Lua function which works like the "customlist" completion mode |:command-completion-customlist|.

desc (string)

Used for listing the command when a Lua function is used for {command}.

force (bool, default true)

Override any previous definition.

func (*Nvim) AllOptionsInfo added in v1.1.4

func (v *Nvim) AllOptionsInfo() (opinfo *OptionInfo, err error)

AllOptionsInfo gets the option information for all options.

The dictionary has the full option names as keys and option metadata dictionaries as detailed at OptionInfo.

Resulting map has keys:

name

Name of the option (like "filetype").

shortname

Shortened name of the option (like "ft").

type

type of option ("string", "number" or "boolean").

default

The default value for the option.

was_set

Whether the option was set.

last_set_sid

Last set script id (if any).

last_set_linenr

line number where option was set.

last_set_chan

Channel where option was set (0 for local).

scope

One of "global", "win", or "buf".

global_local

Whether win or buf option has a global value.

commalist

List of comma separated values.

flaglist

List of single char flags.

func (*Nvim) AttachBuffer

func (v *Nvim) AttachBuffer(buffer Buffer, sendBuffer bool, opts map[string]interface{}) (attached bool, err error)

AttachBuffer activates buffer-update events on a channel.

The buffer is specific Buffer, or 0 for current buffer.

If sendBuffer is true, initial notification should contain the whole buffer. If false, the first notification will be a "nvim_buf_lines_event". Otherwise, the first notification will be a "nvim_buf_changedtick_event".

Returns whether the updates couldn't be enabled because the buffer isn't loaded or opts contained an invalid key.

func (*Nvim) AttachUI

func (v *Nvim) AttachUI(width int, height int, options map[string]interface{}) error

AttachUI registers the client as a remote UI. After this method is called, the client will receive redraw notifications.

:help rpc-remote-ui

The redraw notification method has variadic arguments. Register a handler for the method like this:

v.RegisterHandler("redraw", func(updates ...[]interface{}) {
    for _, update := range updates {
        // handle update
    }
})

func (*Nvim) BufferChangedTick

func (v *Nvim) BufferChangedTick(buffer Buffer) (changedtick int, err error)

BufferChangedTick gets a changed tick of a buffer.

func (*Nvim) BufferCommands

func (v *Nvim) BufferCommands(buffer Buffer, opts map[string]interface{}) (map[string]*Command, error)

BufferCommands gets a map of buffer-local user-commands.

opts is optional parameters. Currently not used.

func (*Nvim) BufferExtmarkByID added in v1.0.2

func (v *Nvim) BufferExtmarkByID(buffer Buffer, nsID int, id int, opt map[string]interface{}) (pos []int, err error)

BufferExtmarkByID beturns position for a given extmark id.

opts is optional parameters.

details

Whether to include the details dict. bool type.

func (*Nvim) BufferExtmarks added in v1.0.2

func (v *Nvim) BufferExtmarks(buffer Buffer, nsID int, start interface{}, end interface{}, opt map[string]interface{}) (marks []ExtMark, err error)

BufferExtmarks gets extmarks in "traversal order" from a |charwise| region defined by buffer positions (inclusive, 0-indexed).

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:

BufferExtmarks(0, myNS, 0, -1, {})
BufferExtmarks(0, myNS, [0,0], [-1,-1], {})

If end arg is less than start arg, traversal works backwards. It useful with limit arg, to get the first marks prior to a given position.

The start and end args is start or end of range, given as (row, col), or valid extmark id whose position defines the bound.

opts is optional parameters.

limit

Maximum number of marks to return. int type.

details

Whether to include the details dict. bool type.

func (*Nvim) BufferKeyMap

func (v *Nvim) BufferKeyMap(buffer Buffer, mode string) ([]*Mapping, error)

BufferKeymap gets a list of buffer-local mapping definitions.

The mode short-name ("n", "i", "v", ...).

func (*Nvim) BufferLineCount

func (v *Nvim) BufferLineCount(buffer Buffer) (count int, err error)

BufferLineCount gets the buffer line count.

The buffer arg is specific Buffer, or 0 for current buffer.

The returns line count, or 0 for unloaded buffer.

func (*Nvim) BufferLines

func (v *Nvim) BufferLines(buffer Buffer, start int, end int, strictIndexing bool) (lines [][]byte, err error)

BufferLines gets a line-range from the buffer.

Indexing is zero-based, end-exclusive. Negative indices are interpreted as length+1+index: -1 refers to the index past the end. So to get the last element use start=-2 and end=-1.

Out-of-bounds indices are clamped to the nearest valid value, unless strictIndexing is set.

func (*Nvim) BufferMark

func (v *Nvim) BufferMark(buffer Buffer, name string) (pos [2]int, err error)

BufferMark return a tuple (row,col) representing the position of the named mark.

Marks are (1,0)-indexed.

func (*Nvim) BufferName

func (v *Nvim) BufferName(buffer Buffer) (name string, err error)

BufferName gets the full file name for the buffer.

func (*Nvim) BufferNumber deprecated

func (v *Nvim) BufferNumber(buffer Buffer) (number int, err error)

BufferNumber gets a buffer's number.

Deprecated: Use int(buffer) to get the buffer's number as an integer.

func (*Nvim) BufferOffset

func (v *Nvim) BufferOffset(buffer Buffer, index int) (offset int, err error)

BufferOffset returns the byte offset of a line (0-indexed).

Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte. "fileformat" and "fileencoding" are ignored.

The line index just after the last line gives the total byte-count of the buffer. A final EOL byte is counted if it would be written, see ":help eol".

Unlike "line2byte" vim function, throws error for out-of-bounds indexing.

If Buffer is unloaded buffer, returns -1.

func (*Nvim) BufferOption

func (v *Nvim) BufferOption(buffer Buffer, name string, result interface{}) error

BufferOption gets a buffer option value.

func (*Nvim) BufferVar

func (v *Nvim) BufferVar(buffer Buffer, name string, result interface{}) error

BufferVar gets a buffer-scoped (b:) variable.

func (*Nvim) Buffers

func (v *Nvim) Buffers() (buffers []Buffer, err error)

Buffers gets the current list of buffer handles.

Includes unlisted (unloaded/deleted) buffers, like ":ls!". Use IsBufferLoaded to check if a buffer is loaded.

func (*Nvim) Call

func (v *Nvim) Call(fname string, result interface{}, args ...interface{}) error

Call calls a VimL function with the given arguments.

Fails with VimL error, does not update "v:errmsg".

fn is Function to call.

args is Function arguments packed in an Array.

result is the result of the function call.

func (*Nvim) CallDict

func (v *Nvim) CallDict(dict []interface{}, fname string, result interface{}, args ...interface{}) error

CallDict calls a VimL dictionary function with the given arguments.

Fails with VimL error, does not update "v:errmsg".

dict is dictionary, or string evaluating to a VimL "self" dict.

fn is name of the function defined on the VimL dict.

args is function arguments packed in an array.

result is the result of the function call.

func (*Nvim) ChannelID

func (v *Nvim) ChannelID() int

ChannelID returns Nvim's channel id for this client.

func (*Nvim) ChannelInfo

func (v *Nvim) ChannelInfo(channelID int) (channel *Channel, err error)

ChannelInfo get information about a channel.

Rreturns Dictionary describing a channel, with these keys:

stream

The stream underlying the channel. value are:

stdio

stdin and stdout of this Nvim instance.

stderr

stderr of this Nvim instance.

socket

TCP/IP socket or named pipe.

job

job with communication over its stdio.

mode

How data received on the channel is interpreted. value are:

bytes

send and receive raw bytes.

terminal

A terminal instance interprets ASCII sequences.

rpc

RPC communication on the channel is active.

pty

Name of pseudoterminal, if one is used (optional). On a POSIX system, this will be a device path like /dev/pts/1. Even if the name is unknown, the key will still be present to indicate a pty is used. This is currently the case when using winpty on windows.

buffer

Buffer with connected |terminal| instance (optional).

client

Information about the client on the other end of the RPC channel, if it has added it using SetClientInfo() (optional).

func (*Nvim) Channels

func (v *Nvim) Channels() (channels []*Channel, err error)

Channels get information about all open channels.

func (*Nvim) ClearBufferHighlight deprecated

func (v *Nvim) ClearBufferHighlight(buffer Buffer, srcID int, startLine int, endLine int) error

ClearBufferHighlight clears highlights from a given source group and a range of lines.

To clear a source group in the entire buffer, pass in 1 and -1 to startLine and endLine respectively.

The lineStart and lineEnd parameters specify the range of lines to clear. The end of range is exclusive. Specify -1 to clear to the end of the file.

Deprecated: Use ClearBufferNamespace instead.

func (*Nvim) ClearBufferNamespace

func (v *Nvim) ClearBufferNamespace(buffer Buffer, nsID int, lineStart int, lineEnd int) error

ClearBufferNamespace clears namespaced objects (highlights, extmarks, virtual text) from a region. Lines are 0-indexed.

To clear the namespace in the entire buffer, specify line_start=0 and line_end=-1.

func (*Nvim) Close

func (v *Nvim) Close() error

Close releases the resources used the client.

func (*Nvim) CloseWindow

func (v *Nvim) CloseWindow(window Window, force bool) error

CloseWindow Closes the window (like ":close" with a window-ID).

func (*Nvim) ColorByName

func (v *Nvim) ColorByName(name string) (color int, err error)

ColorByName Returns the 24-bit RGB value of a ColorMap color name or "#rrggbb" hexadecimal string.

Example:

ColorByName("Pink")
ColorByName("#cbcbcb")

func (*Nvim) ColorMap

func (v *Nvim) ColorMap() (colorMap map[string]int, err error)

ColorMap returns a map of color names and RGB values.

Keys are color names (e.g. "Aqua") and values are 24-bit RGB color values (e.g. 65535).

The returns map is color names and RGB values.

func (*Nvim) Command

func (v *Nvim) Command(cmd string) error

Command executes an ex-command.

When fails with VimL error, does not update "v:errmsg".

func (*Nvim) CommandOutput deprecated

func (v *Nvim) CommandOutput(cmd string) (out string, err error)

CommandOutput executes a single ex command and returns the output.

Deprecated: Use Exec instead.

func (*Nvim) Commands

func (v *Nvim) Commands(opts map[string]interface{}) (commands map[string]*Command, err error)

Commands gets a map of global (non-buffer-local) Ex commands. Currently only user-commands are supported, not builtin Ex commands.

opts is optional parameters. Currently only supports:

{"builtin":false}

func (*Nvim) Context added in v1.0.2

func (v *Nvim) Context(opts map[string][]string) (context map[string]interface{}, err error)

Context gets a map of the current editor state. This API still under development.

The opts arg is optional parameters. Key is "types".

List of context-types to gather, or empty for "all" context.

regs
jumps
bufs
gvars
funcs
sfuncs

func (*Nvim) CreateBuffer

func (v *Nvim) CreateBuffer(listed bool, scratch bool) (buffer Buffer, err error)

CreateBuffer creates a new, empty, unnamed buffer.

listed is sets buflisted buffer opttion. If false, sets "nobuflisted".

scratch is creates a "throwaway" for temporary work (always 'nomodified').

bufhidden=hide
buftype=nofile
noswapfile
nomodeline

func (*Nvim) CreateNamespace

func (v *Nvim) CreateNamespace(name string) (nsID int, err error)

CreateNamespace creates a new namespace, or gets an existing one.

Namespaces are used for buffer highlights and virtual text, see AddBufferHighlight and SetBufferVirtualText.

Namespaces can be named or anonymous. If "name" matches an existing namespace, the associated id is returned. If "name" is an empty string a new, anonymous namespace is created.

The returns the namespace ID.

func (*Nvim) CurrentBuffer

func (v *Nvim) CurrentBuffer() (buffer Buffer, err error)

CurrentBuffer gets the current buffer.

func (*Nvim) CurrentLine

func (v *Nvim) CurrentLine() (line []byte, err error)

CurrentLine gets the current line.

func (*Nvim) CurrentTabpage

func (v *Nvim) CurrentTabpage() (tabpage Tabpage, err error)

CurrentTabpage gets the current tabpage.

func (*Nvim) CurrentWindow

func (v *Nvim) CurrentWindow() (window Window, err error)

CurrentWindow gets the current window.

func (*Nvim) DeleteBuffer added in v1.1.4

func (v *Nvim) DeleteBuffer(buffer Buffer, opts map[string]bool) error

DeleteBuffer deletes the buffer. See

:help :bwipeout

The opts args is optional parameters.

force

Force deletion and ignore unsaved changes. bool type.

unload

Unloaded only, do not delete. See |help :bunload|. bool type.

func (*Nvim) DeleteBufferExtmark added in v1.0.2

func (v *Nvim) DeleteBufferExtmark(buffer Buffer, nsID int, extmarkID int) (deleted bool, err error)

DeleteBufferExtmark removes an extmark.

THe returns whether the extmark was found.

func (*Nvim) DeleteBufferKeyMap added in v1.0.1

func (v *Nvim) DeleteBufferKeyMap(buffer Buffer, mode string, lhs string) error

DeleteBufferKeyMap unmaps a buffer-local mapping for the given mode.

See:

:help nvim_del_keymap()

func (*Nvim) DeleteBufferMark added in v1.2.0

func (v *Nvim) DeleteBufferMark(buffer Buffer, name string) (deleted bool, err error)

DeleteBufferMark deletes a named mark in the buffer. See |help mark-motions|.

func (*Nvim) DeleteBufferUserCommand added in v1.2.1

func (v *Nvim) DeleteBufferUserCommand(buffer Buffer, name string) error

DeleteBufferUserCommand create a new user command |user-commands| in the given buffer.

Only commands created with |:command-buffer| or this function can be deleted with this function.

func (*Nvim) DeleteBufferVar

func (v *Nvim) DeleteBufferVar(buffer Buffer, name string) error

DeleteBufferVar removes a buffer-scoped (b:) variable.

func (*Nvim) DeleteCurrentLine

func (v *Nvim) DeleteCurrentLine() error

DeleteCurrentLine deletes the current line.

func (*Nvim) DeleteKeyMap added in v1.0.1

func (v *Nvim) DeleteKeyMap(mode string, lhs string) error

DeleteKeyMap unmaps a global mapping for the given mode.

To unmap a buffer-local mapping, use DeleteBufferKeyMap().

See:

:help nvim_set_keymap()

func (*Nvim) DeleteMark added in v1.2.0

func (v *Nvim) DeleteMark(name string) (deleted bool, err error)

DeleteMark deletes a uppercase/file named mark. See |help mark-motions|.

func (*Nvim) DeleteTabpageVar

func (v *Nvim) DeleteTabpageVar(tabpage Tabpage, name string) error

DeleteTabpageVar removes a tab-scoped (t:) variable.

func (*Nvim) DeleteUserCommand added in v1.2.1

func (v *Nvim) DeleteUserCommand(name string) error

DeleteUserCommand delete a user-defined command.

func (*Nvim) DeleteVar

func (v *Nvim) DeleteVar(name string) error

DeleteVar removes a global (g:) variable.

func (*Nvim) DeleteWindowVar

func (v *Nvim) DeleteWindowVar(window Window, name string) error

DeleteWindowVar removes a window-scoped (w:) variable.

func (*Nvim) DetachBuffer

func (v *Nvim) DetachBuffer(buffer Buffer) (detached bool, err error)

DetachBuffer deactivate updates from this buffer to the current channel.

Returns whether the updates couldn't be disabled because the buffer isn't loaded.

func (*Nvim) DetachUI

func (v *Nvim) DetachUI() error

DetachUI unregisters the client as a remote UI.

func (*Nvim) Echo added in v1.1.6

func (v *Nvim) Echo(chunks []TextChunk, history bool, opts map[string]interface{}) error

Echo echo a message.

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".

opts is optional parameters. Reserved for future use.

func (*Nvim) Eval

func (v *Nvim) Eval(expr string, result interface{}) error

Eval evaluates a VimL expression.

Dictionaries and Lists are recursively expanded.

Fails with VimL error, does not update "v:errmsg".

expr is VimL expression string.

:help expression

func (*Nvim) EvalStatusLine added in v1.2.0

func (v *Nvim) EvalStatusLine(name string, opts map[string]interface{}) (statusline map[string]interface{}, err error)

EvalStatusLine evaluates statusline string.

opts optional parameters.

winid (int)

Window ID of the window to use as context for statusline.

maxwidth (int)

Maximum width of statusline.

fillchar (string)

Character to fill blank spaces in the statusline (see 'fillchars').

highlights (bool)

Return highlight information.

use_tabline (bool)

Evaluate tabline instead of statusline. When true, {winid} is ignored.

func (*Nvim) Exec added in v1.0.2

func (v *Nvim) Exec(src string, output bool) (out string, err error)

Exec executes Vimscript (multiline block of Ex-commands), like anonymous source.

Unlike Command, this function supports heredocs, script-scope (s:), etc.

When fails with VimL error, does not update "v:errmsg".

func (*Nvim) ExecLua added in v1.0.2

func (v *Nvim) ExecLua(code string, result interface{}, args ...interface{}) error

ExecLua execute Lua code.

Parameters are available as `...` inside the chunk. The chunk can return a value.

Only statements are executed. To evaluate an expression, prefix it with `return` is "return my_function(...)".

code is Lua code to execute.

args is arguments to the code.

The returned result value of Lua code if present or nil.

func (*Nvim) ExecuteLua deprecated

func (v *Nvim) ExecuteLua(code string, result interface{}, args ...interface{}) error

ExecuteLua executes a Lua block.

Deprecated: Use ExecLua instead.

func (*Nvim) FeedKeys

func (v *Nvim) FeedKeys(keys string, mode string, escapeCSI bool) error

FeedKeys input-keys to Nvim, subject to various quirks controlled by "mode" flags. Unlike Input, this is a blocking call.

This function does not fail, but updates "v:errmsg".

If need to input sequences like <C-o> use ReplaceTermcodes to replace the termcodes and then pass the resulting string to nvim_feedkeys. You'll also want to enable escape_csi.

mode is following character flags:

m

Remap keys. This is default.

n

Do not remap keys.

t

Handle keys as if typed; otherwise they are handled as if coming from a mapping. This matters for undo, opening folds, etc.

escapeCSI is whether the escape K_SPECIAL/CSI bytes in keys.

func (*Nvim) HLByID

func (v *Nvim) HLByID(hlID int, rgb bool) (highlight *HLAttrs, err error)

HLByID gets a highlight definition by name.

hlID is the highlight id as returned by HLIDByName.

rgb is the whether the export RGB colors.

The returned highlight is the highlight definition.

func (*Nvim) HLByName

func (v *Nvim) HLByName(name string, rgb bool) (highlight *HLAttrs, err error)

HLByName gets a highlight definition by id.

name is Highlight group name.

rgb is whether the export RGB colors.

The returned highlight is the highlight definition.

func (*Nvim) HLIDByName added in v1.0.2

func (v *Nvim) HLIDByName(name string) (hlID int, err error)

HLIDByName gets a highlight group by name.

name is the Highlight group name.

The returns hlID is the highlight id.

This function similar to HLByID, but allocates a new ID if not present.

func (*Nvim) HideWindow added in v1.2.0

func (v *Nvim) HideWindow(window Window) error

HideWindow closes the window and hide the buffer it contains (like ":hide" with a windowID).

Like ":hide" the buffer becomes hidden unless another window is editing it, or "bufhidden" is "unload", "delete" or "wipe" as opposed to ":close" or CloseWindow, which will close the buffer.

func (*Nvim) Input

func (v *Nvim) Input(keys string) (written int, err error)

Input queues raw user-input.

Unlike FeedKeys, this uses a low-level input buffer and the call is non-blocking (input is processed asynchronously by the eventloop).

This function does not fail but updates "v:errmsg".

keys is to be typed.

Note: "keycodes" like "<CR>" are translated, so "<" is special. To input a literal "<", send "<LT>".

Note: For mouse events use InputMouse. The pseudokey form "<LeftMouse><col,row>" is deprecated.

The returned written is number of bytes actually written (can be fewer than requested if the buffer becomes full).

func (*Nvim) InputMouse

func (v *Nvim) InputMouse(button string, action string, modifier string, grid int, row int, col int) error

InputMouse Send mouse event from GUI.

This API is non-blocking. It does not wait on any result, but queues the event to be processed soon by the event loop.

button is mouse button. One of

left
right
middle
wheel

action is for ordinary buttons. One of

press
drag
release

For the wheel, One of

up
down
left
right

modifier is string of modifiers each represented by a single char. The same specifiers are used as for a key press, except that the "-" separator is optional, so "C-A-", "c-a" and "CA" can all be used to specify "Ctrl+Alt+Click".

grid is grid number if the client uses "ui-multigrid", else 0.

row is mouse row-position (zero-based, like redraw events).

col is mouse column-position (zero-based, like redraw events).

func (*Nvim) IsBufferLoaded

func (v *Nvim) IsBufferLoaded(buffer Buffer) (loaded bool, err error)

IsBufferLoaded checks if a buffer is valid and loaded.

See |help api-buffer| for more info about unloaded buffers.

func (*Nvim) IsBufferValid

func (v *Nvim) IsBufferValid(buffer Buffer) (valied bool, err error)

IsBufferValid returns whether the buffer is valid.

Note: Even if a buffer is valid it may have been unloaded. See |help api-buffer| for more info about unloaded buffers.

func (*Nvim) IsTabpageValid

func (v *Nvim) IsTabpageValid(tabpage Tabpage) (valid bool, err error)

IsTabpageValid checks if a tabpage is valid.

func (*Nvim) IsWindowValid

func (v *Nvim) IsWindowValid(window Window) (valid bool, err error)

IsWindowValid checks if a window is valid.

func (*Nvim) KeyMap

func (v *Nvim) KeyMap(mode string) (maps []*Mapping, err error)

KeyMap gets a list of global (non-buffer-local) |mapping| definitions.

The mode arg is the mode short-name, like "n", "i", "v" or etc.

func (*Nvim) LoadContext added in v1.0.2

func (v *Nvim) LoadContext(context map[string]interface{}, result interface{}) error

LoadContext Sets the current editor state from the given context map.

func (*Nvim) Mark added in v1.2.0

func (v *Nvim) Mark(name string, opts map[string]interface{}) (mark *Mark, err error)

Mark returns a tuple (row, col, buffer, buffername) representing the position of the uppercase/file named mark. See |help mark-motions|.

opts is optional parameters. Reserved for future use.

func (*Nvim) Mode

func (v *Nvim) Mode() (mode *Mode, err error)

Mode gets the current mode.

|mode()| "blocking" is true if Nvim is waiting for input.

func (*Nvim) Namespaces

func (v *Nvim) Namespaces() (namespaces map[string]int, err error)

Namespaces gets existing, non-anonymous namespaces.

The return dict that maps from names to namespace ids.

func (*Nvim) NewBatch

func (v *Nvim) NewBatch() *Batch

NewBatch creates a new batch.

func (*Nvim) Notify added in v1.2.0

func (v *Nvim) Notify(msg string, logLevel LogLevel, opts map[string]interface{}) error

Notify the user with a message.

Relays the call to vim.notify. By default forwards your message in the echo area but can be overriden to trigger desktop notifications.

msg is message to display to the user.

logLevel is the LogLevel.

opts is reserved for future use.

func (*Nvim) OpenTerm added in v1.2.0

func (v *Nvim) OpenTerm(buffer Buffer, opts map[string]interface{}) (channel int, err error)

OpenTerm opens a terminal instance in a buffer.

By default (and currently the only option) the terminal will not be connected to an external process. Instead, input send on the channel will be echoed directly by the terminal. This is useful to disply ANSI terminal sequences returned as part of a rpc message, or similar.

Note that to directly initiate the terminal using the right size, display the buffer in a configured window before calling this. For instance, for a floating display, first create an empty buffer using CreateBuffer, then display it using OpenWindow, and then call this function. Then "nvim_chan_send" cal be called immediately to process sequences in a virtual terminal having the intended size.

buffer is the buffer to use (expected to be empty).

opts is optional parameters. Reserved for future use.

func (*Nvim) OpenWindow

func (v *Nvim) OpenWindow(buffer Buffer, enter bool, config *WindowConfig) (window Window, err error)

OpenWindow open a new window.

Currently this is used to open floating and external windows. Floats are windows that are drawn above the split layout, at some anchor position in some other window. Floats can be drawn internally or by external GUI with the "ui-multigrid" extension. External windows are only supported with multigrid GUIs, and are displayed as separate top-level windows.

For a general overview of floats, see

:help api-floatwin

Exactly one of "external" and "relative" must be specified. The "width" and "height" of the new window must be specified.

With relative=editor (row=0,col=0) refers to the top-left corner of the screen-grid and (row=Lines-1,col=Columns-1) refers to the bottom-right corner. Fractional values are allowed, but the builtin implementation (used by non-multigrid UIs) will always round down to nearest integer.

Out-of-bounds values, and configurations that make the float not fit inside the main editor, are allowed. The builtin implementation truncates values so floats are fully within the main screen grid. External GUIs could let floats hover outside of the main window like a tooltip, but this should not be used to specify arbitrary WM screen positions.

func (*Nvim) Option

func (v *Nvim) Option(name string, result interface{}) error

Option gets an option value string.

func (*Nvim) OptionInfo added in v1.1.4

func (v *Nvim) OptionInfo(name string) (opinfo *OptionInfo, err error)

OptionInfo gets the option information for one option.

Resulting map has keys:

name

Name of the option (like "filetype").

shortname

Shortened name of the option (like "ft").

type

type of option ("string", "number" or "boolean").

default

The default value for the option.

was_set

Whether the option was set.

last_set_sid

Last set script id (if any).

last_set_linenr

line number where option was set.

last_set_chan

Channel where option was set (0 for local).

scope

One of "global", "win", or "buf".

global_local

Whether win or buf option has a global value.

commalist

List of comma separated values.

flaglist

List of single char flags.

func (*Nvim) OptionValue added in v1.2.1

func (v *Nvim) OptionValue(name string, opts map[string]OptionValueScope, result interface{}) error

OptionValue gets the value of an option.

The behavior of this function matches that of |:set|: the local value of an option is returned if it exists; otherwise, the global value is returned. Local values always correspond to the current buffer or window.

To get a buffer-local or window-local option for a specific buffer or window, use BufferOption() or WindowOption().

name is the option name.

opts is the Optional parameters.

scope

Analogous to |:setglobal| and |:setlocal|, respectively.

func (*Nvim) ParseExpression

func (v *Nvim) ParseExpression(expr string, flags string, highlight bool) (expression map[string]interface{}, err error)

ParseExpression parse a VimL expression.

func (*Nvim) Paste added in v1.0.2

func (v *Nvim) Paste(data string, crlf bool, phase int) (state bool, err error)

Paste pastes at cursor, in any mode.

Invokes the "vim.paste" handler, which handles each mode appropriately. Sets redo/undo. Faster than Input(). Lines break at LF ("\n").

Errors ("nomodifiable", "vim.paste()" "failure" ...) are reflected in `err` but do not affect the return value (which is strictly decided by `vim.paste()`).

On error, subsequent calls are ignored ("drained") until the next paste is initiated (phase 1 or -1).

data

multiline input. May be binary (containing NUL bytes).

crlf

also break lines at CR and CRLF.

phase

-1 is paste in a single call (i.e. without streaming).

To stream a paste, call Paste sequentially with these phase args:

1

starts the paste (exactly once)

2

continues the paste (zero or more times)

3

ends the paste (exactly once)

The returned boolean state is:

true

Client may continue pasting.

false

Client must cancel the paste.

func (*Nvim) Proc

func (v *Nvim) Proc(pid int) (process Process, err error)

Proc gets info describing process "pid".

func (*Nvim) ProcChildren

func (v *Nvim) ProcChildren(pid int) (processes []uint, err error)

ProcChildren gets the immediate children of process `pid`.

func (*Nvim) Put added in v1.0.2

func (v *Nvim) Put(lines []string, typ string, after bool, follow bool) error

Put puts text at cursor, in any mode.

Compare :put and p which are always linewise.

lines is readfile() style list of lines.

typ is edit behavior: any getregtype() result, or:

 b
blockwise-visual mode (may include width, e.g. "b3")
 c
characterwise mode
 l
linewise mode
 ""

guess by contents, see |setreg()|.

After is insert after cursor (like `p`), or before (like `P`).

follow arg is place cursor at end of inserted text.

func (*Nvim) RegisterHandler

func (v *Nvim) RegisterHandler(method string, fn interface{}) error

RegisterHandler registers fn as a MessagePack RPC handler for the named method. The function signature for fn is one of

func([v *nvim.Nvim,] {args}) ({resultType}, error)
func([v *nvim.Nvim,] {args}) error
func([v *nvim.Nvim,] {args})

where {args} is zero or more arguments and {resultType} is the type of a return value. Call the handler from Nvim using the rpcnotify and rpcrequest functions:

:help rpcrequest()
:help rpcnotify()

Plugin applications should use the Handler* methods in the ./plugin package to register handlers instead of this method.

func (*Nvim) ReplaceTermcodes

func (v *Nvim) ReplaceTermcodes(str string, fromPart bool, doLT bool, special bool) (input string, err error)

ReplaceTermcodes replaces terminal codes and "keycodes" (<CR>, <Esc>, ...) in a string with the internal representation.

str is string to be converted.

fromPart is legacy Vim parameter. Usually true.

doLT is also translate <lt>. Ignored if "special" is false.

special is replace "keycodes", e.g. "<CR>" becomes a "\n" char.

The returned sequences are Nvim's internal representation of keys, for example:

<esc> -> '\x1b'
<cr>  -> '\r'
<c-l> -> '\x0c'
<up>  -> '\x80ku'

The returned sequences can be used as input to feedkeys.

func (*Nvim) Request

func (v *Nvim) Request(procedure string, result interface{}, args ...interface{}) error

Request makes a any RPC request.

func (*Nvim) RuntimeFiles added in v1.1.1

func (v *Nvim) RuntimeFiles(name string, all bool) (files []string, err error)

RuntimeFiles find files in runtime directories.

name is can contain wildcards.

For example,

RuntimeFiles("colors/*.vim", true)

will return all color scheme files.

Always use forward slashes (/) in the search pattern for subdirectories regardless of platform.

It is not an error to not find any files, returned an empty array.

To find a directory, name must end with a forward slash, like "rplugin/python/". Without the slash it would instead look for an ordinary file called "rplugin/python".

all is whether to return all matches or only the first.

func (*Nvim) RuntimePaths

func (v *Nvim) RuntimePaths() (paths []string, err error)

RuntimePaths gets the paths contained in "runtimepath".

func (*Nvim) SelectPopupmenuItem

func (v *Nvim) SelectPopupmenuItem(item int, insert bool, finish bool, opts map[string]interface{}) error

SelectPopupmenuItem selects an item in the completion popupmenu.

If |ins-completion| is not active this API call is silently ignored. Useful for an external UI using |ui-popupmenu| to control the popupmenu with the mouse. Can also be used in a mapping; use <cmd> |:map-cmd| to ensure the mapping doesn't end completion mode.

opts optional parameters. Reserved for future use.

func (*Nvim) Serve

func (v *Nvim) Serve() error

Serve serves incoming mesages from the peer. Serve blocks until Nvim disconnects or there is an error.

By default, the NewChildProcess and Dial functions start a goroutine to run Serve(). Callers of the low-level New function are responsible for running Serve().

func (*Nvim) SetBufferExtmark added in v1.0.2

func (v *Nvim) SetBufferExtmark(buffer Buffer, nsID int, line int, col int, opts map[string]interface{}) (id int, err error)

SetBufferExtmark creates or updates an extmark.

To create a new extmark, pass id=0. The extmark id will be returned. To move an existing mark, pass 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. (Useful over RPC, to avoid waiting for the return value.)

Using the optional arguments, it is possible to use this to highlight a range of text, and also to associate virtual text to the mark.

The opts arg is optional parameters.

id

ID of the extmark to edit.

end_line

Ending line of the mark, 0-based inclusive.

end_col

Ending col of the mark, 0-based inclusive.

hl_group

Name of the highlight group used to highlight this mark.

virt_text

Virtual text to link to this mark.

virt_text_pos

Positioning of virtual text. Possible values:

eol

right after eol character (default)

overlay

display over the specified column, without shifting the underlying text.

virt_text_win_col

position the virtual text at a fixed window column (starting from the first text column)

virt_text_hide

Hide the virtual text when the background text is selected or hidden due to horizontal scroll "nowrap".

hl_mode

Control how highlights are combined with the highlights of the text. Currently only affects virt_text highlights, but might affect "hl_group" in later versions. Possible values:

replace

only show the virt_text color. This is the default.

combine

combine with background text color

blend

blend with background text color.

hl_eol

when true, for a multiline highlight covering the EOL of a line, continue the highlight for the rest of the screen line (just like for diff and cursorline highlight).

ephemeral

For use with "nvim_set_decoration_provider" callbacks. The mark will only be used for the current redraw cycle, and not be permantently stored in the buffer.

right_gravity

Boolean that indicates the direction the extmark will be shifted in when new text is inserted (true for right, false for left). defaults to true.

end_right_gravity

Boolean that indicates the direction the extmark end position (if it exists) will be shifted in when new text is inserted (true for right, false for left). Defaults to false.

priority

A priority value for the highlight group. For example treesitter highlighting uses a value of 100.

func (*Nvim) SetBufferKeyMap added in v1.0.1

func (v *Nvim) SetBufferKeyMap(buffer Buffer, mode string, lhs string, rhs string, opts map[string]bool) error

SetBufferKeyMap sets a buffer-local mapping for the given mode.

See:

:help nvim_set_keymap()

func (*Nvim) SetBufferLines

func (v *Nvim) SetBufferLines(buffer Buffer, start int, end int, strictIndexing bool, replacement [][]byte) error

SetBufferLines sets or replaces a line-range in the buffer.

Indexing is zero-based, end-exclusive. Negative indices are interpreted as length+1+index: -1 refers to the index past the end. So to change or delete the last element use start=-2 and end=-1.

To insert lines at a given index, set start and end args to the same index.

To delete a range of lines, set replacement arg to an empty array.

Out-of-bounds indices are clamped to the nearest valid value, unless strict_indexing arg is set to true.

func (*Nvim) SetBufferMark added in v1.2.0

func (v *Nvim) SetBufferMark(buffer Buffer, name string, line int, col int, opts map[string]interface{}) (set bool, err error)

SetBufferMark sets a named mark in the given buffer, all marks are allowed file/uppercase, visual, last change, etc. See |help mark-motions|.

line and col are (1,0)-indexed.

opts is optional parameters. Reserved for future use.

func (*Nvim) SetBufferName

func (v *Nvim) SetBufferName(buffer Buffer, name string) error

SetBufferName sets the full file name for a buffer.

func (*Nvim) SetBufferOption

func (v *Nvim) SetBufferOption(buffer Buffer, name string, value interface{}) error

SetBufferOption sets a buffer option value.

Passing nil as value arg to deletes the option (only works if there's a global fallback).

func (*Nvim) SetBufferText added in v1.1.6

func (v *Nvim) SetBufferText(buffer Buffer, startRow int, startCol int, endRow int, endCol int, replacement [][]byte) error

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 startRow and endRow args ranges to the same index.

To delete a range, set replacement arg to an array containing an empty string, or simply an empty array.

Prefer SetBufferLines when adding or deleting entire lines only.

func (*Nvim) SetBufferToWindow

func (v *Nvim) SetBufferToWindow(window Window, buffer Buffer) error

SetBufferToWindow Sets the current buffer in a window, without side-effects.

func (*Nvim) SetBufferVar

func (v *Nvim) SetBufferVar(buffer Buffer, name string, value interface{}) error

SetBufferVar sets a buffer-scoped (b:) variable.

func (*Nvim) SetBufferVirtualText deprecated

func (v *Nvim) SetBufferVirtualText(buffer Buffer, nsID int, line int, chunks []TextChunk, opts map[string]interface{}) (id int, err error)

SetBufferVirtualText set the virtual text (annotation) for a buffer line.

By default (and currently the only option), the text will be placed after the buffer text.

Virtual text will never cause reflow, rather virtual text will be truncated at the end of the screen line. The virtual text will begin one cell (|lcs-eol| or space) after the ordinary text.

Namespaces are used to support batch deletion/updating of virtual text. To create a namespace, use CreateNamespace. Virtual text is cleared using ClearBufferNamespace.

The same nsID can be used for both virtual text and highlights added by AddBufferHighlight, both can then be cleared with a single call to ClearBufferNamespace. If the virtual text never will be cleared by an API call, pass "nsID = -1".

As a shorthand, "nsID = 0" can be used to create a new namespace for the virtual text, the allocated id is then returned.

The opts arg is reserved for future use.

Deprecated: Use SetBufferExtmark instead.

func (*Nvim) SetClientInfo

func (v *Nvim) SetClientInfo(name string, version ClientVersion, typ ClientType, methods map[string]*ClientMethod, attributes ClientAttributes) error

SetClientInfo self-identifies the client.

The client/plugin/application should call this after connecting, to provide hints about its identity and purpose, for debugging and orchestration.

Can be called more than once; the caller should merge old info if appropriate. Example: library first identifies the channel, then a plugin using that library later identifies itself.

func (*Nvim) SetCurrentBuffer

func (v *Nvim) SetCurrentBuffer(buffer Buffer) error

SetCurrentBuffer sets the current buffer.

func (*Nvim) SetCurrentDirectory

func (v *Nvim) SetCurrentDirectory(dir string) error

SetCurrentDirectory changes the global working directory.

func (*Nvim) SetCurrentLine

func (v *Nvim) SetCurrentLine(line []byte) error

SetCurrentLine sets the current line.

func (*Nvim) SetCurrentTabpage

func (v *Nvim) SetCurrentTabpage(tabpage Tabpage) error

SetCurrentTabpage sets the current tabpage.

func (*Nvim) SetCurrentWindow

func (v *Nvim) SetCurrentWindow(window Window) error

SetCurrentWindow sets the current window.

func (*Nvim) SetHighlight added in v1.1.4

func (v *Nvim) SetHighlight(nsID int, name string, val *HLAttrs) error

SetHighlight sets a highlight group.

nsID is number of namespace for this highlight.

name is highlight group name, like "ErrorMsg".

val is highlight definiton map, like HLByName.

in addition the following keys are also recognized:

default

don't override existing definition, like "hi default".

func (*Nvim) SetHighlightNameSpace added in v1.1.4

func (v *Nvim) SetHighlightNameSpace(nsID int) error

SetHighlightNameSpace set active namespace for highlights.

nsID is the namespace to activate.

func (*Nvim) SetKeyMap added in v1.0.1

func (v *Nvim) SetKeyMap(mode string, lhs string, rhs string, opts map[string]bool) error

SetKeyMap sets a global mapping for the given mode.

To set a buffer-local mapping, use SetBufferKeyMap().

Unlike :map, leading/trailing whitespace is accepted as part of the {lhs} or {rhs}. Empty {rhs} is <Nop>. keycodes are replaced as usual.

mode

mode short-name (map command prefix: "n", "i", "v", "x", …) or "!" for :map!, or empty string for :map.

lhs

Left-hand-side {lhs} of the mapping.

rhs

Right-hand-side {rhs} of the mapping.

opts

Optional parameters map. Accepts all ":map-arguments" as keys excluding "buffer" but including "noremap". Values are Booleans. Unknown key is an error.

func (*Nvim) SetOption

func (v *Nvim) SetOption(name string, value interface{}) error

SetOption sets an option value.

func (*Nvim) SetOptionValue added in v1.2.1

func (v *Nvim) SetOptionValue(name string, value interface{}, opts map[string]OptionValueScope) error

SetOptionValue sets the value of an option. The behavior of this function matches that of |:set|: for global-local options, both the global and local value are set unless otherwise specified with {scope}. name is the option name.

opts is the Optional parameters.

scope

Analogous to |:setglobal| and |:setlocal|, respectively.

func (*Nvim) SetPumBounds added in v1.1.4

func (v *Nvim) SetPumBounds(width float64, height float64, row float64, col float64) error

SetPumBounds tells Nvim the geometry of the popumenu, to align floating windows with an external popup menu.

Note that this method is not to be confused with SetPumHeight, which sets the number of visible items in the popup menu, while this function sets the bounding box of the popup menu, including visual elements such as borders and sliders.

Floats need not use the same font size, nor be anchored to exact grid corners, so one can set floating-point numbers to the popup menu geometry.

func (*Nvim) SetPumHeight added in v1.0.2

func (v *Nvim) SetPumHeight(height int) error

SetPumHeight tells Nvim the number of elements displaying in the popumenu, to decide <PageUp> and <PageDown> movement.

height is popupmenu height, must be greater than zero.

func (*Nvim) SetTabpageVar

func (v *Nvim) SetTabpageVar(tabpage Tabpage, name string, value interface{}) error

SetTabpageVar sets a tab-scoped (t:) variable.

func (*Nvim) SetUIOption

func (v *Nvim) SetUIOption(name string, value interface{}) error

SetUIOption sets a UI option.

func (*Nvim) SetVVar

func (v *Nvim) SetVVar(name string, value interface{}) error

SetVVar sets a v: variable, if it is not readonly.

func (*Nvim) SetVar

func (v *Nvim) SetVar(name string, value interface{}) error

SetVar sets a global (g:) variable.

func (*Nvim) SetWindowConfig

func (v *Nvim) SetWindowConfig(window Window, config *WindowConfig) error

SetWindowConfig configure window position. Currently this is only used to configure floating and external windows (including changing a split window to these types).

When reconfiguring a floating window, absent option keys will not be changed. "row"/"col" and "relative" must be reconfigured together.

See documentation at OpenWindow, for the meaning of parameters.

func (*Nvim) SetWindowCursor

func (v *Nvim) SetWindowCursor(window Window, pos [2]int) error

SetWindowCursor sets the (1,0)-indexed cursor position in the window.

func (*Nvim) SetWindowHeight

func (v *Nvim) SetWindowHeight(window Window, height int) error

SetWindowHeight Sets the window height. This will only succeed if the screen is split horizontally.

func (*Nvim) SetWindowOption

func (v *Nvim) SetWindowOption(window Window, name string, value interface{}) error

SetWindowOption sets a window option value. Passing "nil" as value deletes the option(only works if there's a global fallback).

func (*Nvim) SetWindowVar

func (v *Nvim) SetWindowVar(window Window, name string, value interface{}) error

SetWindowVar sets a window-scoped (w:) variable.

func (*Nvim) SetWindowWidth

func (v *Nvim) SetWindowWidth(window Window, width int) error

SetWindowWidth Sets the window width. This will only succeed if the screen is split vertically.

func (*Nvim) StringWidth

func (v *Nvim) StringWidth(s string) (width int, err error)

StringWidth calculates the number of display cells occupied by "text".

"<Tab>" counts as one cell.

func (*Nvim) Subscribe

func (v *Nvim) Subscribe(event string) error

Subscribe subscribes to event broadcasts.

func (*Nvim) TabpageNumber

func (v *Nvim) TabpageNumber(tabpage Tabpage) (number int, err error)

TabpageNumber gets the tabpage number.

func (*Nvim) TabpageVar

func (v *Nvim) TabpageVar(tabpage Tabpage, name string, result interface{}) error

TabpageVar gets a tab-scoped (t:) variable.

func (*Nvim) TabpageWindow

func (v *Nvim) TabpageWindow(tabpage Tabpage) (Window, error)

TabpageWindow gets the current window in a tabpage.

func (*Nvim) TabpageWindows

func (v *Nvim) TabpageWindows(tabpage Tabpage) (windows []Window, err error)

TabpageWindows gets the windows in a tabpage.

func (*Nvim) Tabpages

func (v *Nvim) Tabpages() (tabpages []Tabpage, err error)

Tabpages gets the current list of tabpage handles.

func (*Nvim) TryResizeUI

func (v *Nvim) TryResizeUI(width int, height int) error

TryResizeUI notifies Nvim that the client window has resized. If possible, Nvim will send a redraw request to resize.

func (*Nvim) TryResizeUIGrid

func (v *Nvim) TryResizeUIGrid(grid int, width int, height int) error

TryResizeUIGrid tell Nvim to resize a grid. Triggers a grid_resize event with the requested grid size or the maximum size if it exceeds size limits.

On invalid grid handle, fails with error.

func (*Nvim) UIs

func (v *Nvim) UIs() (uis []*UI, err error)

UIs gets a list of dictionaries representing attached UIs.

func (*Nvim) Unsubscribe

func (v *Nvim) Unsubscribe(event string) error

Unsubscribe unsubscribes to event broadcasts.

func (*Nvim) VVar

func (v *Nvim) VVar(name string, result interface{}) error

VVar gets a v: variable.

func (*Nvim) Var

func (v *Nvim) Var(name string, result interface{}) error

Var gets a global (g:) variable.

func (*Nvim) WindowBuffer

func (v *Nvim) WindowBuffer(window Window) (buffer Buffer, err error)

WindowBuffer gets the current buffer in a window.

func (*Nvim) WindowConfig

func (v *Nvim) WindowConfig(window Window) (config *WindowConfig, err error)

WindowConfig return window configuration.

The returned value may be given to OpenWindow.

Relative will be an empty string for normal windows.

func (*Nvim) WindowCursor

func (v *Nvim) WindowCursor(window Window) (pos [2]int, err error)

WindowCursor gets the (1,0)-indexed cursor position in the window.

func (*Nvim) WindowHeight

func (v *Nvim) WindowHeight(window Window) (height int, err error)

WindowHeight returns the window height.

func (*Nvim) WindowNumber

func (v *Nvim) WindowNumber(window Window) (number int, err error)

WindowNumber gets the window number.

func (*Nvim) WindowOption

func (v *Nvim) WindowOption(window Window, name string, result interface{}) error

WindowOption gets a window option value.

func (*Nvim) WindowPosition

func (v *Nvim) WindowPosition(window Window) (pos [2]int, err error)

WindowPosition gets the window position in display cells. First position is zero.

func (*Nvim) WindowTabpage

func (v *Nvim) WindowTabpage(window Window) (tabpage Tabpage, err error)

WindowTabpage gets the window tabpage.

func (*Nvim) WindowVar

func (v *Nvim) WindowVar(window Window, name string, result interface{}) error

WindowVar gets a window-scoped (w:) variable.

func (*Nvim) WindowWidth

func (v *Nvim) WindowWidth(window Window) (width int, err error)

WindowWidth returns the window width.

func (*Nvim) Windows

func (v *Nvim) Windows() (windows []Window, err error)

Windows gets the current list of window handles.

func (*Nvim) WriteErr

func (v *Nvim) WriteErr(str string) error

WriteErr writes a message to the Vim error buffer.

Does not append "\n", the message is buffered (won't display) until a linefeed is written.

func (*Nvim) WriteOut

func (v *Nvim) WriteOut(str string) error

WriteOut writes a message to the Vim output buffer.

Does not append "\n", the message is buffered (won't display) until a linefeed is written.

func (*Nvim) WritelnErr

func (v *Nvim) WritelnErr(str string) error

WritelnErr writes a message to the Vim error buffer.

Appends "\n", so the buffer is flushed and displayed.

type OptionInfo added in v1.1.4

type OptionInfo struct {
	// Name is the name of the option (like 'filetype').
	Name string `msgpack:"name"`

	// ShortName is the shortened name of the option (like 'ft').
	ShortName string `msgpack:"shortname"`

	// Type is the type of option ("string", "number" or "boolean").
	Type string `msgpack:"type"`

	// Default is the default value for the option.
	Default interface{} `msgpack:"default"`

	// Scope one of "global", "win", or "buf".
	Scope string `msgpack:"scope"`

	// LastSetSid is the last set script id (if any).
	LastSetSid int `msgpack:"last_set_sid"`

	// LastSetLinenr is the line number where option was set.
	LastSetLinenr int `msgpack:"last_set_linenr"`

	// LastSetChan is the channel where option was set (0 for local).
	LastSetChan int `msgpack:"last_set_chan"`

	// WasSet whether the option was set.
	WasSet bool `msgpack:"was_set"`

	// GlobalLocal whether win or buf option has a global value.
	GlobalLocal bool `msgpack:"global_local"`

	// CommaList whether the list of comma separated values.
	CommaList bool `msgpack:"commalist"`

	// FlagList whether the list of single char flags.
	FlagList bool `msgpack:"flaglist"`
}

OptionInfo represents a option information.

type OptionValueScope added in v1.2.1

type OptionValueScope string

OptionValueScope represents a OptionValue scope optional parameter value.

type Process

type Process struct {
	// Name is the name of process command.
	Name string `msgpack:"name,omitempty"`

	// PID is the process ID.
	PID int `msgpack:"pid,omitempty"`

	// PPID is the parent process ID.
	PPID int `msgpack:"ppid,omitempty"`
}

Process represents a Proc and ProcChildren functions return type.

type QuickfixError

type QuickfixError struct {
	// Buffer number
	Bufnr int `msgpack:"bufnr,omitempty"`

	// Line number in the file.
	LNum int `msgpack:"lnum,omitempty"`

	// Search pattern used to locate the error.
	Pattern string `msgpack:"pattern,omitempty"`

	// Column number (first column is 1).
	Col int `msgpack:"col,omitempty"`

	// When Vcol is != 0,  Col is visual column.
	VCol int `msgpack:"vcol,omitempty"`

	// Error number.
	Nr int `msgpack:"nr,omitempty"`

	// Description of the error.
	Text string `msgpack:"text,omitempty"`

	// Single-character error type, 'E', 'W', etc.
	Type string `msgpack:"type,omitempty"`

	// Name of a file; only used when bufnr is not present or it is invalid.
	FileName string `msgpack:"filename,omitempty"`

	// Valid is non-zero if this is a recognized error message.
	Valid int `msgpack:"valid,omitempty"`

	// Module name of a module. If given it will be used in quickfix error window instead of the filename.
	Module string `msgpack:"module,omitempty"`
}

QuickfixError represents an item in a quickfix list.

type Tabpage

type Tabpage int

Tabpage represents a Nvim tabpage.

func (Tabpage) MarshalMsgPack

func (x Tabpage) MarshalMsgPack(enc *msgpack.Encoder) error

MarshalMsgPack implements msgpack.Marshaler.

func (Tabpage) String

func (x Tabpage) String() string

String returns a string representation of the Tabpage.

func (*Tabpage) UnmarshalMsgPack

func (x *Tabpage) UnmarshalMsgPack(dec *msgpack.Decoder) error

UnmarshalMsgPack implements msgpack.Unmarshaler.

type TextChunk added in v1.1.7

type TextChunk struct {
	// Text is text.
	Text string `msgpack:",array"`

	// HLGroup is text highlight group.
	HLGroup string
}

TextChunk represents a text chunk.

type UI

type UI struct {
	// Height requested height of the UI
	Height int `msgpack:"height,omitempty"`

	// Width requested width of the UI
	Width int `msgpack:"width,omitempty"`

	// RGB whether the UI uses rgb colors (false implies cterm colors)
	RGB bool `msgpack:"rgb,omitempty"`

	// ExtPopupmenu externalize the popupmenu.
	ExtPopupmenu bool `msgpack:"ext_popupmenu,omitempty"`

	// ExtTabline externalize the tabline.
	ExtTabline bool `msgpack:"ext_tabline,omitempty"`

	// ExtCmdline externalize the cmdline.
	ExtCmdline bool `msgpack:"ext_cmdline,omitempty"`

	// ExtWildmenu externalize the wildmenu.
	ExtWildmenu bool `msgpack:"ext_wildmenu,omitempty"`

	// ExtNewgrid use new revision of the grid events.
	ExtNewgrid bool `msgpack:"ext_newgrid,omitempty"`

	// ExtHlstate use detailed highlight state.
	ExtHlstate bool `msgpack:"ext_hlstate,omitempty"`

	// ChannelID channel id of remote UI (not present for TUI)
	ChannelID int `msgpack:"chan,omitempty"`
}

UI represents a nvim ui options.

type UserCommand added in v1.2.1

type UserCommand interface {
	// contains filtered or unexported methods
}

UserCommand represesents a user command.

type UserLuaCommand added in v1.2.1

type UserLuaCommand struct {
	// Args passed to the command, if any.
	Args string `msgpack:"args,omitempty"`

	// Bang true if the command was executed with a ! modifier.
	Bang bool `msgpack:"bang"`

	// StartLine is the starting line of the command range.
	StartLine int `msgpack:"line1,omitempty"`

	// FinalLine is the final line of the command range.
	FinalLine int `msgpack:"line2,omitempty"`

	// Range is the number of items in the command range: 0, 1, or 2.
	Range int `msgpack:"range,omitempty"`

	// Count is the any count supplied.
	Count int `msgpack:"count,omitempty"`

	// Reg is the optional register, if specified.
	Reg string `msgpack:"reg,omitempty"`

	// Mode is the command modifiers, if any.
	Mode string `msgpack:"mode,omitempty"`
}

UserLuaCommand is a user Lua command executed at UserCommand.

type UserVimCommand added in v1.2.1

type UserVimCommand string

UserVimCommand is a user Vim command executed at UserCommand.

type Window

type Window int

Window represents a Nvim window.

func (Window) MarshalMsgPack

func (x Window) MarshalMsgPack(enc *msgpack.Encoder) error

MarshalMsgPack implements msgpack.Marshaler.

func (Window) String

func (x Window) String() string

String returns a string representation of the Window.

func (*Window) UnmarshalMsgPack

func (x *Window) UnmarshalMsgPack(dec *msgpack.Decoder) error

UnmarshalMsgPack implements msgpack.Unmarshaler.

type WindowConfig added in v1.0.1

type WindowConfig struct {
	// Relative is the specifies the type of positioning method used for the floating window.
	Relative string `msgpack:"relative,omitempty"`

	// Win is the Window for relative="win".
	Win Window `msgpack:"win,omitempty"`

	// Anchor is the decides which corner of the float to place at row and col.
	Anchor string `msgpack:"anchor,omitempty"`

	// Width is the window width (in character cells). Minimum of 1.
	Width int `msgpack:"width" empty:"1"`

	// Height is the window height (in character cells). Minimum of 1.
	Height int `msgpack:"height" empty:"1"`

	// BufPos places float relative to buffer text only when relative="win".
	BufPos [2]int `msgpack:"bufpos,omitempty"`

	// Row is the row position in units of "screen cell height", may be fractional.
	Row float64 `msgpack:"row,omitempty"`

	// Col is the column position in units of "screen cell width", may be fractional.
	Col float64 `msgpack:"col,omitempty"`

	// Focusable whether the enable focus by user actions (wincmds, mouse events).
	Focusable bool `msgpack:"focusable,omitempty" empty:"true"`

	// External is the GUI should display the window as an external top-level window.
	External bool `msgpack:"external,omitempty"`

	// ZIndex stacking order. floats with higher `zindex` go on top on floats with lower indices. Must be larger than zero.
	ZIndex int `msgpack:"zindex,omitempty" empty:"50"`

	// Style is the Configure the appearance of the window.
	Style string `msgpack:"style,omitempty"`

	// Border is the style of window border.
	Border interface{} `msgpack:"border,omitempty"`

	// NoAutocmd whether the fire buffer-related autocommand events
	NoAutocmd bool `msgpack:"noautocmd,omitempty"`
}

WindowConfig represents a configs of OpenWindow.

Relative is the specifies the type of positioning method used for the floating window. The positioning method string keys names:

editor

The global editor grid.

win

Window given by the `win` field, or current window by default.

cursor

Cursor position in current window.

Win is window ID for Relative="win".

Anchor is the decides which corner of the float to place at row and col.

NW

northwest (default)

NE

northeast

SW

southwest

SE

southeast

BufPos places float relative to buffer text only when Relative == "win". Takes a tuple of zero-indexed [line, column]. Row and Col if given are applied relative to this position, else they default to Row=1 and Col=0 (thus like a tooltip near the buffer text).

Row is the row position in units of "screen cell height", may be fractional.

Col is the column position in units of "screen cell width", may be fractional.

Focusable whether the enable focus by user actions (wincmds, mouse events). Defaults to true. Non-focusable windows can be entered by SetCurrentWindow.

External is the GUI should display the window as an external top-level window. Currently accepts no other positioning configuration together with this.

ZIndex is stacking order. floats with higher "zindex" go on top on floats with lower indices. Must be larger than zero. The default value for floats are 50. In general, values below 100 are recommended, unless there is a good reason to overshadow builtin elements.

Style is the Configure the appearance of the window. Currently only takes one non-empty value:

minimal

Nvim will display the window with many UI options disabled. This is useful when displaying a temporary float where the text should not be edited.

Disables "number", "relativenumber", "cursorline", "cursorcolumn", "foldcolumn", "spell" and "list" options. And, "signcolumn" is changed to "auto" and "colorcolumn" is cleared. The end-of-buffer region is hidden by setting "eob" flag of "fillchars" to a space char, and clearing the EndOfBuffer region in "winhighlight".

border

Style of (optional) window border. This can either be a string or an array. The string values are:

none

No border. This is the default.

single

A single line box.

double

A double line box.

rounded

Like "single", but with rounded corners ("╭" etc.).

solid

Adds padding by a single whitespace cell.

shadow

A drop shadow effect by blending with the background.

If it is an array it should be an array of eight items or any divisor of eight. The array will specifify the eight chars building up the border in a clockwise fashion starting with the top-left corner. As, an example, the double box style could be specified as:

[ "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" ]

If the number of chars are less than eight, they will be repeated. Thus an ASCII border could be specified as:

[ "/", "-", "\\", "|" ]

Or all chars the same as:

[ "x" ]

An empty string can be used to turn off a specific border, for instance,

[ "", "", "", ">", "", "", "", "<" ]

By default "FloatBorder" highlight is used which links to "VertSplit" when not defined. It could also be specified by character:

[ {"+", "MyCorner"}, {"x", "MyBorder"} ]

NoAutocmd is if true then no buffer-related autocommand events such as BufEnter, BufLeave or BufWinEnter may fire from calling this function.

Directories

Path Synopsis
Package plugin is a Nvim remote plugin host.
Package plugin is a Nvim remote plugin host.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL