2019-02-05 11:19:14 +01:00
|
|
|
;;; init.el --- Initialization file for emacs
|
|
|
|
;;; Commentary: Emacs startup file --- initialization file for emacs
|
2019-02-18 18:34:46 +01:00
|
|
|
(setq
|
|
|
|
custom-file (concat user-emacs-directory ".emacs-customize.el")
|
|
|
|
require-final-newline t)
|
2019-02-04 11:12:43 +01:00
|
|
|
|
2019-02-18 18:34:46 +01:00
|
|
|
;; Track emacs load time
|
|
|
|
(defconst emacs-start-time (current-time))
|
2019-02-04 11:12:43 +01:00
|
|
|
|
|
|
|
;; Other configs
|
|
|
|
(setq make-backup-files nil)
|
|
|
|
(setq auto-save-default nil)
|
|
|
|
|
|
|
|
;; Splash Screen
|
|
|
|
(setq inhibit-startup-screen t)
|
|
|
|
(setq initial-scratch-message ";; Happy Hacking")
|
|
|
|
|
|
|
|
;; Show matching parens
|
|
|
|
(setq show-paren-delay 0)
|
2019-02-06 11:53:16 +01:00
|
|
|
(show-paren-mode 1)
|
2019-02-18 18:34:46 +01:00
|
|
|
(electric-pair-mode 1)
|
2019-02-04 11:12:43 +01:00
|
|
|
|
|
|
|
;; UI configurations
|
|
|
|
(if (display-graphic-p)
|
|
|
|
(progn
|
|
|
|
(tool-bar-mode -1)
|
2019-02-18 18:34:46 +01:00
|
|
|
(scroll-bar-mode -1)))
|
|
|
|
(tooltip-mode -1)
|
|
|
|
(menu-bar-mode -1)
|
2019-02-04 11:12:43 +01:00
|
|
|
(global-linum-mode 1)
|
|
|
|
|
2019-02-18 18:34:46 +01:00
|
|
|
;; Font configurations
|
2019-02-05 11:19:14 +01:00
|
|
|
(add-to-list 'default-frame-alist '(font . "Iosevka-14"))
|
2019-02-04 11:12:43 +01:00
|
|
|
(add-to-list 'default-frame-alist '(height . 24))
|
|
|
|
(add-to-list 'default-frame-alist '(width . 80))
|
|
|
|
|
2019-02-18 18:34:46 +01:00
|
|
|
;;; Package Management
|
|
|
|
(require 'package)
|
|
|
|
(setq package-enable-at-startup nil)
|
|
|
|
(setq package-archives
|
|
|
|
'(("org" . "http://orgmode.org/elpa/")
|
|
|
|
("gnu" . "http://elpa.gnu.org/packages/")
|
|
|
|
("melpa" . "https://melpa.org/packages/")))
|
|
|
|
(package-initialize)
|
2019-02-04 11:12:43 +01:00
|
|
|
|
2019-02-18 18:34:46 +01:00
|
|
|
;; Bootstrap `use-package`
|
|
|
|
(unless (package-installed-p 'use-package)
|
|
|
|
(package-refresh-contents)
|
|
|
|
(package-install 'use-package))
|
|
|
|
(eval-when-compile
|
|
|
|
(require 'use-package))
|
|
|
|
|
|
|
|
;; always download all packages if not already downloaded
|
|
|
|
(setq use-package-always-ensure t)
|
|
|
|
;; keep stats about packages
|
|
|
|
(setq use-package-compute-statistics t)
|
|
|
|
; no longer included with use-package by default
|
|
|
|
(use-package diminish)
|
2019-02-11 17:24:39 +01:00
|
|
|
(use-package auto-package-update
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(setq auto-package-update-delete-old-versions t
|
|
|
|
auto-package-update-interval 4)
|
|
|
|
(auto-package-update-maybe))
|
|
|
|
|
2019-02-18 18:34:46 +01:00
|
|
|
;; Restart emacs from within emacs
|
|
|
|
(use-package restart-emacs
|
|
|
|
:ensure t)
|
|
|
|
|
|
|
|
;; Theme
|
|
|
|
(use-package doom-themes
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(load-theme 'doom-molokai t))
|
|
|
|
|
|
|
|
;; Auto enforced consistence
|
|
|
|
(use-package editorconfig
|
|
|
|
:diminish "↹"
|
|
|
|
:init
|
|
|
|
(setq auto-mode-alist
|
|
|
|
(cl-union auto-mode-alist
|
|
|
|
'(("\\.editorconfig\\'" . editorconfig-conf-mode)
|
|
|
|
("editorconfig\\'" . editorconfig-conf-mode))))
|
|
|
|
:config
|
|
|
|
(editorconfig-mode 1))
|
|
|
|
|
|
|
|
(use-package smartparens
|
|
|
|
:hook ((prog-mode-hook) . smartparens-mode)
|
|
|
|
:config
|
|
|
|
(require 'smartparens-config))
|
|
|
|
|
|
|
|
(use-package aggressive-indent
|
|
|
|
:diminish "⇉"
|
|
|
|
:config
|
|
|
|
(global-aggressive-indent-mode t))
|
|
|
|
|
|
|
|
(use-package fzf
|
|
|
|
:ensure t)
|
|
|
|
|
|
|
|
;; Vim mode
|
|
|
|
(use-package evil
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(evil-mode 1))
|
2019-02-04 11:12:43 +01:00
|
|
|
(use-package evil-escape
|
|
|
|
:ensure t
|
|
|
|
:init
|
|
|
|
(setq-default evil-escape-key-sequence "jk")
|
|
|
|
:config
|
|
|
|
(evil-escape-mode 1))
|
|
|
|
|
|
|
|
;; Anzu for search matching
|
|
|
|
(use-package anzu
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(global-anzu-mode 1)
|
|
|
|
(global-set-key [remap query-replace-regexp]
|
|
|
|
'anzu-query-replace-regexp)
|
|
|
|
(global-set-key [remap query-replace]
|
|
|
|
'anzu-query-replace))
|
|
|
|
|
|
|
|
;; Helm
|
|
|
|
(use-package helm
|
|
|
|
:ensure t
|
|
|
|
:init
|
|
|
|
(setq helm-M-x-fuzzy-match t
|
|
|
|
helm-mode-fuzzy-match t
|
|
|
|
helm-buffers-fuzzy-matching t
|
|
|
|
helm-recentf-fuzzy-match t
|
|
|
|
helm-locate-fuzzy-match t
|
|
|
|
helm-semantic-fuzzy-match t
|
|
|
|
helm-imenu-fuzzy-match t
|
|
|
|
helm-completion-in-region-fuzzy-match t
|
|
|
|
helm-candidate-number-list 80
|
2019-02-05 11:19:14 +01:00
|
|
|
helm-split-window-inside-p t
|
2019-02-04 11:12:43 +01:00
|
|
|
helm-move-to-line-cycle-in-source t
|
|
|
|
helm-echo-input-in-header-line t
|
|
|
|
helm-autoresize-max-height 0
|
|
|
|
helm-autoresize-min-height 20)
|
|
|
|
:config
|
|
|
|
(helm-mode 1))
|
|
|
|
;; RipGrep
|
|
|
|
(use-package helm-rg :ensure t)
|
|
|
|
;; Projectile
|
|
|
|
(use-package projectile
|
|
|
|
:ensure t
|
|
|
|
:init
|
|
|
|
(setq projectile-require-project-root nil)
|
|
|
|
:config
|
|
|
|
(projectile-mode 1))
|
|
|
|
;; Helm Projectile
|
|
|
|
(use-package helm-projectile
|
|
|
|
:ensure t
|
|
|
|
:init
|
|
|
|
(setq helm-projectile-fuzzy-match t)
|
|
|
|
:config
|
|
|
|
(helm-projectile-on))
|
|
|
|
;; Helm Gtags
|
|
|
|
(use-package helm-gtags
|
|
|
|
:defer t
|
|
|
|
:ensure t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq helm-gtags-ignore-case t
|
|
|
|
helm-gtags-auto-update t
|
2019-02-04 18:36:55 +01:00
|
|
|
helm-gtags-prefix-key "SPC"
|
2019-02-04 11:12:43 +01:00
|
|
|
helm-gtags-use-input-at-cursor t
|
|
|
|
helm-gtags-pulse-at-cursor t)
|
|
|
|
(add-hook 'c-mode-hook 'helm-gtags-mode)))
|
2019-02-18 18:34:46 +01:00
|
|
|
(defun helm-gtags-dwim-other-window ()
|
|
|
|
;; Enable helm-gtags-dwim in the other window
|
|
|
|
(interactive)
|
|
|
|
(let ((helm-gtags--use-otherwin t)
|
|
|
|
(split-height-threshold nil)
|
|
|
|
(split-width-threshold 140))
|
|
|
|
(helm-gtags-dwim)))
|
2019-02-04 11:12:43 +01:00
|
|
|
|
|
|
|
;; All The Icons
|
|
|
|
(use-package all-the-icons :ensure t)
|
|
|
|
|
|
|
|
;; Which Key
|
|
|
|
(use-package which-key
|
|
|
|
:ensure t
|
|
|
|
:init
|
|
|
|
(setq which-key-separator " ")
|
|
|
|
(setq which-key-prefix-prefix "+")
|
|
|
|
:config
|
|
|
|
(which-key-mode))
|
|
|
|
|
2019-02-06 11:53:16 +01:00
|
|
|
;; Git Support
|
|
|
|
(use-package magit
|
|
|
|
:defer t
|
|
|
|
:ensure t)
|
|
|
|
(use-package evil-magit
|
|
|
|
:defer t
|
|
|
|
:ensure t)
|
|
|
|
(use-package helm-git-grep
|
|
|
|
:defer t
|
|
|
|
:ensure t)
|
|
|
|
(use-package helm-gitignore
|
|
|
|
:defer t
|
|
|
|
:ensure t)
|
|
|
|
(use-package git-commit
|
|
|
|
:defer t
|
|
|
|
:ensure t)
|
|
|
|
(use-package git-messenger
|
|
|
|
:defer t
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(define-key git-messenger-map [escape] 'git-messenger:popup-close))
|
|
|
|
(use-package gitattributes-mode
|
|
|
|
:defer t)
|
|
|
|
(use-package gitconfig-mode
|
|
|
|
:defer t)
|
|
|
|
(use-package gitignore-mode
|
|
|
|
:defer t)
|
2019-02-05 11:19:14 +01:00
|
|
|
|
2019-02-04 11:12:43 +01:00
|
|
|
;; Custom keybinding
|
|
|
|
(use-package general
|
|
|
|
:ensure t
|
2019-02-18 18:34:46 +01:00
|
|
|
:init
|
|
|
|
(setq general-override-states '(insert
|
|
|
|
emacs
|
|
|
|
hybrid
|
|
|
|
normal
|
|
|
|
visual
|
|
|
|
motion
|
|
|
|
operator
|
|
|
|
replace))
|
2019-02-04 11:12:43 +01:00
|
|
|
:config (general-define-key
|
|
|
|
:states '(normal visual insert emacs)
|
|
|
|
:prefix "SPC"
|
|
|
|
:non-normal-prefix "M-SPC"
|
|
|
|
"/" '(helm-projectile-rg
|
|
|
|
:which-key "ripgrep")
|
|
|
|
"TAB" '(switch-to-prev-buffer
|
|
|
|
:which-key "previous buffer")
|
|
|
|
"SPC" '(helm-M-x :which-key "M-x")
|
2019-02-18 18:34:46 +01:00
|
|
|
"ff" '(fzf :which-key "fuzzy file search")
|
2019-02-04 11:12:43 +01:00
|
|
|
"pf" '(helm-projectile-find-file
|
|
|
|
:which-key "find files")
|
|
|
|
"pp" '(helm-projectile-switch-project
|
|
|
|
:which-key "switch project")
|
|
|
|
"pb" '(helm-projectile-switch-to-buffer
|
|
|
|
:which-key "switch buffer")
|
|
|
|
"pr" '(helm-show-kill-ring
|
|
|
|
:which-key "show kill ring")
|
|
|
|
;; Buffers
|
|
|
|
"bb" '(helm-mini :which-key "buffers list")
|
|
|
|
;; Window
|
|
|
|
"wl" '(windmove-right :which-key "move right")
|
|
|
|
"wh" '(windmove-left :which-key "move left")
|
|
|
|
"wk" '(windmove-up :which-key "move up")
|
|
|
|
"wj" '(windmove-down :which-key "move bottom")
|
|
|
|
"w/" '(split-window-right :which-key "split right")
|
|
|
|
"w-" '(split-window-below :which-key "split bottom")
|
|
|
|
"wx" '(delete-window :which-key "delete window")
|
|
|
|
"qz" '(delete-frame :which-key "delete frame")
|
|
|
|
"qq" '(kill-emacs :which-key "quit")
|
2019-02-05 11:19:14 +01:00
|
|
|
"qr" '(restart-emacs :which-key "restart emacs")
|
2019-02-04 11:12:43 +01:00
|
|
|
;; Others
|
|
|
|
"at" '(ansi-term :which-key "open terminal")
|
|
|
|
;; Gtags
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgc" '(helm-gtags-create-tags
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "create tag db")
|
2019-02-04 18:43:01 +01:00
|
|
|
"mgd" '(helm-gtags-find-tag
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "find definitions")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgf" '(helm-gtags-select-path
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "jump to a file in tag db")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgG" '(helm-gtags-dwim-other-window
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "jump to location based on context")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgi" '(helm-gtags-tags-in-this-function
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "present tags in current function")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgl" '(helm-gtags-parse-file
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "jump to definitions in file")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgn" '(helm-gtags-next-history
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "jump to next location in context stack")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgp" '(helm-gtags-previous-history
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "jump to previous location in context stack")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgr" '(helm-gtags-find-rtag
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "find references")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgR" '(helm-gtags-resume
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "resume previous helm-gtags session")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgs" '(helm-gtags-select
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "select any tag in project retrieved by gtags")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgS" '(helm-gtags-show-stack
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "show stack of visited locations")
|
2019-02-04 18:36:55 +01:00
|
|
|
"mgu" '(helm-gtags-update-tags
|
2019-02-06 11:53:16 +01:00
|
|
|
:which-key "create tag db")
|
|
|
|
;; Git key bindings
|
|
|
|
"gc" '(magit-clone :which-key "magit clone")
|
|
|
|
"gff" '(magit-find-file :which-key "magit find file")
|
|
|
|
"gfl" '(magit-log-buffer-file
|
|
|
|
:which-key "magit log buffer file")
|
|
|
|
"gfd" '(magit-diff-buffer-file-popup
|
|
|
|
:which-key "magit diff buffer file popup")
|
|
|
|
"gi" '(magit-init :which-key "magit initialize")
|
|
|
|
"gL" '(magit-list-repositories
|
|
|
|
:which-key "magit list repositories")
|
|
|
|
"gm" '(magit-dispatch-popup "magit dispatch popup")
|
|
|
|
"gs" '(magit-status "open Magit status buffer")
|
|
|
|
"gS" '(magit-stage-file "magit stage file")
|
|
|
|
"gU" '(magit-unstage-file "magit unstage file")
|
|
|
|
"g/" '(helm-git-grep :which-key "open helm git grep")
|
|
|
|
"g*" '(helm-git-grep-at-point
|
2019-02-18 18:34:46 +01:00
|
|
|
:which-key "open helm git grep at point")))
|
|
|
|
|
2019-02-04 11:12:43 +01:00
|
|
|
|
|
|
|
;; Fancy titlebar for MacOS
|
|
|
|
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
|
|
|
|
(add-to-list 'default-frame-alist '(ns-appearance . dark))
|
|
|
|
(setq ns-use-proxy-icon nil)
|
|
|
|
(setq frame-title-format nil)
|
|
|
|
|
|
|
|
;; Flycheck
|
|
|
|
(use-package flycheck
|
|
|
|
:ensure t
|
|
|
|
:init (global-flycheck-mode))
|
2019-02-05 11:19:14 +01:00
|
|
|
;; To disable flycheck while working with this file
|
|
|
|
(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))
|
2019-02-04 11:12:43 +01:00
|
|
|
|
|
|
|
;; Company mode
|
|
|
|
(use-package company
|
|
|
|
:ensure t
|
2019-02-18 18:34:46 +01:00
|
|
|
:diminish "⇥"
|
2019-02-04 11:12:43 +01:00
|
|
|
:init
|
2019-02-18 18:34:46 +01:00
|
|
|
(add-hook 'after-init-hook 'global-company-mode)
|
2019-02-04 11:12:43 +01:00
|
|
|
(setq company-minimum-prefix-length 3)
|
|
|
|
(setq company-auto-complete nil)
|
|
|
|
(setq company-idle-delay 0)
|
|
|
|
(setq company-require-match 'never)
|
|
|
|
(setq company-frontends
|
|
|
|
'(company-pseudo-tooltip-unless-just-one-frontend
|
|
|
|
company-preview-frontend company-echo-metadata-frontend))
|
|
|
|
(setq tab-always-indent 'complete)
|
|
|
|
(defvar completion-at-point-functions-saved nil)
|
|
|
|
:config
|
|
|
|
(global-company-mode 1)
|
|
|
|
(define-key company-active-map (kbd "TAB")
|
|
|
|
'company-complete-common-or-cycle)
|
|
|
|
(define-key company-active-map (kbd "<tab>")
|
|
|
|
'company-complete-common-or-cycle)
|
|
|
|
(define-key company-active-map (kbd "S-TAB")
|
|
|
|
'company-select-previous)
|
|
|
|
(define-key company-active-map (kbd "<backtab>")
|
|
|
|
'company-select-previous)
|
|
|
|
(define-key company-mode-map [remap indent-for-tab-command]
|
|
|
|
'company-indent-for-tab-command)
|
|
|
|
(defun company-indent-for-tab-command (&optional arg)
|
|
|
|
(interactive "P")
|
|
|
|
(let ((completion-at-point-functions-saved completion-at-point-functions)
|
|
|
|
(completion-at-point-functions '(company-complete-common-wrapper)))
|
|
|
|
(indent-for-tab-command arg)))
|
|
|
|
|
2019-02-18 18:34:46 +01:00
|
|
|
(defun company-complete-common-wrapper ()
|
|
|
|
(let ((completion-at-point-functions completion-at-point-functions-saved))
|
|
|
|
(company-complete-common))))
|
|
|
|
|
|
|
|
(use-package company-quickhelp
|
|
|
|
:init
|
|
|
|
(company-quickhelp-mode 1))
|
2019-02-04 11:12:43 +01:00
|
|
|
|
|
|
|
;; Powerline
|
|
|
|
(use-package spaceline
|
|
|
|
:ensure t
|
|
|
|
:init
|
|
|
|
(setq powerline-default-separator 'slant)
|
|
|
|
:config
|
|
|
|
(spaceline-emacs-theme)
|
|
|
|
(spaceline-toggle-minor-modes-off)
|
|
|
|
(spaceline-toggle-buffer-size-off)
|
|
|
|
(spaceline-toggle-evil-state-on))
|
|
|
|
|
2019-02-18 18:34:46 +01:00
|
|
|
;; Language Support
|
|
|
|
(use-package company-ghci
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(push 'haskell-mode-hook 'company-mode)
|
|
|
|
:hook
|
|
|
|
((haskell-interactive-mode . company-mode)))
|
|
|
|
(use-package haskell-mode
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(push 'company-ghci company-backends)
|
|
|
|
:hook
|
|
|
|
((haskell-mode . hindent-mode)
|
|
|
|
(haskell-mode . company-mode))
|
|
|
|
:custom
|
|
|
|
((haskell-stylish-on-save t)
|
|
|
|
(haskell-process-suggest-remove-import-lines t)))
|
|
|
|
(use-package flycheck-haskell
|
|
|
|
:defer t
|
|
|
|
:hook
|
|
|
|
(haskell-mode . flycheck-haskell-setup))
|
|
|
|
(use-package intero
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(intero-global-mode 1))
|
|
|
|
(use-package hindent
|
|
|
|
:defer t)
|
|
|
|
(use-package hlint-refactor
|
|
|
|
:defer t)
|
2019-02-18 19:02:03 +01:00
|
|
|
(use-package rainbow-delimiters
|
|
|
|
:ensure t
|
|
|
|
:hook
|
|
|
|
(prog-mode-hook . rainbow-delimiters-mode))
|
2019-02-04 11:12:43 +01:00
|
|
|
|
2019-02-18 18:34:46 +01:00
|
|
|
(use-package rust-mode
|
|
|
|
:defer t
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(setq rust-format-on-save t))
|
|
|
|
(use-package racer
|
|
|
|
:ensure t
|
|
|
|
:hook
|
|
|
|
((rust-mode . racer-mode)
|
|
|
|
(racer-mode . eldoc-mode)
|
|
|
|
(racer-mode . company-mode)))
|
2019-02-05 11:19:14 +01:00
|
|
|
|
|
|
|
;;; init.el ends
|