comparison .elisp/settings/80.go.el @ 277:884f7f932a83

emacs go: move go config to a new file This uses some clever shell tricks to identify the location (if any) of the go installation and gocode and load their supporting packages if available.
author Augie Fackler <raf@durin42.com>
date Fri, 27 Apr 2012 16:50:05 -0500
parents
children d77b2e253e99
comparison
equal deleted inserted replaced
276:46979cef73b6 277:884f7f932a83
1 ;; completions for go
2 (defun af-go-hook ()
3 ;; enable tabs
4 (setq tab-width 2)
5 (setq-default indent-tabs-mode t)
6 (make-variable-buffer-local 'whitespace-style)
7 (setq whitespace-style '(trailing lines-tail indentation trailing empty))
8 )
9
10 (defun af-get-go-elisp-location ()
11 (let* ((gobinary (shell-command-to-string "which go"))
12 (gobin (substring (file-name-directory gobinary) 0 -1))
13 (goroot (file-name-directory gobin)))
14 (concat goroot "misc/emacs")))
15
16 (defun af-get-gocode-elisp-location ()
17 (let* ((binary (shell-command-to-string "which gocode"))
18 (bin (substring (file-name-directory binary) 0 -1))
19 (basedir (file-name-directory bin)))
20 (concat basedir "src/github.com/nsf/gocode/emacs-company/")))
21
22 (let* ((goloc (af-get-go-elisp-location))
23 (goel (concat goloc "/go-mode.el")))
24 (if (file-exists-p goel)
25 (progn
26 (message "Go is installed, loading go-mode")
27 (add-to-list 'load-path goloc)
28 (require 'go-mode)
29 (let* ((loc (af-get-gocode-elisp-location))
30 (el (concat loc "/company-go.el")))
31 (if (file-exists-p el)
32 (progn
33 (message "Found gocode, loading company-mode support...")
34 (add-to-list 'load-path loc)
35 (require 'company-go))
36 (message "gocode missing, skipping company-mode support."))))
37 (message "Go appears to not be installed, skipping Go setup.")))