nvim

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: Apache-2.0 Imports: 16 Imported by: 114

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)
	}
}

Index

Examples

Constants

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

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(result *[]interface{})

func (*Batch) AddBufferHighlight

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

AddBufferHighlight adds a highlight to buffer and returns the source id of the highlight.

AddBufferHighlight can be used for plugins which dynamically generate highlights to a buffer (like a semantic highlighter or linter). The function adds a single highlight to a buffer. Unlike matchaddpos() highlights follow changes to line numbering (as lines are inserted/removed above the highlighted line), like signs and marks do.

The srcID is useful for batch deletion/updating of a set of highlights. When called with srcID = 0, an unique source id is generated and returned. Successive calls can pass in it as srcID to add new highlights to the same source group. All highlights in the same group can then be cleared with ClearBufferHighlight. If the highlight never will be manually deleted pass in -1 for srcID.

If hlGroup is the empty string no highlight is added, but a new srcID is still returned. This is useful for an external plugin to synchronously request an unique srcID at initialization, and later asynchronously add and clear highlights in response to buffer changes.

The startCol and endCol parameters specify the range of columns to highlight. Use endCol = -1 to highlight to the end of the line.

func (*Batch) AttachBuffer

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

AttachBuffer activate updates from this buffer to the current channel.

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`

opts is optional parameters. Currently not used.

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, result *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, result *[]int)

BufferExtmarkByID returns position for a given extmark id.

func (*Batch) BufferExtmarks added in v1.0.2

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

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` is less than `start`, traversal works backwards. (Useful with `limit`, to get the first marks prior to a given position.)

The `opts` is additional options. Supports the key:

limit: (int) Maximum number of marks to return.

func (*Batch) BufferKeyMap

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

BufferKeymap gets a list of buffer-local mappings.

func (*Batch) BufferLineCount

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

BufferLineCount returns the number of lines in the buffer.

func (*Batch) BufferLines

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

BufferLines retrieves a line range from a buffer.

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

Out-of-bounds indices are clamped to the nearest valid value, unless strict = true.

func (*Batch) BufferMark

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

BufferMark returns the (row,col) of the named mark.

func (*Batch) BufferName

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

BufferName gets the full file name of a buffer.

func (*Batch) BufferNumber deprecated

func (b *Batch) BufferNumber(buffer Buffer, result *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, result *int)

BufferOffset returns the byte offset for a line.

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 'eol'.

Unlike |line2byte()|, throws error for out-of-bounds indexing. Returns -1 for unloaded buffer.

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) BufferVirtualText added in v1.0.2

func (b *Batch) BufferVirtualText(buffer Buffer, lnum int, result *[]VirtualTextChunk)

BufferVirtualText gets the virtual text (annotation) for a buffer line.

The virtual text is returned as list of lists, whereas the inner lists have either one or two elements. The first element is the actual text, the optional second element is the highlight group.

The format is exactly the same as given to SetBufferVirtualText.

If there is no virtual text associated with the given line, an empty list is returned.

func (*Batch) Buffers

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

Buffers returns the current list of buffers.

func (*Batch) Call

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

Call calls a vimscript function.

func (*Batch) CallDict

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

CallDict calls a vimscript Dictionary function.

func (*Batch) ChannelInfo

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

ChannelInfo get information about a channel.

func (*Batch) Channels

func (b *Batch) Channels(result *[]*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 and virtual text, from a line range.

To clear the namespace in the entire buffer, pass in 0 and -1 to line_start and line_end respectively.

func (*Batch) CloseWindow

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

CloseWindow close a window.

This is equivalent to |:close| with count except that it takes a window id.

func (*Batch) ColorByName

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

func (*Batch) ColorMap

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

func (*Batch) Command

func (b *Batch) Command(cmd string)

Command executes a single ex command.

func (*Batch) CommandOutput deprecated

func (b *Batch) CommandOutput(cmd string, result *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{}, result *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, result *map[string]interface{})

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

The `opts` is optional parameters.

types

List of context-types to gather: "regs", "jumps", "bufs", "gvars", "funcs", "sfuncs". empty for all context.

func (*Batch) CreateBuffer

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

CreateBuffer creates a new, empty, unnamed buffer.

func (*Batch) CreateNamespace

func (b *Batch) CreateNamespace(name string, result *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(result *Buffer)

CurrentBuffer returns the current buffer.

func (*Batch) CurrentLine

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

CurrentLine gets the current line in the current buffer.

func (*Batch) CurrentTabpage

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

CurrentTabpage returns the current tabpage.

func (*Batch) CurrentWindow

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

CurrentWindow returns the current window.

func (*Batch) DeleteBufferExtmark added in v1.0.2

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

DeleteBufferExtmark removes an extmark.

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) 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 in the current buffer.

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) DeleteTabpageVar

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

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

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, result *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) Eval

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

