@@ -63,6 +63,19 @@ func SetBufferLines(buffer Buffer, start int, end int, strict bool, replacement
63
63
name (nvim_buf_set_lines )
64
64
}
65
65
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
+
66
79
// BufferVar gets a buffer-scoped (b:) variable.
67
80
func BufferVar (buffer Buffer , name string ) interface {} {
68
81
name (nvim_buf_get_var )
@@ -168,6 +181,14 @@ func AddBufferHighlight(buffer Buffer, srcID int, hlGroup string, line int, star
168
181
name (nvim_buf_add_highlight )
169
182
}
170
183
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
+
171
192
// ClearBufferHighlight clears highlights from a given source group and a range
172
193
// of lines.
173
194
//
@@ -176,10 +197,35 @@ func AddBufferHighlight(buffer Buffer, srcID int, hlGroup string, line int, star
176
197
//
177
198
// The lineStart and lineEnd parameters specify the range of lines to clear.
178
199
// The end of range is exclusive. Specify -1 to clear to the end of the file.
200
+ //
201
+ // Deprecated: Use ClearBufferNamespace() instead.
179
202
func ClearBufferHighlight (buffer Buffer , srcID int , startLine int , endLine int ) {
180
203
name (nvim_buf_clear_highlight )
181
204
}
182
205
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
+
183
229
// TabpageWindows returns the windows in a tabpage.
184
230
func TabpageWindows (tabpage Tabpage ) []Window {
185
231
name (nvim_tabpage_list_wins )
@@ -248,6 +294,14 @@ func SetUIOption(name string, value interface{}) {
248
294
name (nvim_ui_set_option )
249
295
}
250
296
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
+
251
305
// Command executes a single ex command.
252
306
func Command (cmd string ) {
253
307
name (nvim_command )
@@ -283,6 +337,14 @@ func Input(keys string) int {
283
337
name (nvim_input )
284
338
}
285
339
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
+
286
348
// ReplaceTermcodes replaces any terminal code strings by byte sequences. The
287
349
// returned sequences are Nvim's internal representation of keys, for example:
288
350
//
@@ -360,6 +422,11 @@ func VVar(name string) interface{} {
360
422
name (nvim_get_vvar )
361
423
}
362
424
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
+
363
430
// Option gets an option.
364
431
func Option (name string ) interface {} {
365
432
name (nvim_get_option )
@@ -417,6 +484,38 @@ func SetCurrentWindow(window Window) {
417
484
name (nvim_set_current_win )
418
485
}
419
486
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
+
420
519
// Tabpages returns the current list of tabpages.
421
520
func Tabpages () []Tabpage {
422
521
name (nvim_list_tabpages )
@@ -432,6 +531,27 @@ func SetCurrentTabpage(tabpage Tabpage) {
432
531
name (nvim_set_current_tabpage )
433
532
}
434
533
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
+
435
555
// Subscribe subscribes to a Nvim event.
436
556
func Subscribe (event string ) {
437
557
name (nvim_subscribe )
@@ -510,11 +630,28 @@ func Proc(pid int) Process {
510
630
name (nvim_get_proc )
511
631
}
512
632
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
+
513
645
// WindowBuffer returns the current buffer in a window.
514
646
func WindowBuffer (window Window ) Buffer {
515
647
name (nvim_win_get_buf )
516
648
}
517
649
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
+
518
655
// WindowCursor returns the cursor position in the window.
519
656
func WindowCursor (window Window ) [2 ]int {
520
657
name (nvim_win_get_cursor )
@@ -589,3 +726,33 @@ func WindowNumber(window Window) int {
589
726
func IsWindowValid (window Window ) bool {
590
727
name (nvim_win_is_valid )
591
728
}
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