Skip to content

Commit ada0455

Browse files
zcheejustinmk
authored andcommitted
Update to neovim/neovim@a225374 API #36
* nvim: add map[string]int to Dictionary for ColorMap * nvim: support neovim/neovim@a225374 api * nvim: go generate * nvim: add CallDict(nvim_call_dict_function) * nvim: fix typo * nvim: trim 'List' prefix and Channels returns the pointer slice * nvim: add Process and UI struct * nvim: change UIs and Proc(Children) return type to correspond type * nvim: go generate * nvim: change ChannelInfo return type to pointer * nvim: go generate * nvim: change Channel to pointer on nvimTypes map * nvim: implements Client struct * nvim: add godoc comment to Channel and Process struct * nvim: split additional struct types to types.go * nvim/apitool: add some C type to nvimTypes map * nvim: add Version,ClientType,Methods,Attributes and Client for Channel * nvim: go generate * nvim: add Command type and fix {Buffer}Commands return map type * nvim: go generate * nvim: change Version type to struct instead of map * nvim: `map[string]*Command` type to Dictionary * nvim: fix SetClientInfo arguments type * nvim: re-implements several types for SetClientInfo function * nvim: go generate * nvim: fix Version.Major msgpack struct tag * nvim: increase LICENSE Year * nvim: rename some Client related type name to add `Client` prefix * nvim: go generate * nvim: add some godoc comment and format * nvim: fix spell "Deprecated: Use etc" consistently ref: golang/go@9a0a150 * nvim: go generate * nvim: gofmt
1 parent fba3ac8 commit ada0455

File tree

5 files changed

+537
-54
lines changed

5 files changed

+537
-54
lines changed

nvim/apidef.go

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ func BufferLines(buffer Buffer, start int, end int, strict bool) [][]byte {
4242
name(nvim_buf_get_lines)
4343
}
4444

45+
// AttachBuffer activate updates from this buffer to the current channel.
46+
//
47+
// If sendBuffer is true, initial notification should contain the whole buffer.
48+
// If false, the first notification will be a `nvim_buf_lines_event`.
49+
// Otherwise, the first notification will be a `nvim_buf_changedtick_event`
50+
//
51+
// opts is optional parameters. Currently not used.
52+
//
53+
// returns whether the updates couldn't be enabled because the buffer isn't loaded or opts contained an invalid key.
54+
func AttachBuffer(buffer Buffer, sendBuffer bool, opts map[string]interface{}) bool {
55+
name(nvim_buf_attach)
56+
}
57+
58+
// DetachBuffer deactivate updates from this buffer to the current channel.
59+
//
60+
// returns whether the updates couldn't be disabled because the buffer isn't loaded.
61+
func DetachBuffer(buffer Buffer) bool {
62+
name(nvim_buf_detach)
63+
}
64+
4565
// SetBufferLines replaces a line range on a buffer.
4666
//
4767
// Indexing is zero-based, end-exclusive. Negative indices are interpreted as
@@ -72,6 +92,13 @@ func BufferKeyMap(buffer Buffer, mode string) []*Mapping {
7292
name(nvim_buf_get_keymap)
7393
}
7494