Eval evaluates the expression expr using the Vim internal expression evaluator.

:help expression

func (*Batch) Exec added in v1.0.2

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

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

func (*Batch) ExecLua added in v1.0.2

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

ExecLua executes a Lua block.

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 Pushes keys to the Nvim user input buffer. Options can be a string with the 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.

func (*Batch) HLByID

func (b *Batch) HLByID(id int, rgb bool, result **HLAttrs)

HLByID gets a highlight definition by id.

func (*Batch) HLByName

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

HLByName gets a highlight definition by name.

func (*Batch) HLIDByName added in v1.0.2

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

HLIDByName gets a highlight group by name.

func (*Batch) Input

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

Input pushes bytes to the Nvim low level input buffer.

Unlike FeedKeys, this uses the lowest level input buffer and the call is not deferred. It returns the number of bytes actually written(which can be less than what was requested if the buffer is 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.

The call is non-blocking. It doesn't wait on any resulting action, but queues the event to be processed soon by the event loop.

func (*Batch) IsBufferLoaded

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

IsBufferLoaded Checks if a buffer is valid and loaded. See api-buffer for more info about unloaded buffers.

func (*Batch) IsBufferValid

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

IsBufferValid returns true if the buffer is valid.

func (*Batch) IsTabpageValid

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

IsTabpageValid checks if a tab page is valid.

func (*Batch) IsWindowValid

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

IsWindowValid returns true if the window is valid.

func (*Batch) KeyMap

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

func (*Batch) LoadContext added in v1.0.2

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

LoadContext sets the current editor state from the given context map. This API still under development.

func (*Batch) Mode

func (b *Batch) Mode(result *Mode)

Mode gets Nvim's current mode.

func (*Batch) Namespaces

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

Namespaces gets existing named namespaces

The return dict that maps from names to namespace ids.

func (*Batch) OpenWindow

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

OpenWindow opens 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 |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.

The returns the window handle or 0 when error.

func (*Batch) Option

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

Option gets an option.

func (*Batch) ParseExpression

func (b *Batch) ParseExpression(expr string, flags string, highlight bool, result *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, result *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` values:

1: starts the paste (exactly once)
2: continues the paste (zero or more times)
3: ends the paste (exactly once)

func (*Batch) Proc

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

Proc gets info describing process `pid`.

func (*Batch) ProcChildren

func (b *Batch) ProcChildren(pid int, result *[]*Process)

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.

type 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 is place cursor at end of inserted text.

func (*Batch) ReplaceTermcodes

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

ReplaceTermcodes replaces any terminal code strings by byte sequences. 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 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, result *[]string)

RuntimeFiles finds files in runtime directories and returns list of absolute paths to the found files.

name

can contain wildcards. For example

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

will return all color scheme files.

all

whether to return all matches or only the first.

func (*Batch) RuntimePaths

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

RuntimePaths returns a list of paths contained in the runtimepath option.

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.

The `opts` optional parameters. Reserved for future use.

func (*Batch) SetBufferExtmark added in v1.0.2

func (b *Batch) SetBufferExtmark(buffer Buffer, nsID int, extmarkID int, line int, col int, opts map[string]interface{}, result *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.)

Currently opts arg not used.

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, strict bool, replacement [][]byte)

SetBufferLines replaces a line range on a buffer.

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

To insert lines at a given index, set both start and end to the same index. To delete a range of lines, set replacement to an empty array.

Out-of-bounds indices are clamped to the nearest valid value, unless strict = true.

func (*Batch) SetBufferName

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

SetBufferName sets the full file name of a buffer. BufFilePre/BufFilePost are triggered.

func (*Batch) SetBufferOption

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

SetBufferOption sets a buffer option value. The value nil deletes the option in the case where there's a global fallback.

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

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

SetBufferVirtualText sets 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` is optional parameters. Currently not used.

The returns the nsID that was used.

func (*Batch) SetClientInfo

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

SetClientInfo 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)

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 Vim working directory.

func (*Batch) SetCurrentLine

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

SetCurrentLine sets the current line in the current buffer.

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

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 map[string]interface{})

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

