-
Notifications
You must be signed in to change notification settings - Fork 40
Support neovim/neovim@a225374 api #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/cc: @garyburd |
CI is failed :( I'll check it and fix later. @justinmk |
@zchee yes |
@justinmk OK, So I want to the repository owner to rerun the CI because of TravisCI failed caused by wrong(mysterious?) error on
No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received
The build has been terminated Or, Should I just empty |
/ping @garyburd |
Thank you for the ping. I was traveling with limited internet access, and forgot to look at this when I did get access. I'll look at it tomorrow. |
@garyburd Woa! where did you travel? :D FYI, I said before,
It means I can write completely response struct, but might be needs many I want to ask to you whether the needs above implements or not. (in other works, you like or not) |
I've been backpacking, camping and hiking in Washington & Wyoming. |
@garyburd Sorry for the late reply :( |
@garyburd Added |
My feedback on the use of I have more time to work on this now. Do you want me to continue working on it? |
I misunderstood your feedback. It means adding some new API return value to should not use
If you have time, I glad to send PR to my PR. BTW, neovim has been |
I apologize for any confusion. Method return types should not include the type The BufferVar and Eval methods are examples of where The code generator has a special case for a return value of The result of all this is that the application can work with concrete types instead of picking part results with type assertions. |
@garyburd Thanks polite reply. I'll read your comment and will fix this pull request :) |
@garyburd I was many changed and push new commit. If my interpretation is wrong, sorry take your time... PTAL. |
@garyburd /cc @justinmk Also, I think time is come the go-client should release the versions. It is for make compatibility to more explicit with neovim core API. |
Not sure I follow. Nvim API is backwards-compatible, so go-client has no need to make breaking changes. |
Ah, sorry for lack description.
like the neovim/pynvim, go-client also publish release note or etc, and describe what supported neovim upstream API. It's more easy to understand to developer who uses go-client. Also, The Go language has been supported semantic version vendoring in the core runtime (still ALPHA yet, will stable on Go1.12). Now Go package authors preparing it gradually. More details: https://github.com/golang/go/wiki/Modules#gomod But yes, As your said, neovim core api have backward compatibility. I'm just suggested based on the current state of Go language. |
The method BufferCommands is defined as:
Each application that uses this method must use type assertions to access command properties. This work can be eliminated for all applications by declaring a command type:
If the PR is merged as is, then it's ugly moving forward to using a declared type for commands. The addition of the type requires either a breaking change or the addition of the second method for
I think the following are preferable to the current PR:
|
It is more conventional and more convenient to declare types like
Use "omitempty" as needed to omit optional values. If the zero value (typically the empty value) has meaning, then use pointer to value or "empty" field tag to omit the value. |
@garyburd thanks polite reply. |
@garyburd At first, Sorry for late reply :( But I'd added BTW, are you busy these days...? Do you have time to review this PR? |
This comment has been minimized.
This comment has been minimized.
@justinmk Rebased current master branch. Ready to merge! |
|
||
// Blocking is true if Nvim is waiting for input. | ||
Blocking bool `msgpack:"blocking"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why make a new type for this? This seems over-specific. Can't it just be a map? I guess go does not allow heterogeneous maps so it would be map[string]interface{}
.
If having types for every little thing is idiomatic in go, then I guess this is ok. But it means that the client will not be forward-compatible if Nvim API adds a new field to the map. :help api-contract
and :help dev-api-client
explain that clients should be prepared for new, optional fields to appear in any map or list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#36 (comment) leads me to believe this will be forward-compatible. If so, OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinmk I didn't add a new type.
Just move some types to types.go
such as
Lines 645 to 691 in fba3ac8
type Mode struct { | |
// Mode is the current mode. | |
Mode string `msgpack:"mode"` | |
// Blocking is true if Nvim is waiting for input. | |
Blocking bool `msgpack:"blocking"` | |
} | |
type HLAttrs struct { | |
Bold bool `msgpack:"bold,omitempty"` | |
Underline bool `msgpack:"underline,omitempty"` | |
Undercurl bool `msgpack:"undercurl,omitempty"` | |
Italic bool `msgpack:"italic,omitempty"` | |
Reverse bool `msgpack:"reverse,omitempty"` | |
Foreground int `msgpack:"foreground,omitempty" empty:"-1"` | |
Background int `msgpack:"background,omitempty" empty:"-1"` | |
Special int `msgpack:"special,omitempty" empty:"-1"` | |
} | |
type Mapping struct { | |
// LHS is the {lhs} of the mapping. | |
LHS string `msgpack:"lhs"` | |
// RHS is the {hrs} of the mapping as typed. | |
RHS string `msgpack:"rhs"` | |
// Silent is 1 for a |:map-silent| mapping, else 0. | |
Silent int `msgpack:"silent"` | |
// Noremap is 1 if the {rhs} of the mapping is not remappable. | |
NoRemap int `msgpack:"noremap"` | |
// Expr is 1 for an expression mapping. | |
Expr int `msgpack:"expr"` | |
// Buffer for a local mapping. | |
Buffer int `msgpack:"buffer"` | |
// SID is the script local ID, used for <sid> mappings. | |
SID int `msgpack:"sid"` | |
// Nowait is 1 if map does not wait for other, longer mappings. | |
NoWait int `msgpack:"nowait"` | |
// Mode specifies modes for which the mapping is defined. | |
Mode string `msgpack:"string"` | |
} |
Special int `msgpack:"special,omitempty" empty:"-1"` | ||
} | ||
|
||
// Mapping represents a nvim mapping options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That comment doesn't really add any information. But at least "a nvim" should be just "Nvim" (no "a").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinmk I see will fix.
// LHS is the {lhs} of the mapping. | ||
LHS string `msgpack:"lhs"` | ||
|
||
// RHS is the {hrs} of the mapping as typed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// RHS is the {hrs} of the mapping as typed. | |
// RHS is the {rhs} of the mapping as typed. |
or just:
// RHS is the {hrs} of the mapping as typed. | |
// RHS of the mapping. |
BTW, why does every comment start with "Foo is ..." ? It's redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is coding standard in Go. Golang linters demand that every doc string on function, struct or other declaration starts with its name. As I know it is Rob Pike idea.
It could be seemed redundant but in fact it simplifies understanding since doc strings has predefined structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That comment doesn't really add any information. But at least "a nvim" should be just "Nvim" (no "a").
Nevertheless, sometimes such 'comment style' results in useless and meaningless descriptions like above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daskol Thanks for description :)
// For a host, this does not include plugin methods which will be discovered later. | ||
// The key should be the method name, the values are dicts with the following (optional) keys. See below. | ||
// | ||
// Further keys might be added in later versions of nvim and unknown keys are thus ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. Good.
@@ -123,6 +123,50 @@ func (b *Batch) BufferLines(buffer Buffer, start int, end int, strict bool, resu | |||
b.call("nvim_buf_get_lines", result, buffer, start, end, strict) | |||
} | |||
|
|||
// AttachBuffer activate updates from this buffer to the current channel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently updated the Nvim docs for the attach methods. https://neovim.io/doc/user/api.html#nvim_buf_attach()
Could help with clarity/wording of these attach/detach docstrings.
// AttachBuffer activate updates from this buffer to the current channel. | |
// Activates buffer-update events on the channel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also will fix.
Support neovim/neovim@a225374 API.
compare is here: