neovim / go-client

Nvim Go client
https://pkg.go.dev/github.com/neovim/go-client
Apache License 2.0
565 stars 36 forks source link

About HandleFunction #75

Closed glepnir closed 3 years ago

glepnir commented 4 years ago

I found HandleFunciton needs two args options and fn interface{}, the sceond arg is a interface type. so i define a function return a string send functionname as arg to it.got error. but change the return value to (string,error) then it works...

error:
func repoName() string {
    return repo.GetWorkPath()
}
right:
func repoName() (string,error) {
    return repo.GetWorkPath(),nil
}
p.HandleFunction(&plugin.FunctionOptions{Name: "GetRepoName"}, repoName)
WhoIsSethDaniel commented 3 years ago

Hello @zchee and @glepnir . I have created a repo https://github.com/WhoIsSethDaniel/nvim-go-client-examples that attempts to have many examples of how to use the Neovim go-client, along with documentation. I anticipate updating it more over time as I become more familiar with the client. For anyone involved with the neovim go-client feel free to link to this repo, if you want to. Thank you.

zchee commented 3 years ago

@WhoIsSethDaniel thanks for share! also, your repository very helpful. We would be better to your repository link to neovim/go-client README :)

And yeah, go-client has lot of API, also usage is tricky a bit. e.g., Subscribe and Unsubscribe own event. I know this usage so can write code(actually, I wrote some code with that APIs) but still don't understand all. contributing go-client example to your repository separately is make sense. because Go's ExampleXXX document has limited.

Anyway, thanks for write some examples!

glepnir commented 3 years ago

To be honest, I recently used lua to write neovim things, and participated in maintaining neovim's built-in lsp, it is very simple and powerful. I will read your example carefully when I have time, because I am a gopher and neovim also lacks some plugins written in go. Thanks for your work. 😄