See documentation at |nvim_open_win()|, for the meaning of parameters.

When reconfiguring a floating window, absent option keys will not be changed. The following restriction apply: `row`, `col` and `relative` must be reconfigured together. Only changing a subset of these is an error.

func (*Batch) SetWindowCursor

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

SetWindowCursor sets the cursor position in the window to the given position.

func (*Batch) SetWindowHeight

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

SetWindowHeight sets the window height.

func (*Batch) SetWindowOption

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

SetWindowOption sets a window option.

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.

func (*Batch) StringWidth

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

StringWidth returns the number of display cells the string occupies. Tab is counted as one cell.

func (*Batch) Subscribe

func (b *Batch) Subscribe(event string)

Subscribe subscribes to a Nvim event.

func (*Batch) TabpageNumber

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

TabpageNumber gets the tabpage number from the tabpage handle.

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 tab page.

func (*Batch) TabpageWindows

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

TabpageWindows returns the windows in a tabpage.

func (*Batch) Tabpages

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

Tabpages returns the current list of tabpages.

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(result *[]*UI)

UIs gets a list of dictionaries representing attached UIs.

func (*Batch) Unsubscribe

func (b *Batch) Unsubscribe(event string)

Unsubscribe unsubscribes to a Nvim event.

func (*Batch) VVar

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

VVar gets a vim (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, result *Buffer)

WindowBuffer returns the current buffer in a window.

func (*Batch) WindowConfig

func (b *Batch) WindowConfig(window Window, result *map[string]interface{})

WindowConfig return window configuration.

Return a dictionary containing the same config that can be given to |nvim_open_win()|.

`relative` will be an empty string for normal windows.

func (*Batch) WindowCursor

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

WindowCursor returns the cursor position in the window.

func (*Batch) WindowHeight

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

WindowHeight returns the window height.

func (*Batch) WindowNumber

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

WindowNumber gets the window number from the window handle.

func (*Batch) WindowOption

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

WindowOption gets a window option.

func (*Batch) WindowPosition

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

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

func (*Batch) WindowTabpage

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

WindowTabpage gets the tab page that contains the window.

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, result *int)

WindowWidth returns the window width.

func (*Batch) Windows

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

Windows returns the current list of windows.

func (*Batch) WriteErr

func (b *Batch) WriteErr(str string)

WriteErr writes a message to vim error buffer. The string is split and flushed after each newline. Incomplete lines are kept for writing later.

func (*Batch) WriteOut

func (b *Batch) WriteOut(str string)

WriteOut writes a message to vim output buffer. The string is split and flushed after each newline. Incomplete lines are kept for writing later.

func (*Batch) WritelnErr

func (b *Batch) WritelnErr(str string)

WritelnErr writes prints str and a newline as an error message.

type BatchError

type BatchError struct {
	// Index is a zero-based index of the function call which resulted in the
	// error.
	Index int

	// Err is the error.
	Err error
}

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

func (*BatchError) Error

func (e *BatchError) Error() string

type Buffer

type Buffer int

Buffer represents a remote Nvim buffer.

func (Buffer) MarshalMsgPack

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

func (Buffer) String

func (x Buffer) String() string

