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.

Matthew Piziak
  • 5,958
  • 3
  • 29
  • 77

1 Answers1

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.

syohex
  • 456
  • 2
  • 5
  • Hey thanks, worked perfectly (after I unborked my .emacs file...) – Daniel Blezek Feb 25 '15 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 http://stackoverflow.com/questions/39310330/can-i-use-emacs-with-company-mode-and-company-go-to-complete-gos-standard-libra? Also could you share your emacs configuration? Thank you in advance. – Just a learner Sep 04 '16 at 07:59
  • I commented github issues. And my company-go configuration is here(https://github.com/syohex/dot_files/blob/master/emacs/init/golang.el#L32) – syohex Sep 04 '16 at 08:33