95+
// BufferCommands gets a map of buffer-local user-commands.
96+
//
97+
// opts is optional parameters. Currently not used.
98+
func BufferCommands(buffer Buffer, opts map[string]interface{}) map[string]*Command {
99+
name(nvim_buf_get_commands)
100+
}
101+
75102
// SetBufferVar sets a buffer-scoped (b:) variable.
76103
func SetBufferVar(buffer Buffer, name string, value interface{}) {
77104
name(nvim_buf_set_var)
@@ -95,7 +122,7 @@ func SetBufferOption(buffer Buffer, name string, value interface{}) {
95122

96123
// BufferNumber gets a buffer's number.
97124
//
98-
// Deprecated: use int(buffer) to get the buffer's number as an integer.
125+
// Deprecated: Use int(buffer) to get the buffer's number as an integer.
99126
func BufferNumber(buffer Buffer) int {
100127
name(nvim_buf_get_number)
101128
deprecatedSince(2)
@@ -112,6 +139,12 @@ func SetBufferName(buffer Buffer, name string) {
112139
name(nvim_buf_set_name)
113140
}
114141

142+
// IsBufferLoaded Checks if a buffer is valid and loaded.
143+
// See api-buffer for more info about unloaded buffers.
144+
func IsBufferLoaded(buffer Buffer) bool {
145+
name(nvim_buf_is_loaded)
146+
}
147+
115148
// IsBufferValid returns true if the buffer is valid.
116149
func IsBufferValid(buffer Buffer) bool {
117150
name(nvim_buf_is_valid)
@@ -441,10 +474,56 @@ func KeyMap(mode string) []*Mapping {
441474
name(nvim_get_keymap)
442475
}
443476

477+
// Commands gets a map of global (non-buffer-local) Ex commands.
478+
// Currently only user-commands are supported, not builtin Ex commands.
479+
//
480+
// opts is optional parameters. Currently only supports {"builtin":false}.
481+
func Commands(opts map[string]interface{}) map[string]*Command {
482+
name(nvim_get_commands)
483+
}
484+
444485
func APIInfo() []interface{} {
445486
name(nvim_get_api_info)
446487
}
447488

489+
// SetClientInfo identify the client for nvim.
490+
//
491+
// Can be called more than once, but subsequent calls will remove earlier info, which should be resent if it is still valid.
492+
// (This could happen if a library first identifies the channel, and a plugin using that library later overrides that info)
493+
func SetClientInfo(name string, version *ClientVersion, typ string, methods map[string]*ClientMethod, attributes ClientAttributes) {
494+
name(nvim_set_client_info)
495+
}
496+
497+
// ChannelInfo get information about a channel.
498+
func ChannelInfo(channel int) *Channel {
499+
name(nvim_get_chan_info)
500+
}
501+
502+
// Channels get information about all open channels.
503+
func Channels() []*Channel {
504+
name(nvim_list_chans)
505+
}
506+
507+
// ParseExpression parse a VimL expression.
508+
func ParseExpression(expr string, flags string, highlight bool) map[string]interface{} {
509+
name(nvim_parse_expression)
510+
}
511+
512+
// UIs gets a list of dictionaries representing attached UIs.
513+
func UIs() []*UI {
514+
name(nvim_list_uis)
515+
}
516+
517+
// ProcChildren gets the immediate children of process `pid`.
518+
func ProcChildren(pid int) []*Process {
519+
name(nvim_get_proc_children)
520+
}
521+
522+
// Proc gets info describing process `pid`.
523+
func Proc(pid int) Process {
524+
name(nvim_get_proc)
525+
}
526+
448527
// WindowBuffer returns the current buffer in a window.
449528
func WindowBuffer(window Window) Buffer {
450529
name(nvim_win_get_buf)

nvim/apiimp.go

Lines changed: 182 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nvim/apitool.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,14 @@ var nvimTypes = map[string]string{
305305
"int": "Integer",
306306
"interface{}": "Object",
307307
"string": "String",
308+
"Process": "Object",
308309

309310
"map[string]interface{}": "Dictionary",
311+
"map[string]int": "Dictionary",
312+
"map[string]*Command": "Dictionary",
313+
"*ClientVersion": "Dictionary",
314+
"ClientMethods": "Dictionary",
315+
"ClientAttributes": "Dictionary",
310316

311317
"[2]int": "ArrayOf(Integer, 2)",
312318
"[]Buffer": "ArrayOf(Buffer)",
@@ -317,7 +323,11 @@ var nvimTypes = map[string]string{
317323

318324
"Mode": "Dictionary",
319325
"*HLAttrs": "Dictionary",
326+
"*Channel": "Dictionary",
327+
"[]*Channel": "Array",
320328
"[]*Mapping": "ArrayOf(Dictionary)",
329+
"[]*Process": "Array",
330+
"[]*UI": "Array",
321331
}
322332

323333
func convertToNvimTypes(f *Function) *Function {
@@ -351,9 +361,10 @@ var compareTemplate = template.Must(template.New("").Funcs(template.FuncMap{
351361

352362
// specialAPIs lists API calls that are implemented by hand.
353363
var specialAPIs = map[string]bool{
354-
"nvim_call_atomic": true,
355-
"nvim_call_function": true,
356-
"nvim_execute_lua": true,
364+
"nvim_call_atomic": true,
365+
"nvim_call_function": true,
366+
"nvim_call_dict_function": true,
367+
"nvim_execute_lua": true,
357368
}
358369

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

0 commit comments

Comments
 (0)