func (*Buffer) UnmarshalMsgPack

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

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 (optional).
	Pty string `msgpack:"pty,omitempty"`

	// Buffer is the buffer with connected terminal instance (optional).
	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 nvim_set_client_info (optional).
	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 `msgpack:"nargs"`
}

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 `msgpack:",array"`
}

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 {
	Bang        bool   `msgpack:"bang"`
	Complete    string `msgpack:"complete,omitempty"`
	Nargs       string `msgpack:"nargs"`
	Range       string `msgpack:"range,omitempty"`
	Name        string `msgpack:"name"`
	ScriptID    int    `msgpack:"script_id"`
	Bar         bool   `msgpack:"bar"`
	Register    bool   `msgpack:"register"`
	Addr        string `msgpack:"addr,omitempty"`
	Count       string `msgpack:"count,omitempty"`
	CompleteArg string `msgpack:"complete_arg,omitempty"`
	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 string
}

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

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

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

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

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

	Logf func(string, ...interface{})
}

EmbedOptions specifies options for starting an embedded instance of Nvim.

type ErrorList

type ErrorList []error

ErrorList is a list of errors.

func (ErrorList) Error

func (el ErrorList) Error() string

type ExtMarks added in v1.0.2

type ExtMarks struct {
	ExtmarkID int `msgpack:",array"`
	Row       int
	Col       int
}

ExtMarks represents a BufferExtmarks returns type.

type HLAttrs

type HLAttrs struct {
	Bold       bool `msgpack:"bold,omitempty"`
	Underline  bool `msgpack:"underline,omitempty"`
	Undercurl  bool `msgpack:"undercurl,omitempty"`
	Italic     bool `msgpack:"italic,omitempty"`
	Reverse    bool `msgpack:"reverse,omitempty"`
	Foreground int  `msgpack:"foreground,omitempty" empty:"-1"`
	Background int  `msgpack:"background,omitempty" empty:"-1"`
	Special    int  `msgpack:"special,omitempty" empty:"-1"`
}

HLAttrs represents a highlight definitions.

type Mapping

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

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

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

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

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

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

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

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

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

Mapping represents a nvim mapping options.

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() ([]interface{}, error)

func (*Nvim) AddBufferHighlight

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

AddBufferHighlight adds a highlight to buffer and returns the source id of the highlight.

AddBufferHighlight can be used for plugins which dynamically generate highlights to a buffer (like a semantic highlighter or linter). The function adds a single highlight to a buffer. Unlike matchaddpos() highlights follow changes to line numbering (as lines are inserted/removed above the highlighted line), like signs and marks do.

The srcID is useful for batch deletion/updating of a set of highlights. When called with srcID = 0, an unique source id is generated and returned. Successive calls can pass in it as srcID to add new highlights to the same source group. All highlights in the same group can then be cleared with ClearBufferHighlight. If the highlight never will be manually deleted pass in -1 for srcID.

If hlGroup is the empty string no highlight is added, but a new srcID is still returned. This is useful for an external plugin to synchronously request an unique srcID at initialization, and later asynchronously add and clear highlights in response to buffer changes.

The startCol and endCol parameters specify the range of columns to highlight. Use endCol = -1 to highlight to the end of the line.

func (*Nvim) AttachBuffer

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

AttachBuffer activate updates from this buffer to the current channel.

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`

opts is optional parameters. Currently not used.

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) (int, 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) ([]int, error)

BufferExtmarkByID returns position for a given extmark id.

func (*Nvim) BufferExtmarks added in v1.0.2

func (v *Nvim) BufferExtmarks(buffer Buffer, nsID int, start interface{}, end interface{}, opt map[string]interface{}) ([]ExtMarks, 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` is less than `start`, traversal works backwards. (Useful with `limit`, to get the first marks prior to a given position.)

The `opts` is additional options. Supports the key:

limit: (int) Maximum number of marks to return.

func (*Nvim) BufferKeyMap

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

BufferKeymap gets a list of buffer-local mappings.

func (*Nvim) BufferLineCount

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

BufferLineCount returns the number of lines in the buffer.

func (*Nvim) BufferLines

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

BufferLines retrieves a line range from a buffer.

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

Out-of-bounds indices are clamped to the nearest valid value, unless strict = true.

func (*Nvim) BufferMark

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

BufferMark returns the (row,col) of the named mark.

func (*Nvim) BufferName

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

