|
|
@@ -1,10 +1,8 @@
|
|
|
;; Requires:
|
|
|
-;; aspell
|
|
|
+;; aspell - Spell checking
|
|
|
+;; xclip - Copy/Paste
|
|
|
;; Optional:
|
|
|
-;; clang
|
|
|
-
|
|
|
-;; TODO
|
|
|
-;; Look up authors of projects. See what other useful things they make.
|
|
|
+;; gocode - Go auto complete
|
|
|
|
|
|
;; ----------- Default Variables -----------
|
|
|
;; Global variables
|
|
|
@@ -18,8 +16,6 @@
|
|
|
show-paren-delay 0.25
|
|
|
tab-width 4
|
|
|
indent-tabs-mode nil
|
|
|
- ;x-select-enable-clipboard t
|
|
|
- ;interprogram-paste-function 'x-cut-buffer-or-selection-value
|
|
|
backup-directory-alist `(("." . ,backup-directory))
|
|
|
delete-old-versions t)
|
|
|
|
|
|
@@ -28,7 +24,13 @@
|
|
|
;; Delete selected text when typing (normal editor behavior)
|
|
|
(delete-selection-mode t)
|
|
|
|
|
|
-;; ------------- Keybindings -------------
|
|
|
+;; ------------ Utility Code -------------
|
|
|
+(defun package-installed (package)
|
|
|
+ "Checks whether or not a package is installed.
|
|
|
+
|
|
|
+Includes the package if it's available"
|
|
|
+ (require package nil :noerror))
|
|
|
+
|
|
|
(defun smart-beginning-of-line ()
|
|
|
"Move point to first non-whitespace character or beginning-of-line.
|
|
|
|
|
|
@@ -42,6 +44,7 @@ If point was already at that position, move point to beginning of line."
|
|
|
(and (= oldpos (point))
|
|
|
(beginning-of-line))))
|
|
|
|
|
|
+;; ------------- Keybindings -------------
|
|
|
(global-set-key [home] 'smart-beginning-of-line)
|
|
|
(global-set-key (kbd "C-c /") 'comment-or-uncomment-region)
|
|
|
(global-set-key (kbd "C-c C-k") 'compile)
|
|
|
@@ -66,12 +69,14 @@ If point was already at that position, move point to beginning of line."
|
|
|
package-archive-priorities '(("melpa" . 1)))
|
|
|
(package-initialize)
|
|
|
|
|
|
+;; Configure use-package
|
|
|
(unless (package-installed-p 'use-package)
|
|
|
(package-refresh-contents)
|
|
|
(package-install 'use-package))
|
|
|
(require 'use-package)
|
|
|
(setq use-package-always-ensure t)
|
|
|
|
|
|
+;; Auto update packages
|
|
|
(use-package auto-package-update
|
|
|
:config
|
|
|
(add-hook 'auto-package-update-before-hook
|
|
|
@@ -88,10 +93,6 @@ If point was already at that position, move point to beginning of line."
|
|
|
;; Also seems to ignore most properties. (e.g. overline, underline,
|
|
|
;; strike-though, etc.) Maybe it's an xterm problem?
|
|
|
(use-package color-theme
|
|
|
- :init
|
|
|
- ;; TODO: Fixes error about missing directory. Don't know why.
|
|
|
- ;(unless (file-exists-p "~/.emacs.d/elpa/color-theme-20070910.1007/themes")
|
|
|
- ; (make-directory "~/.emacs.d/elpa/color-theme-20070910.1007/themes"))
|
|
|
:config
|
|
|
(color-theme-initialize)
|
|
|
(load-theme 'Thomas-Experiement t))
|
|
|
@@ -99,20 +100,24 @@ If point was already at that position, move point to beginning of line."
|
|
|
;; ---------- Use X11 clipboard -----------
|
|
|
(use-package xclip
|
|
|
:if (executable-find "xclip")
|
|
|
- :config
|
|
|
+ :init
|
|
|
(add-to-list 'load-path "~/.emacs.d/elpa/xclip-1.4/")
|
|
|
+ :config
|
|
|
(xclip-mode 1))
|
|
|
|
|
|
;; --------- Parentheses Matching ---------
|
|
|
(show-paren-mode)
|
|
|
(use-package highlight-parentheses
|
|
|
- :config
|
|
|
+ :init
|
|
|
(define-globalized-minor-mode global-highlight-parentheses-mode
|
|
|
highlight-parentheses-mode
|
|
|
(lambda ()
|
|
|
(highlight-parentheses-mode t)))
|
|
|
+ :config
|
|
|
(global-highlight-parentheses-mode t))
|
|
|
|
|
|
+;; Use built-in pairing if available.
|
|
|
+;; Otherwise install substitute
|
|
|
(if (version<= "24.4" emacs-version)
|
|
|
(electric-pair-mode)
|
|
|
(use-package autopair
|
|
|
@@ -126,15 +131,34 @@ If point was already at that position, move point to beginning of line."
|
|
|
:config
|
|
|
(xterm-mouse-mode t))
|
|
|
|
|
|
+;; ---------- Auto-complete -----------
|
|
|
+(use-package company
|
|
|
+ :init
|
|
|
+ (add-hook 'after-init-hook 'global-company-mode)
|
|
|
+ :config
|
|
|
+ (setq
|
|
|
+ company-minimum-prefix-length 2
|
|
|
+ ;; company-idle-delay nil
|
|
|
+ ;; company-show-numbers t
|
|
|
+ ;; company-tooltip-limit 20
|
|
|
+ ;; company-dabbrev-downcase nil
|
|
|
+ )
|
|
|
+ ;; :bind ("C-;" . company-complete-common)
|
|
|
+ )
|
|
|
+
|
|
|
+;; ---------- Syntax Checking -----------
|
|
|
+(use-package flycheck
|
|
|
+ :config
|
|
|
+ (setq flycheck-check-syntax-automatically '(mode-enabled idle-change save)))
|
|
|
+
|
|
|
;; ----------- Ensime -----------
|
|
|
;; Java/Scala featues. Includes:
|
|
|
;; * Inferred types
|
|
|
-;; * Autocomplete
|
|
|
+;; * Auto-complete
|
|
|
;; * Syntax highlighting
|
|
|
;; * Jump to source/docs
|
|
|
;; * Refactoring
|
|
|
;; * Error detection
|
|
|
-(use-package company)
|
|
|
|
|
|
(if (version<= "24.4" emacs-version)
|
|
|
(use-package ensime
|
|
|
@@ -170,19 +194,6 @@ If point was already at that position, move point to beginning of line."
|
|
|
;; (add-hook 'irony-mode-hook irony-cdb-autosetup-compile-options)
|
|
|
;; )
|
|
|
|
|
|
-;; (use-package company
|
|
|
-;; :init (add-hook 'after-init-hook 'global-company-mode)
|
|
|
-;; :config
|
|
|
-;; (setq company-idle-delay nil
|
|
|
-;; company-minimum-prefix-length 2
|
|
|
-;; company-show-numbers t
|
|
|
-;; company-tooltip-limit 20
|
|
|
-;; company-dabbrev-downcase nil
|
|
|
-;; company-backends '((company-irony company-gtags))
|
|
|
-;; )
|
|
|
-;; :bind ("C-;" . company-complete-common)
|
|
|
-;; )
|
|
|
-
|
|
|
;; (use-package company-irony
|
|
|
;; :requires company)
|
|
|
|
|
|
@@ -229,15 +240,39 @@ an opening tag that is not followed by a matching closing tag."
|
|
|
|
|
|
;; ----------- Rust Mode ------------
|
|
|
(use-package rust-mode)
|
|
|
+
|
|
|
(use-package rust-playground
|
|
|
:requires rust-mode)
|
|
|
-(use-package cargo
|
|
|
- :after rust-mode)
|
|
|
-(use-package flycheck-rust
|
|
|
- :after rust-mode)
|
|
|
+
|
|
|
+(use-package cargo)
|
|
|
+
|
|
|
+(use-package flycheck-rust)
|
|
|
|
|
|
;; ----------- Go Mode -------------
|
|
|
-(use-package go-mode)
|
|
|
+(defun go-sanitize-env ()
|
|
|
+ "Check that then environment is configured properly for Go"
|
|
|
+ (unless (getenv "GOPATH")
|
|
|
+ (error "GOPATH is not set."))
|
|
|
+ (unless (getenv "GOROOT")
|
|
|
+ (error "GOROOT is not set.")))
|
|
|
+
|
|
|
+(defun my-go-mode-hook ()
|
|
|
+ (add-hook 'before-save-hook 'gofmt-before-save)
|
|
|
+ (setq gofmt-command "goimports")
|
|
|
+ (if (not (string-match "go" compile-command))
|
|
|
+ (set (make-local-variable 'compile-command)
|
|
|
+ "go build -v && go test -v && go vet")))
|
|
|
+
|
|
|
+(use-package go-mode
|
|
|
+ :config
|
|
|
+ (add-hook 'go-mode-hook 'my-go-mode-hook)
|
|
|
+ (add-hook 'go-mode-hook 'flycheck-mode))
|
|
|
+
|
|
|
+(use-package company-go
|
|
|
+ :if (executable-find "gocode")
|
|
|
+ :config
|
|
|
+ (add-hook 'go-mode-hook 'go-sanitize-env)
|
|
|
+ (push 'company-go company-backends))
|
|
|
|
|
|
;; ----------- i3 Support ----------
|
|
|
(use-package i3wm
|
|
|
@@ -394,3 +429,11 @@ an opening tag that is not followed by a matching closing tag."
|
|
|
lpr-region)
|
|
|
:config
|
|
|
(pr-update-menus t))
|
|
|
+
|
|
|
+;; Configure auto-complete if installed
|
|
|
+;; Used in case something installs it as a dependency
|
|
|
+(when (package-installed 'auto-complete)
|
|
|
+ (ac-config-default)
|
|
|
+ ;; Fix conflict between flyspell and auto-complete
|
|
|
+ (when (package-installed 'flyspell)
|
|
|
+ (ac-flyspell-workaround)))
|