Skip to content

Commit

Permalink
Update to neovim/neovim@a225374 API #36
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
zchee authored and justinmk committed Apr 24, 2019
1 parent fba3ac8 commit ada0455
Show file tree
Hide file tree
Showing 5 changed files with 537 additions and 54 deletions.
81 changes: 80 additions & 1 deletion nvim/apidef.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ func BufferLines(buffer Buffer, start int, end int, strict bool) [][]byte {
name(nvim_buf_get_lines)
}

// AttachBuffer activate updates from this buffer to the current channel.
//
// 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`
//
// opts is optional parameters. Currently not used.
//
// 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{}) bool {
name(nvim_buf_attach)
}

// DetachBuffer deactivate updates from this buffer to the current channel.
//
// returns whether the updates couldn't be disabled because the buffer isn't loaded.
func DetachBuffer(buffer Buffer) bool {
name(nvim_buf_detach)
}

// SetBufferLines replaces a line range on a buffer.
//
// Indexing is zero-based, end-exclusive. Negative indices are interpreted as
Expand Down Expand Up @@ -72,6 +92,13 @@ func BufferKeyMap(buffer Buffer, mode string) []*Mapping {
name(nvim_buf_get_keymap)
}

// BufferCommands gets a map of buffer-local user-commands.
//
// opts is optional parameters. Currently not used.
func BufferCommands(buffer Buffer, opts map[string]interface{}) map[string]*Command {
name(nvim_buf_get_commands)
}

// SetBufferVar sets a buffer-scoped (b:) variable.
func SetBufferVar(buffer Buffer, name string, value interface{}) {
name(nvim_buf_set_var)
Expand All @@ -95,7 +122,7 @@ func SetBufferOption(buffer Buffer, name string, value interface{}) {

// BufferNumber gets a buffer's number.
//
// Deprecated: use int(buffer) to get the buffer's number as an integer.
// Deprecated: Use int(buffer) to get the buffer's number as an integer.
func BufferNumber(buffer Buffer) int {
name(nvim_buf_get_number)
deprecatedSince(2)
Expand All @@ -112,6 +139,12 @@ func SetBufferName(buffer Buffer, name string) {
name(nvim_buf_set_name)
}

// IsBufferLoaded Checks if a buffer is valid and loaded.
// See api-buffer for more info about unloaded buffers.
func IsBufferLoaded(buffer Buffer) bool {
name(nvim_buf_is_loaded)
}

// IsBufferValid returns true if the buffer is valid.
func IsBufferValid(buffer Buffer) bool {
name(nvim_buf_is_valid)
Expand Down Expand Up @@ -441,10 +474,56 @@ func KeyMap(mode string) []*Mapping {
name(nvim_get_keymap)
}

// Commands gets a map of global (non-buffer-local) Ex commands.
// Currently only user-commands are supported, not builtin Ex commands.
//
// opts is optional parameters. Currently only supports {"builtin":false}.
func Commands(opts map[string]interface{}) map[string]*Command {
name(nvim_get_commands)
}

func APIInfo() []interface{} {
name(nvim_get_api_info)
}

// SetClientInfo identify the client for nvim.
//
// Can be called more than once, but subsequent calls will remove earlier info, which should be resent if it is still valid.
// (This could happen if a library first identifies the channel, and a plugin using that library later overrides that info)
func SetClientInfo(name string, version *ClientVersion, typ string, methods map[string]*ClientMethod, attributes ClientAttributes) {
name(nvim_set_client_info)
}

// ChannelInfo get information about a channel.
func ChannelInfo(channel int) *Channel {
name(nvim_get_chan_info)
}

// Channels get information about all open channels.
func Channels() []*Channel {
name(nvim_list_chans)
}

// ParseExpression parse a VimL expression.
func ParseExpression(expr string, flags string, highlight bool) map[string]interface{} {
name(nvim_parse_expression)
}

// UIs gets a list of dictionaries representing attached UIs.
func UIs() []*UI {
name(nvim_list_uis)
}

// ProcChildren gets the immediate children of process `pid`.
func ProcChildren(pid int) []*Process {
name(nvim_get_proc_children)
}

// Proc gets info describing process `pid`.
func Proc(pid int) Process {
name(nvim_get_proc)
}

// WindowBuffer returns the current buffer in a window.
func WindowBuffer(window Window) Buffer {
name(nvim_win_get_buf)
Expand Down
184 changes: 182 additions & 2 deletions nvim/apiimp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions nvim/apitool.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,14 @@ var nvimTypes = map[string]string{
"int": "Integer",
"interface{}": "Object",
"string": "String",
"Process": "Object",

"map[string]interface{}": "Dictionary",
"map[string]int": "Dictionary",
"map[string]*Command": "Dictionary",
"*ClientVersion": "Dictionary",
"ClientMethods": "Dictionary",
"ClientAttributes": "Dictionary",

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

"Mode": "Dictionary",
"*HLAttrs": "Dictionary",
"*Channel": "Dictionary",
"[]*Channel": "Array",
"[]*Mapping": "ArrayOf(Dictionary)",
"[]*Process": "Array",
"[]*UI": "Array",
}

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

// specialAPIs lists API calls that are implemented by hand.
var specialAPIs = map[string]bool{
"nvim_call_atomic": true,
"nvim_call_function": true,
"nvim_execute_lua": true,
"nvim_call_atomic": true,
"nvim_call_function": true,
"nvim_call_dict_function": true,
"nvim_execute_lua": true,
}

func compareFunctions(functions []*Function) error {
Expand Down
Loading

0 comments on commit ada0455

Please sign in to comment.