BufferName gets the full file name of a buffer.

func (*Nvim) BufferNumber deprecated

func (v *Nvim) BufferNumber(buffer Buffer) (int, 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) (int, error)

BufferOffset returns the byte offset for a line.

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 'eol'.

Unlike |line2byte()|, throws error for out-of-bounds indexing. Returns -1 for unloaded buffer.

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) BufferVirtualText added in v1.0.2

func (v *Nvim) BufferVirtualText(buffer Buffer, lnum int) ([]VirtualTextChunk, error)

BufferVirtualText gets the virtual text (annotation) for a buffer line.

The virtual text is returned as list of lists, whereas the inner lists have either one or two elements. The first element is the actual text, the optional second element is the highlight group.

The format is exactly the same as given to SetBufferVirtualText.

If there is no virtual text associated with the given line, an empty list is returned.

func (*Nvim) Buffers

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

Buffers returns the current list of buffers.

func (*Nvim) Call

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

Call calls a vimscript function.

func (*Nvim) CallDict

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

CallDict calls a vimscript Dictionary function.

func (*Nvim) ChannelID

func (v *Nvim) ChannelID() int

ChannelID returns Nvim's channel id for this client.

func (*Nvim) ChannelInfo

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

ChannelInfo get information about a channel.

func (*Nvim) Channels

func (v *Nvim) Channels() ([]*Channel, 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 and virtual text, from a line range.

To clear the namespace in the entire buffer, pass in 0 and -1 to line_start and line_end respectively.

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 close a window.

This is equivalent to |:close| with count except that it takes a window id.

func (*Nvim) ColorByName

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

func (*Nvim) ColorMap

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

func (*Nvim) Command

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

Command executes a single ex command.

func (*Nvim) CommandOutput deprecated

func (v *Nvim) CommandOutput(cmd string) (string, 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{}) (map[string]*Command, 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) (map[string]interface{}, error)

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

The `opts` is optional parameters.

types

List of context-types to gather: "regs", "jumps", "bufs", "gvars", "funcs", "sfuncs". empty for all context.

func (*Nvim) CreateBuffer

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

CreateBuffer creates a new, empty, unnamed buffer.

func (*Nvim) CreateNamespace

func (v *Nvim) CreateNamespace(name string) (int, 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, error)

CurrentBuffer returns the current buffer.

func (*Nvim) CurrentLine

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

CurrentLine gets the current line in the current buffer.

func (*Nvim) CurrentTabpage

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

CurrentTabpage returns the current tabpage.

func (*Nvim) CurrentWindow

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

CurrentWindow returns the current window.

func (*Nvim) DeleteBufferExtmark added in v1.0.2

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

DeleteBufferExtmark removes an extmark.

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) 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 in the current buffer.

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) DeleteTabpageVar

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

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

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) (bool, 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) Eval

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

Eval evaluates the expression expr using the Vim internal expression evaluator.

:help expression

func (*Nvim) Exec added in v1.0.2

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

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

func (*Nvim) ExecLua added in v1.0.2

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

ExecLua executes a Lua block.

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 Pushes keys to the Nvim user input buffer. Options can be a string with the 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.

func (*Nvim) HLByID

func (v *Nvim) HLByID(id int, rgb bool) (*HLAttrs, error)

HLByID gets a highlight definition by id.

func (*Nvim) HLByName

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

HLByName gets a highlight definition by name.

func (*Nvim) HLIDByName added in v1.0.2

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

HLIDByName gets a highlight group by name.

func (*Nvim) Input

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

Input pushes bytes to the Nvim low level input buffer.

Unlike FeedKeys, this uses the lowest level input buffer and the call is not deferred. It returns the number of bytes actually written(which can be less than what was requested if the buffer is 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.

The call is non-blocking. It doesn't wait on any resulting action, but queues the event to be processed soon by the event loop.

func (*Nvim) IsBufferLoaded

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

IsBufferLoaded Checks if a buffer is valid and loaded. See api-buffer for more info about unloaded buffers.

func (*Nvim) IsBufferValid

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

IsBufferValid returns true if the buffer is valid.

func (*Nvim) IsTabpageValid

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

IsTabpageValid checks if a tab page is valid.

func (*Nvim) IsWindowValid

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

IsWindowValid returns true if the window is valid.

func (*Nvim) KeyMap

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

func (*Nvim) LoadContext added in v1.0.2

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

LoadContext sets the current editor state from the given context map. This API still under development.

func (*Nvim) Mode

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

Mode gets Nvim's current mode.

func (*Nvim) Namespaces

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

Namespaces gets existing named 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) OpenWindow

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

