annotate .elisp/settings/80.go.el @ 295:026344f083ef

af-generic-diff-repo: use monky or magit if available
author Augie Fackler <raf@durin42.com>
date Mon, 12 Nov 2012 16:27:49 -0600
parents a8caf664abdc
children aa5afa13e12c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
277
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
1 ;; completions for go
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
2 (defun af-go-hook ()
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
3 ;; enable tabs
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
4 (setq tab-width 2)
294
a8caf664abdc go emacs: fix bug in enabling tabs for go files
Augie Fackler <raf@durin42.com>
parents: 288
diff changeset
5 (setq indent-tabs-mode t)
277
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
6 (make-variable-buffer-local 'whitespace-style)
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
7 (setq whitespace-style '(trailing lines-tail indentation trailing empty))
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
8 )
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
9
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
10 (defun af-get-go-elisp-location ()
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
11 (let* ((gobinary (shell-command-to-string "which go"))
288
e00b19603472 go.el: Fix some bugs exposed on a new machine.
Augie Fackler <raf@durin42.com>
parents: 285
diff changeset
12 (gobin (substring (let ((x (file-name-directory gobinary)))
e00b19603472 go.el: Fix some bugs exposed on a new machine.
Augie Fackler <raf@durin42.com>
parents: 285
diff changeset
13 (if x x "z")) 0 -1))
277
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
14 (goroot (file-name-directory gobin)))
288
e00b19603472 go.el: Fix some bugs exposed on a new machine.
Augie Fackler <raf@durin42.com>
parents: 285
diff changeset
15 (if goroot (concat goroot "misc/emacs") "")))
277
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
16
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
17 (defun af-get-gocode-elisp-location ()
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
18 (let* ((binary (shell-command-to-string "which gocode"))
288
e00b19603472 go.el: Fix some bugs exposed on a new machine.
Augie Fackler <raf@durin42.com>
parents: 285
diff changeset
19 (bin (substring (let ((x (file-name-directory binary)))
e00b19603472 go.el: Fix some bugs exposed on a new machine.
Augie Fackler <raf@durin42.com>
parents: 285
diff changeset
20 (if x x "z")) 0 -1))
277
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
21 (basedir (file-name-directory bin)))
288
e00b19603472 go.el: Fix some bugs exposed on a new machine.
Augie Fackler <raf@durin42.com>
parents: 285
diff changeset
22 (if basedir
e00b19603472 go.el: Fix some bugs exposed on a new machine.
Augie Fackler <raf@durin42.com>
parents: 285
diff changeset
23 (concat basedir "src/github.com/nsf/gocode/emacs-company/")
e00b19603472 go.el: Fix some bugs exposed on a new machine.
Augie Fackler <raf@durin42.com>
parents: 285
diff changeset
24 "")))
277
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
25
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
26 (let* ((goloc (af-get-go-elisp-location))
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
27 (goel (concat goloc "/go-mode.el")))
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
28 (if (file-exists-p goel)
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
29 (progn
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
30 (message "Go is installed, loading go-mode")
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
31 (add-to-list 'load-path goloc)
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
32 (require 'go-mode)
285
d77b2e253e99 emacs go: actually use af-go-mode-hook
Augie Fackler <raf@durin42.com>
parents: 277
diff changeset
33 (add-hook 'go-mode-hook 'af-go-hook)
277
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
34 (let* ((loc (af-get-gocode-elisp-location))
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
35 (el (concat loc "/company-go.el")))
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
36 (if (file-exists-p el)
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
37 (progn
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
38 (message "Found gocode, loading company-mode support...")
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
39 (add-to-list 'load-path loc)
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
40 (require 'company-go))
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
41 (message "gocode missing, skipping company-mode support."))))
884f7f932a83 emacs go: move go config to a new file
Augie Fackler <raf@durin42.com>
parents:
diff changeset
42 (message "Go appears to not be installed, skipping Go setup.")))