diff --git a/nvim/api.go b/nvim/api.go index fd1e56cc..8eda7cf3 100644 --- a/nvim/api.go +++ b/nvim/api.go @@ -97,7 +97,7 @@ func (x Window) String() string { // // Unlike Command, this function supports heredocs, script-scope (s:), etc. // -// On execution error: fails with VimL error, does not update v:errmsg. +// When fails with VimL error, does not update "v:errmsg". func (v *Nvim) Exec(src string, output bool) (out string, err error) { err = v.call("nvim_exec", &out, src, output) return out, err @@ -107,45 +107,79 @@ func (v *Nvim) Exec(src string, output bool) (out string, err error) { // // Unlike Command, this function supports heredocs, script-scope (s:), etc. // -// On execution error: fails with VimL error, does not update v:errmsg. +// When fails with VimL error, does not update "v:errmsg". func (b *Batch) Exec(src string, output bool, out *string) { b.call("nvim_exec", out, src, output) } // Command executes an ex-command. +// +// When fails with VimL error, does not update "v:errmsg". func (v *Nvim) Command(cmd string) error { return v.call("nvim_command", nil, cmd) } // Command executes an ex-command. +// +// When fails with VimL error, does not update "v:errmsg". func (b *Batch) Command(cmd string) { b.call("nvim_command", nil, cmd) } // HLByID gets a highlight definition by name. -func (v *Nvim) HLByID(id int, rgb bool) (highlight *HLAttrs, err error) { +// +// hlID is the highlight id as returned by HLIDByName. +// +// rgb is the whether the export RGB colors. +// +// The returned highlight is the highlight definition. +func (v *Nvim) HLByID(hlID int, rgb bool) (highlight *HLAttrs, err error) { var result HLAttrs - err = v.call("nvim_get_hl_by_id", &result, id, rgb) + err = v.call("nvim_get_hl_by_id", &result, hlID, rgb) return &result, err } // HLByID gets a highlight definition by name. -func (b *Batch) HLByID(id int, rgb bool, highlight *HLAttrs) { - b.call("nvim_get_hl_by_id", highlight, id, rgb) +// +// hlID is the highlight id as returned by HLIDByName. +// +// rgb is the whether the export RGB colors. +// +// The returned highlight is the highlight definition. +func (b *Batch) HLByID(hlID int, rgb bool, highlight *HLAttrs) { + b.call("nvim_get_hl_by_id", highlight, hlID, rgb) } // HLIDByName gets a highlight group by name. -func (v *Nvim) HLIDByName(name string) (highlightID int, err error) { - err = v.call("nvim_get_hl_id_by_name", &highlightID, name) - return highlightID, err +// +// name is the Highlight group name. +// +// The returns hlID is the highlight id. +// +// This function similar to HLByID, but allocates a new ID if not present. +func (v *Nvim) HLIDByName(name string) (hlID int, err error) { + err = v.call("nvim_get_hl_id_by_name", &hlID, name) + return hlID, err } // HLIDByName gets a highlight group by name. -func (b *Batch) HLIDByName(name string, highlightID *int) { - b.call("nvim_get_hl_id_by_name", highlightID, name) +// +// name is the Highlight group name. +// +// The returns hlID is the highlight id. +// +// This function similar to HLByID, but allocates a new ID if not present. +func (b *Batch) HLIDByName(name string, hlID *int) { + b.call("nvim_get_hl_id_by_name", hlID, name) } // HLByName gets a highlight definition by id. +// +// name is Highlight group name. +// +// rgb is whether the export RGB colors. +// +// The returned highlight is the highlight definition. func (v *Nvim) HLByName(name string, rgb bool) (highlight *HLAttrs, err error) { var result HLAttrs err = v.call("nvim_get_hl_by_name", &result, name, rgb) @@ -153,15 +187,23 @@ func (v *Nvim) HLByName(name string, rgb bool) (highlight *HLAttrs, err error) { } // HLByName gets a highlight definition by id. +// +// name is Highlight group name. +// +// rgb is whether the export RGB colors. +// +// The returned highlight is the highlight definition. func (b *Batch) HLByName(name string, rgb bool, highlight *HLAttrs) { b.call("nvim_get_hl_by_name", highlight, name, rgb) } -// SetHighlight set a highlight group. +// SetHighlight sets a highlight group. +// +// nsID is number of namespace for this highlight. // -// name arg is highlight group name, like ErrorMsg. +// name is highlight group name, like "ErrorMsg". // -// val arg is highlight definition map, like HLByName. +// val is highlight definiton map, like HLByName. // // in addition the following keys are also recognized: // @@ -171,11 +213,13 @@ func (v *Nvim) SetHighlight(nsID int, name string, val *HLAttrs) error { return v.call("nvim_set_hl", nil, nsID, name, val) } -// SetHighlight set a highlight group. +// SetHighlight sets a highlight group. +// +// nsID is number of namespace for this highlight. // -// name arg is highlight group name, like ErrorMsg. +// name is highlight group name, like "ErrorMsg". // -// val arg is highlight definition map, like HLByName. +// val is highlight definiton map, like HLByName. // // in addition the following keys are also recognized: // @@ -187,34 +231,24 @@ func (b *Batch) SetHighlight(nsID int, name string, val *HLAttrs) { // SetHighlightNameSpace set active namespace for highlights. // -// NB: this function can be called from async contexts, but the -// semantics are not yet well-defined. -// To start with SetDecorationProvider on_win and on_line callbacks -// are explicitly allowed to change the namespace during a redraw cycle. -// -// The nsID arg is the namespace to activate. +// nsID is the namespace to activate. func (v *Nvim) SetHighlightNameSpace(nsID int) error { return v.call("nvim__set_hl_ns", nil, nsID) } // SetHighlightNameSpace set active namespace for highlights. // -// NB: this function can be called from async contexts, but the -// semantics are not yet well-defined. -// To start with SetDecorationProvider on_win and on_line callbacks -// are explicitly allowed to change the namespace during a redraw cycle. -// -// The nsID arg is the namespace to activate. +// nsID is the namespace to activate. func (b *Batch) SetHighlightNameSpace(nsID int) { b.call("nvim__set_hl_ns", nil, nsID) } -// FeedKeys sends input-keys to Nvim, subject to various quirks controlled by mode flags. -// This is a blocking call, unlike Input. +// FeedKeys input-keys to Nvim, subject to various quirks controlled by "mode" +// flags. Unlike Input, this is a blocking call. // -// On execution error: does not fail, but updates v:errmsg. +// This function does not fail, but updates "v:errmsg". // -// If you need to input sequences like use ReplaceTermcodes to +// If need to input sequences like use ReplaceTermcodes to // replace the termcodes and then pass the resulting string to nvim_feedkeys. // You'll also want to enable escape_csi. // @@ -222,23 +256,25 @@ func (b *Batch) SetHighlightNameSpace(nsID int) { // // 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. // -// The escapeCSI arg is whether the escape K_SPECIAL/CSI bytes in keys arg. +// escapeCSI is whether the escape K_SPECIAL/CSI bytes in keys. func (v *Nvim) FeedKeys(keys string, mode string, escapeCSI bool) error { return v.call("nvim_feedkeys", nil, keys, mode, escapeCSI) } -// FeedKeys sends input-keys to Nvim, subject to various quirks controlled by mode flags. -// This is a blocking call, unlike Input. +// FeedKeys input-keys to Nvim, subject to various quirks controlled by "mode" +// flags. Unlike Input, this is a blocking call. // -// On execution error: does not fail, but updates v:errmsg. +// This function does not fail, but updates "v:errmsg". // -// If you need to input sequences like use ReplaceTermcodes to +// If need to input sequences like use ReplaceTermcodes to // replace the termcodes and then pass the resulting string to nvim_feedkeys. // You'll also want to enable escape_csi. // @@ -246,13 +282,15 @@ func (v *Nvim) FeedKeys(keys string, mode string, escapeCSI bool) error { // // 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. // -// The escapeCSI arg is whether the escape K_SPECIAL/CSI bytes in keys arg. +// escapeCSI is whether the escape K_SPECIAL/CSI bytes in keys. func (b *Batch) FeedKeys(keys string, mode string, escapeCSI bool) { b.call("nvim_feedkeys", nil, keys, mode, escapeCSI) } @@ -261,6 +299,17 @@ func (b *Batch) FeedKeys(keys string, mode string, escapeCSI bool) { // // Unlike FeedKeys, this uses a low-level input buffer and the call // is non-blocking (input is processed asynchronously by the eventloop). +// +// This function does not fail but updates "v:errmsg". +// +// keys is to be typed. +// +// Note: "keycodes" like "" are translated, so "<" is special. To input a literal "<", send "". +// +// Note: For mouse events use InputMouse. The pseudokey form "" is deprecated. +// +// The returned written is number of bytes actually written (can be fewer than +// requested if the buffer becomes full). func (v *Nvim) Input(keys string) (written int, err error) { err = v.call("nvim_input", &written, keys) return written, err @@ -270,83 +319,102 @@ func (v *Nvim) Input(keys string) (written int, err error) { // // Unlike FeedKeys, this uses a low-level input buffer and the call // is non-blocking (input is processed asynchronously by the eventloop). +// +// This function does not fail but updates "v:errmsg". +// +// keys is to be typed. +// +// Note: "keycodes" like "" are translated, so "<" is special. To input a literal "<", send "". +// +// Note: For mouse events use InputMouse. The pseudokey form "" is deprecated. +// +// The returned written is number of bytes actually written (can be fewer than +// requested if the buffer becomes full). func (b *Batch) Input(keys string, written *int) { b.call("nvim_input", written, keys) } -// InputMouse send mouse event from GUI. +// InputMouse Send mouse event from GUI. // -// This API is non-blocking. It doesn't wait on any resulting action, but -// queues the event to be processed soon by the event loop. +// This API is non-blocking. It does not wait on any result, but queues the event to be +// processed soon by the event loop. // -// The button arg is mouse button. One of -// "left" -// "right" -// "middle" -// "wheel" +// button is mouse button. One of +// left +// right +// middle +// wheel // -// The action arg is for ordinary buttons. One of -// "press" -// "drag" -// "release" +// action is for ordinary buttons. One of +// press +// drag +// release // For the wheel, One of -// "up" -// "down -// "left" -// "right" +// up +// down +// left +// right // -// The modifier arg is string of modifiers each represented by a single char. +// modifier is string of modifiers each represented by a single char. // The same specifiers are used as for a key press, except // that the "-" separator is optional, so "C-A-", "c-a" -// and "CA" can all be used to specify Ctrl+Alt+click. +// and "CA" can all be used to specify "Ctrl+Alt+Click". // -// The grid arg is grid number if the client uses "ui-multigrid", else 0. +// grid is grid number if the client uses "ui-multigrid", else 0. // -// The row arg is mouse row-position (zero-based, like redraw events). +// row is mouse row-position (zero-based, like redraw events). // -// The col arg is mouse column-position (zero-based, like redraw events). +// col is mouse column-position (zero-based, like redraw events). func (v *Nvim) InputMouse(button string, action string, modifier string, grid int, row int, col int) error { return v.call("nvim_input_mouse", nil, button, action, modifier, grid, row, col) } -// InputMouse send mouse event from GUI. +// InputMouse Send mouse event from GUI. // -// This API is non-blocking. It doesn't wait on any resulting action, but -// queues the event to be processed soon by the event loop. +// This API is non-blocking. It does not wait on any result, but queues the event to be +// processed soon by the event loop. // -// The button arg is mouse button. One of -// "left" -// "right" -// "middle" -// "wheel" +// button is mouse button. One of +// left +// right +// middle +// wheel // -// The action arg is for ordinary buttons. One of -// "press" -// "drag" -// "release" +// action is for ordinary buttons. One of +// press +// drag +// release // For the wheel, One of -// "up" -// "down -// "left" -// "right" +// up +// down +// left +// right // -// The modifier arg is string of modifiers each represented by a single char. +// modifier is string of modifiers each represented by a single char. // The same specifiers are used as for a key press, except // that the "-" separator is optional, so "C-A-", "c-a" -// and "CA" can all be used to specify Ctrl+Alt+click. +// and "CA" can all be used to specify "Ctrl+Alt+Click". // -// The grid arg is grid number if the client uses "ui-multigrid", else 0. +// grid is grid number if the client uses "ui-multigrid", else 0. // -// The row arg is mouse row-position (zero-based, like redraw events). +// row is mouse row-position (zero-based, like redraw events). // -// The col arg is mouse column-position (zero-based, like redraw events). +// col is mouse column-position (zero-based, like redraw events). func (b *Batch) InputMouse(button string, action string, modifier string, grid int, row int, col int) { b.call("nvim_input_mouse", nil, button, action, modifier, grid, row, col) } -// ReplaceTermcodes replaces terminal codes and |keycodes| (, , ...) in a string with +// ReplaceTermcodes replaces terminal codes and "keycodes" (, , ...) in a string with // the internal representation. // +// str is string to be converted. +// +// fromPart is legacy Vim parameter. Usually true. +// +// doLT is also translate . Ignored if "special" is false. +// +// special is replace "keycodes", e.g. "" becomes a "\n" char. +// // The returned sequences are Nvim's internal representation of keys, for example: // // -> '\x1b' @@ -355,20 +423,22 @@ func (b *Batch) InputMouse(button string, action string, modifier string, grid i // -> '\x80ku' // // The returned sequences can be used as input to feedkeys. -// -// The fromPart arg is legacy Vim parameter. Usually true. -// -// The doLT arg is also translate . Ignored if "special" is false. -// -// The special arg is replace "keycodes", e.g. becomes a "\n" char. func (v *Nvim) ReplaceTermcodes(str string, fromPart bool, doLT bool, special bool) (input string, err error) { err = v.call("nvim_replace_termcodes", &input, str, fromPart, doLT, special) return input, err } -// ReplaceTermcodes replaces terminal codes and |keycodes| (, , ...) in a string with +// ReplaceTermcodes replaces terminal codes and "keycodes" (, , ...) in a string with // the internal representation. // +// str is string to be converted. +// +// fromPart is legacy Vim parameter. Usually true. +// +// doLT is also translate . Ignored if "special" is false. +// +// special is replace "keycodes", e.g. "" becomes a "\n" char. +// // The returned sequences are Nvim's internal representation of keys, for example: // // -> '\x1b' @@ -377,12 +447,6 @@ func (v *Nvim) ReplaceTermcodes(str string, fromPart bool, doLT bool, special bo // -> '\x80ku' // // The returned sequences can be used as input to feedkeys. -// -// The fromPart arg is legacy Vim parameter. Usually true. -// -// The doLT arg is also translate . Ignored if "special" is false. -// -// The special arg is replace "keycodes", e.g. becomes a "\n" char. func (b *Batch) ReplaceTermcodes(str string, fromPart bool, doLT bool, special bool, input *string) { b.call("nvim_replace_termcodes", input, str, fromPart, doLT, special) } @@ -391,7 +455,9 @@ func (b *Batch) ReplaceTermcodes(str string, fromPart bool, doLT bool, special b // // Dictionaries and Lists are recursively expanded. // -// The expr arg is VimL expression string. +// Fails with VimL error, does not update "v:errmsg". +// +// expr is VimL expression string. // // :help expression func (v *Nvim) Eval(expr string, result interface{}) error { @@ -402,62 +468,84 @@ func (v *Nvim) Eval(expr string, result interface{}) error { // // Dictionaries and Lists are recursively expanded. // -// The expr arg is VimL expression string. +// Fails with VimL error, does not update "v:errmsg". +// +// expr is VimL expression string. // // :help expression func (b *Batch) Eval(expr string, result interface{}) { b.call("nvim_eval", &result, expr) } -// StringWidth calculates the number of display cells occupied by `text`. +// StringWidth calculates the number of display cells occupied by "text". // -// counts as one cell. +// "" counts as one cell. func (v *Nvim) StringWidth(s string) (width int, err error) { err = v.call("nvim_strwidth", &width, s) return width, err } -// StringWidth calculates the number of display cells occupied by `text`. +// StringWidth calculates the number of display cells occupied by "text". // -// counts as one cell. +// "" counts as one cell. func (b *Batch) StringWidth(s string, width *int) { b.call("nvim_strwidth", width, s) } -// RuntimePaths gets the paths contained in 'runtimepath'. +// RuntimePaths gets the paths contained in "runtimepath". func (v *Nvim) RuntimePaths() (paths []string, err error) { err = v.call("nvim_list_runtime_paths", &paths) return paths, err } -// RuntimePaths gets the paths contained in 'runtimepath'. +// RuntimePaths gets the paths contained in "runtimepath". func (b *Batch) RuntimePaths(paths *[]string) { b.call("nvim_list_runtime_paths", paths) } -// RuntimeFiles finds files in runtime directories and returns list of absolute paths to the found files. +// RuntimeFiles find files in runtime directories. +// +// name is can contain wildcards. // -// The name arg is can contain wildcards. For example, +// For example, // // RuntimeFiles("colors/*.vim", true) // // will return all color scheme files. // -// The all arg is whether to return all matches or only the first. +// Always use forward slashes (/) in the search pattern for subdirectories regardless of platform. +// +// It is not an error to not find any files, returned an empty array. +// +// To find a directory, name must end with a forward slash, like +// "rplugin/python/". +// Without the slash it would instead look for an ordinary file called "rplugin/python". +// +// all is whether to return all matches or only the first. func (v *Nvim) RuntimeFiles(name string, all bool) (files []string, err error) { err = v.call("nvim_get_runtime_file", &files, name, all) return files, err } -// RuntimeFiles finds files in runtime directories and returns list of absolute paths to the found files. +// RuntimeFiles find files in runtime directories. // -// The name arg is can contain wildcards. For example, +// name is can contain wildcards. +// +// For example, // // RuntimeFiles("colors/*.vim", true) // // will return all color scheme files. // -// The all arg is whether to return all matches or only the first. +// Always use forward slashes (/) in the search pattern for subdirectories regardless of platform. +// +// It is not an error to not find any files, returned an empty array. +// +// To find a directory, name must end with a forward slash, like +// "rplugin/python/". +// Without the slash it would instead look for an ordinary file called "rplugin/python". +// +// all is whether to return all matches or only the first. func (b *Batch) RuntimeFiles(name string, all bool, files *[]string) { b.call("nvim_get_runtime_file", files, name, all) } @@ -571,10 +659,10 @@ func (b *Batch) Option(name string, result interface{}) { // Resulting map has keys: // // name -// Name of the option (like 'filetype'). +// Name of the option (like "filetype"). // // shortname -// Shortened name of the option (like 'ft'). +// Shortened name of the option (like "ft"). // // type // type of option ("string", "number" or "boolean"). @@ -595,10 +683,10 @@ func (b *Batch) Option(name string, result interface{}) { // Channel where option was set (0 for local). // // scope -// one of "global", "win", or "buf". +// One of "global", "win", or "buf". // // global_local -// whether win or buf option has a global value. +// Whether win or buf option has a global value. // // commalist // List of comma separated values. @@ -619,10 +707,10 @@ func (v *Nvim) AllOptionsInfo() (opinfo *OptionInfo, err error) { // Resulting map has keys: // // name -// Name of the option (like 'filetype'). +// Name of the option (like "filetype"). // // shortname -// Shortened name of the option (like 'ft'). +// Shortened name of the option (like "ft"). // // type // type of option ("string", "number" or "boolean"). @@ -643,10 +731,10 @@ func (v *Nvim) AllOptionsInfo() (opinfo *OptionInfo, err error) { // Channel where option was set (0 for local). // // scope -// one of "global", "win", or "buf". +// One of "global", "win", or "buf". // // global_local -// whether win or buf option has a global value. +// Whether win or buf option has a global value. // // commalist // List of comma separated values. @@ -659,13 +747,13 @@ func (b *Batch) AllOptionsInfo(opinfo *OptionInfo) { // OptionInfo gets the option information for one option. // -// Resulting dictionary has keys: +// Resulting map has keys: // // name -// Name of the option (like 'filetype'). +// Name of the option (like "filetype"). // // shortname -// Shortened name of the option (like 'ft'). +// Shortened name of the option (like "ft"). // // type // type of option ("string", "number" or "boolean"). @@ -686,10 +774,10 @@ func (b *Batch) AllOptionsInfo(opinfo *OptionInfo) { // Channel where option was set (0 for local). // // scope -// one of "global", "win", or "buf". +// One of "global", "win", or "buf". // // global_local -// whether win or buf option has a global value. +// Whether win or buf option has a global value. // // commalist // List of comma separated values. @@ -704,13 +792,13 @@ func (v *Nvim) OptionInfo(name string) (opinfo *OptionInfo, err error) { // OptionInfo gets the option information for one option. // -// Resulting dictionary has keys: +// Resulting map has keys: // // name -// Name of the option (like 'filetype'). +// Name of the option (like "filetype"). // // shortname -// Shortened name of the option (like 'ft'). +// Shortened name of the option (like "ft"). // // type // type of option ("string", "number" or "boolean"). @@ -731,10 +819,10 @@ func (v *Nvim) OptionInfo(name string) (opinfo *OptionInfo, err error) { // Channel where option was set (0 for local). // // scope -// one of "global", "win", or "buf". +// One of "global", "win", or "buf". // // global_local -// whether win or buf option has a global value. +// Whether win or buf option has a global value. // // commalist // List of comma separated values. @@ -757,24 +845,24 @@ func (b *Batch) SetOption(name string, value interface{}) { // Echo echo a message. // -// The chunks is a list of [text, hl_group] arrays, each representing a +// chunks is a list of [text, hl_group] arrays, each representing a // text chunk with specified highlight. hl_group element can be omitted for no highlight. // // If history is true, add to "message-history". // -// The opts arg is optional parameters. Reserved for future use. +// opts is optional parameters. Reserved for future use. func (v *Nvim) Echo(chunks []TextChunk, history bool, opts map[string]interface{}) error { return v.call("nvim_echo", nil, chunks, history, opts) } // Echo echo a message. // -// The chunks is a list of [text, hl_group] arrays, each representing a +// chunks is a list of [text, hl_group] arrays, each representing a // text chunk with specified highlight. hl_group element can be omitted for no highlight. // // If history is true, add to "message-history". // -// The opts arg is optional parameters. Reserved for future use. +// opts is optional parameters. Reserved for future use. func (b *Batch) Echo(chunks []TextChunk, history bool, opts map[string]interface{}) { b.call("nvim_echo", nil, chunks, history, opts) } @@ -822,12 +910,16 @@ func (b *Batch) WritelnErr(str string) { } // Buffers gets the current list of buffer handles. +// +// Includes unlisted (unloaded/deleted) buffers, like ":ls!". Use IsBufferLoaded to check if a buffer is loaded. func (v *Nvim) Buffers() (buffers []Buffer, err error) { err = v.call("nvim_list_bufs", &buffers) return buffers, err } // Buffers gets the current list of buffer handles. +// +// Includes unlisted (unloaded/deleted) buffers, like ":ls!". Use IsBufferLoaded to check if a buffer is loaded. func (b *Batch) Buffers(buffers *[]Buffer) { b.call("nvim_list_bufs", buffers) } @@ -885,23 +977,31 @@ func (b *Batch) SetCurrentWindow(window Window) { b.call("nvim_set_current_win", nil, window) } -// CreateBuffer greates a new, empty, unnamed buffer. +// CreateBuffer creates a new, empty, unnamed buffer. +// +// listed is sets buflisted buffer opttion. If false, sets "nobuflisted". // -// The listed arg sets buflisted buffer opttion. +// scratch is creates a "throwaway" for temporary work (always 'nomodified'). // -// The scratch arg creates a "throwaway" "scratch-buffer" for temporary work (always "nomodified"). -// Also sets "nomodeline" on the buffer. +// bufhidden=hide +// buftype=nofile +// noswapfile +// nomodeline func (v *Nvim) CreateBuffer(listed bool, scratch bool) (buffer Buffer, err error) { err = v.call("nvim_create_buf", &buffer, listed, scratch) return buffer, err } -// CreateBuffer greates a new, empty, unnamed buffer. +// CreateBuffer creates a new, empty, unnamed buffer. // -// The listed arg sets buflisted buffer opttion. +// listed is sets buflisted buffer opttion. If false, sets "nobuflisted". // -// The scratch arg creates a "throwaway" "scratch-buffer" for temporary work (always "nomodified"). -// Also sets "nomodeline" on the buffer. +// scratch is creates a "throwaway" for temporary work (always 'nomodified'). +// +// bufhidden=hide +// buftype=nofile +// noswapfile +// nomodeline func (b *Batch) CreateBuffer(listed bool, scratch bool, buffer *Buffer) { b.call("nvim_create_buf", buffer, listed, scratch) } @@ -920,9 +1020,9 @@ func (b *Batch) CreateBuffer(listed bool, scratch bool, buffer *Buffer) { // Then "nvim_chan_send" cal be called immediately to process sequences // in a virtual terminal having the intended size. // -// The buffer arg is the buffer to use (expected to be empty). +// buffer is the buffer to use (expected to be empty). // -// The opts arg is optional parameters. Reserved for future use. +// opts is optional parameters. Reserved for future use. func (v *Nvim) OpenTerm(buffer Buffer, opts map[string]interface{}) (channel int, err error) { err = v.call("nvim_open_term", &channel, buffer, opts) return channel, err @@ -942,9 +1042,9 @@ func (v *Nvim) OpenTerm(buffer Buffer, opts map[string]interface{}) (channel int // Then "nvim_chan_send" cal be called immediately to process sequences // in a virtual terminal having the intended size. // -// The buffer arg is the buffer to use (expected to be empty). +// buffer is the buffer to use (expected to be empty). // -// The opts arg is optional parameters. Reserved for future use. +// opts is optional parameters. Reserved for future use. func (b *Batch) OpenTerm(buffer Buffer, opts map[string]interface{}, channel *int) { b.call("nvim_open_term", channel, buffer, opts) } @@ -954,14 +1054,14 @@ func (b *Batch) OpenTerm(buffer Buffer, opts map[string]interface{}, channel *in // 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. +// Floats can be drawn internally or by external GUI with the "ui-multigrid" extension. // External windows are only supported with multigrid GUIs, and are displayed as separate top-level windows. // // For a general overview of floats, see // :help api-floatwin // -// Exactly one of `external` and `relative` must be specified. -// The `width` and `height` of the new window must be specified. +// 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 @@ -971,7 +1071,6 @@ func (b *Batch) OpenTerm(buffer Buffer, opts map[string]interface{}, channel *in // // 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. @@ -985,14 +1084,14 @@ func (v *Nvim) OpenWindow(buffer Buffer, enter bool, config *WindowConfig) (wind // 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. +// Floats can be drawn internally or by external GUI with the "ui-multigrid" extension. // External windows are only supported with multigrid GUIs, and are displayed as separate top-level windows. // // For a general overview of floats, see // :help api-floatwin // -// Exactly one of `external` and `relative` must be specified. -// The `width` and `height` of the new window must be specified. +// 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 @@ -1002,7 +1101,6 @@ func (v *Nvim) OpenWindow(buffer Buffer, enter bool, config *WindowConfig) (wind // // 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. @@ -1047,9 +1145,9 @@ func (b *Batch) SetCurrentTabpage(tabpage Tabpage) { // 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. +// 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 (v *Nvim) CreateNamespace(name string) (nsID int, err error) { @@ -1062,9 +1160,9 @@ func (v *Nvim) CreateNamespace(name string) (nsID int, err error) { // 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. +// 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 (b *Batch) CreateNamespace(name string, nsID *int) { @@ -1088,10 +1186,10 @@ func (b *Batch) Namespaces(namespaces *map[string]int) { // Paste pastes at cursor, in any mode. // -// Invokes the `vim.paste` handler, which handles each mode appropriately. +// 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` +// 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). @@ -1105,7 +1203,7 @@ func (b *Batch) Namespaces(namespaces *map[string]int) { // phase // -1 is paste in a single call (i.e. without streaming). // -// To `stream` a paste, call Paste sequentially with these `phase` args: +// To stream a paste, call Paste sequentially with these phase args: // 1 // starts the paste (exactly once) // 2 @@ -1113,11 +1211,9 @@ func (b *Batch) Namespaces(namespaces *map[string]int) { // 3 // ends the paste (exactly once) // -// The returned boolean state is: -// +// The returned boolean state is: // true // Client may continue pasting. -// // false // Client must cancel the paste. func (v *Nvim) Paste(data string, crlf bool, phase int) (state bool, err error) { @@ -1127,10 +1223,10 @@ func (v *Nvim) Paste(data string, crlf bool, phase int) (state bool, err error) // Paste pastes at cursor, in any mode. // -// Invokes the `vim.paste` handler, which handles each mode appropriately. +// 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` +// 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). @@ -1144,7 +1240,7 @@ func (v *Nvim) Paste(data string, crlf bool, phase int) (state bool, err error) // phase // -1 is paste in a single call (i.e. without streaming). // -// To `stream` a paste, call Paste sequentially with these `phase` args: +// To stream a paste, call Paste sequentially with these phase args: // 1 // starts the paste (exactly once) // 2 @@ -1152,11 +1248,9 @@ func (v *Nvim) Paste(data string, crlf bool, phase int) (state bool, err error) // 3 // ends the paste (exactly once) // -// The returned boolean state is: -// +// The returned boolean state is: // true // Client may continue pasting. -// // false // Client must cancel the paste. func (b *Batch) Paste(data string, crlf bool, phase int, state *bool) { @@ -1170,14 +1264,14 @@ func (b *Batch) Paste(data string, crlf bool, phase int, state *bool) { // lines is readfile() style list of lines. // // typ is edit behavior: any getregtype() result, or: -// "b" +// b // blockwise-visual mode (may include width, e.g. "b3") -// "c" +// c // characterwise mode -// "l" +// l // linewise mode // "" -// guess by contents, see setreg(). +// guess by contents, see |setreg()|. // // After is insert after cursor (like `p`), or before (like `P`). // @@ -1193,14 +1287,14 @@ func (v *Nvim) Put(lines []string, typ string, after bool, follow bool) error { // lines is readfile() style list of lines. // // typ is edit behavior: any getregtype() result, or: -// "b" +// b // blockwise-visual mode (may include width, e.g. "b3") -// "c" +// c // characterwise mode -// "l" +// l // linewise mode // "" -// guess by contents, see setreg(). +// guess by contents, see |setreg()|. // // After is insert after cursor (like `p`), or before (like `P`). // @@ -1209,33 +1303,41 @@ func (b *Batch) Put(lines []string, typ string, after bool, follow bool) { b.call("nvim_put", nil, lines, typ, after, follow) } -// Subscribe subscribes to a Nvim event. +// Subscribe subscribes to event broadcasts. func (v *Nvim) Subscribe(event string) error { return v.call("nvim_subscribe", nil, event) } -// Subscribe subscribes to a Nvim event. +// Subscribe subscribes to event broadcasts. func (b *Batch) Subscribe(event string) { b.call("nvim_subscribe", nil, event) } -// Unsubscribe unsubscribes to a Nvim event. +// Unsubscribe unsubscribes to event broadcasts. func (v *Nvim) Unsubscribe(event string) error { return v.call("nvim_unsubscribe", nil, event) } -// Unsubscribe unsubscribes to a Nvim event. +// Unsubscribe unsubscribes to event broadcasts. func (b *Batch) Unsubscribe(event string) { b.call("nvim_unsubscribe", nil, event) } -// ColorByName returns the 24-bit RGB value of a ColorMap color name or `#rrggbb` hexadecimal string. +// ColorByName Returns the 24-bit RGB value of a ColorMap color name or "#rrggbb" hexadecimal string. +// +// Example: +// ColorByName("Pink") +// ColorByName("#cbcbcb") func (v *Nvim) ColorByName(name string) (color int, err error) { err = v.call("nvim_get_color_by_name", &color, name) return color, err } -// ColorByName returns the 24-bit RGB value of a ColorMap color name or `#rrggbb` hexadecimal string. +// ColorByName Returns the 24-bit RGB value of a ColorMap color name or "#rrggbb" hexadecimal string. +// +// Example: +// ColorByName("Pink") +// ColorByName("#cbcbcb") func (b *Batch) ColorByName(name string, color *int) { b.call("nvim_get_color_by_name", color, name) } @@ -1263,50 +1365,50 @@ func (b *Batch) ColorMap(colorMap *map[string]int) { // This API still under development. // // The opts arg is optional parameters. -// Key is `types`. -// -// List of context-types to gather, or empty for `all` context. +// Key is "types". // +// List of context-types to gather, or empty for "all" context. // regs // jumps // bufs // gvars // funcs // sfuncs -func (v *Nvim) Context(opts map[string][]string) (contexts map[string]interface{}, err error) { - err = v.call("nvim_get_context", &contexts, opts) - return contexts, err +func (v *Nvim) Context(opts map[string][]string) (context map[string]interface{}, err error) { + err = v.call("nvim_get_context", &context, opts) + return context, err } // Context gets a map of the current editor state. // This API still under development. // // The opts arg is optional parameters. -// Key is `types`. -// -// List of context-types to gather, or empty for `all` context. +// Key is "types". // +// List of context-types to gather, or empty for "all" context. // regs // jumps // bufs // gvars // funcs // sfuncs -func (b *Batch) Context(opts map[string][]string, contexts *map[string]interface{}) { - b.call("nvim_get_context", contexts, opts) +func (b *Batch) Context(opts map[string][]string, context *map[string]interface{}) { + b.call("nvim_get_context", context, opts) } -// LoadContext sets the current editor state from the given context map. -func (v *Nvim) LoadContext(dict map[string]interface{}, result interface{}) error { - return v.call("nvim_load_context", result, dict) +// LoadContext Sets the current editor state from the given context map. +func (v *Nvim) LoadContext(context map[string]interface{}, result interface{}) error { + return v.call("nvim_load_context", result, context) } -// LoadContext sets the current editor state from the given context map. -func (b *Batch) LoadContext(dict map[string]interface{}, result interface{}) { - b.call("nvim_load_context", &result, dict) +// LoadContext Sets the current editor state from the given context map. +func (b *Batch) LoadContext(context map[string]interface{}, result interface{}) { + b.call("nvim_load_context", &result, context) } // Mode gets the current mode. +// +// |mode()| "blocking" is true if Nvim is waiting for input. func (v *Nvim) Mode() (mode *Mode, err error) { var result Mode err = v.call("nvim_get_mode", &result) @@ -1314,21 +1416,23 @@ func (v *Nvim) Mode() (mode *Mode, err error) { } // Mode gets the current mode. +// +// |mode()| "blocking" is true if Nvim is waiting for input. func (b *Batch) Mode(mode *Mode) { b.call("nvim_get_mode", mode) } -// KeyMap gets a list of global (non-buffer-local) mapping definitions. +// KeyMap gets a list of global (non-buffer-local) |mapping| definitions. // -// The mode arg is the mode short-name, like `n`, `i`, `v` or etc. +// The mode arg is the mode short-name, like "n", "i", "v" or etc. func (v *Nvim) KeyMap(mode string) (maps []*Mapping, err error) { err = v.call("nvim_get_keymap", &maps, mode) return maps, err } -// KeyMap gets a list of global (non-buffer-local) mapping definitions. +// KeyMap gets a list of global (non-buffer-local) |mapping| definitions. // -// The mode arg is the mode short-name, like `n`, `i`, `v` or etc. +// The mode arg is the mode short-name, like "n", "i", "v" or etc. func (b *Batch) KeyMap(mode string, maps *[]*Mapping) { b.call("nvim_get_keymap", maps, mode) } @@ -1421,7 +1525,7 @@ func (b *Batch) Commands(opts map[string]interface{}, commands *map[string]*Comm } // APIInfo returns a 2-tuple (Array), where item 0 is the current channel id and item -// 1 is the "pi-metadata|" map (Dictionary). +// 1 is the "api-metadata" map (Dictionary). // // Returns 2-tuple [{channel-id}, {api-metadata}]. func (v *Nvim) APIInfo() (apiInfo []interface{}, err error) { @@ -1430,7 +1534,7 @@ func (v *Nvim) APIInfo() (apiInfo []interface{}, err error) { } // APIInfo returns a 2-tuple (Array), where item 0 is the current channel id and item -// 1 is the "pi-metadata|" map (Dictionary). +// 1 is the "api-metadata" map (Dictionary). // // Returns 2-tuple [{channel-id}, {api-metadata}]. func (b *Batch) APIInfo(apiInfo *[]interface{}) { @@ -1465,36 +1569,36 @@ func (b *Batch) SetClientInfo(name string, version ClientVersion, typ ClientType // // Rreturns Dictionary describing a channel, with these keys: // -// "stream" +// stream // The stream underlying the channel. value are: -// "stdio" +// stdio // stdin and stdout of this Nvim instance. -// "stderr" +// stderr // stderr of this Nvim instance. -// "socket" +// socket // TCP/IP socket or named pipe. -// "job" +// job // job with communication over its stdio. // -// "mode" +// mode // How data received on the channel is interpreted. value are: -// "bytes" +// bytes // send and receive raw bytes. -// "terminal" +// terminal // A terminal instance interprets ASCII sequences. -// "rpc" +// rpc // RPC communication on the channel is active. // -// "pty" +// pty // Name of pseudoterminal, if one is used (optional). // On a POSIX system, this will be a device path like /dev/pts/1. // Even if the name is unknown, the key will still be present to indicate a pty is used. // This is currently the case when using winpty on windows. // -// "buffer" +// buffer // Buffer with connected |terminal| instance (optional). // -// "client" +// client // Information about the client on the other end of the RPC channel, if it has added it using SetClientInfo() (optional). func (v *Nvim) ChannelInfo(channelID int) (channel *Channel, err error) { var result Channel @@ -1506,36 +1610,36 @@ func (v *Nvim) ChannelInfo(channelID int) (channel *Channel, err error) { // // Rreturns Dictionary describing a channel, with these keys: // -// "stream" +// stream // The stream underlying the channel. value are: -// "stdio" +// stdio // stdin and stdout of this Nvim instance. -// "stderr" +// stderr // stderr of this Nvim instance. -// "socket" +// socket // TCP/IP socket or named pipe. -// "job" +// job // job with communication over its stdio. // -// "mode" +// mode // How data received on the channel is interpreted. value are: -// "bytes" +// bytes // send and receive raw bytes. -// "terminal" +// terminal // A terminal instance interprets ASCII sequences. -// "rpc" +// rpc // RPC communication on the channel is active. // -// "pty" +// pty // Name of pseudoterminal, if one is used (optional). // On a POSIX system, this will be a device path like /dev/pts/1. // Even if the name is unknown, the key will still be present to indicate a pty is used. // This is currently the case when using winpty on windows. // -// "buffer" +// buffer // Buffer with connected |terminal| instance (optional). // -// "client" +// client // Information about the client on the other end of the RPC channel, if it has added it using SetClientInfo() (optional). func (b *Batch) ChannelInfo(channelID int, channel *Channel) { b.call("nvim_get_chan_info", channel, channelID) @@ -1585,13 +1689,13 @@ func (b *Batch) ProcChildren(pid int, processes *[]uint) { b.call("nvim_get_proc_children", processes, pid) } -// Proc gets info describing process `pid`. +// Proc gets info describing process "pid". func (v *Nvim) Proc(pid int) (process Process, err error) { err = v.call("nvim_get_proc", &process, pid) return process, err } -// Proc gets info describing process `pid`. +// Proc gets info describing process "pid". func (b *Batch) Proc(pid int, process *Process) { b.call("nvim_get_proc", process, pid) } @@ -1603,7 +1707,7 @@ func (b *Batch) Proc(pid int, process *Process) { // with the mouse. Can also be used in a mapping; use |:map-cmd| to // ensure the mapping doesn't end completion mode. // -// The `opts` optional parameters. Reserved for future use. +// opts optional parameters. Reserved for future use. func (v *Nvim) SelectPopupmenuItem(item int, insert bool, finish bool, opts map[string]interface{}) error { return v.call("nvim_select_popupmenu_item", nil, item, insert, finish, opts) } @@ -1615,11 +1719,79 @@ func (v *Nvim) SelectPopupmenuItem(item int, insert bool, finish bool, opts map[ // with the mouse. Can also be used in a mapping; use |:map-cmd| to // ensure the mapping doesn't end completion mode. // -// The `opts` optional parameters. Reserved for future use. +// opts optional parameters. Reserved for future use. func (b *Batch) SelectPopupmenuItem(item int, insert bool, finish bool, opts map[string]interface{}) { b.call("nvim_select_popupmenu_item", nil, item, insert, finish, opts) } +// DeleteMark deletes a uppercase/file named mark. +// See |help mark-motions|. +func (v *Nvim) DeleteMark(name string) (deleted bool, err error) { + err = v.call("nvim_del_mark", &deleted, name) + return deleted, err +} + +// DeleteMark deletes a uppercase/file named mark. +// See |help mark-motions|. +func (b *Batch) DeleteMark(name string, deleted *bool) { + b.call("nvim_del_mark", deleted, name) +} + +// Mark returns a tuple (row, col, buffer, buffername) representing the position of +// the uppercase/file named mark. +// See |help mark-motions|. +// +// opts is optional parameters. Reserved for future use. +func (v *Nvim) Mark(name string, opts map[string]interface{}) (mark *Mark, err error) { + var result Mark + err = v.call("nvim_get_mark", &result, name, opts) + return &result, err +} + +// Mark returns a tuple (row, col, buffer, buffername) representing the position of +// the uppercase/file named mark. +// See |help mark-motions|. +// +// opts is optional parameters. Reserved for future use. +func (b *Batch) Mark(name string, opts map[string]interface{}, mark *Mark) { + b.call("nvim_get_mark", mark, name, opts) +} + +// EvalStatusLine evaluates statusline string. +// +// opts optional parameters. +// winid (int) +// Window ID of the window to use as context for statusline. +// maxwidth (int) +// Maximum width of statusline. +// fillchar (string) +// Character to fill blank spaces in the statusline (see 'fillchars'). +// highlights (bool) +// Return highlight information. +// use_tabline (bool) +// Evaluate tabline instead of statusline. When true, {winid} is ignored. +func (v *Nvim) EvalStatusLine(name string, opts map[string]interface{}) (statusline map[string]interface{}, err error) { + err = v.call("nvim_eval_statusline", &statusline, name, opts) + return statusline, err +} + +// EvalStatusLine evaluates statusline string. +// +// opts optional parameters. +// winid (int) +// Window ID of the window to use as context for statusline. +// maxwidth (int) +// Maximum width of statusline. +// fillchar (string) +// Character to fill blank spaces in the statusline (see 'fillchars'). +// highlights (bool) +// Return highlight information. +// use_tabline (bool) +// Evaluate tabline instead of statusline. When true, {winid} is ignored. +func (b *Batch) EvalStatusLine(name string, opts map[string]interface{}, statusline *map[string]interface{}) { + b.call("nvim_eval_statusline", statusline, name, opts) +} + // BufferLineCount gets the buffer line count. // // The buffer arg is specific Buffer, or 0 for current buffer. @@ -1644,8 +1816,8 @@ func (b *Batch) BufferLineCount(buffer Buffer, count *int) { // The buffer is specific Buffer, or 0 for current buffer. // // If sendBuffer is true, initial notification should contain the whole buffer. -// If false, the first notification will be a `nvim_buf_lines_event`. -// Otherwise, the first notification will be a `nvim_buf_changedtick_event` +// If false, the first notification will be a "nvim_buf_lines_event". +// Otherwise, the first notification will be a "nvim_buf_changedtick_event". // // Returns whether the updates couldn't be enabled because the buffer isn't loaded or opts contained an invalid key. func (v *Nvim) AttachBuffer(buffer Buffer, sendBuffer bool, opts map[string]interface{}) (attached bool, err error) { @@ -1658,8 +1830,8 @@ func (v *Nvim) AttachBuffer(buffer Buffer, sendBuffer bool, opts map[string]inte // The buffer is specific Buffer, or 0 for current buffer. // // If sendBuffer is true, initial notification should contain the whole buffer. -// If false, the first notification will be a `nvim_buf_lines_event`. -// Otherwise, the first notification will be a `nvim_buf_changedtick_event` +// If false, the first notification will be a "nvim_buf_lines_event". +// Otherwise, the first notification will be a "nvim_buf_changedtick_event". // // Returns whether the updates couldn't be enabled because the buffer isn't loaded or opts contained an invalid key. func (b *Batch) AttachBuffer(buffer Buffer, sendBuffer bool, opts map[string]interface{}, attached *bool) { @@ -1770,15 +1942,15 @@ func (b *Batch) SetBufferText(buffer Buffer, startRow int, startCol int, endRow b.call("nvim_buf_set_text", nil, buffer, startRow, startCol, endRow, endCol, replacement) } -// BufferOffset returns the byte offset for a line. +// BufferOffset returns the byte offset of a line (0-indexed). // // Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte. -// 'fileformat' and 'fileencoding' are ignored. +// "fileformat" and "fileencoding" are ignored. // // The line index just after the last line gives the total byte-count of the buffer. -// A final EOL byte is counted if it would be written, see ':help eol'. +// A final EOL byte is counted if it would be written, see ":help eol". // -// Unlike `line2byte` vim function, throws error for out-of-bounds indexing. +// Unlike "line2byte" vim function, throws error for out-of-bounds indexing. // // If Buffer is unloaded buffer, returns -1. func (v *Nvim) BufferOffset(buffer Buffer, index int) (offset int, err error) { @@ -1786,15 +1958,15 @@ func (v *Nvim) BufferOffset(buffer Buffer, index int) (offset int, err error) { return offset, err } -// BufferOffset returns the byte offset for a line. +// BufferOffset returns the byte offset of a line (0-indexed). // // Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte. -// 'fileformat' and 'fileencoding' are ignored. +// "fileformat" and "fileencoding" are ignored. // // The line index just after the last line gives the total byte-count of the buffer. -// A final EOL byte is counted if it would be written, see ':help eol'. +// A final EOL byte is counted if it would be written, see ":help eol". // -// Unlike `line2byte` vim function, throws error for out-of-bounds indexing. +// Unlike "line2byte" vim function, throws error for out-of-bounds indexing. // // If Buffer is unloaded buffer, returns -1. func (b *Batch) BufferOffset(buffer Buffer, index int, offset *int) { @@ -1968,7 +2140,7 @@ func (b *Batch) IsBufferLoaded(buffer Buffer, loaded *bool) { // DeleteBuffer deletes the buffer. // See -// help :bwipeout +// :help :bwipeout // // The opts args is optional parameters. // @@ -1983,7 +2155,7 @@ func (v *Nvim) DeleteBuffer(buffer Buffer, opts map[string]bool) error { // DeleteBuffer deletes the buffer. // See -// help :bwipeout +// :help :bwipeout // // The opts args is optional parameters. // @@ -2013,6 +2185,42 @@ func (b *Batch) IsBufferValid(buffer Buffer, valied *bool) { b.call("nvim_buf_is_valid", valied, buffer) } +// DeleteBufferMark deletes a named mark in the buffer. +// See |help mark-motions|. +func (v *Nvim) DeleteBufferMark(buffer Buffer, name string) (deleted bool, err error) { + err = v.call("nvim_buf_del_mark", &deleted, buffer, name) + return deleted, err +} + +// DeleteBufferMark deletes a named mark in the buffer. +// See |help mark-motions|. +func (b *Batch) DeleteBufferMark(buffer Buffer, name string, deleted *bool) { + b.call("nvim_buf_del_mark", deleted, buffer, name) +} + +// SetBufferMark sets a named mark in the given buffer, all marks are allowed +// file/uppercase, visual, last change, etc. +// See |help mark-motions|. +// +// line and col are (1,0)-indexed. +// +// opts is optional parameters. Reserved for future use. +func (v *Nvim) SetBufferMark(buffer Buffer, name string, line int, col int, opts map[string]interface{}) (set bool, err error) { + err = v.call("nvim_buf_set_mark", &set, buffer, name, line, col, opts) + return set, err +} + +// SetBufferMark sets a named mark in the given buffer, all marks are allowed +// file/uppercase, visual, last change, etc. +// See |help mark-motions|. +// +// line and col are (1,0)-indexed. +// +// opts is optional parameters. Reserved for future use. +func (b *Batch) SetBufferMark(buffer Buffer, name string, line int, col int, opts map[string]interface{}, set *bool) { + b.call("nvim_buf_set_mark", set, buffer, name, line, col, opts) +} + // BufferMark return a tuple (row,col) representing the position of the named mark. // // Marks are (1,0)-indexed. @@ -2030,11 +2238,7 @@ func (b *Batch) BufferMark(buffer Buffer, name string, pos *[2]int) { // BufferExtmarkByID beturns position for a given extmark id. // -// The opts arg is optional parameters. -// -// limit -// Maximum number of marks to return. int type. -// +// opts is optional parameters. // details // Whether to include the details dict. bool type. func (v *Nvim) BufferExtmarkByID(buffer Buffer, nsID int, id int, opt map[string]interface{}) (pos []int, err error) { @@ -2044,11 +2248,7 @@ func (v *Nvim) BufferExtmarkByID(buffer Buffer, nsID int, id int, opt map[string // BufferExtmarkByID beturns position for a given extmark id. // -// The opts arg is optional parameters. -// -// limit -// Maximum number of marks to return. int type. -// +// opts is optional parameters. // details // Whether to include the details dict. bool type. func (b *Batch) BufferExtmarkByID(buffer Buffer, nsID int, id int, opt map[string]interface{}, pos *[]int) { @@ -2071,11 +2271,9 @@ func (b *Batch) BufferExtmarkByID(buffer Buffer, nsID int, id int, opt map[strin // The start and end args is start or end of range, given as (row, col), or // valid extmark id whose position defines the bound. // -// The opts arg is optional parameters. -// +// opts is optional parameters. // limit // Maximum number of marks to return. int type. -// // details // Whether to include the details dict. bool type. func (v *Nvim) BufferExtmarks(buffer Buffer, nsID int, start interface{}, end interface{}, opt map[string]interface{}) (marks []ExtMark, err error) { @@ -2099,11 +2297,9 @@ func (v *Nvim) BufferExtmarks(buffer Buffer, nsID int, start interface{}, end in // The start and end args is start or end of range, given as (row, col), or // valid extmark id whose position defines the bound. // -// The opts arg is optional parameters. -// +// opts is optional parameters. // limit // Maximum number of marks to return. int type. -// // details // Whether to include the details dict. bool type. func (b *Batch) BufferExtmarks(buffer Buffer, nsID int, start interface{}, end interface{}, opt map[string]interface{}, marks *[]ExtMark) { @@ -2142,25 +2338,32 @@ func (b *Batch) BufferExtmarks(buffer Buffer, nsID int, start interface{}, end i // virt_text_pos // Positioning of virtual text. // Possible values: -// "eol" +// eol // right after eol character (default) -// "overlay" +// overlay // display over the specified column, without shifting the underlying text. // +// virt_text_win_col +// position the virtual text at a fixed window column (starting from the first text column) +// // virt_text_hide -// Hide the virtual text when the background text is selected or hidden due to horizontal scroll 'nowrap'. +// Hide the virtual text when the background text is selected or hidden due to horizontal scroll "nowrap". // // hl_mode // Control how highlights are combined with the highlights of the text. Currently only affects // virt_text highlights, but might affect "hl_group" in later versions. // Possible values: -// "replace" +// replace // only show the virt_text color. This is the default. -// "combine" +// combine // combine with background text color -// "blend" +// blend // blend with background text color. // +// hl_eol +// when true, for a multiline highlight covering the EOL of a line, continue the highlight for the rest +// of the screen line (just like for diff and cursorline highlight). +// // ephemeral // For use with "nvim_set_decoration_provider" callbacks. The mark will only be used for the current redraw cycle, // and not be permantently stored in the buffer. @@ -2172,6 +2375,9 @@ func (b *Batch) BufferExtmarks(buffer Buffer, nsID int, start interface{}, end i // end_right_gravity // Boolean that indicates the direction the extmark end position (if it exists) will be // shifted in when new text is inserted (true for right, false for left). Defaults to false. +// +// priority +// A priority value for the highlight group. For example treesitter highlighting uses a value of 100. func (v *Nvim) SetBufferExtmark(buffer Buffer, nsID int, line int, col int, opts map[string]interface{}) (id int, err error) { err = v.call("nvim_buf_set_extmark", &id, buffer, nsID, line, col, opts) return id, err @@ -2209,25 +2415,32 @@ func (v *Nvim) SetBufferExtmark(buffer Buffer, nsID int, line int, col int, opts // virt_text_pos // Positioning of virtual text. // Possible values: -// "eol" +// eol // right after eol character (default) -// "overlay" +// overlay // display over the specified column, without shifting the underlying text. // +// virt_text_win_col +// position the virtual text at a fixed window column (starting from the first text column) +// // virt_text_hide -// Hide the virtual text when the background text is selected or hidden due to horizontal scroll 'nowrap'. +// Hide the virtual text when the background text is selected or hidden due to horizontal scroll "nowrap". // // hl_mode // Control how highlights are combined with the highlights of the text. Currently only affects // virt_text highlights, but might affect "hl_group" in later versions. // Possible values: -// "replace" +// replace // only show the virt_text color. This is the default. -// "combine" +// combine // combine with background text color -// "blend" +// blend // blend with background text color. // +// hl_eol +// when true, for a multiline highlight covering the EOL of a line, continue the highlight for the rest +// of the screen line (just like for diff and cursorline highlight). +// // ephemeral // For use with "nvim_set_decoration_provider" callbacks. The mark will only be used for the current redraw cycle, // and not be permantently stored in the buffer. @@ -2239,6 +2452,9 @@ func (v *Nvim) SetBufferExtmark(buffer Buffer, nsID int, line int, col int, opts // end_right_gravity // Boolean that indicates the direction the extmark end position (if it exists) will be // shifted in when new text is inserted (true for right, false for left). Defaults to false. +// +// priority +// A priority value for the highlight group. For example treesitter highlighting uses a value of 100. func (b *Batch) SetBufferExtmark(buffer Buffer, nsID int, line int, col int, opts map[string]interface{}, id *int) { b.call("nvim_buf_set_extmark", id, buffer, nsID, line, col, opts) } @@ -2272,7 +2488,7 @@ func (b *Batch) DeleteBufferExtmark(buffer Buffer, nsID int, extmarkID int, dele // All highlights in the same namespace can then be cleared with single call to ClearBufferNamespace. // If the highlight never will be deleted by an API call, pass nsID = -1. // -// As a shorthand, `nsID = 0` can be used to create a new namespace for the +// As a shorthand, "srcID = 0" can be used to create a new namespace for the // highlight, the allocated id is then returned. // // If hlGroup arg is the empty string, no highlight is added, but a new `nsID` is still returned. @@ -2296,7 +2512,7 @@ func (v *Nvim) AddBufferHighlight(buffer Buffer, srcID int, hlGroup string, line // All highlights in the same namespace can then be cleared with single call to ClearBufferNamespace. // If the highlight never will be deleted by an API call, pass nsID = -1. // -// As a shorthand, `nsID = 0` can be used to create a new namespace for the +// As a shorthand, "srcID = 0" can be used to create a new namespace for the // highlight, the allocated id is then returned. // // If hlGroup arg is the empty string, no highlight is added, but a new `nsID` is still returned. @@ -2321,44 +2537,44 @@ func (b *Batch) ClearBufferNamespace(buffer Buffer, nsID int, lineStart int, lin b.call("nvim_buf_clear_namespace", nil, buffer, nsID, lineStart, lineEnd) } -// WindowBuffer returns the current buffer in a window. +// WindowBuffer gets the current buffer in a window. func (v *Nvim) WindowBuffer(window Window) (buffer Buffer, err error) { err = v.call("nvim_win_get_buf", &buffer, window) return buffer, err } -// WindowBuffer returns the current buffer in a window. +// WindowBuffer gets the current buffer in a window. func (b *Batch) WindowBuffer(window Window, buffer *Buffer) { b.call("nvim_win_get_buf", buffer, window) } -// SetBufferToWindow sets the current buffer in a window, without side-effects. +// SetBufferToWindow Sets the current buffer in a window, without side-effects. func (v *Nvim) SetBufferToWindow(window Window, buffer Buffer) error { return v.call("nvim_win_set_buf", nil, window, buffer) } -// SetBufferToWindow sets the current buffer in a window, without side-effects. +// SetBufferToWindow Sets the current buffer in a window, without side-effects. func (b *Batch) SetBufferToWindow(window Window, buffer Buffer) { b.call("nvim_win_set_buf", nil, window, buffer) } -// WindowCursor returns the cursor position in the window. +// WindowCursor gets the (1,0)-indexed cursor position in the window. func (v *Nvim) WindowCursor(window Window) (pos [2]int, err error) { err = v.call("nvim_win_get_cursor", &pos, window) return pos, err } -// WindowCursor returns the cursor position in the window. +// WindowCursor gets the (1,0)-indexed cursor position in the window. func (b *Batch) WindowCursor(window Window, pos *[2]int) { b.call("nvim_win_get_cursor", pos, window) } -// SetWindowCursor sets the cursor position in the window to the given position. +// SetWindowCursor sets the (1,0)-indexed cursor position in the window. func (v *Nvim) SetWindowCursor(window Window, pos [2]int) error { return v.call("nvim_win_set_cursor", nil, window, pos) } -// SetWindowCursor sets the cursor position in the window to the given position. +// SetWindowCursor sets the (1,0)-indexed cursor position in the window. func (b *Batch) SetWindowCursor(window Window, pos [2]int) { b.call("nvim_win_set_cursor", nil, window, pos) } @@ -2374,12 +2590,12 @@ func (b *Batch) WindowHeight(window Window, height *int) { b.call("nvim_win_get_height", height, window) } -// SetWindowHeight sets the window height. +// SetWindowHeight Sets the window height. This will only succeed if the screen is split horizontally. func (v *Nvim) SetWindowHeight(window Window, height int) error { return v.call("nvim_win_set_height", nil, window, height) } -// SetWindowHeight sets the window height. +// SetWindowHeight Sets the window height. This will only succeed if the screen is split horizontally. func (b *Batch) SetWindowHeight(window Window, height int) { b.call("nvim_win_set_height", nil, window, height) } @@ -2395,12 +2611,12 @@ func (b *Batch) WindowWidth(window Window, width *int) { b.call("nvim_win_get_width", width, window) } -// SetWindowWidth sets the window width. +// SetWindowWidth Sets the window width. This will only succeed if the screen is split vertically. func (v *Nvim) SetWindowWidth(window Window, width int) error { return v.call("nvim_win_set_width", nil, window, width) } -// SetWindowWidth sets the window width. +// SetWindowWidth Sets the window width. This will only succeed if the screen is split vertically. func (b *Batch) SetWindowWidth(window Window, width int) { b.call("nvim_win_set_width", nil, window, width) } @@ -2435,22 +2651,22 @@ func (b *Batch) DeleteWindowVar(window Window, name string) { b.call("nvim_win_del_var", nil, window, name) } -// WindowOption gets a window option. +// WindowOption gets a window option value. func (v *Nvim) WindowOption(window Window, name string, result interface{}) error { return v.call("nvim_win_get_option", result, window, name) } -// WindowOption gets a window option. +// WindowOption gets a window option value. func (b *Batch) WindowOption(window Window, name string, result interface{}) { b.call("nvim_win_get_option", &result, window, name) } -// SetWindowOption sets a window option. +// SetWindowOption sets a window option value. Passing "nil" as value deletes the option(only works if there's a global fallback). func (v *Nvim) SetWindowOption(window Window, name string, value interface{}) error { return v.call("nvim_win_set_option", nil, window, name, value) } -// SetWindowOption sets a window option. +// SetWindowOption sets a window option value. Passing "nil" as value deletes the option(only works if there's a global fallback). func (b *Batch) SetWindowOption(window Window, name string, value interface{}) { b.call("nvim_win_set_option", nil, window, name, value) } @@ -2466,35 +2682,35 @@ func (b *Batch) WindowPosition(window Window, pos *[2]int) { b.call("nvim_win_get_position", pos, window) } -// WindowTabpage gets the tab page that contains the window. +// WindowTabpage gets the window tabpage. func (v *Nvim) WindowTabpage(window Window) (tabpage Tabpage, err error) { err = v.call("nvim_win_get_tabpage", &tabpage, window) return tabpage, err } -// WindowTabpage gets the tab page that contains the window. +// WindowTabpage gets the window tabpage. func (b *Batch) WindowTabpage(window Window, tabpage *Tabpage) { b.call("nvim_win_get_tabpage", tabpage, window) } -// WindowNumber gets the window number from the window handle. +// WindowNumber gets the window number. func (v *Nvim) WindowNumber(window Window) (number int, err error) { err = v.call("nvim_win_get_number", &number, window) return number, err } -// WindowNumber gets the window number from the window handle. +// WindowNumber gets the window number. func (b *Batch) WindowNumber(window Window, number *int) { b.call("nvim_win_get_number", number, window) } -// IsWindowValid returns true if the window is valid. +// IsWindowValid checks if a window is valid. func (v *Nvim) IsWindowValid(window Window) (valid bool, err error) { err = v.call("nvim_win_is_valid", &valid, window) return valid, err } -// IsWindowValid returns true if the window is valid. +// IsWindowValid checks if a window is valid. func (b *Batch) IsWindowValid(window Window, valid *bool) { b.call("nvim_win_is_valid", valid, window) } @@ -2502,14 +2718,10 @@ func (b *Batch) IsWindowValid(window Window, valid *bool) { // 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 OpenWindow, for the meaning of parameters. -// // When reconfiguring a floating window, absent option keys will not be -// changed. -// The following restriction are apply must be reconfigured together. Only changing a subset of these is an error. -// row -// col -// relative +// changed. "row"/"col" and "relative" must be reconfigured together. +// +// See documentation at OpenWindow, for the meaning of parameters. func (v *Nvim) SetWindowConfig(window Window, config *WindowConfig) error { return v.call("nvim_win_set_config", nil, window, config) } @@ -2517,23 +2729,19 @@ func (v *Nvim) SetWindowConfig(window Window, config *WindowConfig) error { // SetWindowConfig configure window position. Currently this is only used to configure // floating and external windows (including changing a split window to these types). // -// See documentation at OpenWindow, for the meaning of parameters. -// // When reconfiguring a floating window, absent option keys will not be -// changed. -// The following restriction are apply must be reconfigured together. Only changing a subset of these is an error. -// row -// col -// relative +// changed. "row"/"col" and "relative" must be reconfigured together. +// +// See documentation at OpenWindow, for the meaning of parameters. func (b *Batch) SetWindowConfig(window Window, config *WindowConfig) { b.call("nvim_win_set_config", nil, window, config) } // WindowConfig return window configuration. // -// Return a dictionary containing the same config that can be given to OpenWindow. +// The returned value may be given to OpenWindow. // -// The `relative` will be an empty string for normal windows. +// Relative will be an empty string for normal windows. func (v *Nvim) WindowConfig(window Window) (config *WindowConfig, err error) { var result WindowConfig err = v.call("nvim_win_get_config", &result, window) @@ -2542,9 +2750,9 @@ func (v *Nvim) WindowConfig(window Window) (config *WindowConfig, err error) { // WindowConfig return window configuration. // -// Return a dictionary containing the same config that can be given to OpenWindow. +// The returned value may be given to OpenWindow. // -// The `relative` will be an empty string for normal windows. +// Relative will be an empty string for normal windows. func (b *Batch) WindowConfig(window Window, config *WindowConfig) { b.call("nvim_win_get_config", config, window) } @@ -2569,27 +2777,23 @@ func (b *Batch) HideWindow(window Window) { b.call("nvim_win_hide", nil, window) } -// CloseWindow close a window. -// -// This is equivalent to |:close| with count except that it takes a window id. +// CloseWindow Closes the window (like ":close" with a window-ID). func (v *Nvim) CloseWindow(window Window, force bool) error { return v.call("nvim_win_close", nil, window, force) } -// CloseWindow close a window. -// -// This is equivalent to |:close| with count except that it takes a window id. +// CloseWindow Closes the window (like ":close" with a window-ID). func (b *Batch) CloseWindow(window Window, force bool) { b.call("nvim_win_close", nil, window, force) } -// TabpageWindows returns the windows in a tabpage. +// TabpageWindows gets the windows in a tabpage. func (v *Nvim) TabpageWindows(tabpage Tabpage) (windows []Window, err error) { err = v.call("nvim_tabpage_list_wins", &windows, tabpage) return windows, err } -// TabpageWindows returns the windows in a tabpage. +// TabpageWindows gets the windows in a tabpage. func (b *Batch) TabpageWindows(tabpage Tabpage, windows *[]Window) { b.call("nvim_tabpage_list_wins", windows, tabpage) } @@ -2624,36 +2828,36 @@ func (b *Batch) DeleteTabpageVar(tabpage Tabpage, name string) { b.call("nvim_tabpage_del_var", nil, tabpage, name) } -// TabpageWindow gets the current window in a tab page. +// TabpageWindow gets the current window in a tabpage. func (v *Nvim) TabpageWindow(tabpage Tabpage) (Window, error) { var result Window err := v.call("nvim_tabpage_get_win", &result, tabpage) return result, err } -// TabpageWindow gets the current window in a tab page. +// TabpageWindow gets the current window in a tabpage. func (b *Batch) TabpageWindow(tabpage Tabpage, result *Window) { b.call("nvim_tabpage_get_win", result, tabpage) } -// TabpageNumber gets the tabpage number from the tabpage handle. +// TabpageNumber gets the tabpage number. func (v *Nvim) TabpageNumber(tabpage Tabpage) (number int, err error) { err = v.call("nvim_tabpage_get_number", &number, tabpage) return number, err } -// TabpageNumber gets the tabpage number from the tabpage handle. +// TabpageNumber gets the tabpage number. func (b *Batch) TabpageNumber(tabpage Tabpage, number *int) { b.call("nvim_tabpage_get_number", number, tabpage) } -// IsTabpageValid checks if a tab page is valid. +// IsTabpageValid checks if a tabpage is valid. func (v *Nvim) IsTabpageValid(tabpage Tabpage) (valid bool, err error) { err = v.call("nvim_tabpage_is_valid", &valid, tabpage) return valid, err } -// IsTabpageValid checks if a tab page is valid. +// IsTabpageValid checks if a tabpage is valid. func (b *Batch) IsTabpageValid(tabpage Tabpage, valid *bool) { b.call("nvim_tabpage_is_valid", valid, tabpage) } diff --git a/nvim/api_def.go b/nvim/api_def.go index 9f9edced..e1913b7d 100644 --- a/nvim/api_def.go +++ b/nvim/api_def.go @@ -18,38 +18,60 @@ package main // // Unlike Command, this function supports heredocs, script-scope (s:), etc. // -// On execution error: fails with VimL error, does not update v:errmsg. +// When fails with VimL error, does not update "v:errmsg". func Exec(src string, output bool) (out string) { name(nvim_exec) } // Command executes an ex-command. +// +// When fails with VimL error, does not update "v:errmsg". func Command(cmd string) { name(nvim_command) } // HLByID gets a highlight definition by name. -func HLByID(id int, rgb bool) (highlight HLAttrs) { +// +// hlID is the highlight id as returned by HLIDByName. +// +// rgb is the whether the export RGB colors. +// +// The returned highlight is the highlight definition. +func HLByID(hlID int, rgb bool) (highlight HLAttrs) { name(nvim_get_hl_by_id) returnPtr() } // HLIDByName gets a highlight group by name. -func HLIDByName(name string) (highlightID int) { +// +// name is the Highlight group name. +// +// The returns hlID is the highlight id. +// +// This function similar to HLByID, but allocates a new ID if not present. +func HLIDByName(name string) (hlID int) { name(nvim_get_hl_id_by_name) } // HLByName gets a highlight definition by id. +// +// name is Highlight group name. +// +// rgb is whether the export RGB colors. +// +// The returned highlight is the highlight definition. func HLByName(name string, rgb bool) (highlight HLAttrs) { name(nvim_get_hl_by_name) returnPtr() } -// SetHighlight set a highlight group. +// SetHighlight sets a highlight group. +// +// nsID is number of namespace for this highlight. // -// name arg is highlight group name, like ErrorMsg. +// name is highlight group name, like "ErrorMsg". // -// val arg is highlight definition map, like HLByName. +// val is highlight definiton map, like HLByName. // // in addition the following keys are also recognized: // @@ -61,22 +83,17 @@ func SetHighlight(nsID int, name string, val *HLAttrs) { // SetHighlightNameSpace set active namespace for highlights. // -// NB: this function can be called from async contexts, but the -// semantics are not yet well-defined. -// To start with SetDecorationProvider on_win and on_line callbacks -// are explicitly allowed to change the namespace during a redraw cycle. -// -// The nsID arg is the namespace to activate. +// nsID is the namespace to activate. func SetHighlightNameSpace(nsID int) { name(nvim__set_hl_ns) } -// FeedKeys sends input-keys to Nvim, subject to various quirks controlled by mode flags. -// This is a blocking call, unlike Input. +// FeedKeys input-keys to Nvim, subject to various quirks controlled by "mode" +// flags. Unlike Input, this is a blocking call. // -// On execution error: does not fail, but updates v:errmsg. +// This function does not fail, but updates "v:errmsg". // -// If you need to input sequences like use ReplaceTermcodes to +// If need to input sequences like use ReplaceTermcodes to // replace the termcodes and then pass the resulting string to nvim_feedkeys. // You'll also want to enable escape_csi. // @@ -84,13 +101,15 @@ func SetHighlightNameSpace(nsID int) { // // 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. // -// The escapeCSI arg is whether the escape K_SPECIAL/CSI bytes in keys arg. +// escapeCSI is whether the escape K_SPECIAL/CSI bytes in keys. func FeedKeys(keys, mode string, escapeCSI bool) { name(nvim_feedkeys) } @@ -99,48 +118,67 @@ func FeedKeys(keys, mode string, escapeCSI bool) { // // Unlike FeedKeys, this uses a low-level input buffer and the call // is non-blocking (input is processed asynchronously by the eventloop). +// +// This function does not fail but updates "v:errmsg". +// +// keys is to be typed. +// +// Note: "keycodes" like "" are translated, so "<" is special. To input a literal "<", send "". +// +// Note: For mouse events use InputMouse. The pseudokey form "" is deprecated. +// +// The returned written is number of bytes actually written (can be fewer than +// requested if the buffer becomes full). func Input(keys string) (written int) { name(nvim_input) } -// InputMouse send mouse event from GUI. +// InputMouse Send mouse event from GUI. // -// This API is non-blocking. It doesn't wait on any resulting action, but -// queues the event to be processed soon by the event loop. +// This API is non-blocking. It does not wait on any result, but queues the event to be +// processed soon by the event loop. // -// The button arg is mouse button. One of -// "left" -// "right" -// "middle" -// "wheel" +// button is mouse button. One of +// left +// right +// middle +// wheel // -// The action arg is for ordinary buttons. One of -// "press" -// "drag" -// "release" +// action is for ordinary buttons. One of +// press +// drag +// release // For the wheel, One of -// "up" -// "down -// "left" -// "right" +// up +// down +// left +// right // -// The modifier arg is string of modifiers each represented by a single char. +// modifier is string of modifiers each represented by a single char. // The same specifiers are used as for a key press, except // that the "-" separator is optional, so "C-A-", "c-a" -// and "CA" can all be used to specify Ctrl+Alt+click. +// and "CA" can all be used to specify "Ctrl+Alt+Click". // -// The grid arg is grid number if the client uses "ui-multigrid", else 0. +// grid is grid number if the client uses "ui-multigrid", else 0. // -// The row arg is mouse row-position (zero-based, like redraw events). +// row is mouse row-position (zero-based, like redraw events). // -// The col arg is mouse column-position (zero-based, like redraw events). +// col is mouse column-position (zero-based, like redraw events). func InputMouse(button, action, modifier string, grid, row, col int) { name(nvim_input_mouse) } -// ReplaceTermcodes replaces terminal codes and |keycodes| (, , ...) in a string with +// ReplaceTermcodes replaces terminal codes and "keycodes" (, , ...) in a string with // the internal representation. // +// str is string to be converted. +// +// fromPart is legacy Vim parameter. Usually true. +// +// doLT is also translate . Ignored if "special" is false. +// +// special is replace "keycodes", e.g. "" becomes a "\n" char. +// // The returned sequences are Nvim's internal representation of keys, for example: // // -> '\x1b' @@ -149,12 +187,6 @@ func InputMouse(button, action, modifier string, grid, row, col int) { // -> '\x80ku' // // The returned sequences can be used as input to feedkeys. -// -// The fromPart arg is legacy Vim parameter. Usually true. -// -// The doLT arg is also translate . Ignored if "special" is false. -// -// The special arg is replace "keycodes", e.g. becomes a "\n" char. func ReplaceTermcodes(str string, fromPart, doLT, special bool) (input string) { name(nvim_replace_termcodes) } @@ -171,34 +203,46 @@ func CommandOutput(cmd string) (out string) { // // Dictionaries and Lists are recursively expanded. // -// The expr arg is VimL expression string. +// Fails with VimL error, does not update "v:errmsg". +// +// expr is VimL expression string. // // :help expression func Eval(expr string) (result interface{}) { name(nvim_eval) } -// StringWidth calculates the number of display cells occupied by `text`. +// StringWidth calculates the number of display cells occupied by "text". // -// counts as one cell. +// "" counts as one cell. func StringWidth(s string) (width int) { name(nvim_strwidth) } -// RuntimePaths gets the paths contained in 'runtimepath'. +// RuntimePaths gets the paths contained in "runtimepath". func RuntimePaths() (paths []string) { name(nvim_list_runtime_paths) } -// RuntimeFiles finds files in runtime directories and returns list of absolute paths to the found files. +// RuntimeFiles find files in runtime directories. // -// The name arg is can contain wildcards. For example, +// name is can contain wildcards. +// +// For example, // // RuntimeFiles("colors/*.vim", true) // // will return all color scheme files. // -// The all arg is whether to return all matches or only the first. +// Always use forward slashes (/) in the search pattern for subdirectories regardless of platform. +// +// It is not an error to not find any files, returned an empty array. +// +// To find a directory, name must end with a forward slash, like +// "rplugin/python/". +// Without the slash it would instead look for an ordinary file called "rplugin/python". +// +// all is whether to return all matches or only the first. func RuntimeFiles(name string, all bool) (files []string) { name(nvim_get_runtime_file) } @@ -261,10 +305,10 @@ func Option(name string) (option interface{}) { // Resulting map has keys: // // name -// Name of the option (like 'filetype'). +// Name of the option (like "filetype"). // // shortname -// Shortened name of the option (like 'ft'). +// Shortened name of the option (like "ft"). // // type // type of option ("string", "number" or "boolean"). @@ -285,10 +329,10 @@ func Option(name string) (option interface{}) { // Channel where option was set (0 for local). // // scope -// one of "global", "win", or "buf". +// One of "global", "win", or "buf". // // global_local -// whether win or buf option has a global value. +// Whether win or buf option has a global value. // // commalist // List of comma separated values. @@ -302,13 +346,13 @@ func AllOptionsInfo() (opinfo OptionInfo) { // OptionInfo gets the option information for one option. // -// Resulting dictionary has keys: +// Resulting map has keys: // // name -// Name of the option (like 'filetype'). +// Name of the option (like "filetype"). // // shortname -// Shortened name of the option (like 'ft'). +// Shortened name of the option (like "ft"). // // type // type of option ("string", "number" or "boolean"). @@ -329,10 +373,10 @@ func AllOptionsInfo() (opinfo OptionInfo) { // Channel where option was set (0 for local). // // scope -// one of "global", "win", or "buf". +// One of "global", "win", or "buf". // // global_local -// whether win or buf option has a global value. +// Whether win or buf option has a global value. // // commalist // List of comma separated values. @@ -351,12 +395,12 @@ func SetOption(name string, value interface{}) { // Echo echo a message. // -// The chunks is a list of [text, hl_group] arrays, each representing a +// chunks is a list of [text, hl_group] arrays, each representing a // text chunk with specified highlight. hl_group element can be omitted for no highlight. // // If history is true, add to "message-history". // -// The opts arg is optional parameters. Reserved for future use. +// opts is optional parameters. Reserved for future use. func Echo(chunks []TextChunk, history bool, opts map[string]interface{}) { name(nvim_echo) } @@ -383,6 +427,8 @@ func WritelnErr(str string) { } // Buffers gets the current list of buffer handles. +// +// Includes unlisted (unloaded/deleted) buffers, like ":ls!". Use IsBufferLoaded to check if a buffer is loaded. func Buffers() (buffers []Buffer) { name(nvim_list_bufs) } @@ -412,12 +458,16 @@ func SetCurrentWindow(window Window) { name(nvim_set_current_win) } -// CreateBuffer greates a new, empty, unnamed buffer. +// CreateBuffer creates a new, empty, unnamed buffer. +// +// listed is sets buflisted buffer opttion. If false, sets "nobuflisted". // -// The listed arg sets buflisted buffer opttion. +// scratch is creates a "throwaway" for temporary work (always 'nomodified'). // -// The scratch arg creates a "throwaway" "scratch-buffer" for temporary work (always "nomodified"). -// Also sets "nomodeline" on the buffer. +// bufhidden=hide +// buftype=nofile +// noswapfile +// nomodeline func CreateBuffer(listed, scratch bool) (buffer Buffer) { name(nvim_create_buf) } @@ -436,9 +486,9 @@ func CreateBuffer(listed, scratch bool) (buffer Buffer) { // Then "nvim_chan_send" cal be called immediately to process sequences // in a virtual terminal having the intended size. // -// The buffer arg is the buffer to use (expected to be empty). +// buffer is the buffer to use (expected to be empty). // -// The opts arg is optional parameters. Reserved for future use. +// opts is optional parameters. Reserved for future use. func OpenTerm(buffer Buffer, opts map[string]interface{}) (channel int) { name(nvim_open_term) } @@ -448,14 +498,14 @@ func OpenTerm(buffer Buffer, opts map[string]interface{}) (channel int) { // 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. +// Floats can be drawn internally or by external GUI with the "ui-multigrid" extension. // External windows are only supported with multigrid GUIs, and are displayed as separate top-level windows. // // For a general overview of floats, see // :help api-floatwin // -// Exactly one of `external` and `relative` must be specified. -// The `width` and `height` of the new window must be specified. +// 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 @@ -465,7 +515,6 @@ func OpenTerm(buffer Buffer, opts map[string]interface{}) (channel int) { // // 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. @@ -493,9 +542,9 @@ func SetCurrentTabpage(tabpage Tabpage) { // 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. +// 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 CreateNamespace(name string) (nsID int) { @@ -511,10 +560,10 @@ func Namespaces() (namespaces map[string]int) { // Paste pastes at cursor, in any mode. // -// Invokes the `vim.paste` handler, which handles each mode appropriately. +// 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` +// 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). @@ -528,7 +577,7 @@ func Namespaces() (namespaces map[string]int) { // phase // -1 is paste in a single call (i.e. without streaming). // -// To `stream` a paste, call Paste sequentially with these `phase` args: +// To stream a paste, call Paste sequentially with these phase args: // 1 // starts the paste (exactly once) // 2 @@ -536,11 +585,9 @@ func Namespaces() (namespaces map[string]int) { // 3 // ends the paste (exactly once) // -// The returned boolean state is: -// +// The returned boolean state is: // true // Client may continue pasting. -// // false // Client must cancel the paste. func Paste(data string, crlf bool, phase int) (state bool) { @@ -554,14 +601,14 @@ func Paste(data string, crlf bool, phase int) (state bool) { // lines is readfile() style list of lines. // // typ is edit behavior: any getregtype() result, or: -// "b" +// b // blockwise-visual mode (may include width, e.g. "b3") -// "c" +// c // characterwise mode -// "l" +// l // linewise mode // "" -// guess by contents, see setreg(). +// guess by contents, see |setreg()|. // // After is insert after cursor (like `p`), or before (like `P`). // @@ -570,17 +617,21 @@ func Put(lines []string, typ string, after, follow bool) { name(nvim_put) } -// Subscribe subscribes to a Nvim event. +// Subscribe subscribes to event broadcasts. func Subscribe(event string) { name(nvim_subscribe) } -// Unsubscribe unsubscribes to a Nvim event. +// Unsubscribe unsubscribes to event broadcasts. func Unsubscribe(event string) { name(nvim_unsubscribe) } -// ColorByName returns the 24-bit RGB value of a ColorMap color name or `#rrggbb` hexadecimal string. +// ColorByName Returns the 24-bit RGB value of a ColorMap color name or "#rrggbb" hexadecimal string. +// +// Example: +// ColorByName("Pink") +// ColorByName("#cbcbcb") func ColorByName(name string) (color int) { name(nvim_get_color_by_name) } @@ -598,34 +649,35 @@ func ColorMap() (colorMap map[string]int) { // This API still under development. // // The opts arg is optional parameters. -// Key is `types`. -// -// List of context-types to gather, or empty for `all` context. +// Key is "types". // +// List of context-types to gather, or empty for "all" context. // regs // jumps // bufs // gvars // funcs // sfuncs -func Context(opts map[string][]string) (contexts map[string]interface{}) { +func Context(opts map[string][]string) (context map[string]interface{}) { name(nvim_get_context) } -// LoadContext sets the current editor state from the given context map. -func LoadContext(dict map[string]interface{}) (contextMap interface{}) { +// LoadContext Sets the current editor state from the given context map. +func LoadContext(context map[string]interface{}) (contextMap interface{}) { name(nvim_load_context) } // Mode gets the current mode. +// +// |mode()| "blocking" is true if Nvim is waiting for input. func Mode() (mode Mode) { name(nvim_get_mode) returnPtr() } -// KeyMap gets a list of global (non-buffer-local) mapping definitions. +// KeyMap gets a list of global (non-buffer-local) |mapping| definitions. // -// The mode arg is the mode short-name, like `n`, `i`, `v` or etc. +// The mode arg is the mode short-name, like "n", "i", "v" or etc. func KeyMap(mode string) (maps []*Mapping) { name(nvim_get_keymap) } @@ -674,7 +726,7 @@ func Commands(opts map[string]interface{}) (commands map[string]*Command) { } // APIInfo returns a 2-tuple (Array), where item 0 is the current channel id and item -// 1 is the "pi-metadata|" map (Dictionary). +// 1 is the "api-metadata" map (Dictionary). // // Returns 2-tuple [{channel-id}, {api-metadata}]. func APIInfo() (apiInfo []interface{}) { @@ -697,36 +749,36 @@ func SetClientInfo(name string, version ClientVersion, typ ClientType, methods m // // Rreturns Dictionary describing a channel, with these keys: // -// "stream" +// stream // The stream underlying the channel. value are: -// "stdio" +// stdio // stdin and stdout of this Nvim instance. -// "stderr" +// stderr // stderr of this Nvim instance. -// "socket" +// socket // TCP/IP socket or named pipe. -// "job" +// job // job with communication over its stdio. // -// "mode" +// mode // How data received on the channel is interpreted. value are: -// "bytes" +// bytes // send and receive raw bytes. -// "terminal" +// terminal // A terminal instance interprets ASCII sequences. -// "rpc" +// rpc // RPC communication on the channel is active. // -// "pty" +// pty // Name of pseudoterminal, if one is used (optional). // On a POSIX system, this will be a device path like /dev/pts/1. // Even if the name is unknown, the key will still be present to indicate a pty is used. // This is currently the case when using winpty on windows. // -// "buffer" +// buffer // Buffer with connected |terminal| instance (optional). // -// "client" +// client // Information about the client on the other end of the RPC channel, if it has added it using SetClientInfo() (optional). func ChannelInfo(channelID int) (channel Channel) { name(nvim_get_chan_info) @@ -753,7 +805,7 @@ func ProcChildren(pid int) (processes []uint) { name(nvim_get_proc_children) } -// Proc gets info describing process `pid`. +// Proc gets info describing process "pid". func Proc(pid int) (process Process) { name(nvim_get_proc) } @@ -765,12 +817,43 @@ func Proc(pid int) (process Process) { // with the mouse. Can also be used in a mapping; use |:map-cmd| to // ensure the mapping doesn't end completion mode. // -// The `opts` optional parameters. Reserved for future use. +// opts optional parameters. Reserved for future use. func SelectPopupmenuItem(item int, insert, finish bool, opts map[string]interface{}) { name(nvim_select_popupmenu_item) } -// TODO(zchee): nvim_set_decoration_provider +// DeleteMark deletes a uppercase/file named mark. +// See |help mark-motions|. +func DeleteMark(name string) (deleted bool) { + name(nvim_del_mark) +} + +// Mark returns a tuple (row, col, buffer, buffername) representing the position of +// the uppercase/file named mark. +// See |help mark-motions|. +// +// opts is optional parameters. Reserved for future use. +func Mark(name string, opts map[string]interface{}) (mark Mark) { + name(nvim_get_mark) + returnPtr() +} + +// EvalStatusLine evaluates statusline string. +// +// opts optional parameters. +// winid (int) +// Window ID of the window to use as context for statusline. +// maxwidth (int) +// Maximum width of statusline. +// fillchar (string) +// Character to fill blank spaces in the statusline (see 'fillchars'). +// highlights (bool) +// Return highlight information. +// use_tabline (bool) +// Evaluate tabline instead of statusline. When true, {winid} is ignored. +func EvalStatusLine(name string, opts map[string]interface{}) (statusline map[string]interface{}) { + name(nvim_eval_statusline) +} // buffer.c @@ -788,8 +871,8 @@ func BufferLineCount(buffer Buffer) (count int) { // The buffer is specific Buffer, or 0 for current buffer. // // If sendBuffer is true, initial notification should contain the whole buffer. -// If false, the first notification will be a `nvim_buf_lines_event`. -// Otherwise, the first notification will be a `nvim_buf_changedtick_event` +// If false, the first notification will be a "nvim_buf_lines_event". +// Otherwise, the first notification will be a "nvim_buf_changedtick_event". // // Returns whether the updates couldn't be enabled because the buffer isn't loaded or opts contained an invalid key. func AttachBuffer(buffer Buffer, sendBuffer bool, opts map[string]interface{}) (attached bool) { @@ -847,15 +930,15 @@ func SetBufferText(buffer Buffer, startRow, startCol, endRow, endCol int, replac name(nvim_buf_set_text) } -// BufferOffset returns the byte offset for a line. +// BufferOffset returns the byte offset of a line (0-indexed). // // Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte. -// 'fileformat' and 'fileencoding' are ignored. +// "fileformat" and "fileencoding" are ignored. // // The line index just after the last line gives the total byte-count of the buffer. -// A final EOL byte is counted if it would be written, see ':help eol'. +// A final EOL byte is counted if it would be written, see ":help eol". // -// Unlike `line2byte` vim function, throws error for out-of-bounds indexing. +// Unlike "line2byte" vim function, throws error for out-of-bounds indexing. // // If Buffer is unloaded buffer, returns -1. func BufferOffset(buffer Buffer, index int) (offset int) { @@ -951,7 +1034,7 @@ func IsBufferLoaded(buffer Buffer) (loaded bool) { // DeleteBuffer deletes the buffer. // See -// help :bwipeout +// :help :bwipeout // // The opts args is optional parameters. // @@ -972,6 +1055,23 @@ func IsBufferValid(buffer Buffer) (valied bool) { name(nvim_buf_is_valid) } +// DeleteBufferMark deletes a named mark in the buffer. +// See |help mark-motions|. +func DeleteBufferMark(buffer Buffer, name string) (deleted bool) { + name(nvim_buf_del_mark) +} + +// SetBufferMark sets a named mark in the given buffer, all marks are allowed +// file/uppercase, visual, last change, etc. +// See |help mark-motions|. +// +// line and col are (1,0)-indexed. +// +// opts is optional parameters. Reserved for future use. +func SetBufferMark(buffer Buffer, name string, line, col int, opts map[string]interface{}) (set bool) { + name(nvim_buf_set_mark) +} + // BufferMark return a tuple (row,col) representing the position of the named mark. // // Marks are (1,0)-indexed. @@ -981,11 +1081,7 @@ func BufferMark(buffer Buffer, name string) (pos [2]int) { // BufferExtmarkByID beturns position for a given extmark id. // -// The opts arg is optional parameters. -// -// limit -// Maximum number of marks to return. int type. -// +// opts is optional parameters. // details // Whether to include the details dict. bool type. func BufferExtmarkByID(buffer Buffer, nsID, id int, opt map[string]interface{}) (pos []int) { @@ -1008,11 +1104,9 @@ func BufferExtmarkByID(buffer Buffer, nsID, id int, opt map[string]interface{}) // The start and end args is start or end of range, given as (row, col), or // valid extmark id whose position defines the bound. // -// The opts arg is optional parameters. -// +// opts is optional parameters. // limit // Maximum number of marks to return. int type. -// // details // Whether to include the details dict. bool type. func BufferExtmarks(buffer Buffer, nsID int, start, end interface{}, opt map[string]interface{}) (marks []ExtMark) { @@ -1051,25 +1145,32 @@ func BufferExtmarks(buffer Buffer, nsID int, start, end interface{}, opt map[str // virt_text_pos // Positioning of virtual text. // Possible values: -// "eol" +// eol // right after eol character (default) -// "overlay" +// overlay // display over the specified column, without shifting the underlying text. // +// virt_text_win_col +// position the virtual text at a fixed window column (starting from the first text column) +// // virt_text_hide -// Hide the virtual text when the background text is selected or hidden due to horizontal scroll 'nowrap'. +// Hide the virtual text when the background text is selected or hidden due to horizontal scroll "nowrap". // // hl_mode // Control how highlights are combined with the highlights of the text. Currently only affects // virt_text highlights, but might affect "hl_group" in later versions. // Possible values: -// "replace" +// replace // only show the virt_text color. This is the default. -// "combine" +// combine // combine with background text color -// "blend" +// blend // blend with background text color. // +// hl_eol +// when true, for a multiline highlight covering the EOL of a line, continue the highlight for the rest +// of the screen line (just like for diff and cursorline highlight). +// // ephemeral // For use with "nvim_set_decoration_provider" callbacks. The mark will only be used for the current redraw cycle, // and not be permantently stored in the buffer. @@ -1081,6 +1182,9 @@ func BufferExtmarks(buffer Buffer, nsID int, start, end interface{}, opt map[str // end_right_gravity // Boolean that indicates the direction the extmark end position (if it exists) will be // shifted in when new text is inserted (true for right, false for left). Defaults to false. +// +// priority +// A priority value for the highlight group. For example treesitter highlighting uses a value of 100. func SetBufferExtmark(buffer Buffer, nsID, line, col int, opts map[string]interface{}) (id int) { name(nvim_buf_set_extmark) } @@ -1106,7 +1210,7 @@ func DeleteBufferExtmark(buffer Buffer, nsID, extmarkID int) (deleted bool) { // All highlights in the same namespace can then be cleared with single call to ClearBufferNamespace. // If the highlight never will be deleted by an API call, pass nsID = -1. // -// As a shorthand, `nsID = 0` can be used to create a new namespace for the +// As a shorthand, "srcID = 0" can be used to create a new namespace for the // highlight, the allocated id is then returned. // // If hlGroup arg is the empty string, no highlight is added, but a new `nsID` is still returned. @@ -1151,9 +1255,9 @@ func ClearBufferHighlight(buffer Buffer, srcID, startLine, endLine int) { // // 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`. +// 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 +// As a shorthand, "nsID = 0" can be used to create a new namespace for the // virtual text, the allocated id is then returned. // // The opts arg is reserved for future use. @@ -1166,22 +1270,22 @@ func SetBufferVirtualText(buffer Buffer, nsID, line int, chunks []TextChunk, opt // window.c -// WindowBuffer returns the current buffer in a window. +// WindowBuffer gets the current buffer in a window. func WindowBuffer(window Window) (buffer Buffer) { name(nvim_win_get_buf) } -// SetBufferToWindow sets the current buffer in a window, without side-effects. +// SetBufferToWindow Sets the current buffer in a window, without side-effects. func SetBufferToWindow(window Window, buffer Buffer) { name(nvim_win_set_buf) } -// WindowCursor returns the cursor position in the window. +// WindowCursor gets the (1,0)-indexed cursor position in the window. func WindowCursor(window Window) (pos [2]int) { name(nvim_win_get_cursor) } -// SetWindowCursor sets the cursor position in the window to the given position. +// SetWindowCursor sets the (1,0)-indexed cursor position in the window. func SetWindowCursor(window Window, pos [2]int) { name(nvim_win_set_cursor) } @@ -1191,7 +1295,7 @@ func WindowHeight(window Window) (height int) { name(nvim_win_get_height) } -// SetWindowHeight sets the window height. +// SetWindowHeight Sets the window height. This will only succeed if the screen is split horizontally. func SetWindowHeight(window Window, height int) { name(nvim_win_set_height) } @@ -1201,7 +1305,7 @@ func WindowWidth(window Window) (width int) { name(nvim_win_get_width) } -// SetWindowWidth sets the window width. +// SetWindowWidth Sets the window width. This will only succeed if the screen is split vertically. func SetWindowWidth(window Window, width int) { name(nvim_win_set_width) } @@ -1221,12 +1325,12 @@ func DeleteWindowVar(window Window, name string) { name(nvim_win_del_var) } -// WindowOption gets a window option. +// WindowOption gets a window option value. func WindowOption(window Window, name string) (value interface{}) { name(nvim_win_get_option) } -// SetWindowOption sets a window option. +// SetWindowOption sets a window option value. Passing "nil" as value deletes the option(only works if there's a global fallback). func SetWindowOption(window Window, name string, value interface{}) { name(nvim_win_set_option) } @@ -1236,17 +1340,17 @@ func WindowPosition(window Window) (pos [2]int) { name(nvim_win_get_position) } -// WindowTabpage gets the tab page that contains the window. +// WindowTabpage gets the window tabpage. func WindowTabpage(window Window) (tabpage Tabpage) { name(nvim_win_get_tabpage) } -// WindowNumber gets the window number from the window handle. +// WindowNumber gets the window number. func WindowNumber(window Window) (number int) { name(nvim_win_get_number) } -// IsWindowValid returns true if the window is valid. +// IsWindowValid checks if a window is valid. func IsWindowValid(window Window) (valid bool) { name(nvim_win_is_valid) } @@ -1254,23 +1358,19 @@ func IsWindowValid(window Window) (valid bool) { // 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 OpenWindow, for the meaning of parameters. -// // When reconfiguring a floating window, absent option keys will not be -// changed. -// The following restriction are apply must be reconfigured together. Only changing a subset of these is an error. -// row -// col -// relative +// changed. "row"/"col" and "relative" must be reconfigured together. +// +// See documentation at OpenWindow, for the meaning of parameters. func SetWindowConfig(window Window, config *WindowConfig) { name(nvim_win_set_config) } // WindowConfig return window configuration. // -// Return a dictionary containing the same config that can be given to OpenWindow. +// The returned value may be given to OpenWindow. // -// The `relative` will be an empty string for normal windows. +// Relative will be an empty string for normal windows. func WindowConfig(window Window) (config WindowConfig) { name(nvim_win_get_config) returnPtr() @@ -1286,16 +1386,14 @@ func HideWindow(window Window) { name(nvim_win_hide) } -// CloseWindow close a window. -// -// This is equivalent to |:close| with count except that it takes a window id. +// CloseWindow Closes the window (like ":close" with a window-ID). func CloseWindow(window Window, force bool) { name(nvim_win_close) } // tabpage.c -// TabpageWindows returns the windows in a tabpage. +// TabpageWindows gets the windows in a tabpage. func TabpageWindows(tabpage Tabpage) (windows []Window) { name(nvim_tabpage_list_wins) } @@ -1315,17 +1413,17 @@ func DeleteTabpageVar(tabpage Tabpage, name string) { name(nvim_tabpage_del_var) } -// TabpageWindow gets the current window in a tab page. +// TabpageWindow gets the current window in a tabpage. func TabpageWindow(tabpage Tabpage) Window { name(nvim_tabpage_get_win) } -// TabpageNumber gets the tabpage number from the tabpage handle. +// TabpageNumber gets the tabpage number. func TabpageNumber(tabpage Tabpage) (number int) { name(nvim_tabpage_get_number) } -// IsTabpageValid checks if a tab page is valid. +// IsTabpageValid checks if a tabpage is valid. func IsTabpageValid(tabpage Tabpage) (valid bool) { name(nvim_tabpage_is_valid) } diff --git a/nvim/api_deprecated.go b/nvim/api_deprecated.go index 1a306052..3c88b801 100644 --- a/nvim/api_deprecated.go +++ b/nvim/api_deprecated.go @@ -53,7 +53,7 @@ func NewEmbedded(options *EmbedOptions) (*Nvim, error) { // Deprecated: Use ExecLua instead. func (v *Nvim) ExecuteLua(code string, result interface{}, args ...interface{}) error { if args == nil { - args = []interface{}{} + args = emptyArgs } return v.call("nvim_execute_lua", result, code, args) } @@ -63,7 +63,7 @@ func (v *Nvim) ExecuteLua(code string, result interface{}, args ...interface{}) // Deprecated: Use ExecLua instead. func (b *Batch) ExecuteLua(code string, result interface{}, args ...interface{}) { if args == nil { - args = []interface{}{} + args = emptyArgs } b.call("nvim_execute_lua", result, code, args) } @@ -139,9 +139,9 @@ func (b *Batch) ClearBufferHighlight(buffer Buffer, srcID int, startLine int, en // // 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`. +// 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 +// As a shorthand, "nsID = 0" can be used to create a new namespace for the // virtual text, the allocated id is then returned. // // The opts arg is reserved for future use. @@ -165,9 +165,9 @@ func (v *Nvim) SetBufferVirtualText(buffer Buffer, nsID int, line int, chunks [] // // 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`. +// 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 +// As a shorthand, "nsID = 0" can be used to create a new namespace for the // virtual text, the allocated id is then returned. // // The opts arg is reserved for future use. diff --git a/nvim/api_test.go b/nvim/api_test.go index 798c3b9d..21f36fcd 100644 --- a/nvim/api_test.go +++ b/nvim/api_test.go @@ -133,6 +133,8 @@ func TestAPI(t *testing.T) { t.Run("ChannelClientInfo", testChannelClientInfo(v)) t.Run("UI", testUI(v)) t.Run("Proc", testProc(v)) + t.Run("Mark", testMark(v)) + t.Run("StatusLine", testStatusLine(v)) } func testBufAttach(v *Nvim) func(*testing.T) { @@ -177,7 +179,7 @@ func testBufAttach(v *Nvim) func(*testing.T) { t.Fatal(err) } if !ok { - t.Fatal(errors.New("could not attach buffer")) + t.Fatal("could not attach buffer") } changedtickExpected := &ChangedtickEvent{ @@ -290,7 +292,7 @@ func testBufAttach(v *Nvim) func(*testing.T) { t.Fatal(err) } if !attached { - t.Fatal(errors.New("could not attach buffer")) + t.Fatal("could not attach buffer") } changedtickExpected := &ChangedtickEvent{ @@ -433,8 +435,11 @@ func testBuffer(v *Nvim) func(*testing.T) { return func(t *testing.T) { t.Run("Nvim", func(t *testing.T) { t.Run("BufferName", func(t *testing.T) { - cwd, _ := os.Getwd() // buffer name is full path - wantBufName := filepath.Join(cwd, "/test_buffer") + cwd, err := os.Getwd() // buffer name is full path + if err != nil { + t.Fatal(err) + } + wantBufName := filepath.Join(cwd, "test_buffer") if err := v.SetBufferName(Buffer(0), wantBufName); err != nil { t.Fatal(err) } @@ -449,7 +454,7 @@ func testBuffer(v *Nvim) func(*testing.T) { } t.Cleanup(func() { - // cleanup cindent option + // cleanup buffer name if err := v.SetBufferName(Buffer(0), ""); err != nil { t.Fatal(err) } @@ -657,18 +662,28 @@ func testBuffer(v *Nvim) func(*testing.T) { if err := v.SetBufferLines(Buffer(0), -1, -1, true, lines); err != nil { t.Fatal(err) } + t.Cleanup(func() { + clearBuffer(t, v, Buffer(0)) + }) + if err := v.SetWindowCursor(Window(0), [2]int{3, 4}); err != nil { t.Fatal(err) } - if err := v.Command("mark v"); err != nil { - t.Fatal(err) - } const ( + mark = "V" wantLine = 3 wantCol = 0 ) - pos, err := v.BufferMark(Buffer(0), "v") + set, err := v.SetBufferMark(Buffer(0), mark, wantLine, wantCol, make(map[string]interface{})) + if err != nil { + t.Fatal(err) + } + if !set { + t.Fatalf("could not set %s mark", mark) + } + + pos, err := v.BufferMark(Buffer(0), mark) if err != nil { t.Fatal(err) } @@ -679,9 +694,21 @@ func testBuffer(v *Nvim) func(*testing.T) { t.Fatalf("got %d extMark col but want %d", pos[1], wantCol) } - t.Cleanup(func() { - clearBuffer(t, v, Buffer(0)) - }) + deleted, err := v.DeleteBufferMark(Buffer(0), mark) + if err != nil { + t.Fatal(err) + } + if !deleted { + t.Fatalf("could not delete %s mark", mark) + } + + pos2, err := v.BufferMark(Buffer(0), mark) + if err != nil { + t.Fatal(err) + } + if pos2[0] != 0 || pos2[1] != 0 { + t.Fatalf("got %d mark but want zero", pos2) + } }) }) @@ -689,8 +716,11 @@ func testBuffer(v *Nvim) func(*testing.T) { t.Run("BufferName", func(t *testing.T) { b := v.NewBatch() - cwd, _ := os.Getwd() // buffer name is full path - wantBufName := filepath.Join(cwd, "/test_buffer") + cwd, err := os.Getwd() // buffer name is full path + if err != nil { + t.Fatal(err) + } + wantBufName := filepath.Join(cwd, "test_buffer") b.SetBufferName(Buffer(0), wantBufName) if err := b.Execute(); err != nil { t.Fatal(err) @@ -707,7 +737,7 @@ func testBuffer(v *Nvim) func(*testing.T) { } t.Cleanup(func() { - // cleanup cindent option + // cleanup buffer name b.SetBufferName(Buffer(0), "") if err := b.Execute(); err != nil { t.Fatal(err) @@ -954,18 +984,28 @@ func testBuffer(v *Nvim) func(*testing.T) { if err := b.Execute(); err != nil { t.Fatal(err) } + t.Cleanup(func() { + clearBuffer(t, v, Buffer(0)) + }) + b.SetWindowCursor(Window(0), [2]int{3, 4}) - b.Command("mark v") - if err := b.Execute(); err != nil { - t.Fatal(err) - } const ( + mark = "V" wantLine = 3 wantCol = 0 ) + var set bool + b.SetBufferMark(Buffer(0), mark, wantLine, wantCol, make(map[string]interface{}), &set) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + if !set { + t.Fatalf("could not set %s mark", mark) + } + var pos [2]int - b.BufferMark(Buffer(0), "v", &pos) + b.BufferMark(Buffer(0), mark, &pos) if err := b.Execute(); err != nil { t.Fatal(err) } @@ -976,9 +1016,23 @@ func testBuffer(v *Nvim) func(*testing.T) { t.Fatalf("got %d extMark col but want %d", pos[1], wantCol) } - t.Cleanup(func() { - clearBuffer(t, v, Buffer(0)) - }) + var deleted bool + b.DeleteBufferMark(Buffer(0), mark, &deleted) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + if !deleted { + t.Fatalf("could not delete %s mark", mark) + } + + var pos2 [2]int + b.BufferMark(Buffer(0), mark, &pos2) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + if pos2[0] != 0 || pos2[1] != 0 { + t.Fatalf("got %d mark but want zero", pos2) + } }) }) } @@ -3154,16 +3208,20 @@ func testHighlight(v *Nvim) func(*testing.T) { } wantCTerm := &HLAttrs{ - Underline: true, - Foreground: -1, - Background: 10, - Special: -1, + Underline: true, + Foreground: -1, + Background: 10, + Special: -1, + CtermForeground: -1, + CtermBackground: -1, } wantGUI := &HLAttrs{ - Bold: true, - Foreground: cm["Red"], - Background: cm["Yellow"], - Special: cm["Blue"], + Bold: true, + Foreground: cm["Red"], + Background: cm["Yellow"], + Special: cm["Blue"], + CtermForeground: -1, + CtermBackground: -1, } var nsID int @@ -3213,12 +3271,14 @@ func testHighlight(v *Nvim) func(*testing.T) { } wantErrorMsgEHL := &HLAttrs{ - Bold: true, - Underline: true, - Italic: true, - Foreground: 16777215, - Background: 16711680, - Special: -1, + Bold: true, + Underline: true, + Italic: true, + Foreground: 16777215, + Background: 16711680, + Special: -1, + CtermForeground: -1, + CtermBackground: -1, } if !reflect.DeepEqual(wantErrorMsgEHL, errorMsgHL) { t.Fatalf("SetHighlight:\nwant %#v\n got %#v", wantErrorMsgEHL, errorMsgHL) @@ -3236,14 +3296,16 @@ func testHighlight(v *Nvim) func(*testing.T) { t.Fatal(err) } want := &HLAttrs{ - Bold: true, - Underline: false, - Undercurl: false, - Italic: false, - Reverse: false, - Foreground: 16776960, - Background: 16711680, - Special: -1, + Bold: true, + Underline: false, + Undercurl: false, + Italic: false, + Reverse: false, + Foreground: 16776960, + Background: 16711680, + Special: -1, + CtermForeground: -1, + CtermBackground: -1, } got, err := v.HLByID(nsID2, true) if err != nil { @@ -3284,16 +3346,20 @@ func testHighlight(v *Nvim) func(*testing.T) { } wantCTerm := &HLAttrs{ - Underline: true, - Foreground: -1, - Background: 10, - Special: -1, + Underline: true, + Foreground: -1, + Background: 10, + Special: -1, + CtermForeground: -1, + CtermBackground: -1, } wantGUI := &HLAttrs{ - Bold: true, - Foreground: cm[`Red`], - Background: cm[`Yellow`], - Special: cm[`Blue`], + Bold: true, + Foreground: cm[`Red`], + Background: cm[`Yellow`], + Special: cm[`Blue`], + CtermForeground: -1, + CtermBackground: -1, } var nsID int @@ -3350,12 +3416,14 @@ func testHighlight(v *Nvim) func(*testing.T) { } wantErrorMsgEHL := &HLAttrs{ - Bold: true, - Underline: true, - Italic: true, - Foreground: 16777215, - Background: 16711680, - Special: -1, + Bold: true, + Underline: true, + Italic: true, + Foreground: 16777215, + Background: 16711680, + Special: -1, + CtermForeground: -1, + CtermBackground: -1, } if !reflect.DeepEqual(&errorMsgHL, wantErrorMsgEHL) { t.Fatalf("SetHighlight:\ngot %#v\nwant %#v", &errorMsgHL, wantErrorMsgEHL) @@ -3374,14 +3442,16 @@ func testHighlight(v *Nvim) func(*testing.T) { t.Fatal(err) } want := &HLAttrs{ - Bold: true, - Underline: false, - Undercurl: false, - Italic: false, - Reverse: false, - Foreground: 16776960, - Background: 16711680, - Special: -1, + Bold: true, + Underline: false, + Undercurl: false, + Italic: false, + Reverse: false, + Foreground: 16776960, + Background: 16711680, + Special: -1, + CtermForeground: -1, + CtermBackground: -1, } var got HLAttrs @@ -3472,6 +3542,7 @@ func testFloatingWindow(v *Nvim) func(*testing.T) { Col: 0, Focusable: true, Style: "minimal", + ZIndex: 50, } w, err := v.OpenWindow(Buffer(0), true, cfg) if err != nil { @@ -3512,6 +3583,7 @@ func testFloatingWindow(v *Nvim) func(*testing.T) { Height: 10, Row: 1, Focusable: false, + ZIndex: 50, } if err := v.SetWindowConfig(w, wantWinConfig); err != nil { t.Fatal(err) @@ -3589,6 +3661,7 @@ func testFloatingWindow(v *Nvim) func(*testing.T) { Col: 0, Focusable: true, Style: "minimal", + ZIndex: 50, } var w Window b.OpenWindow(Buffer(0), true, cfg, &w) @@ -3628,6 +3701,7 @@ func testFloatingWindow(v *Nvim) func(*testing.T) { Height: 10, Row: 1, Focusable: false, + ZIndex: 50, } b.SetWindowConfig(w, wantWinConfig) if err := b.Execute(); err != nil { @@ -4519,6 +4593,7 @@ func testTerm(v *Nvim) func(*testing.T) { Height: 31, Row: 1, Col: 1, + ZIndex: 50, } if _, err := v.OpenWindow(buf, false, cfg); err != nil { t.Fatal(err) @@ -4550,6 +4625,7 @@ func testTerm(v *Nvim) func(*testing.T) { Height: 31, Row: 1, Col: 1, + ZIndex: 50, } var win Window b.OpenWindow(buf, false, cfg, &win) @@ -4869,3 +4945,259 @@ func testProc(v *Nvim) func(*testing.T) { }) } } + +func testMark(v *Nvim) func(*testing.T) { + return func(t *testing.T) { + t.Run("Nvim", func(t *testing.T) { + // set dummy lines + lines := [][]byte{ + []byte("a"), + []byte("bit of"), + []byte("text"), + } + if err := v.SetBufferLines(Buffer(0), 0, -1, true, lines); err != nil { + t.Fatal(err) + } + t.Cleanup(func() { + clearBuffer(t, v, Buffer(0)) + }) + + // set cursor position + if err := v.SetWindowCursor(Window(0), [2]int{3, 0}); err != nil { + t.Fatal(err) + } + + // set buffer name + cwd, err := os.Getwd() // buffer name is full path + if err != nil { + t.Fatal(err) + } + // shrink home path + cwd = strings.ReplaceAll(cwd, os.Getenv("HOME"), "~") + bufName := filepath.Join(cwd, "test_mark_buffer") + if err := v.SetBufferName(Buffer(0), bufName); err != nil { + t.Fatal(err) + } + + // set mark + const mark = "X" + if err := v.Command(fmt.Sprintf("mark %s", mark)); err != nil { + t.Fatal(err) + } + + gotMark, err := v.Mark(mark, make(map[string]interface{})) + if err != nil { + t.Fatal(err) + } + wantMark := &Mark{ + Row: 3, + Col: 0, + Buffer: 0, + BufferName: bufName, + } + + if !reflect.DeepEqual(gotMark, wantMark) { + t.Fatalf("got %#v mark but want %#v", gotMark, wantMark) + } + + deleted, err := v.DeleteMark(mark) + if err != nil { + t.Fatal(err) + } + if !deleted { + t.Fatalf("could not delete %s mark", mark) + } + + gotMark2, err := v.Mark(mark, make(map[string]interface{})) + if err != nil { + t.Fatal(err) + } + wantMark2 := &Mark{ + Row: 0, + Col: 0, + Buffer: 0, + BufferName: "", + } + + if !reflect.DeepEqual(gotMark2, wantMark2) { + t.Fatalf("got %#v mark but want %#v", gotMark2, wantMark2) + } + }) + + t.Run("Batch", func(t *testing.T) { + b := v.NewBatch() + + // set dummy lines + lines := [][]byte{ + []byte("a"), + []byte("bit of"), + []byte("text"), + } + b.SetBufferLines(Buffer(0), 0, -1, true, lines) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + t.Cleanup(func() { + clearBuffer(t, v, Buffer(0)) + }) + + // set cursor position + b.SetWindowCursor(Window(0), [2]int{3, 0}) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + + // set buffer name + cwd, err := os.Getwd() // buffer name is full path + if err != nil { + t.Fatal(err) + } + // shrink home path + cwd = strings.ReplaceAll(cwd, os.Getenv("HOME"), "~") + bufName := filepath.Join(cwd, "test_mark_buffer") + b.SetBufferName(Buffer(0), bufName) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + + // set mark + const mark = "X" + b.Command(fmt.Sprintf("mark %s", mark)) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + + gotMark := new(Mark) + b.Mark(mark, make(map[string]interface{}), gotMark) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + wantMark := &Mark{ + Row: 3, + Col: 0, + Buffer: 0, + BufferName: bufName, + } + + if !reflect.DeepEqual(gotMark, wantMark) { + t.Fatalf("got %#v mark but want %#v", gotMark, wantMark) + } + + var deleted bool + b.DeleteMark(mark, &deleted) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + if !deleted { + t.Fatalf("could not delete %s mark", mark) + } + + gotMark2 := new(Mark) + b.Mark(mark, make(map[string]interface{}), gotMark2) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + wantMark2 := &Mark{ + Row: 0, + Col: 0, + Buffer: 0, + BufferName: "", + } + + if !reflect.DeepEqual(gotMark2, wantMark2) { + t.Fatalf("got %#v mark but want %#v", gotMark2, wantMark2) + } + }) + } +} + +func testStatusLine(v *Nvim) func(*testing.T) { + return func(t *testing.T) { + t.Run("Nvim", func(t *testing.T) { + opts := map[string]interface{}{ + "highlights": true, + } + gotStatusLine, err := v.EvalStatusLine("TextWithNoHighlight", opts) + if err != nil { + t.Fatal(err) + } + + wantStatusLine := map[string]interface{}{ + "highlights": []interface{}{ + map[string]interface{}{ + "group": "StatusLine", + "start": int64(0), + }, + }, + "str": "TextWithNoHighlight", + "width": 19, + } + + gotHighlight := gotStatusLine["highlights"].([]interface{})[0].(map[string]interface{}) + wantHighlight := wantStatusLine["highlights"].([]interface{})[0].(map[string]interface{}) + if !reflect.DeepEqual(gotHighlight["group"], wantHighlight["group"]) { + t.Fatalf("got %#v highlight group but want %#v", gotHighlight["group"], wantHighlight["group"]) + } + if gotHighlight["start"] != wantHighlight["start"] { + t.Fatalf("got %#v highlight start but want %#v", gotHighlight["start"], wantHighlight["start"]) + } + + gotStr := gotStatusLine["str"] + wantStr := gotStatusLine["str"] + if gotStr != wantStr { + t.Fatalf("got %#v str but want %#v", gotStr, wantStr) + } + + gotWidth := gotStatusLine["width"] + wantWidth := gotStatusLine["width"] + if gotWidth != wantWidth { + t.Fatalf("got %#v width but want %#v", gotWidth, wantWidth) + } + }) + + t.Run("Batch", func(t *testing.T) { + b := v.NewBatch() + + opts := map[string]interface{}{ + "highlights": true, + } + var gotStatusLine map[string]interface{} + b.EvalStatusLine("TextWithNoHighlight", opts, &gotStatusLine) + if err := b.Execute(); err != nil { + t.Fatal(err) + } + + wantStatusLine := map[string]interface{}{ + "highlights": []interface{}{ + map[string]interface{}{ + "group": "StatusLine", + "start": int64(0), + }, + }, + "str": "TextWithNoHighlight", + "width": 19, + } + + gotHighlight := gotStatusLine["highlights"].([]interface{})[0].(map[string]interface{}) + wantHighlight := wantStatusLine["highlights"].([]interface{})[0].(map[string]interface{}) + if !reflect.DeepEqual(gotHighlight["group"], wantHighlight["group"]) { + t.Fatalf("got %#v highlight group but want %#v", gotHighlight["group"], wantHighlight["group"]) + } + if gotHighlight["start"] != wantHighlight["start"] { + t.Fatalf("got %#v highlight start but want %#v", gotHighlight["start"], wantHighlight["start"]) + } + + gotStr := gotStatusLine["str"] + wantStr := gotStatusLine["str"] + if gotStr != wantStr { + t.Fatalf("got %#v str but want %#v", gotStr, wantStr) + } + + gotWidth := gotStatusLine["width"] + wantWidth := gotStatusLine["width"] + if gotWidth != wantWidth { + t.Fatalf("got %#v width but want %#v", gotWidth, wantWidth) + } + }) + } +} diff --git a/nvim/api_tool.go b/nvim/api_tool.go index a7153390..494fb01e 100644 --- a/nvim/api_tool.go +++ b/nvim/api_tool.go @@ -130,7 +130,7 @@ func parseAPIDef() ([]*Function, []*Function, error) { } var functions []*Function - var deprecateds []*Function + var deprecated []*Function for _, decl := range file.Decls { fdecl, ok := decl.(*ast.FuncDecl) @@ -191,13 +191,13 @@ func parseAPIDef() ([]*Function, []*Function, error) { } if m.DeprecatedSince > 0 { - deprecateds = append(deprecateds, m) + deprecated = append(deprecated, m) continue } functions = append(functions, m) } - return functions, deprecateds, nil + return functions, deprecated, nil } const genTemplate = ` @@ -370,7 +370,7 @@ func NewEmbedded(options *EmbedOptions) (*Nvim, error) { // Deprecated: Use ExecLua instead. func (v *Nvim) ExecuteLua(code string, result interface{}, args ...interface{}) error { if args == nil { - args = []interface{}{} + args = emptyArgs } return v.call("nvim_execute_lua", result, code, args) } @@ -380,7 +380,7 @@ func (v *Nvim) ExecuteLua(code string, result interface{}, args ...interface{}) // Deprecated: Use ExecLua instead. func (b *Batch) ExecuteLua(code string, result interface{}, args ...interface{}) { if args == nil { - args = []interface{}{} + args = emptyArgs } b.call("nvim_execute_lua", result, code, args) } @@ -463,6 +463,7 @@ var nvimTypes = map[string]string{ "[]*UI": "Array", "[]ExtMark": "Array", "[]TextChunk": "Array", + "Mark": "Array", "[2]int": "ArrayOf(Integer, 2)", "[]*Mapping": "ArrayOf(Dictionary)", @@ -513,6 +514,7 @@ var specialAPIs = map[string]bool{ "nvim_buf_call": true, "nvim_set_decoration_provider": true, "nvim_chan_send": true, // FUNC_API_LUA_ONLY + "nvim_win_call": true, // FUNC_API_LUA_ONLY "nvim_notify": true, // implements underling nlua(vim.notify) } @@ -620,27 +622,30 @@ func main() { return } - functions, deprecateds, err := parseAPIDef() + functions, deprecated, err := parseAPIDef() if err != nil { log.Fatal(err) } switch { case *compareFlag: - functions = append(functions, deprecateds...) - err = compareFunctions(functions) - default: - if *generateFlag != "" { - if *deprecatedFlag == "" { - functions = append(functions, deprecateds...) - } - err = printImplementation(functions, implementationTemplate, *generateFlag) + functions = append(functions, deprecated...) + if err := compareFunctions(functions); err != nil { + log.Fatal(err) + } + + case *generateFlag != "": + if *deprecatedFlag == "" { + functions = append(functions, deprecated...) + } + if err := printImplementation(functions, implementationTemplate, *generateFlag); err != nil { + log.Fatal(err) } + if *deprecatedFlag != "" { - err = printImplementation(deprecateds, deprecatedTemplate, *deprecatedFlag) + if err := printImplementation(deprecated, deprecatedTemplate, *deprecatedFlag); err != nil { + log.Fatal(err) + } } } - if err != nil { - log.Fatal(err) - } } diff --git a/nvim/nvim.go b/nvim/nvim.go index 203e92b8..c3822c45 100644 --- a/nvim/nvim.go +++ b/nvim/nvim.go @@ -517,92 +517,106 @@ func (b *Batch) Request(procedure string, result interface{}, args ...interface{ // Call calls a VimL function with the given arguments. // -// On execution error: fails with VimL error, does not update v:errmsg. +// Fails with VimL error, does not update "v:errmsg". // -// The fn arg is Function to call. +// fn is Function to call. // -// The args arg is Function arguments packed in an Array. +// args is Function arguments packed in an Array. // -// The result is result of the function call. +// result is the result of the function call. func (v *Nvim) Call(fname string, result interface{}, args ...interface{}) error { if args == nil { - args = []interface{}{} + args = emptyArgs } return v.call("nvim_call_function", result, fname, args) } // Call calls a VimL function with the given arguments. // -// On execution error: fails with VimL error, does not update v:errmsg. +// Fails with VimL error, does not update "v:errmsg". // -// The fn arg is Function to call. +// fn is Function to call. // -// The args arg is Function arguments packed in an Array. +// args is function arguments packed in an array. // -// The result is result of the function call. +// result is the result of the function call. func (b *Batch) Call(fname string, result interface{}, args ...interface{}) { if args == nil { - args = []interface{}{} + args = emptyArgs } b.call("nvim_call_function", result, fname, args) } -// CallDict calls a VimL Dictionary function with the given arguments. +// CallDict calls a VimL dictionary function with the given arguments. +// +// Fails with VimL error, does not update "v:errmsg". // -// The dict arg is Dictionary, or String evaluating to a VimL "self" dict. +// dict is dictionary, or string evaluating to a VimL "self" dict. // -// The fn arg is name of the function defined on the VimL dict. +// fn is name of the function defined on the VimL dict. // -// The args arg is Function arguments packed in an Array. +// args is function arguments packed in an array. // -// The result is result of the function call. +// result is the result of the function call. func (v *Nvim) CallDict(dict []interface{}, fname string, result interface{}, args ...interface{}) error { if args == nil { - args = []interface{}{} + args = emptyArgs } return v.call("nvim_call_dict_function", result, fname, dict, args) } -// CallDict calls a VimL Dictionary function with the given arguments. +// CallDict calls a VimL dictionary function with the given arguments. +// +// Fails with VimL error, does not update "v:errmsg". // -// The dict arg is Dictionary, or String evaluating to a VimL "self" dict. +// dict is dictionary, or string evaluating to a VimL "self" dict. // -// The fn arg is name of the function defined on the VimL dict. +// fn is name of the function defined on the VimL dict. // -// The args arg is Function arguments packed in an Array. +// args is Function arguments packed in an Array. // -// The result is result of the function call. +// result is the result of the function call. func (b *Batch) CallDict(dict []interface{}, fname string, result interface{}, args ...interface{}) { if args == nil { - args = []interface{}{} + args = emptyArgs } b.call("nvim_call_dict_function", result, fname, dict, args) } // ExecLua execute Lua code. // -// The code arg is Lua code to execute. +// Parameters are available as `...` inside the chunk. The chunk can return a value. // -// The args arg is arguments to the code. +// Only statements are executed. To evaluate an expression, prefix it +// with `return` is "return my_function(...)". // -// Parameters (if any) are available as "..." inside the chunk. The chunk can return a value. +// code is Lua code to execute. +// +// args is arguments to the code. +// +// The returned result value of Lua code if present or nil. func (v *Nvim) ExecLua(code string, result interface{}, args ...interface{}) error { if args == nil { - args = []interface{}{} + args = emptyArgs } return v.call("nvim_exec_lua", result, code, args) } // ExecLua execute Lua code. // -// The code arg is Lua code to execute. +// Parameters are available as `...` inside the chunk. The chunk can return a value. // -// The args arg is arguments to the code. +// Only statements are executed. To evaluate an expression, prefix it +// with `return` is "return my_function(...)". // -// Parameters (if any) are available as "..." inside the chunk. The chunk can return a value. +// code is Lua code to execute. +// +// args is arguments to the code. +// +// The returned result value of Lua code if present or nil. func (b *Batch) ExecLua(code string, result interface{}, args ...interface{}) { if args == nil { - args = []interface{}{} + args = emptyArgs } b.call("nvim_exec_lua", result, code, args) } @@ -612,11 +626,11 @@ func (b *Batch) ExecLua(code string, result interface{}, args ...interface{}) { // Relays the call to vim.notify. By default forwards your message in the // echo area but can be overriden to trigger desktop notifications. // -// The msg arg is message to display to the user. +// msg is message to display to the user. // -// The logLevel arg is the LogLevel. +// logLevel is the LogLevel. // -// The opts arg is reserved for future use. +// opts is reserved for future use. func (v *Nvim) Notify(msg string, logLevel LogLevel, opts map[string]interface{}) error { if logLevel == LogErrorLevel { return v.WritelnErr(msg) @@ -635,11 +649,11 @@ func (v *Nvim) Notify(msg string, logLevel LogLevel, opts map[string]interface{} // Relays the call to vim.notify. By default forwards your message in the // echo area but can be overriden to trigger desktop notifications. // -// The msg arg is message to display to the user. +// msg is message to display to the user. // -// The logLevel arg is the LogLevel. +// logLevel is the LogLevel. // -// The opts arg is reserved for future use. +// opts is reserved for future use. func (b *Batch) Notify(msg string, logLevel LogLevel, opts map[string]interface{}) { if logLevel == LogErrorLevel { b.WritelnErr(msg) diff --git a/nvim/types.go b/nvim/types.go index 103b71bb..1928410a 100644 --- a/nvim/types.go +++ b/nvim/types.go @@ -104,6 +104,9 @@ type HLAttrs struct { // Bold is the bold font style. Bold bool `msgpack:"bold,omitempty"` + // Standout is the standout font style. + Standout int `msgpack:"standout,omitempty"` + // Underline is the underline font style. Underline bool `msgpack:"underline,omitempty"` @@ -116,19 +119,17 @@ type HLAttrs struct { // Reverse is the reverse to foreground and background. Reverse bool `msgpack:"reverse,omitempty"` - // Inverse same as Reverse. - Inverse bool `msgpack:"inverse,omitempty"` + // Strikethrough is the strikethrough font style. + Strikethrough bool `msgpack:"strikethrough,omitempty"` - // Standout is the standout font style. - Standout int `msgpack:"standout,omitempty"` + ForegroundIndexed bool `msgpack:"fg_indexed,omitempty"` - // Nocombine override attributes instead of combining them. - Nocombine int `msgpack:"nocombine,omitempty"` + BackgroundIndexed bool `msgpack:"bg_indexed,omitempty"` - // Foreground use normal foreground color. + // Foreground is foreground color of RGB color. Foreground int `msgpack:"foreground,omitempty" empty:"-1"` - // Background use normal background color. + // Background is background color of RGB color. Background int `msgpack:"background,omitempty" empty:"-1"` // Special is used for undercurl and underline. @@ -140,6 +141,31 @@ type HLAttrs struct { // Only takes effect if 'pumblend' or 'winblend' is set for the menu or window. // See the help at the respective option. Blend int `msgpack:"blend,omitempty"` + + // Nocombine override attributes instead of combining them. + Nocombine bool `msgpack:"nocombine,omitempty"` + + // Default don't override existing definition, like "hi default". + // + // This value is used only SetHighlight. + Default bool `msgpack:"default,omitempty"` + + // Cterm is cterm attribute map. Sets attributed for cterm colors. + // + // Note thet by default cterm attributes are same as attributes of gui color. + // + // This value is used only SetHighlight. + Cterm *HLAttrs `msgpack:"cterm,omitempty"` + + // CtermForeground is the foreground of cterm color. + // + // This value is used only SetHighlight. + CtermForeground int `msgpack:"ctermfg,omitempty" empty:"-1"` + + // CtermBackground is the background of cterm color. + // + // This value is used only SetHighlight. + CtermBackground int `msgpack:"ctermbg,omitempty" empty:"-1"` } // Mapping represents a nvim mapping options. @@ -400,6 +426,8 @@ type TextChunk struct { // cursor // Cursor position in current window. // +// Win is window ID for Relative="win". +// // Anchor is the decides which corner of the float to place at row and col. // // NW @@ -413,7 +441,6 @@ type TextChunk struct { // // 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. @@ -426,6 +453,9 @@ type TextChunk struct { // External is the GUI should display the window as an external top-level window. // Currently accepts no other positioning configuration together with this. // +// ZIndex is stacking order. floats with higher "zindex" go on top on floats with lower indices. Must be larger than zero. +// The default value for floats are 50. In general, values below 100 are recommended, unless there is a good reason to overshadow builtin elements. +// // Style is the Configure the appearance of the window. // Currently only takes one non-empty value: // @@ -435,18 +465,24 @@ type TextChunk struct { // // Disables "number", "relativenumber", "cursorline", "cursorcolumn", "foldcolumn", "spell" and "list" options. // And, "signcolumn" is changed to "auto" and "colorcolumn" is cleared. -// // The end-of-buffer region is hidden by setting "eob" flag of "fillchars" to a space char, and clearing the EndOfBuffer region in "winhighlight". // // border // Style of (optional) window border. This can either be a string or an array. // The string values are: -// "none" +// +// none // No border. This is the default. -// "single" +// single // A single line box. -// "double" +// double // A double line box. +// rounded +// Like "single", but with rounded corners ("╭" etc.). +// solid +// Adds padding by a single whitespace cell. +// shadow +// A drop shadow effect by blending with the background. // // If it is an array it should be an array of eight items or any divisor of // eight. The array will specifify the eight chars building up the border @@ -461,10 +497,15 @@ type TextChunk struct { // Or all chars the same as: // [ "x" ] // +// An empty string can be used to turn off a specific border, for instance, +// [ "", "", "", ">", "", "", "", "<" ] +// // By default "FloatBorder" highlight is used which links to "VertSplit" // when not defined. // It could also be specified by character: // [ {"+", "MyCorner"}, {"x", "MyBorder"} ] +// +// NoAutocmd is if true then no buffer-related autocommand events such as BufEnter, BufLeave or BufWinEnter may fire from calling this function. type WindowConfig struct { // Relative is the specifies the type of positioning method used for the floating window. Relative string `msgpack:"relative,omitempty"` @@ -496,13 +537,38 @@ type WindowConfig struct { // External is the GUI should display the window as an external top-level window. External bool `msgpack:"external,omitempty"` + // ZIndex stacking order. floats with higher `zindex` go on top on floats with lower indices. Must be larger than zero. + ZIndex int `msgpack:"zindex,omitempty" empty:"50"` + // Style is the Configure the appearance of the window. Style string `msgpack:"style,omitempty"` // Border is the style of window border. - Border []string `msgpack:"border,omitempty"` + Border interface{} `msgpack:"border,omitempty"` + + // NoAutocmd whether the fire buffer-related autocommand events + NoAutocmd bool `msgpack:"noautocmd,omitempty"` } +// BorderStyle represents a WindowConfig.Border style. +type BorderStyle string + +// list of BorderStyle. +const ( + // BorderStyleNone is the no border. This is the default. + BorderStyleNone = BorderStyle("none") + // BorderStyleSingle is a single line box. + BorderStyleSingle = BorderStyle("single") + // BorderStyleDouble a double line box. + BorderStyleDouble = BorderStyle("double") + // BorderStyleRounded like "single", but with rounded corners ("╭" etc.). + BorderStyleRounded = BorderStyle("rounded") + // BorderStyleSolid adds padding by a single whitespace cell. + BorderStyleSolid = BorderStyle("solid") + // BorderStyleShadow a drop shadow effect by blending with the background. + BorderStyleShadow = BorderStyle("shadow") +) + // ExtMark represents a extmarks type. type ExtMark struct { // ID is the extmarks ID. @@ -515,6 +581,14 @@ type ExtMark struct { Col int } +// Mark represents a mark. +type Mark struct { + Row int `msgpack:",array"` + Col int + Buffer Buffer + BufferName string +} + // OptionInfo represents a option information. type OptionInfo struct { // Name is the name of the option (like 'filetype'). @@ -582,6 +656,6 @@ func (level LogLevel) String() string { case LogErrorLevel: return "ErrorLevel" default: - return "unkonwn Level" + return "unknown Level" } } diff --git a/nvim/types_test.go b/nvim/types_test.go index d52cda2f..9e4e35f1 100644 --- a/nvim/types_test.go +++ b/nvim/types_test.go @@ -38,9 +38,9 @@ func TestLogLevel_String(t *testing.T) { want: "ErrorLevel", }, { - name: "unkonwn", + name: "unknown", level: LogLevel(-1), - want: "unkonwn Level", + want: "unknown Level", }, } for _, tt := range tests {