ray-x / go.nvim

G'day Nvimer, Joyful Gopher: Discover the Feature-Rich Go Plugin for Neovim
MIT License
1.93k stars 119 forks source link

Could you help me to alter this snippet so that it returns the error without wrapping it? #367

Closed delabere closed 11 months ago

delabere commented 11 months ago

Thank you for all the effort you've put into this plugin and the snippets specifically

I wondered if you could help me out - I'd like to just have:

// if return values are (bool, error) for example
if err != nil {
    return false, err
}

also how would I go about defining my own code to wrap in the error for example

// if return values are (bool, error) for example
if err != nil {
    return false, customWrapperFunc("error message", err)
}

https://github.com/ray-x/go.nvim/blob/c61f9371cdaaec40cccf0783ff968bee83df5bda/lua/snips/go.lua#L124-L133

ray-x commented 11 months ago

You may need to refer to the https://github.com/L3MON4D3/LuaSnip document. Looks to me you might need update go_err_snippet in lua/snips/go.lua folder and add a new choice for customWrapperFunc

delabere commented 11 months ago

Thank you I think I can take it from here! 🙇