|
|
|
@ -1,3 +1,17 @@
|
|
|
|
|
;;; init.el -- Emacs initialization file. |
|
|
|
|
;;; |
|
|
|
|
;;; Commentary: |
|
|
|
|
;;; |
|
|
|
|
;;; This file is broken out to be modular. |
|
|
|
|
;;; The following directories are used: |
|
|
|
|
;;; |
|
|
|
|
;;; ~/.emacs.d/elisp - Contains all customization. |
|
|
|
|
;;; ~/.emacs.d/elisp/modes - Refers to mode specific functions. |
|
|
|
|
;;; |
|
|
|
|
;;; General initialization code, theming, and global settings are stored here for now. |
|
|
|
|
;;; I may move them into a global configuration file later if this gets too crowded |
|
|
|
|
;;; again. |
|
|
|
|
|
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
;; Enable MELPA |
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
@ -37,8 +51,16 @@ There are two things you can do about this warning:
|
|
|
|
|
|
|
|
|
|
(require 'use-package) |
|
|
|
|
|
|
|
|
|
(add-to-list 'load-path "~/.emacs.d/elisp") |
|
|
|
|
(add-to-list 'load-path "~/.emacs.d/elisp/modes") |
|
|
|
|
|
|
|
|
|
(setq custom-file "~/.emacs.d/elisp/custom.el") |
|
|
|
|
(when (file-exists-p custom-file) |
|
|
|
|
(load custom-file)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Load the package.el file |
|
|
|
|
(load-file "~/.emacs.d/package.el") |
|
|
|
|
(load-library "package") |
|
|
|
|
|
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
;; Turn off the startup screen |
|
|
|
@ -113,232 +135,21 @@ There are two things you can do about this warning:
|
|
|
|
|
|
|
|
|
|
(global-auto-revert-mode t) |
|
|
|
|
|
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
;; IBuffer configurations (C-x C-b) |
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
(setq ibuffer-saved-filter-groups |
|
|
|
|
'(("default" |
|
|
|
|
("Emacs Configuration" (or (filename . ".emacs.d") |
|
|
|
|
(filename . "init.el") |
|
|
|
|
(filename . "package.el") |
|
|
|
|
(filename . "private.el") |
|
|
|
|
(filename . "emacs.d"))) |
|
|
|
|
("Org" (or (mode . org-mode) |
|
|
|
|
(filename . "OrgMode"))) |
|
|
|
|
("Magit" (name . "magit")) |
|
|
|
|
("Help" (or (name . "\*Help\*") |
|
|
|
|
(name . "\*Apropos\*") |
|
|
|
|
(name . "\*info\*"))) |
|
|
|
|
("Dired" (mode . dired-mode)) |
|
|
|
|
;; Dev has groups for all languages you program in |
|
|
|
|
("Dev" (or |
|
|
|
|
(filename . ".c") |
|
|
|
|
(filename . ".cpp") |
|
|
|
|
(filename . ".hpp") |
|
|
|
|
(filename . ".h") |
|
|
|
|
(filename . ".java") |
|
|
|
|
(filename . ".py") |
|
|
|
|
(filename . ".lisp") |
|
|
|
|
(filename . ".properties") |
|
|
|
|
(filename . ".gradle") |
|
|
|
|
(filename . ".am") |
|
|
|
|
(mode . yaml-mode)) |
|
|
|
|
) |
|
|
|
|
("Text" (or (filename . ".csv") |
|
|
|
|
(filename . ".tsv") |
|
|
|
|
(filename . ".txt") |
|
|
|
|
(filename . ".log") |
|
|
|
|
(filename . ".json"))) |
|
|
|
|
|
|
|
|
|
("Emacs" (or (name . "^\\*scratch\\*$") |
|
|
|
|
(name . "^\\*Messages\\*$"))) |
|
|
|
|
("Gnus" (or (mode . message-mode) |
|
|
|
|
(mode . bbdb-mode) |
|
|
|
|
(mode . mail-mode) |
|
|
|
|
(mode . gnus-group-mode) |
|
|
|
|
(mode . gnus-summary-mode) |
|
|
|
|
(mode . gnus-article-mode) |
|
|
|
|
(name . "^\\.bbdb$") |
|
|
|
|
(name . "^\\.newsrc-dribble"))) |
|
|
|
|
))) |
|
|
|
|
|
|
|
|
|
;; Automatically keep buffers up to date and load the filter |
|
|
|
|
(add-hook 'ibuffer-mode-hook |
|
|
|
|
'(lambda () |
|
|
|
|
(ibuffer-auto-mode 1) |
|
|
|
|
(ibuffer-switch-to-saved-filter-groups "default"))) |
|
|
|
|
|
|
|
|
|
;; Disable eager line numbering |
|
|
|
|
(add-hook 'ibuffer-mode-hook 'nolinum) |
|
|
|
|
|
|
|
|
|
(setq ibuffer-expert t) |
|
|
|
|
|
|
|
|
|
(setq ibuffer-show-empty-filter-groups nil) |
|
|
|
|
(load-library "ibuffer-settings.el") |
|
|
|
|
|
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
;; Default modes |
|
|
|
|
;; Modes |
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
(require 'use-package) |
|
|
|
|
|
|
|
|
|
(ivy-mode 1) |
|
|
|
|
|
|
|
|
|
(setq ivy-use-virtual-buffers t) |
|
|
|
|
(setq enable-recursive-minibuffers t) |
|
|
|
|
|
|
|
|
|
;; Configure ivy to be similar to flx-ido. |
|
|
|
|
(setq ivy-re-builders-alist |
|
|
|
|
'((t . ivy--regex-plus))) |
|
|
|
|
|
|
|
|
|
(setq ivy-initial-inputs-alist nil) |
|
|
|
|
|
|
|
|
|
;; Enable column numbers |
|
|
|
|
(column-number-mode 1) |
|
|
|
|
|
|
|
|
|
;; Enable paredit for lisp |
|
|
|
|
(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t) |
|
|
|
|
(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode) |
|
|
|
|
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode) |
|
|
|
|
(add-hook 'ielm-mode-hook #'enable-paredit-mode) |
|
|
|
|
(add-hook 'lisp-mode-hook #'enable-paredit-mode) |
|
|
|
|
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode) |
|
|
|
|
(add-hook 'scheme-mode-hook #'enable-paredit-mode) |
|
|
|
|
|
|
|
|
|
(require 'rainbow-delimiters) |
|
|
|
|
|
|
|
|
|
(add-hook 'clojure-mode-hook 'rainbow-delimiters-mode) |
|
|
|
|
(add-hook 'lisp-mode-hook 'rainbow-delimiters-mode) |
|
|
|
|
(add-hook 'scheme-mode-hook 'rainbow-delimiters-mode) |
|
|
|
|
(add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode) |
|
|
|
|
|
|
|
|
|
;; Only enable aggressive indent on lisp-likes |
|
|
|
|
(add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode) |
|
|
|
|
(add-hook 'lisp-mode-hook #'aggressive-indent-mode) |
|
|
|
|
(add-hook 'scheme-mode-hook #'aggressive-indent-mode) |
|
|
|
|
(add-hook 'clojure-mode-hook #'aggressive-indent-mode) |
|
|
|
|
|
|
|
|
|
;; Slime - requires SBCL to be installed in /usr/local/bin/ (default for the install.sh |
|
|
|
|
;; script) |
|
|
|
|
|
|
|
|
|
(setq inferior-lisp-program "sbcl") |
|
|
|
|
(setq slime-contribs '(slime-fancy)) |
|
|
|
|
|
|
|
|
|
;; Enable semantic for language-aware editing commands |
|
|
|
|
(setq semantic-mode 't) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Enable company mode |
|
|
|
|
(add-hook 'after-init-hook 'global-company-mode) |
|
|
|
|
|
|
|
|
|
;; Globally enable flycheck |
|
|
|
|
(add-hook 'after-init-hook #'global-flycheck-mode) |
|
|
|
|
|
|
|
|
|
;; LSP |
|
|
|
|
(use-package lsp-mode |
|
|
|
|
:ensure t |
|
|
|
|
:hook ((python-mode . lsp-deferred) |
|
|
|
|
(c-mode . lsp-deferred) |
|
|
|
|
(ruby-mode . lsp-deferred)) |
|
|
|
|
:commands (lsp lsp-deferred)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(use-package lsp-ui |
|
|
|
|
:ensure t |
|
|
|
|
:hook (lsp-mode . lsp-ui-mode)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;; PYTHON ;;;;;;;;;;;;;;;;;; |
|
|
|
|
;; |
|
|
|
|
;; NOTES: |
|
|
|
|
;; |
|
|
|
|
;; - For each project you will need to install flake8/autopep8 into the virtualenv |
|
|
|
|
;; - For each project you will need to install jedi into the virtualenv |
|
|
|
|
;; - To set your pyenv use M-x pyenv-mode and select your local virtualenv |
|
|
|
|
;; |
|
|
|
|
;; |
|
|
|
|
|
|
|
|
|
;; thx rakan.me |
|
|
|
|
(defun pyenv-activate-current-project () |
|
|
|
|
"Automatically activates pyenv version if .python-version file exists." |
|
|
|
|
(interactive) |
|
|
|
|
(f-traverse-upwards |
|
|
|
|
(lambda (path) |
|
|
|
|
(message path) |
|
|
|
|
(let ((pyenv-version-path (f-expand ".python-version" path))) |
|
|
|
|
(if (f-exists? pyenv-version-path) |
|
|
|
|
(let ((pyenv-current-version (s-trim (f-read-text pyenv-version-path 'utf-8)))) |
|
|
|
|
(pyenv-mode-set pyenv-current-version) |
|
|
|
|
(message (concat "Setting virtualenv to " pyenv-current-version)))))))) |
|
|
|
|
|
|
|
|
|
;; For Python enable Elpy. |
|
|
|
|
(use-package elpy |
|
|
|
|
:ensure t |
|
|
|
|
:init (elpy-enable)) |
|
|
|
|
|
|
|
|
|
(setq elpy-rpc-backend "jedi") |
|
|
|
|
(setq jedi:complete-on-dot t) |
|
|
|
|
|
|
|
|
|
;; Enable pyenv integration. |
|
|
|
|
(use-package pyenv-mode |
|
|
|
|
:config |
|
|
|
|
(pyenv-mode)) |
|
|
|
|
|
|
|
|
|
;; Disable elpy default virtualenv (use the pyenv one) |
|
|
|
|
(setq elpy-rpc-virtualenv-path 'current) |
|
|
|
|
|
|
|
|
|
;; Enable autopep8 |
|
|
|
|
|
|
|
|
|
(require 'py-autopep8) |
|
|
|
|
|
|
|
|
|
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save) |
|
|
|
|
(load-library "default-modes") |
|
|
|
|
(load-library "lisp-mode-settings") |
|
|
|
|
(load-library "python-mode-settings") |
|
|
|
|
(load-library "ruby-mode-settings") |
|
|
|
|
(load-library "c-mode-settings") |
|
|
|
|
|
|
|
|
|
;; Enable flake8 - requires flake8 in your path so use pyenv/global pip install |
|
|
|
|
(add-hook 'python-mode-hook '(lambda () |
|
|
|
|
(setq flycheck-python-flake8-executable "flake8") |
|
|
|
|
(flycheck-select-checker 'python-flake8) |
|
|
|
|
(flycheck-mode t))) |
|
|
|
|
|
|
|
|
|
;; Activate pyenv automatically if a .python-version is supplied |
|
|
|
|
(add-hook 'python-mode-hook 'pyenv-activate-current-project) |
|
|
|
|
|
|
|
|
|
;; Add company-jedi hook to python mode |
|
|
|
|
(add-hook 'python-mode-hook (lambda () |
|
|
|
|
(add-to-list 'company-backends 'company-jedi))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Use microsoft's python language server |
|
|
|
|
(add-hook 'python-mode-hook (lambda () (lsp-python-enable))) |
|
|
|
|
(require 'lsp-python-ms) |
|
|
|
|
(use-package lsp-python-ms |
|
|
|
|
:ensure t |
|
|
|
|
:init (setq lsp-python-ms-auto-install-server t) |
|
|
|
|
:hook (python-mode . (lambda () |
|
|
|
|
(require 'lsp-python-ms) |
|
|
|
|
(lsp)))) ; or lsp-deferred |
|
|
|
|
|
|
|
|
|
;; Python testing helpers |
|
|
|
|
(use-package python-pytest) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RUBY ;;;;;;;;;;;;;;;;;; |
|
|
|
|
|
|
|
|
|
(require 'rvm) |
|
|
|
|
(rvm-use-default) |
|
|
|
|
|
|
|
|
|
(advice-add 'inf-ruby-console-auto :before #'rvm-activate-corresponding-ruby) |
|
|
|
|
|
|
|
|
|
;;;;;;;;;;; C/C++ |
|
|
|
|
|
|
|
|
|
(use-package clang-format+) |
|
|
|
|
(use-package counsel-gtags) |
|
|
|
|
|
|
|
|
|
(add-hook 'c-mode-common-hook #'clang-format+-mode) |
|
|
|
|
(add-hook 'c-mode-hook 'counsel-gtags-mode) |
|
|
|
|
(add-hook 'c++-mode-hook 'counsel-gtags-mode) |
|
|
|
|
|
|
|
|
|
;; 4 space offset for c |
|
|
|
|
(setq-default c-basic-offset 4) |
|
|
|
|
|
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
;; Save hooks |
|
|
|
@ -351,94 +162,10 @@ There are two things you can do about this warning:
|
|
|
|
|
;; Keybinds |
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
;; <f1> is a mode bind for compile/eval based on language |
|
|
|
|
(global-unset-key (kbd "<f1>")) |
|
|
|
|
|
|
|
|
|
(global-unset-key (kbd "<f2>")) |
|
|
|
|
|
|
|
|
|
;; Load up swiper search with C-s |
|
|
|
|
(global-set-key "\C-s" 'swiper) |
|
|
|
|
|
|
|
|
|
;; High powered fuzzy searching for large projects using |
|
|
|
|
;; projectile--find-file. |
|
|
|
|
(global-set-key (kbd "C-x f") 'projectile--find-file) |
|
|
|
|
|
|
|
|
|
;; Ivy |
|
|
|
|
(global-set-key (kbd "C-c C-r") 'ivy-resume) |
|
|
|
|
|
|
|
|
|
;; Switch windows with M-o |
|
|
|
|
(global-set-key (kbd "M-o") 'other-window) |
|
|
|
|
|
|
|
|
|
;; Bind pytest in python mode to M-p |
|
|
|
|
(define-key python-mode-map (kbd "M-p") 'python-pytest-file) |
|
|
|
|
|
|
|
|
|
;; Git - Magit |
|
|
|
|
(global-set-key (kbd "C-x g") 'magit-status) |
|
|
|
|
|
|
|
|
|
;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lisp Binds ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
|
|
|
|
|
|
|
;; Note: SLIME bindings require slime to be running. |
|
|
|
|
|
|
|
|
|
;; Press <f1> in lisp mode to evaluate the buffer in SLIME |
|
|
|
|
(define-key lisp-mode-map (kbd "<f1>") 'slime-eval-buffer) |
|
|
|
|
|
|
|
|
|
;; Press <f2> in lisp mode to evaluate the current defun in SLIME. |
|
|
|
|
(define-key lisp-mode-map (kbd "<f2>") 'slime-eval-defun) |
|
|
|
|
|
|
|
|
|
;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(with-eval-after-load 'counsel-gtags |
|
|
|
|
(define-key counsel-gtags-mode-map (kbd "M-t") 'counsel-gtags-find-definition) |
|
|
|
|
(define-key counsel-gtags-mode-map (kbd "M-r") 'counsel-gtags-find-reference) |
|
|
|
|
(define-key counsel-gtags-mode-map (kbd "M-s") 'counsel-gtags-find-symbol) |
|
|
|
|
(define-key counsel-gtags-mode-map (kbd "M-,") 'counsel-gtags-go-backward)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
;; Install and load Packages |
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
(load-file "~/.emacs.d/package.el") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(custom-set-variables |
|
|
|
|
;; custom-set-variables was added by Custom. |
|
|
|
|
;; If you edit it by hand, you could mess it up, so be careful. |
|
|
|
|
;; Your init file should contain only one such instance. |
|
|
|
|
;; If there is more than one, they won't work right. |
|
|
|
|
'(lisp-indent-function 'common-lisp-indent-function) |
|
|
|
|
'(package-selected-packages |
|
|
|
|
'(arjen-grey-theme oceanic-theme company-lsp projectile smex grizzl flycheck-pos-tip flycheck material-theme expand-region wrap-region rainbow-delimiters powerline linum-relative golden-ratio fill-column-indicator autopair exec-path-from-shell ws-butler yaml-mode python-mode protobuf-mode paredit nasm-mode meson-mode markdown-mode magit gradle-mode gitignore-mode feature-mode counsel company-jedi jedi-core company-emacs-eclim company-irony company ag)) |
|
|
|
|
'(safe-local-variable-values |
|
|
|
|
'((eval setq flycheck-command-wrapper-function |
|
|
|
|
(lambda |
|
|
|
|
(command) |
|
|
|
|
(append |
|
|
|
|
'("bundle" "exec") |
|
|
|
|
command)))))) |
|
|
|
|
|
|
|
|
|
(custom-set-faces |
|
|
|
|
;; custom-set-faces was added by Custom. |
|
|
|
|
;; If you edit it by hand, you could mess it up, so be careful. |
|
|
|
|
;; Your init file should contain only one such instance. |
|
|
|
|
;; If there is more than one, they won't work right. |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
;; Autoload the indent function |
|
|
|
|
(autoload 'common-lisp-indent-function "cl-indent" "Common Lisp indent.") |
|
|
|
|
(load-library "keybinds") |
|
|
|
|
|
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
;; Theming |
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
(load-theme 'arjen-grey t) |
|
|
|
|
|
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
;; SLIME Quicklisp Integration |
|
|
|
|
;;-------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
(when (file-exists-p "~/quicklisp/slime-helper.el") |
|
|
|
|
(load (expand-file-name "~/quicklisp/slime-helper.el")) |
|
|
|
|
(setq inferior-lisp-program "sbcl")) |
|
|
|
|