1

Autocomplete for Go code (fantastically) suggests functions and helpfully shows the documentation for the function, e.g. arguments and return types.

Example completion

If I hit tab, the DialHTTP function is inserted.

My question: is it possible to insert a "template" of the argument call? Since autocomplete shows the arguments, I would like to have this line inserted when I press tab:

client, err := rpc.DialHTTP(network, address)

Then I can replace the arguments with my arguments.

1 Answer 1

2

If you install yasnippet and ac-go-expand-arguments-into-snippets is non-nil(Default is t) then argument snippet is expanded like following animation gif.

enter image description here

company-mode provides such feature by itself, so you can use it without yasnippet by company-mode.

3
  • Hey thanks, worked perfectly (after I unborked my .emacs file...) Commented Feb 25, 2015 at 18:07
  • Hi @syohex, your emacs looks great! I'm trying to configure company-mode but it seems not work. Could you help me to take a look at stackoverflow.com/questions/39310330/…? Also could you share your emacs configuration? Thank you in advance. Commented Sep 4, 2016 at 7:59
  • I commented github issues. And my company-go configuration is here(github.com/syohex/dot_files/blob/master/emacs/init/…) Commented Sep 4, 2016 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.