Skip to content

Commit eaaca6f

Browse files
zcheejustinmk
authored andcommitted
Update to neovim/neovim@9d77a07 API #49
* nvim: implements neovim/neovim@9d77a07 APIs * nvim: go generate * nvim: add map[string]*ClientMethod to Dictionary C type
1 parent c611899 commit eaaca6f

File tree

3 files changed

+522
-6
lines changed

3 files changed

+522
-6
lines changed

nvim/apidef.go

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ func SetBufferLines(buffer Buffer, start int, end int, strict bool, replacement
6363
name(nvim_buf_set_lines)
6464
}
6565

66+
// BufferOffset returns the byte offset for a line.
67+
//
68+
// Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte.
69+
// 'fileformat' and 'fileencoding' are ignored. The line index just after the
70+
// last line gives the total byte-count of the buffer. A final EOL byte is
71+
// counted if it would be written, see 'eol'.
72+
//
73+
// Unlike |line2byte()|, throws error for out-of-bounds indexing.
74+
// Returns -1 for unloaded buffer.
75+
func BufferOffset(buffer Buffer, index int) int {
76+
name(nvim_buf_get_offset)
77+
}
78+
6679
// BufferVar gets a buffer-scoped (b:) variable.
6780
func BufferVar(buffer Buffer, name string) interface{} {
6881
name(nvim_buf_get_var)
@@ -168,6 +181,14 @@ func AddBufferHighlight(buffer Buffer, srcID int, hlGroup string, line int, star
168181
name(nvim_buf_add_highlight)
169182
}
170183

184+
// ClearBufferNamespace clears namespaced objects, highlights and virtual text, from a line range.
185+
//
186+
// To clear the namespace in the entire buffer, pass in 0 and -1 to
187+
// line_start and line_end respectively.
188+
func ClearBufferNamespace(buffer Buffer, nsID int, lineStart int, lineEnd int) {
189+
name(nvim_buf_clear_namespace)
190+
}
191+
171192
// ClearBufferHighlight clears highlights from a given source group and a range
172193
// of lines.
173194
//
@@ -176,10 +197,35 @@ func AddBufferHighlight(buffer Buffer, srcID int, hlGroup string, line int, star
176197
//
177198
// The lineStart and lineEnd parameters specify the range of lines to clear.
178199
// The end of range is exclusive. Specify -1 to clear to the end of the file.
200+
//
201+
// Deprecated: Use ClearBufferNamespace() instead.
179202
func ClearBufferHighlight(buffer Buffer, srcID int, startLine int, endLine int) {
180203
name(nvim_buf_clear_highlight)
181204
}
182205

206+
// Set the virtual text (annotation) for a buffer line.
207+
//
208+
// By default (and currently the only option) the text will be placed after
209+
// the buffer text. Virtual text will never cause reflow, rather virtual
210+
// text will be truncated at the end of the screen line. The virtual text will
211+
// begin one cell (|lcs-eol| or space) after the ordinary text.
212+
//
213+
// Namespaces are used to support batch deletion/updating of virtual text.
214+
// To create a namespace, use CreateNamespace(). Virtual text is
215+
// cleared using ClearBufferNamespace(). The same `nsID` can be used for
216+
// both virtual text and highlights added by AddBufferHighlight(), both
217+
// can then be cleared with a single call to ClearBufferNamespace(). If the
218+
// virtual text never will be cleared by an API call, pass `nsID = -1`.
219+
//
220+
// As a shorthand, `nsID = 0` can be used to create a new namespace for the virtual text, the allocated id is then returned.
221+
//
222+
// The `opts` is optional parameters. Currently not used.
223+
//
224+
// The returns the nsID that was used.
225+
func SetBufferVirtualText(buffer Buffer, nsID int, line int, chunks []interface{}, opts map[string]interface{}) int {
226+
name(nvim_buf_set_virtual_text)
227+
}
228+
183229
// TabpageWindows returns the windows in a tabpage.
184230
func TabpageWindows(tabpage Tabpage) []Window {
185231
name(nvim_tabpage_list_wins)
@@ -248,6 +294,14 @@ func SetUIOption(name string, value interface{}) {
248294
name(nvim_ui_set_option)
249295
}
250296

297+
// TryResizeUIGrid tell Nvim to resize a grid. Triggers a grid_resize event with the requested
298+
// grid size or the maximum size if it exceeds size limits.
299+
//
300+
// On invalid grid handle, fails with error.
301+
func TryResizeUIGrid(grid, width, height int) {
302+
name(nvim_ui_try_resize_grid)
303+
}
304+
251305
// Command executes a single ex command.
252306
func Command(cmd string) {
253307
name(nvim_command)
@@ -283,6 +337,14 @@ func Input(keys string) int {
283337
name(nvim_input)
284338
}
285339

340+
// InputMouse send mouse event from GUI.
341+
//
342+
// The call is non-blocking. It doesn't wait on any resulting action, but
343+
// queues the event to be processed soon by the event loop.
344+
func InputMouse(button, action, modifier string, grid, row, col int) {
345+
name(nvim_input_mouse)
346+
}
347+
286348
// ReplaceTermcodes replaces any terminal code strings by byte sequences. The
287349
// returned sequences are Nvim's internal representation of keys, for example:
288350
//
@@ -360,6 +422,11 @@ func VVar(name string) interface{} {
360422
name(nvim_get_vvar)
361423
}
362424

425+
// SetVVar sets a v: variable, if it is not readonly.
426+
func SetVVar(name string, value interface{}) {
427+
name(nvim_set_vvar)
428+
}
429+
363430
// Option gets an option.
364431
func Option(name string) interface{} {
365432
name(nvim_get_option)
@@ -417,6 +484,38 @@ func SetCurrentWindow(window Window) {
417484
name(nvim_set_current_win)
418485
}
419486

487+
// CreateBuffer creates a new, empty, unnamed buffer.
488+
func CreateBuffer(listed, scratch bool) Buffer {
489+
name(nvim_create_buf)
490+
}
491+
492+
// OpenWindow open a new window.
493+
//
494+
// Currently this is used to open floating and external windows.
495+
// Floats are windows that are drawn above the split layout, at some anchor
496+
// position in some other window. Floats can be draw internally or by external
497+
// GUI with the |ui-multigrid| extension. External windows are only supported
498+
// with multigrid GUIs, and are displayed as separate top-level windows.
499+
//
500+
// Exactly one of `external` and `relative` must be specified.
501+
//
502+
// With editor positioning row=0, col=0 refers to the top-left corner of the
503+
// screen-grid and row=Lines-1, Columns-1 refers to the bottom-right corner.
504+
// Floating point values are allowed, but the builtin implementation (used by
505+
// TUI and GUIs without multigrid support) will always round down to nearest
506+
// integer.
507+
//
508+
// Out-of-bounds values, and configurations that make the float not fit inside
509+
// the main editor, are allowed. The builtin implementation will truncate
510+
// values so floats are completely within the main screen grid. External GUIs
511+
// could let floats hover outside of the main window like a tooltip, but
512+
// this should not be used to specify arbitrary WM screen positions.
513+
//
514+
// The returns the window handle or 0 when error.
515+
func OpenWindow(buffer Buffer, enter bool, config map[string]interface{}) Window {
516+
name(nvim_open_win)
517+
}
518+
420519
// Tabpages returns the current list of tabpages.
421520
func Tabpages() []Tabpage {
422521
name(nvim_list_tabpages)
@@ -432,6 +531,27 @@ func SetCurrentTabpage(tabpage Tabpage) {
432531
name(nvim_set_current_tabpage)
433532
}
434533

534+
// CreateNamespace creates a new namespace, or gets an existing one.
535+
//
536+
// Namespaces are used for buffer highlights and virtual text, see
537+
// AddBufferHighlight() and SetBufferVirtualText().
538+
//
539+
// Namespaces can be named or anonymous. If `name` matches an existing
540+
// namespace, the associated id is returned. If `name` is an empty string
541+
// a new, anonymous namespace is created.
542+
//
543+
// The returns the namespace ID.
544+
func CreateNamespace(name string) int {
545+
name(nvim_create_namespace)
546+
}
547+
548+
// Namespaces gets existing named namespaces
549+
//
550+
// The return dict that maps from names to namespace ids.
551+
func Namespaces() map[string]int {
552+
name(nvim_get_namespaces)
553+
}
554+
435555
// Subscribe subscribes to a Nvim event.
436556
func Subscribe(event string) {
437557
name(nvim_subscribe)
@@ -510,11 +630,28 @@ func Proc(pid int) Process {
510630
name(nvim_get_proc)
511631
}
512632

633+
// SelectPopupmenuItem selects an item in the completion popupmenu.
634+
//
635+
// If |ins-completion| is not active this API call is silently ignored.
636+
// Useful for an external UI using |ui-popupmenu| to control the popupmenu
637+
// with the mouse. Can also be used in a mapping; use <cmd> |:map-cmd| to
638+
// ensure the mapping doesn't end completion mode.
639+
//
640+
// The `opts` optional parameters. Reserved for future use.
641+
func SelectPopupmenuItem(item int, insert, finish bool, opts map[string]interface{}) {
642+
name(nvim_select_popupmenu_item)
643+
}
644+
513645
// WindowBuffer returns the current buffer in a window.
514646
func WindowBuffer(window Window) Buffer {
515647
name(nvim_win_get_buf)
516648
}
517649

650+
// SetBufferToWindow sets the current buffer in a window, without side-effects.
651+
func SetBufferToWindow(window Window, buffer Buffer) {
652+
name(nvim_win_set_buf)
653+
}
654+
518655
// WindowCursor returns the cursor position in the window.
519656
func WindowCursor(window Window) [2]int {
520657
name(nvim_win_get_cursor)
@@ -589,3 +726,33 @@ func WindowNumber(window Window) int {
589726
func IsWindowValid(window Window) bool {
590727
name(nvim_win_is_valid)
591728
}
729+
730+
// SetWindowConfig configure window position. Currently this is only used to configure
731+
// floating and external windows (including changing a split window to these
732+
// types).
733+
//
734+
// See documentation at |nvim_open_win()|, for the meaning of parameters.
735+
//
736+
// When reconfiguring a floating window, absent option keys will not be
737+
// changed. The following restriction apply: `row`, `col` and `relative`
738+
// must be reconfigured together. Only changing a subset of these is an error.
739+
func SetWindowConfig(window Window, config map[string]interface{}) {
740+
name(nvim_win_set_config)
741+
}
742+
743+
// WindowConfig return window configuration.
744+
//
745+
// Return a dictionary containing the same config that can be given to
746+
// |nvim_open_win()|.
747+
//
748+
// `relative` will be an empty string for normal windows.
749+
func WindowConfig(window Window) map[string]interface{} {
750+
name(nvim_win_get_config)
751+
}
752+
753+
// CloseWindow close a window.
754+
//
755+
// This is equivalent to |:close| with count except that it takes a window id.
756+
func CloseWindow(window Window, force bool) {
757+
name(nvim_win_close)
758+
}

0 commit comments

Comments
 (0)