OpenWindow opens 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 |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.

The returns the window handle or 0 when error.

func (*Nvim) Option

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

Option gets an option.

func (*Nvim) ParseExpression

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

ParseExpression parse a VimL expression.

func (*Nvim) Paste added in v1.0.2

func (v *Nvim) Paste(data string, crlf bool, phase int) (bool, 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` values:

1: starts the paste (exactly once)
2: continues the paste (zero or more times)
3: ends the paste (exactly once)

func (*Nvim) Proc

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

Proc gets info describing process `pid`.

func (*Nvim) ProcChildren

func (v *Nvim) ProcChildren(pid int) ([]*Process, 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.

type 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 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) (string, error)

ReplaceTermcodes replaces any terminal code strings by byte sequences. 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 RPC request.

func (*Nvim) RuntimeFiles added in v1.1.1

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

RuntimeFiles finds files in runtime directories and returns list of absolute paths to the found files.

name

can contain wildcards. For example

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

will return all color scheme files.

all

whether to return all matches or only the first.

func (*Nvim) RuntimePaths

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

RuntimePaths returns a list of paths contained in the runtimepath option.

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.

The `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, extmarkID int, line int, col int, opts map[string]interface{}) (int, 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.)

Currently opts arg not used.

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, strict bool, replacement [][]byte) error

SetBufferLines replaces a line range on a buffer.

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

To insert lines at a given index, set both start and end to the same index. To delete a range of lines, set replacement to an empty array.

Out-of-bounds indices are clamped to the nearest valid value, unless strict = true.

func (*Nvim) SetBufferName

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

SetBufferName sets the full file name of a buffer. BufFilePre/BufFilePost are triggered.

func (*Nvim) SetBufferOption

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

SetBufferOption sets a buffer option value. The value nil deletes the option in the case where there's a global fallback.

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

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

