|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; Enable MELPA
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(require 'package)
|
|
|
|
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
|
|
|
|
(not (gnutls-available-p))))
|
|
|
|
(proto (if no-ssl "http" "https")))
|
|
|
|
(when no-ssl
|
|
|
|
(warn "\
|
|
|
|
Your version of Emacs does not support SSL connections,
|
|
|
|
which is unsafe because it allows man-in-the-middle attacks.
|
|
|
|
There are two things you can do about this warning:
|
|
|
|
1. Install an Emacs version that does support SSL and be safe.
|
|
|
|
2. Remove this warning from your init file so you won't see it again."))
|
|
|
|
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
|
|
|
|
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
|
|
|
|
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
|
|
|
|
(when (< emacs-major-version 24)
|
|
|
|
;; For important compatibility libraries like cl-lib
|
|
|
|
(add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
|
|
|
|
(package-initialize)
|
|
|
|
|
|
|
|
(add-to-list 'package-archives
|
|
|
|
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
|
|
|
|
|
|
|
|
;; This will force any out of date packages to update automatically
|
|
|
|
(when (not package-archive-contents)
|
|
|
|
(package-refresh-contents))
|
|
|
|
|
|
|
|
;; Bootstrap use-package if it doesn't exist
|
|
|
|
(when (not (package-installed-p 'use-package))
|
|
|
|
(package-refresh-contents)
|
|
|
|
(package-install 'use-package))
|
|
|
|
|
|
|
|
(require 'use-package)
|
|
|
|
|
|
|
|
;; Load the package.el file
|
|
|
|
(load-file "~/.emacs.d/package.el")
|
|
|
|
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; Turn off the startup screen
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(setq inhibit-startup-screen t)
|
|
|
|
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; Display battery life in modeline
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(display-battery-mode 1)
|
|
|
|
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; Always follow symbolic links to version controlled files
|
|
|
|
;;
|
|
|
|
;; I prefer this option because I generally only get this message when I edit
|
|
|
|
;; a dotfile under version control, and repeatedly typing "yes" is annoying.
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(setq vc-follow-symlinks t)
|
|
|
|
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; Enable Org-mode and set agenda files
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(require 'org)
|
|
|
|
|
|
|
|
;; Stuff all of the org files you want under ~/org and they will be loaded automatically
|
|
|
|
;; and have their TODO items accessible by typing C-c a t
|
|
|
|
(setq org-agenda-files '("~/org"))
|
|
|
|
(setq org-log-done t)
|
|
|
|
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; Prefer unix style line endings
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(set-buffer-file-coding-system 'unix)
|
|
|
|
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; Populate emacs path to $PATH when on *nix or OS X
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(when (memq window-system '(mac ns x))
|
|
|
|
(exec-path-from-shell-initialize))
|
|
|
|
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; Enable auto-refresh to keep buffers up to date when git or another program
|
|
|
|
;; modifies them
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(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 (mode . cc-mode)
|
|
|
|
(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)
|
|
|
|
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; Default modes
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(require 'use-package)
|
|
|
|
|
|
|
|
(ivy-mode 1)
|
|
|
|
|
|
|
|
;; 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)
|
|
|
|
|
|
|
|
;; 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)
|
|
|
|
|
|
|
|
(add-hook 'ruby-mode-hook 'robe-mode)
|
|
|
|
|
|
|
|
(eval-after-load 'company
|
|
|
|
'(push 'company-robe company-backends))
|
|
|
|
|
|
|
|
(add-hook 'robe-mode-hook 'ac-robe-setup)
|
|
|
|
|
|
|
|
(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
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
|
|
|
|
|
|
|
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; 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)
|
|
|
|
|
|
|
|
;; 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)
|
|
|
|
|
|
|
|
;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 (quote common-lisp-indent-function))
|
|
|
|
'(package-selected-packages
|
|
|
|
(quote
|
|
|
|
(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))))
|
|
|
|
|
|
|
|
(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.")
|
|
|
|
|
|
|
|
;;--------------------------------------------------------------------------------------
|
|
|
|
;; 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"))
|