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 ¶
- Constants
- func NewBufferReader(v *Nvim, b Buffer) io.Reader
- type Batch
- func (b *Batch) APIInfo(result *[]interface{})
- func (b *Batch) AddBufferHighlight(buffer Buffer, srcID int, hlGroup string, line int, startCol int, endCol int, ...)
- func (b *Batch) AttachBuffer(buffer Buffer, sendBuffer bool, opts map[string]interface{}, result *bool)
- func (b *Batch) AttachUI(width int, height int, options map[string]interface{})
- func (b *Batch) BufferChangedTick(buffer Buffer, result *int)
- func (b *Batch) BufferCommands(buffer Buffer, opts map[string]interface{}, result *map[string]*Command)
- func (b *Batch) BufferExtmarkByID(buffer Buffer, nsID int, id int, result *[]int)
- func (b *Batch) BufferExtmarks(buffer Buffer, nsID int, start interface{}, end interface{}, ...)
- func (b *Batch) BufferKeyMap(buffer Buffer, mode string, result *[]*Mapping)
- func (b *Batch) BufferLineCount(buffer Buffer, result *int)
- func (b *Batch) BufferLines(buffer Buffer, start int, end int, strict bool, result *[][]byte)
- func (b *Batch) BufferMark(buffer Buffer, name string, result *[2]int)
- func (b *Batch) BufferName(buffer Buffer, result *string)
- func (b *Batch) BufferNumber(buffer Buffer, result *int)deprecated
- func (b *Batch) BufferOffset(buffer Buffer, index int, result *int)
- func (b *Batch) BufferOption(buffer Buffer, name string, result interface{})
- func (b *Batch) BufferVar(buffer Buffer, name string, result interface{})
- func (b *Batch) BufferVirtualText(buffer Buffer, lnum int, result *[]VirtualTextChunk)
- func (b *Batch) Buffers(result *[]Buffer)
- func (b *Batch) Call(fname string, result interface{}, args ...interface{})
- func (b *Batch) CallDict(dict []interface{}, fname string, result interface{}, args ...interface{})
- func (b *Batch) ChannelInfo(channel int, result **Channel)
- func (b *Batch) Channels(result *[]*Channel)
- func (b *Batch) ClearBufferHighlight(buffer Buffer, srcID int, startLine int, endLine int)deprecated
- func (b *Batch) ClearBufferNamespace(buffer Buffer, nsID int, lineStart int, lineEnd int)
- func (b *Batch) CloseWindow(window Window, force bool)
- func (b *Batch) ColorByName(name string, result *int)
- func (b *Batch) ColorMap(result *map[string]int)
- func (b *Batch) Command(cmd string)
- func (b *Batch) CommandOutput(cmd string, result *string)deprecated
- func (b *Batch) Commands(opts map[string]interface{}, result *map[string]*Command)
- func (b *Batch) Context(opts map[string][]string, result *map[string]interface{})
- func (b *Batch) CreateBuffer(listed bool, scratch bool, result *Buffer)
- func (b *Batch) CreateNamespace(name string, result *int)
- func (b *Batch) CurrentBuffer(result *Buffer)
- func (b *Batch) CurrentLine(result *[]byte)
- func (b *Batch) CurrentTabpage(result *Tabpage)
- func (b *Batch) CurrentWindow(result *Window)
- func (b *Batch) DeleteBufferExtmark(buffer Buffer, nsID int, extmarkID int, result *bool)
- func (b *Batch) DeleteBufferKeyMap(buffer Buffer, mode string, lhs string)
- func (b *Batch) DeleteBufferVar(buffer Buffer, name string)
- func (b *Batch) DeleteCurrentLine()
- func (b *Batch) DeleteKeyMap(mode string, lhs string)
- func (b *Batch) DeleteTabpageVar(tabpage Tabpage, name string)
- func (b *Batch) DeleteVar(name string)
- func (b *Batch) DeleteWindowVar(window Window, name string)
- func (b *Batch) DetachBuffer(buffer Buffer, result *bool)
- func (b *Batch) DetachUI()
- func (b *Batch) Eval(expr string, result interface{})
- func (b *Batch) Exec(src string, output bool, result *string)
- func (b *Batch) ExecLua(code string, result interface{}, args ...interface{})
- func (b *Batch) Execute() error
- func (b *Batch) ExecuteLua(code string, result interface{}, args ...interface{})deprecated
- func (b *Batch) FeedKeys(keys string, mode string, escapeCSI bool)
- func (b *Batch) HLByID(id int, rgb bool, result **HLAttrs)
- func (b *Batch) HLByName(name string, rgb bool, result **HLAttrs)
- func (b *Batch) HLIDByName(name string, result *int)
- func (b *Batch) Input(keys string, result *int)
- func (b *Batch) InputMouse(button string, action string, modifier string, grid int, row int, col int)
- func (b *Batch) IsBufferLoaded(buffer Buffer, result *bool)
- func (b *Batch) IsBufferValid(buffer Buffer, result *bool)
- func (b *Batch) IsTabpageValid(tabpage Tabpage, result *bool)
- func (b *Batch) IsWindowValid(window Window, result *bool)
- func (b *Batch) KeyMap(mode string, result *[]*Mapping)
- func (b *Batch) LoadContext(dict map[string]interface{}, result interface{})
- func (b *Batch) Mode(result *Mode)
- func (b *Batch) Namespaces(result *map[string]int)
- func (b *Batch) OpenWindow(buffer Buffer, enter bool, config *WindowConfig, result *Window)
- func (b *Batch) Option(name string, result interface{})
- func (b *Batch) ParseExpression(expr string, flags string, highlight bool, result *map[string]interface{})
- func (b *Batch) Paste(data string, crlf bool, phase int, result *bool)
- func (b *Batch) Proc(pid int, result *Process)
- func (b *Batch) ProcChildren(pid int, result *[]*Process)
- func (b *Batch) Put(lines []string, typ string, after bool, follow bool)
- func (b *Batch) ReplaceTermcodes(str string, fromPart bool, doLT bool, special bool, result *string)
- func (b *Batch) Request(procedure string, result interface{}, args ...interface{})
- func (b *Batch) RuntimeFiles(name string, all bool, result *[]string)
- func (b *Batch) RuntimePaths(result *[]string)
- func (b *Batch) SelectPopupmenuItem(item int, insert bool, finish bool, opts map[string]interface{})
- func (b *Batch) SetBufferExtmark(buffer Buffer, nsID int, extmarkID int, line int, col int, ...)
- func (b *Batch) SetBufferKeyMap(buffer Buffer, mode string, lhs string, rhs string, opts map[string]bool)
- func (b *Batch) SetBufferLines(buffer Buffer, start int, end int, strict bool, replacement [][]byte)
- func (b *Batch) SetBufferName(buffer Buffer, name string)
- func (b *Batch) SetBufferOption(buffer Buffer, name string, value interface{})
- func (b *Batch) SetBufferToWindow(window Window, buffer Buffer)
- func (b *Batch) SetBufferVar(buffer Buffer, name string, value interface{})
- func (b *Batch) SetBufferVirtualText(buffer Buffer, nsID int, line int, chunks []VirtualTextChunk, ...)
- func (b *Batch) SetClientInfo(name string, version *ClientVersion, typ string, ...)
- func (b *Batch) SetCurrentBuffer(buffer Buffer)
- func (b *Batch) SetCurrentDirectory(dir string)
- func (b *Batch) SetCurrentLine(line []byte)
- func (b *Batch) SetCurrentTabpage(tabpage Tabpage)
- func (b *Batch) SetCurrentWindow(window Window)
- func (b *Batch) SetKeyMap(mode string, lhs string, rhs string, opts map[string]bool)
- func (b *Batch) SetOption(name string, value interface{})
- func (b *Batch) SetPumHeight(height int)
- func (b *Batch) SetTabpageVar(tabpage Tabpage, name string, value interface{})
- func (b *Batch) SetUIOption(name string, value interface{})
- func (b *Batch) SetVVar(name string, value interface{})
- func (b *Batch) SetVar(name string, value interface{})
- func (b *Batch) SetWindowConfig(window Window, config map[string]interface{})
- func (b *Batch) SetWindowCursor(window Window, pos [2]int)
- func (b *Batch) SetWindowHeight(window Window, height int)
- func (b *Batch) SetWindowOption(window Window, name string, value interface{})
- func (b *Batch) SetWindowVar(window Window, name string, value interface{})
- func (b *Batch) SetWindowWidth(window Window, width int)
- func (b *Batch) StringWidth(s string, result *int)
- func (b *Batch) Subscribe(event string)
- func (b *Batch) TabpageNumber(tabpage Tabpage, result *int)
- func (b *Batch) TabpageVar(tabpage Tabpage, name string, result interface{})
- func (b *Batch) TabpageWindow(tabpage Tabpage, result *Window)
- func (b *Batch) TabpageWindows(tabpage Tabpage, result *[]Window)
- func (b *Batch) Tabpages(result *[]Tabpage)
- func (b *Batch) TryResizeUI(width int, height int)
- func (b *Batch) TryResizeUIGrid(grid int, width int, height int)
- func (b *Batch) UIs(result *[]*UI)
- func (b *Batch) Unsubscribe(event string)
- func (b *Batch) VVar(name string, result interface{})
- func (b *Batch) Var(name string, result interface{})
- func (b *Batch) WindowBuffer(window Window, result *Buffer)
- func (b *Batch) WindowConfig(window Window, result *map[string]interface{})
- func (b *Batch) WindowCursor(window Window, result *[2]int)
- func (b *Batch) WindowHeight(window Window, result *int)
- func (b *Batch) WindowNumber(window Window, result *int)
- func (b *Batch) WindowOption(window Window, name string, result interface{})
- func (b *Batch) WindowPosition(window Window, result *[2]int)
- func (b *Batch) WindowTabpage(window Window, result *Tabpage)
- func (b *Batch) WindowVar(window Window, name string, result interface{})
- func (b *Batch) WindowWidth(window Window, result *int)
- func (b *Batch) Windows(result *[]Window)
- func (b *Batch) WriteErr(str string)
- func (b *Batch) WriteOut(str string)
- func (b *Batch) WritelnErr(str string)
- type BatchError
- type Buffer
- type Channel
- type ChildProcessOption
- func ChildProcessArgs(args ...string) ChildProcessOption
- func ChildProcessCommand(command string) ChildProcessOption
- func ChildProcessContext(ctx context.Context) ChildProcessOption
- func ChildProcessDir(dir string) ChildProcessOption
- func ChildProcessEnv(env []string) ChildProcessOption
- func ChildProcessLogf(logf func(string, ...interface{})) ChildProcessOption
- func ChildProcessServe(serve bool) ChildProcessOption
- type Client
- type ClientAttributes
- type ClientMethod
- type ClientMethodNArgs
- type ClientType
- type ClientVersion
- type Command
- type CommandCompletionArgs
- type DialOption
- type EmbedOptions
- type ErrorList
- type ExtMarks
- type HLAttrs
- type Mapping
- type Mode
- type Nvim
- func (v *Nvim) APIInfo() ([]interface{}, error)
- func (v *Nvim) AddBufferHighlight(buffer Buffer, srcID int, hlGroup string, line int, startCol int, endCol int) (int, error)
- func (v *Nvim) AttachBuffer(buffer Buffer, sendBuffer bool, opts map[string]interface{}) (bool, error)
- func (v *Nvim) AttachUI(width int, height int, options map[string]interface{}) error
- func (v *Nvim) BufferChangedTick(buffer Buffer) (int, error)
- func (v *Nvim) BufferCommands(buffer Buffer, opts map[string]interface{}) (map[string]*Command, error)
- func (v *Nvim) BufferExtmarkByID(buffer Buffer, nsID int, id int) ([]int, error)
- func (v *Nvim) BufferExtmarks(buffer Buffer, nsID int, start interface{}, end interface{}, ...) ([]ExtMarks, error)
- func (v *Nvim) BufferKeyMap(buffer Buffer, mode string) ([]*Mapping, error)
- func (v *Nvim) BufferLineCount(buffer Buffer) (int, error)
- func (v *Nvim) BufferLines(buffer Buffer, start int, end int, strict bool) ([][]byte, error)
- func (v *Nvim) BufferMark(buffer Buffer, name string) ([2]int, error)
- func (v *Nvim) BufferName(buffer Buffer) (string, error)
- func (v *Nvim) BufferNumber(buffer Buffer) (int, error)deprecated
- func (v *Nvim) BufferOffset(buffer Buffer, index int) (int, error)
- func (v *Nvim) BufferOption(buffer Buffer, name string, result interface{}) error
- func (v *Nvim) BufferVar(buffer Buffer, name string, result interface{}) error
- func (v *Nvim) BufferVirtualText(buffer Buffer, lnum int) ([]VirtualTextChunk, error)
- func (v *Nvim) Buffers() ([]Buffer, error)
- func (v *Nvim) Call(fname string, result interface{}, args ...interface{}) error
- func (v *Nvim) CallDict(dict []interface{}, fname string, result interface{}, args ...interface{}) error
- func (v *Nvim) ChannelID() int
- func (v *Nvim) ChannelInfo(channel int) (*Channel, error)
- func (v *Nvim) Channels() ([]*Channel, error)
- func (v *Nvim) ClearBufferHighlight(buffer Buffer, srcID int, startLine int, endLine int) errordeprecated
- func (v *Nvim) ClearBufferNamespace(buffer Buffer, nsID int, lineStart int, lineEnd int) error
- func (v *Nvim) Close() error
- func (v *Nvim) CloseWindow(window Window, force bool) error
- func (v *Nvim) ColorByName(name string) (int, error)
- func (v *Nvim) ColorMap() (map[string]int, error)
- func (v *Nvim) Command(cmd string) error
- func (v *Nvim) CommandOutput(cmd string) (string, error)deprecated
- func (v *Nvim) Commands(opts map[string]interface{}) (map[string]*Command, error)
- func (v *Nvim) Context(opts map[string][]string) (map[string]interface{}, error)
- func (v *Nvim) CreateBuffer(listed bool, scratch bool) (Buffer, error)
- func (v *Nvim) CreateNamespace(name string) (int, error)
- func (v *Nvim) CurrentBuffer() (Buffer, error)
- func (v *Nvim) CurrentLine() ([]byte, error)
- func (v *Nvim) CurrentTabpage() (Tabpage, error)
- func (v *Nvim) CurrentWindow() (Window, error)
- func (v *Nvim) DeleteBufferExtmark(buffer Buffer, nsID int, extmarkID int) (bool, error)
- func (v *Nvim) DeleteBufferKeyMap(buffer Buffer, mode string, lhs string) error
- func (v *Nvim) DeleteBufferVar(buffer Buffer, name string) error
- func (v *Nvim) DeleteCurrentLine() error
- func (v *Nvim) DeleteKeyMap(mode string, lhs string) error
- func (v *Nvim) DeleteTabpageVar(tabpage Tabpage, name string) error
- func (v *Nvim) DeleteVar(name string) error
- func (v *Nvim) DeleteWindowVar(window Window, name string) error
- func (v *Nvim) DetachBuffer(buffer Buffer) (bool, error)
- func (v *Nvim) DetachUI() error
- func (v *Nvim) Eval(expr string, result interface{}) error
- func (v *Nvim) Exec(src string, output bool) (string, error)
- func (v *Nvim) ExecLua(code string, result interface{}, args ...interface{}) error
- func (v *Nvim) ExecuteLua(code string, result interface{}, args ...interface{}) errordeprecated
- func (v *Nvim) FeedKeys(keys string, mode string, escapeCSI bool) error
- func (v *Nvim) HLByID(id int, rgb bool) (*HLAttrs, error)
- func (v *Nvim) HLByName(name string, rgb bool) (*HLAttrs, error)
- func (v *Nvim) HLIDByName(name string) (int, error)
- func (v *Nvim) Input(keys string) (int, error)
- func (v *Nvim) InputMouse(button string, action string, modifier string, grid int, row int, col int) error
- func (v *Nvim) IsBufferLoaded(buffer Buffer) (bool, error)
- func (v *Nvim) IsBufferValid(buffer Buffer) (bool, error)
- func (v *Nvim) IsTabpageValid(tabpage Tabpage) (bool, error)
- func (v *Nvim) IsWindowValid(window Window) (bool, error)
- func (v *Nvim) KeyMap(mode string) ([]*Mapping, error)
- func (v *Nvim) LoadContext(dict map[string]interface{}, result interface{}) error
- func (v *Nvim) Mode() (*Mode, error)
- func (v *Nvim) Namespaces() (map[string]int, error)
- func (v *Nvim) NewBatch() *Batch
- func (v *Nvim) OpenWindow(buffer Buffer, enter bool, config *WindowConfig) (Window, error)
- func (v *Nvim) Option(name string, result interface{}) error
- func (v *Nvim) ParseExpression(expr string, flags string, highlight bool) (map[string]interface{}, error)
- func (v *Nvim) Paste(data string, crlf bool, phase int) (bool, error)
- func (v *Nvim) Proc(pid int) (Process, error)
- func (v *Nvim) ProcChildren(pid int) ([]*Process, error)
- func (v *Nvim) Put(lines []string, typ string, after bool, follow bool) error
- func (v *Nvim) RegisterHandler(method string, fn interface{}) error
- func (v *Nvim) ReplaceTermcodes(str string, fromPart bool, doLT bool, special bool) (string, error)
- func (v *Nvim) Request(procedure string, result interface{}, args ...interface{}) error
- func (v *Nvim) RuntimeFiles(name string, all bool) ([]string, error)
- func (v *Nvim) RuntimePaths() ([]string, error)
- func (v *Nvim) SelectPopupmenuItem(item int, insert bool, finish bool, opts map[string]interface{}) error
- func (v *Nvim) Serve() error
- func (v *Nvim) SetBufferExtmark(buffer Buffer, nsID int, extmarkID int, line int, col int, ...) (int, error)
- func (v *Nvim) SetBufferKeyMap(buffer Buffer, mode string, lhs string, rhs string, opts map[string]bool) error
- func (v *Nvim) SetBufferLines(buffer Buffer, start int, end int, strict bool, replacement [][]byte) error
- func (v *Nvim) SetBufferName(buffer Buffer, name string) error
- func (v *Nvim) SetBufferOption(buffer Buffer, name string, value interface{}) error
- func (v *Nvim) SetBufferToWindow(window Window, buffer Buffer) error
- func (v *Nvim) SetBufferVar(buffer Buffer, name string, value interface{}) error
- func (v *Nvim) SetBufferVirtualText(buffer Buffer, nsID int, line int, chunks []VirtualTextChunk, ...) (int, error)
- func (v *Nvim) SetClientInfo(name string, version *ClientVersion, typ string, ...) error
- func (v *Nvim) SetCurrentBuffer(buffer Buffer) error
- func (v *Nvim) SetCurrentDirectory(dir string) error
- func (v *Nvim) SetCurrentLine(line []byte) error
- func (v *Nvim) SetCurrentTabpage(tabpage Tabpage) error
- func (v *Nvim) SetCurrentWindow(window Window) error
- func (v *Nvim) SetKeyMap(mode string, lhs string, rhs string, opts map[string]bool) error
- func (v *Nvim) SetOption(name string, value interface{}) error
- func (v *Nvim) SetPumHeight(height int) error
- func (v *Nvim) SetTabpageVar(tabpage Tabpage, name string, value interface{}) error
- func (v *Nvim) SetUIOption(name string, value interface{}) error
- func (v *Nvim) SetVVar(name string, value interface{}) error
- func (v *Nvim) SetVar(name string, value interface{}) error
- func (v *Nvim) SetWindowConfig(window Window, config map[string]interface{}) error
- func (v *Nvim) SetWindowCursor(window Window, pos [2]int) error
- func (v *Nvim) SetWindowHeight(window Window, height int) error
- func (v *Nvim) SetWindowOption(window Window, name string, value interface{}) error
- func (v *Nvim) SetWindowVar(window Window, name string, value interface{}) error
- func (v *Nvim) SetWindowWidth(window Window, width int) error
- func (v *Nvim) StringWidth(s string) (int, error)
- func (v *Nvim) Subscribe(event string) error
- func (v *Nvim) TabpageNumber(tabpage Tabpage) (int, error)
- func (v *Nvim) TabpageVar(tabpage Tabpage, name string, result interface{}) error
- func (v *Nvim) TabpageWindow(tabpage Tabpage) (Window, error)
- func (v *Nvim) TabpageWindows(tabpage Tabpage) ([]Window, error)
- func (v *Nvim) Tabpages() ([]Tabpage, error)
- func (v *Nvim) TryResizeUI(width int, height int) error
- func (v *Nvim) TryResizeUIGrid(grid int, width int, height int) error
- func (v *Nvim) UIs() ([]*UI, error)
- func (v *Nvim) Unsubscribe(event string) error
- func (v *Nvim) VVar(name string, result interface{}) error
- func (v *Nvim) Var(name string, result interface{}) error
- func (v *Nvim) WindowBuffer(window Window) (Buffer, error)
- func (v *Nvim) WindowConfig(window Window) (map[string]interface{}, error)
- func (v *Nvim) WindowCursor(window Window) ([2]int, error)
- func (v *Nvim) WindowHeight(window Window) (int, error)
- func (v *Nvim) WindowNumber(window Window) (int, error)
- func (v *Nvim) WindowOption(window Window, name string, result interface{}) error
- func (v *Nvim) WindowPosition(window Window) ([2]int, error)
- func (v *Nvim) WindowTabpage(window Window) (Tabpage, error)
- func (v *Nvim) WindowVar(window Window, name string, result interface{}) error
- func (v *Nvim) WindowWidth(window Window) (int, error)
- func (v *Nvim) Windows() ([]Window, error)
- func (v *Nvim) WriteErr(str string) error
- func (v *Nvim) WriteOut(str string) error
- func (v *Nvim) WritelnErr(str string) error
- type Process
- type QuickfixError
- type Tabpage
- type UI
- type VirtualTextChunk
- type Window
- type WindowConfig
Examples ¶
Constants ¶
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 URI or path to image, preferably small logo or icon. .png or .svg format is preferred. ClientoAttributeKeyLogo = "logo" )
Variables ¶
This section is empty.
Functions ¶
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) 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 ¶
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 ¶
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
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 ¶
BufferKeymap gets a list of buffer-local mappings.
func (*Batch) BufferLineCount ¶
BufferLineCount returns the number of lines in the buffer.
func (*Batch) BufferLines ¶
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 ¶
BufferMark returns the (row,col) of the named mark.
func (*Batch) BufferName ¶
BufferName gets the full file name of a buffer.
func (*Batch) BufferNumber
deprecated
func (*Batch) BufferOffset ¶
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 ¶
BufferOption gets a buffer option value.
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) ChannelInfo ¶
ChannelInfo get information about a channel.
func (*Batch) ClearBufferHighlight
deprecated
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 ¶
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 ¶
CloseWindow close a window.
This is equivalent to |:close| with count except that it takes a window id.
func (*Batch) ColorByName ¶
func (*Batch) CommandOutput
deprecated
func (*Batch) Commands ¶
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
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 ¶
CreateBuffer creates a new, empty, unnamed buffer.
func (*Batch) CreateNamespace ¶
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 ¶
CurrentBuffer returns the current buffer.
func (*Batch) CurrentLine ¶
CurrentLine gets the current line in the current buffer.
func (*Batch) CurrentTabpage ¶
CurrentTabpage returns the current tabpage.
func (*Batch) CurrentWindow ¶
CurrentWindow returns the current window.
func (*Batch) DeleteBufferExtmark ¶ added in v1.0.2
DeleteBufferExtmark removes an extmark.
func (*Batch) DeleteBufferKeyMap ¶ added in v1.0.1
DeleteBufferKeyMap unmaps a buffer-local mapping for the given mode.
see
:help nvim_del_keymap()
func (*Batch) DeleteBufferVar ¶
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
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 ¶
DeleteTabpageVar removes a tab-scoped (t:) variable.
func (*Batch) DeleteWindowVar ¶
DeleteWindowVar removes a window-scoped (w:) variable.
func (*Batch) DetachBuffer ¶
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) Eval ¶
Eval evaluates the expression expr using the Vim internal expression evaluator.
:help expression
func (*Batch) Exec ¶ added in v1.0.2
Exec executes Vimscript (multiline block of Ex-commands), like anonymous source.
func (*Batch) ExecuteLua
deprecated
func (*Batch) FeedKeys ¶
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) HLIDByName ¶ added in v1.0.2
HLIDByName gets a highlight group by name.
func (*Batch) Input ¶
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 ¶
IsBufferLoaded Checks if a buffer is valid and loaded. See api-buffer for more info about unloaded buffers.
func (*Batch) IsBufferValid ¶
IsBufferValid returns true if the buffer is valid.
func (*Batch) IsTabpageValid ¶
IsTabpageValid checks if a tab page is valid.
func (*Batch) IsWindowValid ¶
IsWindowValid returns true if the window is valid.
func (*Batch) LoadContext ¶ added in v1.0.2
LoadContext sets the current editor state from the given context map. This API still under development.
func (*Batch) Namespaces ¶
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) 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
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) ProcChildren ¶
ProcChildren gets the immediate children of process `pid`.
func (*Batch) Put ¶ added in v1.0.2
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) RuntimeFiles ¶ added in v1.1.1
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 ¶
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 ¶
SetBufferName sets the full file name of a buffer. BufFilePre/BufFilePost are triggered.
func (*Batch) SetBufferOption ¶
SetBufferOption sets a buffer option value. The value nil deletes the option in the case where there's a global fallback.
func (*Batch) SetBufferToWindow ¶
SetBufferToWindow sets the current buffer in a window, without side-effects.
func (*Batch) SetBufferVar ¶
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 ¶
SetCurrentBuffer sets the current buffer.
func (*Batch) SetCurrentDirectory ¶
SetCurrentDirectory changes the Vim working directory.
func (*Batch) SetCurrentLine ¶
SetCurrentLine sets the current line in the current buffer.
func (*Batch) SetCurrentTabpage ¶
SetCurrentTabpage sets the current tabpage.
func (*Batch) SetCurrentWindow ¶
SetCurrentWindow sets the current window.
func (*Batch) SetKeyMap ¶ added in v1.0.1
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) SetPumHeight ¶ added in v1.0.2
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 ¶
SetTabpageVar sets a tab-scoped (t:) variable.
func (*Batch) SetUIOption ¶
SetUIOption sets a UI option.
func (*Batch) SetWindowConfig ¶
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 ¶
SetWindowCursor sets the cursor position in the window to the given position.
func (*Batch) SetWindowHeight ¶
SetWindowHeight sets the window height.
func (*Batch) SetWindowOption ¶
SetWindowOption sets a window option.
func (*Batch) SetWindowVar ¶
SetWindowVar sets a window-scoped (w:) variable.
func (*Batch) SetWindowWidth ¶
SetWindowWidth sets the window width.
func (*Batch) StringWidth ¶
StringWidth returns the number of display cells the string occupies. Tab is counted as one cell.
func (*Batch) TabpageNumber ¶
TabpageNumber gets the tabpage number from the tabpage handle.
func (*Batch) TabpageVar ¶
TabpageVar gets a tab-scoped (t:) variable.
func (*Batch) TabpageWindow ¶
TabpageWindow gets the current window in a tab page.
func (*Batch) TabpageWindows ¶
TabpageWindows returns the windows in a tabpage.
func (*Batch) TryResizeUI ¶
TryResizeUI notifies Nvim that the client window has resized. If possible, Nvim will send a redraw request to resize.
func (*Batch) TryResizeUIGrid ¶
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) Unsubscribe ¶
Unsubscribe unsubscribes to a Nvim event.
func (*Batch) WindowBuffer ¶
WindowBuffer returns the current buffer in a window.
func (*Batch) WindowConfig ¶
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 ¶
WindowCursor returns the cursor position in the window.
func (*Batch) WindowHeight ¶
WindowHeight returns the window height.
func (*Batch) WindowNumber ¶
WindowNumber gets the window number from the window handle.
func (*Batch) WindowOption ¶
WindowOption gets a window option.
func (*Batch) WindowPosition ¶
WindowPosition gets the window position in display cells. First position is zero.
func (*Batch) WindowTabpage ¶
WindowTabpage gets the tab page that contains the window.
func (*Batch) WindowWidth ¶
WindowWidth returns the window width.
func (*Batch) WriteErr ¶
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 ¶
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 ¶
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 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 ¶
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 ¶
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 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 ¶
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) 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 ¶
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 ¶
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
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 ¶
BufferKeymap gets a list of buffer-local mappings.
func (*Nvim) BufferLineCount ¶
BufferLineCount returns the number of lines in the buffer.
func (*Nvim) BufferLines ¶
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 ¶
BufferMark returns the (row,col) of the named mark.
func (*Nvim) BufferName ¶
BufferName gets the full file name of a buffer.
func (*Nvim) BufferNumber
deprecated
func (*Nvim) BufferOffset ¶
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 ¶
BufferOption gets a buffer option value.
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) CallDict ¶
func (v *Nvim) CallDict(dict []interface{}, fname string, result interface{}, args ...interface{}) error
CallDict calls a vimscript Dictionary function.
func (*Nvim) ChannelInfo ¶
ChannelInfo get information about a channel.
func (*Nvim) ClearBufferHighlight
deprecated
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 ¶
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) CloseWindow ¶
CloseWindow close a window.
This is equivalent to |:close| with count except that it takes a window id.
func (*Nvim) CommandOutput
deprecated
func (*Nvim) Commands ¶
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
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 ¶
CreateBuffer creates a new, empty, unnamed buffer.
func (*Nvim) CreateNamespace ¶
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 ¶
CurrentBuffer returns the current buffer.
func (*Nvim) CurrentLine ¶
CurrentLine gets the current line in the current buffer.
func (*Nvim) CurrentTabpage ¶
CurrentTabpage returns the current tabpage.
func (*Nvim) CurrentWindow ¶
CurrentWindow returns the current window.
func (*Nvim) DeleteBufferExtmark ¶ added in v1.0.2
DeleteBufferExtmark removes an extmark.
func (*Nvim) DeleteBufferKeyMap ¶ added in v1.0.1
DeleteBufferKeyMap unmaps a buffer-local mapping for the given mode.
see
:help nvim_del_keymap()
func (*Nvim) DeleteBufferVar ¶
DeleteBufferVar removes a buffer-scoped (b:) variable.
func (*Nvim) DeleteCurrentLine ¶
DeleteCurrentLine deletes the current line in the current buffer.
func (*Nvim) DeleteKeyMap ¶ added in v1.0.1
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 ¶
DeleteTabpageVar removes a tab-scoped (t:) variable.
func (*Nvim) DeleteWindowVar ¶
DeleteWindowVar removes a window-scoped (w:) variable.
func (*Nvim) DetachBuffer ¶
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) Eval ¶
Eval evaluates the expression expr using the Vim internal expression evaluator.
:help expression
func (*Nvim) Exec ¶ added in v1.0.2
Exec executes Vimscript (multiline block of Ex-commands), like anonymous source.
func (*Nvim) ExecuteLua
deprecated
func (*Nvim) FeedKeys ¶
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) HLIDByName ¶ added in v1.0.2
HLIDByName gets a highlight group by name.
func (*Nvim) Input ¶
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 ¶
IsBufferLoaded Checks if a buffer is valid and loaded. See api-buffer for more info about unloaded buffers.
func (*Nvim) IsBufferValid ¶
IsBufferValid returns true if the buffer is valid.
func (*Nvim) IsTabpageValid ¶
IsTabpageValid checks if a tab page is valid.
func (*Nvim) IsWindowValid ¶
IsWindowValid returns true if the window is valid.
func (*Nvim) LoadContext ¶ added in v1.0.2
LoadContext sets the current editor state from the given context map. This API still under development.
func (*Nvim) Namespaces ¶
Namespaces gets existing named namespaces
The return dict that maps from names to namespace ids.
func (*Nvim) OpenWindow ¶
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) 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
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) ProcChildren ¶
ProcChildren gets the immediate children of process `pid`.
func (*Nvim) Put ¶ added in v1.0.2
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 ¶
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 ¶
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) RuntimeFiles ¶ added in v1.1.1
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 ¶
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 ¶
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 ¶
SetBufferName sets the full file name of a buffer. BufFilePre/BufFilePost are triggered.
func (*Nvim) SetBufferOption ¶
SetBufferOption sets a buffer option value. The value nil deletes the option in the case where there's a global fallback.
func (*Nvim) SetBufferToWindow ¶
SetBufferToWindow sets the current buffer in a window, without side-effects.
func (*Nvim) SetBufferVar ¶
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 ¶
SetCurrentBuffer sets the current buffer.
func (*Nvim) SetCurrentDirectory ¶
SetCurrentDirectory changes the Vim working directory.
func (*Nvim) SetCurrentLine ¶
SetCurrentLine sets the current line in the current buffer.
func (*Nvim) SetCurrentTabpage ¶
SetCurrentTabpage sets the current tabpage.
func (*Nvim) SetCurrentWindow ¶
SetCurrentWindow sets the current window.
func (*Nvim) SetKeyMap ¶ added in v1.0.1
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) SetPumHeight ¶ added in v1.0.2
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 ¶
SetTabpageVar sets a tab-scoped (t:) variable.
func (*Nvim) SetUIOption ¶
SetUIOption sets a UI option.
func (*Nvim) SetWindowConfig ¶
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 ¶
SetWindowCursor sets the cursor position in the window to the given position.
func (*Nvim) SetWindowHeight ¶
SetWindowHeight sets the window height.
func (*Nvim) SetWindowOption ¶
SetWindowOption sets a window option.
func (*Nvim) SetWindowVar ¶
SetWindowVar sets a window-scoped (w:) variable.
func (*Nvim) SetWindowWidth ¶
SetWindowWidth sets the window width.
func (*Nvim) StringWidth ¶
StringWidth returns the number of display cells the string occupies. Tab is counted as one cell.
func (*Nvim) TabpageNumber ¶
TabpageNumber gets the tabpage number from the tabpage handle.
func (*Nvim) TabpageVar ¶
TabpageVar gets a tab-scoped (t:) variable.
func (*Nvim) TabpageWindow ¶
TabpageWindow gets the current window in a tab page.
func (*Nvim) TabpageWindows ¶
TabpageWindows returns the windows in a tabpage.
func (*Nvim) TryResizeUI ¶
TryResizeUI notifies Nvim that the client window has resized. If possible, Nvim will send a redraw request to resize.
func (*Nvim) TryResizeUIGrid ¶
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) Unsubscribe ¶
Unsubscribe unsubscribes to a Nvim event.
func (*Nvim) WindowBuffer ¶
WindowBuffer returns the current buffer in a window.
func (*Nvim) WindowConfig ¶
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 ¶
WindowCursor returns the cursor position in the window.
func (*Nvim) WindowHeight ¶
WindowHeight returns the window height.
func (*Nvim) WindowNumber ¶
WindowNumber gets the window number from the window handle.
func (*Nvim) WindowOption ¶
WindowOption gets a window option.
func (*Nvim) WindowPosition ¶
WindowPosition gets the window position in display cells. First position is zero.
func (*Nvim) WindowTabpage ¶
WindowTabpage gets the tab page that contains the window.
func (*Nvim) WindowWidth ¶
WindowWidth returns the window width.
func (*Nvim) WriteErr ¶
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 ¶
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 ¶
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 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 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 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 ¶
VirtualTextChunk represents a virtual text chunk.
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'.