Skip to content

Commit 228eb96

Browse files
committed
nvim: implements neovim/neovim@4ae31c46f75a APIs
1 parent 3d2a7d9 commit 228eb96

File tree

2 files changed

+57
-5
lines changed

2 files changed

+57
-5
lines changed

nvim/apidef.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,20 @@ func IsBufferLoaded(buffer Buffer) bool {
160160
name(nvim_buf_is_loaded)
161161
}
162162

163+
// DeleteBuffer deletes the buffer.
164+
//
165+
// See:
166+
// :help bwipeout
167+
//
168+
// The `opts` is additional options. Supports the key:
169+
// force
170+
// Force deletion and ignore unsaved changes.
171+
// unload
172+
// Unloaded only, do not delete. See :help bunload.
173+
func DeleteBuffer(buffer Buffer, opts map[string]bool) {
174+
name(nvim_buf_delete)
175+
}
176+
163177
// IsBufferValid returns true if the buffer is valid.
164178
func IsBufferValid(buffer Buffer) bool {
165179
name(nvim_buf_is_valid)
@@ -369,6 +383,20 @@ func SetPumHeight(height int) {
369383
name(nvim_ui_pum_set_height)
370384
}
371385

386+
// SetPumBounds tells Nvim the geometry of the popumenu, to align floating windows with an
387+
// external popup menu.
388+
//
389+
// Note that this method is not to be confused with SetPumHeight,
390+
// which sets the number of visible items in the popup menu, while this
391+
// function sets the bounding box of the popup menu, including visual
392+
// elements such as borders and sliders.
393+
//
394+
// Floats need not use the same font size, nor be anchored to exact grid corners, so one can set floating-point
395+
// numbers to the popup menu geometry.
396+
func SetPumBounds(width, height, row, col float64) {
397+
name(nvim_ui_pum_set_bounds)
398+
}
399+
372400
// Exec executes Vimscript (multiline block of Ex-commands), like anonymous source.
373401
func Exec(src string, output bool) string {
374402
name(nvim_exec)
@@ -394,6 +422,27 @@ func HLByName(name string, rgb bool) *HLAttrs {
394422
name(nvim_get_hl_by_name)
395423
}
396424

425+
// SetHighlight set a highlight group.
426+
//
427+
// name arg is highlight group name, like ErrorMsg.
428+
//
429+
// val arg is highlight definiton map, like HLByName.
430+
func SetHighlight(nsID int, name string, val *HLAttrs) {
431+
name(nvim_set_hl)
432+
}
433+
434+
// SetHighlightNameSpace set active namespace for highlights.
435+
//
436+
// NB: this function can be called from async contexts, but the
437+
// semantics are not yet well-defined.
438+
// To start with SetDecorationProvider on_win and on_line callbacks
439+
// are explicitly allowed to change the namespace during a redraw cycle.
440+
//
441+
// The `nsID` arg is the namespace to activate.
442+
func SetHighlightNameSpace(nsID int) {
443+
name(nvim_set_hl_ns)
444+
}
445+
397446
// FeedKeys Pushes keys to the Nvim user input buffer. Options can be a string
398447
// with the following character flags:
399448
//

nvim/apitool.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ var nvimTypes = map[string]string{
292292
"interface{}": "Object",
293293
"Process": "Object",
294294
"string": "String",
295+
"float64": "Float",
295296

296297
"*Channel": "Dictionary",
297298
"*ClientVersion": "Dictionary",
@@ -354,11 +355,13 @@ var compareTemplate = template.Must(template.New("").Funcs(template.FuncMap{
354355

355356
// specialAPIs lists API calls that are implemented by hand.
356357
var specialAPIs = map[string]bool{
357-
"nvim_call_atomic": true,
358-
"nvim_call_function": true,
359-
"nvim_call_dict_function": true,
360-
"nvim_execute_lua": true,
361-
"nvim_exec_lua": true,
358+
"nvim_call_atomic": true,
359+
"nvim_call_function": true,
360+
"nvim_call_dict_function": true,
361+
"nvim_execute_lua": true,
362+
"nvim_exec_lua": true,
363+
"nvim_buf_call": true,
364+
"nvim_set_decoration_provider": true,
362365
}
363366

364367
func compareFunctions(functions []*Function) error {

0 commit comments

Comments
 (0)