Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
improve formatting and generalize company-go docs
Browse files Browse the repository at this point in the history
  • Loading branch information
xorrr committed Apr 25, 2014
1 parent 94f5ada commit 21aebf0
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions emacs-company/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
This is an alternative emacs plugin, uses company-mode:
http://company-mode.github.io
# Company-go
Company-go is an alternative emacs plugin for autocompletion. Is uses [company-mode](http://company-mode.github.io). Completion will start automatically after you type a few letters.

Here's how I use it in my .emacs:
## Setup
Install `company` and `company-go`.

Add the following to your emacs-config:

```lisp
(require 'company) ; load company mode
(require 'company-go) ; load company mode go backend
```

## Possible improvements

```lisp
(setq company-tooltip-limit 20) ; bigger popup window
(setq company-minimum-prefix-length 0) ; autocomplete right after '.'
(setq company-idle-delay .3) ; shorter delay before autocompletion popup
(setq company-echo-delay 0) ; removes annoying blinking
(setq company-idle-delay .3) ; decrease delay before autocompletion popup shows
(setq company-echo-delay 0) ; remove annoying blinking
(setq company-begin-commands '(self-insert-command)) ; start autocompletion only after typing
```

One thing to note here is the 'company-backends' list. By default company mode
loads every backend it has. And while I could simply add company-go backend to
that list using a hook, I'm leaving it to the end user. Perhaps it would be
preferrable for you to use multiple backends at the same time, or maybe you
just want the company-go backend only in the go-mode. I prefer to use the
company-go backend only and having company-mode enabled only for go-mode.
That's the way you can do it:
### Only use company-mode with company-go in go-mode
By default company-mode loads every backend it has. If you want to only have company-mode enabled in go-mode add the following to your emacs-config:

```lisp
(add-hook 'go-mode-hook (lambda ()
(set (make-local-variable 'company-backends) '(company-go))
(company-mode)))
```

I hope you get the idea.

P.S. Also, default company mode colors are kind of ugly, I took these from
auto-complete-mode defaults:
### Color customization

```lisp
(custom-set-faces
'(company-preview
((t (:foreground "darkgray" :underline t))))
Expand All @@ -43,5 +48,4 @@ auto-complete-mode defaults:
'(company-tooltip-common-selection
((((type x)) (:inherit company-tooltip-selection :weight bold))
(t (:inherit company-tooltip-selection)))))

Of course you can change them the way you prefer, use customize-mode or do it manually.
```

0 comments on commit 21aebf0

Please sign in to comment.