SetBufferVirtualText sets 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` is optional parameters. Currently not used.

The returns the nsID that was used.

func (*Nvim) SetClientInfo

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

SetClientInfo 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)

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 Vim working directory.

func (*Nvim) SetCurrentLine

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

SetCurrentLine sets the current line in the current buffer.

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

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 map[string]interface{}) error

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

See documentation at |nvim_open_win()|, for the meaning of parameters.

When reconfiguring a floating window, absent option keys will not be changed. The following restriction apply: `row`, `col` and `relative` must be reconfigured together. Only changing a subset of these is an error.

func (*Nvim) SetWindowCursor

func (v *Nvim) SetWindowCursor(window Window, pos [2]int) error

SetWindowCursor sets the cursor position in the window to the given position.

func (*Nvim) SetWindowHeight

func (v *Nvim) SetWindowHeight(window Window, height int) error

SetWindowHeight sets the window height.

func (*Nvim) SetWindowOption

func (v *Nvim) SetWindowOption(window Window, name string, value interface{}) error

SetWindowOption sets a window option.

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.

func (*Nvim) StringWidth

func (v *Nvim) StringWidth(s string) (int, error)

StringWidth returns the number of display cells the string occupies. Tab is counted as one cell.

func (*Nvim) Subscribe

func (v *Nvim) Subscribe(event string) error

Subscribe subscribes to a Nvim event.

func (*Nvim) TabpageNumber

func (v *Nvim) TabpageNumber(tabpage Tabpage) (int, error)

TabpageNumber gets the tabpage number from the tabpage handle.

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 tab page.

func (*Nvim) TabpageWindows

func (v *Nvim) TabpageWindows(tabpage Tabpage) ([]Window, error)

TabpageWindows returns the windows in a tabpage.

func (*Nvim) Tabpages

func (v *Nvim) Tabpages() ([]Tabpage, error)

Tabpages returns the current list of tabpages.

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() ([]*UI, error)

UIs gets a list of dictionaries representing attached UIs.

func (*Nvim) Unsubscribe

func (v *Nvim) Unsubscribe(event string) error

Unsubscribe unsubscribes to a Nvim event.

func (*Nvim) VVar

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

VVar gets a vim (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, error)

WindowBuffer returns the current buffer in a window.

func (*Nvim) WindowConfig

func (v *Nvim) WindowConfig(window Window) (map[string]interface{}, error)

WindowConfig return window configuration.

Return a dictionary containing the same config that can be given to |nvim_open_win()|.

`relative` will be an empty string for normal windows.

func (*Nvim) WindowCursor

func (v *Nvim) WindowCursor(window Window) ([2]int, error)

WindowCursor returns the cursor position in the window.

func (*Nvim) WindowHeight

func (v *Nvim) WindowHeight(window Window) (int, error)

WindowHeight returns the window height.

func (*Nvim) WindowNumber

func (v *Nvim) WindowNumber(window Window) (int, error)

WindowNumber gets the window number from the window handle.

func (*Nvim) WindowOption

func (v *Nvim) WindowOption(window Window, name string, result interface{}) error

WindowOption gets a window option.

func (*Nvim) WindowPosition

func (v *Nvim) WindowPosition(window Window) ([2]int, error)

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

func (*Nvim) WindowTabpage

func (v *Nvim) WindowTabpage(window Window) (Tabpage, error)

WindowTabpage gets the tab page that contains the window.

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) (int, error)

WindowWidth returns the window width.

func (*Nvim) Windows

func (v *Nvim) Windows() ([]Window, error)

Windows returns the current list of windows.

func (*Nvim) WriteErr

func (v *Nvim) WriteErr(str string) error

WriteErr writes a message to vim error buffer. The string is split and flushed after each newline. Incomplete lines are kept for writing later.

func (*Nvim) WriteOut

func (v *Nvim) WriteOut(str string) error

WriteOut writes a message to vim output buffer. The string is split and flushed after each newline. Incomplete lines are kept for writing later.

func (*Nvim) WritelnErr

func (v *Nvim) WritelnErr(str string) error

WritelnErr writes prints str and a newline as an error message.

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 remote Nvim tabpage.

func (Tabpage) MarshalMsgPack

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

func (Tabpage) String

func (x Tabpage) String() string

func (*Tabpage) UnmarshalMsgPack

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

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 VirtualTextChunk

type VirtualTextChunk struct {
	Text    string `msgpack:",array"`
	HLGroup string `msgpack:",array"`
}

VirtualTextChunk represents a virtual text chunk.

type Window

type Window int

Window represents a remote Nvim window.

func (Window) MarshalMsgPack

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

func (Window) String

func (x Window) String() string

func (*Window) UnmarshalMsgPack

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

type WindowConfig added in v1.0.1

type WindowConfig struct {
	Relative  string `msgpack:"relative,omitempty"`
	Win       Window `msgpack:"win,omitempty"`
	Anchor    string `msgpack:"anchor,omitempty" empty:"NW"`
	Width     int    `msgpack:"width" empty:"1"`
	Height    int    `msgpack:"height" empty:"1"`
	BufPos    [2]int `msgpack:"bufpos,omitempty"`
	Row       int    `msgpack:"row,omitempty"`
	Col       int    `msgpack:"col,omitempty"`
	Focusable bool   `msgpack:"focusable,omitempty" empty:"true"`
	External  bool   `msgpack:"external,omitempty"`
	Style     string `msgpack:"style,omitempty"`
}

WindowConfig represents a configs of OpenWindow.

Relative is the specifies the type of positioning method used for the floating window. The positioning method 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 the Window 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

Width is the window width (in character cells). Minimum of 1.

Height is the window height (in character cells). Minimum of 1.

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.

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. 'signcolumn' is changed to `auto`.
  The end-of-buffer region is hidden by setting `eob` flag of 'fillchars' to a space char, and clearing the EndOfBuffer region in 'winhighlight'.

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