From 6bd093ebf70dfc589ca1c28c73cff51d4e93bcd1 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Fri, 9 Oct 2020 09:40:50 -0700 Subject: [PATCH] Modularize emacs folder --- dotfiles/emacs.d/elisp/custom.el | 32 ++ dotfiles/emacs.d/elisp/ibuffer-settings.el | 65 ++++ dotfiles/emacs.d/elisp/keybinds.el | 42 +++ dotfiles/emacs.d/elisp/modes/c-mode-settings.el | 11 + dotfiles/emacs.d/elisp/modes/default-modes.el | 44 +++ dotfiles/emacs.d/elisp/modes/lisp-mode-settings.el | 40 +++ .../emacs.d/elisp/modes/python-mode-settings.el | 71 +++++ dotfiles/emacs.d/elisp/modes/ruby-mode-settings.el | 6 + dotfiles/emacs.d/elisp/package.el | 125 ++++++++ dotfiles/emacs.d/init.el | 335 ++------------------- dotfiles/emacs.d/package.el | 125 -------- 11 files changed, 467 insertions(+), 429 deletions(-) create mode 100644 dotfiles/emacs.d/elisp/custom.el create mode 100644 dotfiles/emacs.d/elisp/ibuffer-settings.el create mode 100644 dotfiles/emacs.d/elisp/keybinds.el create mode 100644 dotfiles/emacs.d/elisp/modes/c-mode-settings.el create mode 100644 dotfiles/emacs.d/elisp/modes/default-modes.el create mode 100644 dotfiles/emacs.d/elisp/modes/lisp-mode-settings.el create mode 100644 dotfiles/emacs.d/elisp/modes/python-mode-settings.el create mode 100644 dotfiles/emacs.d/elisp/modes/ruby-mode-settings.el create mode 100644 dotfiles/emacs.d/elisp/package.el delete mode 100644 dotfiles/emacs.d/package.el diff --git a/dotfiles/emacs.d/elisp/custom.el b/dotfiles/emacs.d/elisp/custom.el new file mode 100644 index 0000000..81a994f --- /dev/null +++ b/dotfiles/emacs.d/elisp/custom.el @@ -0,0 +1,32 @@ +;;; custom.el --- A special place to shove the custom-set-variable code that emacs 25.1 +;;; insists on using for package management. +;;; +;;; Commentary: +;;; +;;; These variables are used by the package manager to handle dependencies. As a result, +;;; they are necessary. This file exists in order to move this rather noisy section out +;;; of the init.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. + ) diff --git a/dotfiles/emacs.d/elisp/ibuffer-settings.el b/dotfiles/emacs.d/elisp/ibuffer-settings.el new file mode 100644 index 0000000..b42bb93 --- /dev/null +++ b/dotfiles/emacs.d/elisp/ibuffer-settings.el @@ -0,0 +1,65 @@ +;;; ibuffer-settings.el --- Settings for ibuffer. +;;; +;;; Commentary: +;;; +;;; Use C-x C-b to launch ibuffer. + + +(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) diff --git a/dotfiles/emacs.d/elisp/keybinds.el b/dotfiles/emacs.d/elisp/keybinds.el new file mode 100644 index 0000000..da5f5f9 --- /dev/null +++ b/dotfiles/emacs.d/elisp/keybinds.el @@ -0,0 +1,42 @@ +;; is a mode bind for compile/eval based on language +(global-unset-key (kbd "")) + +(global-unset-key (kbd "")) + +;; 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 in lisp mode to evaluate the buffer in SLIME +(define-key lisp-mode-map (kbd "") 'slime-eval-buffer) + +;; Press in lisp mode to evaluate the current defun in SLIME. +(define-key lisp-mode-map (kbd "") '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)) diff --git a/dotfiles/emacs.d/elisp/modes/c-mode-settings.el b/dotfiles/emacs.d/elisp/modes/c-mode-settings.el new file mode 100644 index 0000000..9581567 --- /dev/null +++ b/dotfiles/emacs.d/elisp/modes/c-mode-settings.el @@ -0,0 +1,11 @@ +;;; c-mode-settings.el --- Settings for c modes. + +(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) diff --git a/dotfiles/emacs.d/elisp/modes/default-modes.el b/dotfiles/emacs.d/elisp/modes/default-modes.el new file mode 100644 index 0000000..0dae69b --- /dev/null +++ b/dotfiles/emacs.d/elisp/modes/default-modes.el @@ -0,0 +1,44 @@ +;;; default-modes.el --- Sets default mode configurations. +;;; +;;; Commentary: +;;; +;;; This package breaks out mode setting commands that are general +;;; to the configuration of emacs itself. Other specific mode +;;; settings are placed in a corresponding elisp file in this +;;; folder. + +(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 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)) diff --git a/dotfiles/emacs.d/elisp/modes/lisp-mode-settings.el b/dotfiles/emacs.d/elisp/modes/lisp-mode-settings.el new file mode 100644 index 0000000..614c647 --- /dev/null +++ b/dotfiles/emacs.d/elisp/modes/lisp-mode-settings.el @@ -0,0 +1,40 @@ +;;; lisp-mode-settings.el --- Settings for lisp modes. + +;; 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 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) + +;; Autoload the indent function +(autoload 'common-lisp-indent-function "cl-indent" "Common Lisp indent.") + +;;-------------------------------------------------------------------------------------- +;; SLIME Quicklisp Integration +;;-------------------------------------------------------------------------------------- + +(when (file-exists-p "~/quicklisp/slime-helper.el") + (load (expand-file-name "~/quicklisp/slime-helper.el")) + (setq inferior-lisp-program "sbcl")) diff --git a/dotfiles/emacs.d/elisp/modes/python-mode-settings.el b/dotfiles/emacs.d/elisp/modes/python-mode-settings.el new file mode 100644 index 0000000..441e795 --- /dev/null +++ b/dotfiles/emacs.d/elisp/modes/python-mode-settings.el @@ -0,0 +1,71 @@ +;;; python-mode-settings.el --- Defines mode settings for python. +;;; +;;; Commentary: +;;; +;;; +;;; - 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) diff --git a/dotfiles/emacs.d/elisp/modes/ruby-mode-settings.el b/dotfiles/emacs.d/elisp/modes/ruby-mode-settings.el new file mode 100644 index 0000000..2ab0623 --- /dev/null +++ b/dotfiles/emacs.d/elisp/modes/ruby-mode-settings.el @@ -0,0 +1,6 @@ +;;; ruby-mode-settings.el --- Settings for ruby mode. + +(require 'rvm) +(rvm-use-default) + +(advice-add 'inf-ruby-console-auto :before #'rvm-activate-corresponding-ruby) diff --git a/dotfiles/emacs.d/elisp/package.el b/dotfiles/emacs.d/elisp/package.el new file mode 100644 index 0000000..335ea39 --- /dev/null +++ b/dotfiles/emacs.d/elisp/package.el @@ -0,0 +1,125 @@ +(require 'cl) + +(defvar my-packages '(ag + ;; Completion Frameworks + company + company-irony + company-emacs-eclim + jedi-core + + ;; We don't need the `jedi` package + ;; since we are using company. If we + ;; include both we get an annoying + ;; *Python Completions* buffer that + ;; isn't useful to us. + company-jedi + + eclim + irony + ivy + counsel + swiper + + ;; LSP is compatible with company and the lsp-ui gives a + ;; vscode-like experience. + lsp-mode + lsp-ui + lsp-python-ms + ;;;;;;;;;;;;;;;;;;;;;;;; + + cmake-ide + cmake-mode + clang-format+ + + ;;;;;;;;;;;;;;;;;;;;;;;; + + ;; Programming modes + feature-mode + gitignore-mode + gradle-mode + magit + markdown-mode + meson-mode + nasm-mode + paredit + protobuf-mode + elpy + yaml-mode + slime + + ;; Rails + rinari + + ;; RVM support + rvm + ;;;;;;;;;;;;;;;;;;;; + + ;; Test helpers + python-pytest + + ;; Cleanup + ws-butler + ;;;;;;;;;; + + ;; Shell helpers + exec-path-from-shell + ;;;;;;;;;;;;;;;;;;;; + + ;; Editing Utility + autopair + + ;; Keeps things indented even when you don't want it to + aggressive-indent + ;;;;;;;;;;;;;;;;;; + + ;; UI + fill-column-indicator + golden-ratio + linum-relative + powerline + rainbow-delimiters + wrap-region + expand-region + wrap-region + material-theme + oceanic-theme + arjen-grey-theme + ;;;;; + + ;; Project Interaction/Search/Syntax + flycheck + flycheck-pos-tip + flycheck-rtags + flx + smex + projectile + counsel-gtags + rtags + company-rtags + + ;; Environments + pyenv-mode + + ;; Python specific stuff + py-autopep8 + + ;;General + use-package + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ) + "Packages to make sure are installed") + +(defun my-packages-installed-p () + (loop for p in my-packages + when (not (package-installed-p p)) do (return nil) + finally (return t))) + +(unless (my-packages-installed-p) + ;; check for new packages (package versions) + (package-refresh-contents) + ;; install the missing packages + (dolist (p my-packages) + (when (not (package-installed-p p)) + (package-install p)))) diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index 0bd92a2..d74f63e 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -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 ;;-------------------------------------------------------------------------------------- -;; is a mode bind for compile/eval based on language -(global-unset-key (kbd "")) - -(global-unset-key (kbd "")) - -;; 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 in lisp mode to evaluate the buffer in SLIME -(define-key lisp-mode-map (kbd "") 'slime-eval-buffer) - -;; Press in lisp mode to evaluate the current defun in SLIME. -(define-key lisp-mode-map (kbd "") '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")) diff --git a/dotfiles/emacs.d/package.el b/dotfiles/emacs.d/package.el deleted file mode 100644 index 335ea39..0000000 --- a/dotfiles/emacs.d/package.el +++ /dev/null @@ -1,125 +0,0 @@ -(require 'cl) - -(defvar my-packages '(ag - ;; Completion Frameworks - company - company-irony - company-emacs-eclim - jedi-core - - ;; We don't need the `jedi` package - ;; since we are using company. If we - ;; include both we get an annoying - ;; *Python Completions* buffer that - ;; isn't useful to us. - company-jedi - - eclim - irony - ivy - counsel - swiper - - ;; LSP is compatible with company and the lsp-ui gives a - ;; vscode-like experience. - lsp-mode - lsp-ui - lsp-python-ms - ;;;;;;;;;;;;;;;;;;;;;;;; - - cmake-ide - cmake-mode - clang-format+ - - ;;;;;;;;;;;;;;;;;;;;;;;; - - ;; Programming modes - feature-mode - gitignore-mode - gradle-mode - magit - markdown-mode - meson-mode - nasm-mode - paredit - protobuf-mode - elpy - yaml-mode - slime - - ;; Rails - rinari - - ;; RVM support - rvm - ;;;;;;;;;;;;;;;;;;;; - - ;; Test helpers - python-pytest - - ;; Cleanup - ws-butler - ;;;;;;;;;; - - ;; Shell helpers - exec-path-from-shell - ;;;;;;;;;;;;;;;;;;;; - - ;; Editing Utility - autopair - - ;; Keeps things indented even when you don't want it to - aggressive-indent - ;;;;;;;;;;;;;;;;;; - - ;; UI - fill-column-indicator - golden-ratio - linum-relative - powerline - rainbow-delimiters - wrap-region - expand-region - wrap-region - material-theme - oceanic-theme - arjen-grey-theme - ;;;;; - - ;; Project Interaction/Search/Syntax - flycheck - flycheck-pos-tip - flycheck-rtags - flx - smex - projectile - counsel-gtags - rtags - company-rtags - - ;; Environments - pyenv-mode - - ;; Python specific stuff - py-autopep8 - - ;;General - use-package - - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - ) - "Packages to make sure are installed") - -(defun my-packages-installed-p () - (loop for p in my-packages - when (not (package-installed-p p)) do (return nil) - finally (return t))) - -(unless (my-packages-installed-p) - ;; check for new packages (package versions) - (package-refresh-contents) - ;; install the missing packages - (dolist (p my-packages) - (when (not (package-installed-p p)) - (package-install p))))