|
|
@@ -4,6 +4,9 @@
|
|
|
;; Optional:
|
|
|
;; gocode - Go auto complete
|
|
|
|
|
|
+;; Enable loading my custom config files
|
|
|
+(add-to-list 'load-path "~/.emacs.d/configs/")
|
|
|
+
|
|
|
;; ----------- Default Variables -----------
|
|
|
;; Global variables
|
|
|
(defvar backup-directory (concat user-emacs-directory "backups"))
|
|
|
@@ -24,28 +27,8 @@
|
|
|
;; Delete selected text when typing (normal editor behavior)
|
|
|
(delete-selection-mode t)
|
|
|
|
|
|
-;; ------------ 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.
|
|
|
-
|
|
|
-Move point to the first non-whitespace character on this line.
|
|
|
-If point was already at that position, move point to beginning of line."
|
|
|
- (interactive "^")
|
|
|
- ;(if (version< "22" emacs-version) (interactive "^") (interactive))
|
|
|
- (let ((oldpos (point)))
|
|
|
- (beginning-of-line-text); goes to first significant character
|
|
|
- ;(back-to-indentation); goes to first non-whitespace
|
|
|
- (and (= oldpos (point))
|
|
|
- (beginning-of-line))))
|
|
|
-
|
|
|
;; ------------- Keybindings -------------
|
|
|
-(global-set-key [home] 'smart-beginning-of-line)
|
|
|
+(require 'smart-home)
|
|
|
(global-set-key (kbd "C-c /") 'comment-or-uncomment-region)
|
|
|
(global-set-key (kbd "C-c C-k") 'compile)
|
|
|
(global-set-key (kbd "M-<left>") 'backward-list)
|
|
|
@@ -57,35 +40,7 @@ If point was already at that position, move point to beginning of line."
|
|
|
(global-set-key (kbd "M-<delete>") 'kill-sexp)
|
|
|
|
|
|
;; ----------- Package Managing -----------
|
|
|
-;; The package manager
|
|
|
-(require 'package)
|
|
|
-
|
|
|
-;; Add package sources
|
|
|
-(setq package-archives
|
|
|
- '(("gnu" . "https://elpa.gnu.org/packages/")
|
|
|
- ("melpa" . "https://melpa.org/packages/")
|
|
|
- ("melpa-stable" . "https://stable.melpa.org/packages/")
|
|
|
- ("org" . "https://orgmode.org/elpa/"))
|
|
|
- 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
|
|
|
- (lambda () (package-refresh-contents)))
|
|
|
- (setq auto-package-update-delete-old-versions t
|
|
|
- auto-package-update-interval 4
|
|
|
- auto-package-update-prompt-before-update t
|
|
|
- auto-package-update-hide-results t)
|
|
|
- (auto-package-update-maybe))
|
|
|
+(require 'package-loader)
|
|
|
|
|
|
;; ---------- Color Themes ----------
|
|
|
;; TODO: Fix warning underline to always be orange/yellow
|
|
|
@@ -151,85 +106,11 @@ If point was already at that position, move point to beginning of line."
|
|
|
:config
|
|
|
(setq flycheck-check-syntax-automatically '(mode-enabled idle-change save)))
|
|
|
|
|
|
-;; ----------- Ensime -----------
|
|
|
-;; Java/Scala featues. Includes:
|
|
|
-;; * Inferred types
|
|
|
-;; * Auto-complete
|
|
|
-;; * Syntax highlighting
|
|
|
-;; * Jump to source/docs
|
|
|
-;; * Refactoring
|
|
|
-;; * Error detection
|
|
|
-
|
|
|
-(if (version<= "24.4" emacs-version)
|
|
|
- (use-package ensime
|
|
|
- :requires company
|
|
|
- :hook (scala-mode java-mode)
|
|
|
- :config
|
|
|
- (setq ensime-startup-notification nil)
|
|
|
- (eval-after-load 'ensime-mode
|
|
|
- '(define-key ensime-mode-map (kbd "C-c i")
|
|
|
- (lambda () "Generate ensime.sbt file"
|
|
|
- (interactive)
|
|
|
- (write-region "ensimeScalaVersion in ThisBuild := \"2.11.8\""
|
|
|
- nil (concat (read-directory-name "SBT Root:") "ensime.sbt"))))))
|
|
|
- (use-package scala-mode
|
|
|
- :commands (scala-mode)))
|
|
|
-
|
|
|
-;; --------- C Syntax checker ---------
|
|
|
-;; TODO: C autocomplete. Both with clang integration and backup naive method
|
|
|
-;; (use-package irony
|
|
|
-;; ;;:hook (c-mode c++-mode objc-mode)
|
|
|
-;; :init
|
|
|
-;; (add-hook 'c++-mode-hook 'irony-mode)
|
|
|
-;; (add-hook 'c-mode-hook 'irony-mode)
|
|
|
-;; (add-hook 'objc-mode-hook 'irony-mode)
|
|
|
-;; :commands (irony-mode irony-version)
|
|
|
-;; :config
|
|
|
-;; (defun my-irony-mode-hook ()
|
|
|
-;; (define-key irony-mode-map [remap completion-at-point]
|
|
|
-;; 'irony-completion-at-point-async)
|
|
|
-;; (define-key irony-mode-map [remap complete-symbol]
|
|
|
-;; 'irony-completion-at-point-async))
|
|
|
-;; (add-hook 'irony-mode-hook 'my-irony-mode-hook)
|
|
|
-;; (add-hook 'irony-mode-hook irony-cdb-autosetup-compile-options)
|
|
|
-;; )
|
|
|
-
|
|
|
-;; (use-package company-irony
|
|
|
-;; :requires company)
|
|
|
-
|
|
|
-;; (use-package flycheck-irony
|
|
|
-;; :hook c-mode)
|
|
|
-;; ; :mode ("\\.c\\'" "\\.h\\'")
|
|
|
+;; ----------- Scala Mode -----------
|
|
|
+(require 'scala)
|
|
|
|
|
|
;; ------------ Web Mode ------------
|
|
|
-(defun my-sgml-insert-gt ()
|
|
|
- "Inserts a `>' character and calls
|
|
|
-`my-sgml-close-tag-if-necessary', leaving point where it is."
|
|
|
- (interactive)
|
|
|
- (insert ">")
|
|
|
- (save-excursion (my-sgml-close-tag-if-necessary)))
|
|
|
-
|
|
|
-(defun my-sgml-close-tag-if-necessary ()
|
|
|
- "Calls sgml-close-tag if the tag immediately before point is
|
|
|
-an opening tag that is not followed by a matching closing tag."
|
|
|
- (when (looking-back "<\\s-*\\([^</> \t\r\n]+\\)[^</>]*>")
|
|
|
- (let ((tag (match-string 1)))
|
|
|
- (unless (and (not (sgml-unclosed-tag-p tag))
|
|
|
- (looking-at (concat "\\s-*<\\s-*/\\s-*" tag "\\s-*>")))
|
|
|
- (sgml-close-tag)))))
|
|
|
-
|
|
|
-;; TODO: Disable autopair in HTML. Interferes with autoclose tab.
|
|
|
-(use-package multi-web-mode
|
|
|
- :init
|
|
|
- (setq mweb-default-major-mode 'html-mode
|
|
|
- mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
|
|
|
- (js-mode "<script[^>]*>" "</script>")
|
|
|
- (css-mode "<style[^>]*>" "</style>"))
|
|
|
- mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
|
|
|
- :config
|
|
|
- (multi-web-global-mode 1)
|
|
|
- (eval-after-load "sgml-mode"
|
|
|
- '(define-key sgml-mode-map ">" 'my-sgml-insert-gt)))
|
|
|
+(require 'web)
|
|
|
|
|
|
;; ------------ Git Mode ------------
|
|
|
;; TODO: make resolving merge conflicts hotkeys not use "^"
|
|
|
@@ -239,40 +120,10 @@ an opening tag that is not followed by a matching closing tag."
|
|
|
:bind ("C-x g" . magit-status)))
|
|
|
|
|
|
;; ----------- Rust Mode ------------
|
|
|
-(use-package rust-mode)
|
|
|
-
|
|
|
-(use-package rust-playground
|
|
|
- :requires rust-mode)
|
|
|
-
|
|
|
-(use-package cargo)
|
|
|
-
|
|
|
-(use-package flycheck-rust)
|
|
|
+(require 'rust)
|
|
|
|
|
|
;; ----------- 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))
|
|
|
+(require 'go)
|
|
|
|
|
|
;; ----------- i3 Support ----------
|
|
|
(use-package i3wm
|
|
|
@@ -291,144 +142,19 @@ an opening tag that is not followed by a matching closing tag."
|
|
|
(use-package markdown-mode))
|
|
|
|
|
|
;; ---- StackOverflow Client ------
|
|
|
-(use-package sx
|
|
|
- ;; TODO: More keybindings if useful
|
|
|
- :bind (("C-c C-q" . sx-search))
|
|
|
- :config
|
|
|
- (defvar sx-dir (concat user-emacs-directory ".sx"))
|
|
|
- (if (file-exists-p sx-dir)
|
|
|
- (and (shell-command (concat "chmod 700 " sx-dir))
|
|
|
- (shell-command (concat "chmod 600 " sx-dir "/*.el")))
|
|
|
- )
|
|
|
- :commands (sx-accept
|
|
|
- sx-answer
|
|
|
- sx-ask
|
|
|
- sx-authenticate
|
|
|
- sx-bug-report
|
|
|
- sx-button-copy
|
|
|
- sx-button-edit-this
|
|
|
- sx-button-follow-link
|
|
|
- sx-cache-invalidate-all
|
|
|
- sx-comment
|
|
|
- sx-compose-insert-tags
|
|
|
- sx-compose-mode
|
|
|
- sx-compose-quit
|
|
|
- sx-compose-send
|
|
|
- sx-delete
|
|
|
- sx-display
|
|
|
- sx-display-question
|
|
|
- sx-downvote
|
|
|
- sx-edit
|
|
|
- sx-favorite
|
|
|
- sx-inbox
|
|
|
- sx-inbox-mode
|
|
|
- sx-inbox-notifications
|
|
|
- sx-open-link
|
|
|
- sx-question-list-hide
|
|
|
- sx-question-list-mark-read
|
|
|
- sx-question-list-mode
|
|
|
- sx-question-list-next
|
|
|
- sx-question-list-next-far
|
|
|
- sx-question-list-next-page
|
|
|
- sx-question-list-order-by
|
|
|
- sx-question-list-previous
|
|
|
- sx-question-list-previous-far
|
|
|
- sx-question-list-refresh
|
|
|
- sx-question-list-switch-site
|
|
|
- sx-question-list-view-next
|
|
|
- sx-question-list-view-previous
|
|
|
- sx-question-mode
|
|
|
- sx-question-mode-hide-show-section
|
|
|
- sx-question-mode-next-section
|
|
|
- sx-question-mode-order-by
|
|
|
- sx-question-mode-previous-section
|
|
|
- sx-question-mode-refresh
|
|
|
- sx-search
|
|
|
- sx-search-tag-at-point
|
|
|
- sx-star
|
|
|
- sx-tab-all-questions
|
|
|
- sx-tab-featured
|
|
|
- sx-tab-frontpage
|
|
|
- sx-tab-hot
|
|
|
- sx-tab-month
|
|
|
- sx-tab-newest
|
|
|
- sx-tab-starred
|
|
|
- sx-tab-topvoted
|
|
|
- sx-tab-unanswered
|
|
|
- sx-tab-unanswered-my-tags
|
|
|
- sx-tab-week
|
|
|
- sx-upvote
|
|
|
- sx-version
|
|
|
- sx-visit-externally))
|
|
|
+(require 'stackoverflow)
|
|
|
|
|
|
;; -------- Spellcheck ------------
|
|
|
-(defun flyspell-detect-ispell-args (&optional run-together)
|
|
|
- (cond ((string-match "aspell$" ispell-program-name)
|
|
|
- (append (list "--sug-mode=ultra" "--lang=en_US")
|
|
|
- (if run-together '("--run-together" "--run-together-limit=5" "--run-together-min=2"))))
|
|
|
- ((string-match "hunspell$" ispell-program-name)
|
|
|
- "-d en_US")))
|
|
|
-
|
|
|
-(use-package flyspell-correct-popup
|
|
|
- :bind ("M-s" . ispell-word)
|
|
|
- :hook ((text-mode . flyspell-mode)
|
|
|
- (prog-mode . flyspell-prog-mode)
|
|
|
- ((flyspell-mode flyspell-prog-mode) . flyspell-buffer))
|
|
|
- :config
|
|
|
- (cond
|
|
|
- ((executable-find "aspell")
|
|
|
- (setq ispell-program-name "aspell"))
|
|
|
- ((executable-find "hunspell")
|
|
|
- (setq ispell-program-name "hunspell")
|
|
|
- (setq ispell-local-dictionary "en_US")
|
|
|
- (setq ispell-local-dictionary-alist
|
|
|
- '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US") nil utf-8))))
|
|
|
- (t
|
|
|
- (setq ispell-program-name nil)))
|
|
|
- (setq-default ispell-extra-args (flyspell-detect-ispell-args t))
|
|
|
- (setq-default flyspell-issue-message-flag nil))
|
|
|
+(require 'spellcheck)
|
|
|
|
|
|
;; -------- REST Client ---------
|
|
|
-(use-package restclient
|
|
|
- :commands (restclient-copy-curl-command
|
|
|
- restclient-http-send-current
|
|
|
- restclient-http-send-current-raw
|
|
|
- restclient-http-send-current-stay-in-window
|
|
|
- restclient-jump-next
|
|
|
- restclient-jump-prev
|
|
|
- restclient-mark-current
|
|
|
- restclient-mode
|
|
|
- restclient-narrow-to-current
|
|
|
- restclient-outline-mode
|
|
|
- restclient-toggle-body-visibility
|
|
|
- restclient-toggle-body-visibility-or-indent))
|
|
|
+(require 'rest-client)
|
|
|
|
|
|
;; ------- Highlight TODO -------
|
|
|
-;; Remove transpose bindings. I don't have any reasonable use for them
|
|
|
-;; and would much rather use them for navigating TODO's.
|
|
|
-
|
|
|
-(let ((trans-chars "\C-t");; Transpose (swap) adjacent characters
|
|
|
- )
|
|
|
- (global-unset-key trans-chars))
|
|
|
-(use-package hl-todo
|
|
|
- :commands (hl-todo-mode
|
|
|
- hl-todo-next
|
|
|
- hl-todo-occur
|
|
|
- hl-todo-previous)
|
|
|
- :hook (prog-mode . hl-todo-mode)
|
|
|
- :bind (("C-t n" . hl-todo-next)
|
|
|
- ("C-t p" . hl-todo-previous)))
|
|
|
+(require 'todo)
|
|
|
|
|
|
;; ---- Printer Integration -----
|
|
|
-(use-package printing
|
|
|
- :bind ("M-p" . print-buffer)
|
|
|
- :commands (print-buffer
|
|
|
- print-region
|
|
|
- lpr-buffer
|
|
|
- lpr-customize
|
|
|
- lpr-region)
|
|
|
- :config
|
|
|
- (pr-update-menus t))
|
|
|
+(require 'printer)
|
|
|
|
|
|
;; Configure auto-complete if installed
|
|
|
;; Used in case something installs it as a dependency
|