├── snippets ├── .nosearch ├── python-mode │ ├── .yas-parents │ └── .yas-setup.el ├── .gitignore └── rename_add_contr.py ├── screenshot.png ├── lang ├── lang-solidity.el ├── lang-elixir.el ├── lang-web.el ├── lang-go.el ├── lang-rust.el ├── lang-javascript.el ├── lang-c.el └── lang-python.el ├── config ├── config-aliases.el ├── config-ivy.el ├── config-keys.el ├── config-dired.el ├── config-org.el ├── config-ui.el ├── config-base.el ├── config-shell.el ├── config-hydra.el ├── config-functions.el └── config-extensions.el ├── .gitignore ├── README.md ├── init.el ├── custom_keys.org └── emacs-logo.svg /snippets/.nosearch: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /snippets/python-mode/.yas-parents: -------------------------------------------------------------------------------- 1 | prog-mode 2 | -------------------------------------------------------------------------------- /snippets/.gitignore: -------------------------------------------------------------------------------- 1 | **/.yas-compiled-snippets.el 2 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rakanalh/dotemacs/HEAD/screenshot.png -------------------------------------------------------------------------------- /lang/lang-solidity.el: -------------------------------------------------------------------------------- 1 | (use-package solidity-mode 2 | :mode ("\\.sol" . solidity-mode) 3 | :config 4 | (push 'solidity-mode irony-supported-major-modes)) 5 | 6 | (provide 'lang-solidity) 7 | -------------------------------------------------------------------------------- /lang/lang-elixir.el: -------------------------------------------------------------------------------- 1 | (use-package alchemist 2 | :config 3 | (add-hook 'elixir-mode-hook 'alchemist-mode)) 4 | 5 | (use-package flycheck-elixir) 6 | 7 | (use-package flycheck-mix 8 | :commands (flycheck-mix-setup)) 9 | 10 | (use-package elixir-mode) 11 | 12 | (provide 'lang-elixir) 13 | -------------------------------------------------------------------------------- /config/config-aliases.el: -------------------------------------------------------------------------------- 1 | ; elisp 2 | (defalias 'eb 'eval-buffer) 3 | (defalias 'er 'eval-region) 4 | (defalias 'lf 'load-file) 5 | 6 | (defalias 'rg 'rgrep) 7 | 8 | (defalias 'cr 'comment-region) 9 | (defalias 'ucr' 'uncomment-region) 10 | (defalias 'plp 'package-list-packages) 11 | 12 | (provide 'config-aliases) 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .python-environments/ 3 | .emacs.desktop* 4 | .custom.el 5 | .cask 6 | .local 7 | .mc-lists.el 8 | ac-comphist.dat 9 | auto-save-list/ 10 | elpa/ 11 | eshell/ 12 | init-elpy-experiment 13 | init_bash.sh 14 | places 15 | projectile-bookmarks.eld 16 | recentf 17 | private/ 18 | vendor/ 19 | irony 20 | todo.org -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |

GNU Emacs

3 |

4 | 5 | 6 | 7 |

8 | 9 | My emacs configurations. 10 | 11 | ![screenshot](https://github.com/rakanalh/dotemacs/raw/master/screenshot.png?cache=0 "Screenshot") 12 | 13 | Theme: [Doom Theme](https://github.com/hlissner/emacs-doom-theme) 14 | -------------------------------------------------------------------------------- /lang/lang-web.el: -------------------------------------------------------------------------------- 1 | (use-package web-mode 2 | :mode 3 | ("\\.html$" . web-mode) 4 | ("\\.phtml$" . web-mode) 5 | ("\\.mustache$" . web-mode) 6 | ("\\.djhtml$" . web-mode) 7 | :config 8 | (setq web-mode-markup-indent-offset 2 9 | web-mode-css-indent-offset 2 10 | web-mode-code-indent-offset 2 11 | web-mode-enable-current-element-highlight t 12 | web-mode-engines-alist '(("django" . "\\\\.html\\\\'")))) 13 | ;(add-hook 'web-mode-hook #'js2-minor-mode)) 14 | 15 | (use-package company-web 16 | :config 17 | (add-hook 'web-mode-hook (lambda () 18 | (set (make-local-variable 'company-backends) '(company-web-html)) 19 | (company-mode t)))) 20 | ;; (defun my-web-mode-hook () 21 | ;; "Hook for `web-mode'." 22 | ;; (set (make-local-variable 'company-backends) 23 | ;; '(company-tern company-web-html company-yasnippet company-files))) 24 | 25 | ;; (add-hook 'web-mode-hook 'my-web-mode-hook)) 26 | 27 | (provide 'lang-web) 28 | -------------------------------------------------------------------------------- /snippets/rename_add_contr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import re 4 | from os.path import join 5 | from shutil import move 6 | 7 | 8 | def rename(root, f): 9 | if f.endswith('.yasnippet'): 10 | base, _ = f.split('.') 11 | print("move %s to %s" % (join(root, f), join(root, base))) 12 | move(join(root, f), join(root, base)) 13 | 14 | 15 | CONT = "# contributor: Andrea crotti\n# --" 16 | END = "# --\n\n" 17 | 18 | orig = "# --\n\n" 19 | to = "# --\n" 20 | 21 | def insert(root, f, orig, to): 22 | fname = join(root, f) 23 | text = open(fname).read() 24 | nex_text = re.sub(orig, to, text) 25 | open(fname, 'w').write(nex_text) 26 | 27 | if __name__ == '__main__': 28 | for root, dirs, files in os.walk('.'): 29 | if "mode" in root: 30 | # os.popen("git add *yasnippet") 31 | for f in files: 32 | rename(root, f) 33 | # insert(root, f, orig, to) 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /snippets/python-mode/.yas-setup.el: -------------------------------------------------------------------------------- 1 | (defun python-split-args (arg-string) 2 | "Split a python argument string into ((name, default)..) tuples" 3 | (mapcar (lambda (x) 4 | (split-string x "[[:blank:]]*=[[:blank:]]*" t)) 5 | (split-string arg-string "[[:blank:]]*,[[:blank:]]*" t))) 6 | 7 | (defun python-args-to-docstring () 8 | "return docstring format for the python arguments in yas-text" 9 | (let* ((indent (concat "\n" (make-string (current-column) 32))) 10 | (args (python-split-args yas-text)) 11 | (max-len (if args (apply 'max (mapcar (lambda (x) (length (nth 0 x))) args)) 0)) 12 | (formatted-args (mapconcat 13 | (lambda (x) 14 | (concat (nth 0 x) (make-string (- max-len (length (nth 0 x))) ? ) " -- " 15 | (if (nth 1 x) (concat "\(default " (nth 1 x) "\)")))) 16 | args 17 | indent))) 18 | (unless (string= formatted-args "") 19 | (mapconcat 'identity (list "Keyword Arguments:" formatted-args) indent)))) 20 | 21 | (add-hook 'python-mode-hook 22 | '(lambda () (set (make-local-variable 'yas-indent-line) 'fixed))) 23 | -------------------------------------------------------------------------------- /init.el: -------------------------------------------------------------------------------- 1 | ;;; package --- Main init file 2 | ;;; Commentary: 3 | ;;; This is my init file 4 | 5 | ;;; Code: 6 | 7 | 8 | ;; Added by Package.el. This must come before configurations of 9 | ;; installed packages. Don't delete this line. If you don't want it, 10 | ;; just comment it out by adding a semicolon to the start of the line. 11 | ;; You may delete these explanatory comments. 12 | 13 | 14 | ;; Added by Package.el. This must come before configurations of 15 | ;; installed packages. Don't delete this line. If you don't want it, 16 | ;; just comment it out by adding a semicolon to the start of the line. 17 | ;; You may delete these explanatory comments. 18 | 19 | ;;(package-initialize) 20 | 21 | (add-to-list 'load-path (concat user-emacs-directory "config")) 22 | (add-to-list 'load-path (concat user-emacs-directory "lang")) 23 | (add-to-list 'load-path "~/.emacs.d/vendor/") 24 | (add-to-list 'load-path "~/.emacs.d/vendor/greview") 25 | 26 | (require 'config-base) 27 | (require 'config-org) 28 | (require 'config-extensions) 29 | (require 'config-ivy) 30 | (require 'config-hydra) 31 | (require 'config-functions) 32 | (require 'config-dired) 33 | ;;(require 'config-shell) 34 | (require 'config-aliases) 35 | (require 'config-keys) 36 | (require 'config-ui) 37 | 38 | (require 'lang-c) 39 | (require 'lang-go) 40 | (require 'lang-javascript) 41 | (require 'lang-python) 42 | (require 'lang-rust) 43 | (require 'lang-solidity) 44 | (require 'lang-web) 45 | (require 'greview) 46 | -------------------------------------------------------------------------------- /config/config-ivy.el: -------------------------------------------------------------------------------- 1 | (use-package ivy 2 | :bind 3 | ("C-c s s" . swiper) 4 | ("C-c r l" . ivy-resume) 5 | ("C-c b b" . ivy-switch-buffer) 6 | ("C-c b o" . ivy-switch-buffer-other-window) 7 | ("C-c b n" . next-buffer) 8 | ("C-c b p" . previous-buffer) 9 | :custom 10 | (ivy-display-style 'fancy) 11 | :config 12 | (ivy-mode 1) 13 | (setq ivy-use-virtual-buffers nil 14 | ivy-count-format "%d/%d ") 15 | (define-key read-expression-map (kbd "C-r") 16 | 'counsel-expression-history)) 17 | 18 | (use-package ivy-pass 19 | :after ivy 20 | :commands ivy-pass) 21 | 22 | (use-package ivy-rich 23 | :after ivy 24 | :config 25 | (defun ivy-rich-switch-buffer-icon (candidate) 26 | (with-current-buffer 27 | (get-buffer candidate) 28 | (let ((icon (all-the-icons-icon-for-mode major-mode))) 29 | (if (symbolp icon) 30 | (all-the-icons-icon-for-mode 'fundamental-mode) 31 | icon)))) 32 | (setq ivy-rich--display-transformers-list 33 | '(ivy-switch-buffer 34 | (:columns 35 | ((ivy-rich-switch-buffer-icon :width 2) 36 | (ivy-rich-candidate (:width 30)) 37 | (ivy-rich-switch-buffer-indicators (:width 4 :face error :align right)) 38 | (ivy-rich-switch-buffer-major-mode (:width 12 :face warning)) 39 | (ivy-rich-switch-buffer-project (:width 15 :face success)) 40 | (ivy-rich-switch-buffer-path (:width (lambda (x) (ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.3)))))) 41 | :predicate 42 | (lambda (cand) (get-buffer cand))))) 43 | (ivy-rich-mode 1)) 44 | 45 | (use-package ivy-hydra) 46 | 47 | (use-package ivy-xref 48 | :ensure t 49 | :init (setq xref-show-xrefs-function #'ivy-xref-show-xrefs)) 50 | 51 | (provide 'config-ivy) 52 | -------------------------------------------------------------------------------- /lang/lang-go.el: -------------------------------------------------------------------------------- 1 | ;; REQUIREMENTS: 2 | ;; go get -u golang.org/x/tools/cmd/... 3 | ;; go get -u github.com/rogpeppe/godef 4 | ;; go get -u github.com/nsf/gocode 5 | ;; go get -u github.com/kisielk/errcheck 6 | ;; go get -u github.com/dougm/goflymake 7 | ;; go get -u github.com/golang/lint/golint 8 | 9 | 10 | (use-package go-guru) 11 | (use-package go-mode 12 | :config 13 | ; Use goimports instead of go-fmt 14 | (setq gofmt-command "goimports") 15 | (add-hook 'go-mode-hook 'company-mode) 16 | ;; Call Gofmt before saving 17 | (add-hook 'before-save-hook 'gofmt-before-save) 18 | (add-hook 'go-mode-hook 'setup-go-mode-compile) 19 | (add-hook 'go-mode-hook #'smartparens-mode) 20 | (add-hook 'go-mode-hook #'go-guru-hl-identifier-mode) 21 | (add-hook 'go-mode-hook (lambda () 22 | (setq tab-width 4) 23 | (local-set-key (kbd "C-c C-r") 'go-remove-unused-imports) 24 | (local-set-key (kbd "C-c C-g") 'go-goto-imports) 25 | (set (make-local-variable 'company-backends) '(company-go)) 26 | (company-mode)))) 27 | 28 | (use-package go-errcheck) 29 | 30 | (use-package go-add-tags) 31 | 32 | (use-package company-go 33 | :after go-mode 34 | :bind (:map go-mode-map 35 | ; Godef jump key binding 36 | ("M-." . godef-jump) 37 | ("M-," . pop-tag-mark))) 38 | 39 | (use-package flycheck-gometalinter 40 | :ensure t 41 | :config 42 | (setq flycheck-gometalinter-fast t) 43 | (progn 44 | (flycheck-gometalinter-setup))) 45 | 46 | (use-package go-eldoc 47 | :config 48 | (add-hook 'go-mode-hook 'go-eldoc-setup)) 49 | 50 | (defun setup-go-mode-compile () 51 | ; Customize compile command to run go build 52 | (if (not (string-match "go" compile-command)) 53 | (set (make-local-variable 'compile-command) 54 | "go build -v && go test -v && go vet"))) 55 | 56 | (provide 'lang-go) 57 | -------------------------------------------------------------------------------- /config/config-keys.el: -------------------------------------------------------------------------------- 1 | (setq ns-function-modifier 'control) 2 | ;; Set global keys not specific to a certain package 3 | ;(global-set-key (kbd "M-f") (lambda () (interactive) (forward-word))) 4 | ;(global-set-key (kbd "M-b") (lambda () (interactive) (backward-word))) 5 | (global-set-key (read-kbd-macro "") 'backward-delete-word) 6 | (global-set-key (kbd "C-d") 'delete-word) 7 | 8 | (global-set-key [home] 'smart-beginning-of-line) 9 | (global-set-key "\C-a" 'smart-beginning-of-line) 10 | 11 | (global-set-key (kbd "C-x 2") 'split-window-below-and-switch) 12 | (global-set-key (kbd "C-x 3") 'split-window-right-and-switch) 13 | 14 | (global-set-key (kbd "C-x C-b") 'switch-to-buffer) 15 | 16 | ;; Custom Emacs Shortcuts 17 | ;; Move more quickly 18 | (global-set-key (kbd "C-S-n") (lambda () (interactive) (ignore-errors (forward-line 5)))) 19 | (global-set-key (kbd "C-S-p") (lambda () (interactive) (ignore-errors (forward-line -5)))) 20 | (global-set-key (kbd "C-S-f") (lambda () (interactive) (ignore-errors (forward-char 5)))) 21 | (global-set-key (kbd "C-S-b") (lambda () (interactive) (ignore-errors (backward-char 5)))) 22 | (global-set-key (kbd "M-<") (lambda () (interactive) (beginning-of-buffer-record))) 23 | (global-set-key (kbd "M->") (lambda () (interactive) (end-of-buffer-record))) 24 | (global-set-key (kbd "M-/") (lambda () (interactive) (go-back-to-point))) 25 | (global-set-key (kbd "M-i") (lambda () (interactive) (codenav-prev-definition))) 26 | (global-set-key (kbd "M-k") (lambda () (interactive) (codenav-next-definition))) 27 | (global-set-key (kbd "C-c r f") (lambda () (interactive) (call-interactively 'xref-find-references))) 28 | 29 | ;; iTerm2 30 | (global-set-key (kbd "C-'") 'iterm-focus) 31 | 32 | ;; ag 33 | (global-set-key (kbd "C-x c g") (lambda () (interactive) (call-interactively 'ag))) 34 | 35 | (define-key ctl-x-r-map "b" 'bookmark-jump-or-find-file) 36 | 37 | (provide 'config-keys) 38 | -------------------------------------------------------------------------------- /lang/lang-rust.el: -------------------------------------------------------------------------------- 1 | (use-package rust-mode 2 | :bind (:map rust-mode-map 3 | ("C-c C-f" . nil) 4 | ("C-c C-d" . nil) 5 | ("C-c , f" . rust-format-buffer) 6 | ("C-c , d" . rist-dbg-wrap-or-unwrap))) 7 | 8 | (use-package cargo 9 | :bind (:map cargo-minor-mode-map 10 | ("C-c C-c" . nil) 11 | 12 | ("C-c m e" . 'cargo-process-bench) 13 | ("C-c m b" . 'cargo-process-build) 14 | ("C-c m l" . 'cargo-process-clean) 15 | ("C-c m d" . 'cargo-process-doc) 16 | ("C-c m v" . 'cargo-process-doc-open) 17 | ("C-c m n" . 'cargo-process-new) 18 | ("C-c m i" . 'cargo-process-init) 19 | ("C-c m r" . 'cargo-process-run) 20 | ("C-c m x" . 'cargo-process-run-example) 21 | ("C-c m s" . 'cargo-process-search) 22 | ("C-c m t" . 'cargo-process-test) 23 | ("C-c m u" . 'cargo-process-update) 24 | ("C-c m c" . 'cargo-process-repeat) 25 | ("C-c m f" . 'cargo-process-current-test) 26 | ("C-c m o" . 'cargo-process-current-file-tests) 27 | ("C-c m m" . 'cargo-process-fmt) 28 | ("C-c m k" . 'cargo-process-check) 29 | ("C-c m a" . 'cargo-process-add) 30 | ("C-c m C-S-o" . 'cargo-process-outdated) 31 | ("C-c m C-S-k" . 'cargo-process-clippy) 32 | ("C-c m C-S-d" . 'cargo-process-rm) 33 | ("C-c m C-S-u" . 'cargo-process-upgrade) 34 | ("C-c m C-S-a" . 'cargo-process-audit)) 35 | :hook 36 | (rust-mode . cargo-minor-mode)) 37 | 38 | (use-package flycheck-rust 39 | :custom 40 | (flycheck-rust-check-tests nil) 41 | :hook 42 | (flycheck-mode . flycheck-rust-setup)) 43 | 44 | (use-package racer 45 | :after rust-mode 46 | :hook 47 | (rust-mode . racer-mode) 48 | (racer-mode . eldoc-mode) 49 | (racer-mode . company-mode) 50 | :custom 51 | (racer-cmd (expand-file-name "~/.cargo/bin/racer")) 52 | (company-tooltip-align-annotations t)) 53 | 54 | (use-package company-racer 55 | :custom 56 | (company-racer-executable (expand-file-name "~/.cargo/bin/racer")) 57 | :config 58 | (add-to-list 'company-backends 'company-racer)) 59 | 60 | ;; (use-package rustic 61 | ;; :mode ("\\.rs" . rustic-mode) 62 | ;; :after lsp-mode 63 | ;; :bind (:map rustic-mode-map 64 | ;; ("M-." . xref-find-definitions) 65 | ;; ("M-," . pop-tag-mark)) 66 | ;; :custom 67 | ;; (rustic-format-display-method 'ignore) 68 | ;; (rustic-format-trigger 'on-save)) 69 | 70 | (provide 'lang-rust) 71 | -------------------------------------------------------------------------------- /lang/lang-javascript.el: -------------------------------------------------------------------------------- 1 | ;; Favor local eslint over global, if available 2 | (defun javascript-init-flycheck-eslint () 3 | (when (derived-mode-p 'js2-mode) 4 | (when-let ((eslint (expand-file-name "node_modules/eslint/bin/eslint.js" 5 | (lang-project-root))) 6 | (exists-p (file-exists-p eslint)) 7 | (executable-p (file-executable-p eslint))) 8 | (setq-local flycheck-javascript-eslint-executable eslint)))) 9 | 10 | (defun javascript-init-flycheck () 11 | (setq-default flycheck-disabled-checkers '(javascript-jshint)) 12 | (flycheck-add-mode 'javascript-eslint 'js2-mode) 13 | (add-hook 'flycheck-mode-hook #'javascript-init-flycheck-eslint)) 14 | 15 | (use-package emmet-mode 16 | :init 17 | (add-hook 'js2-mode-hook #'emmet-mode) 18 | :config 19 | (setq emmet-move-cursor-between-quotes t) 20 | (setq emmet-expand-jsx-className? t)) 21 | 22 | (use-package js2-mode 23 | :after flycheck-mode 24 | :mode 25 | ("\\.js$" . js2-mode) 26 | ("\\.jsx$" . js2-jsx-mode) 27 | ("\\.json$" . js2-jsx-mode) 28 | :config 29 | (setq js-indent-level 2 30 | js2-basic-offset 0 31 | js2-bounce-indent-p t) 32 | (add-hook 'js2-mode-hook #'js2-imenu-extras-mode) 33 | (add-hook 'js2-mode-hook #'company-mode) 34 | (define-key js-mode-map (kbd "M-.") nil) 35 | (javascript-init-flycheck)) 36 | 37 | (use-package xref-js2 38 | :init 39 | (add-hook 'js2-mode-hook (lambda () 40 | (add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t))) 41 | :config 42 | (define-key js2-mode-map (kbd "M-.") nil)) 43 | 44 | (use-package tern 45 | :init (add-hook 'js2-mode-hook #'tern-mode) 46 | :config 47 | (advice-add #'tern-project-dir :override #'core*project-root)) 48 | 49 | (use-package company-tern 50 | :config 51 | (defun activate-tern-hook () 52 | "Hook for `js-mode'." 53 | (set (make-local-variable 'company-backends) 54 | '((company-tern company-files)))) 55 | (add-hook 'js2-mode-hook 'activate-tern-hook)) 56 | 57 | (use-package web-beautify) 58 | 59 | (use-package vue-mode 60 | :init 61 | (add-to-list 'auto-mode-alist '("\\.vue\\'" . vue-mode)) 62 | :config 63 | (setq js-indent-level 2 64 | js2-basic-offset 2 65 | js2-bounce-indent-p t 66 | web-mode-markup-indent-offset 2 67 | web-mode-css-indent-offset 2 68 | web-mode-code-indent-offset 2)) 69 | 70 | (provide 'lang-javascript) 71 | -------------------------------------------------------------------------------- /config/config-dired.el: -------------------------------------------------------------------------------- 1 | (use-package dired :ensure nil 2 | :bind (:map dired-mode-map 3 | ("/" . dired-narrow-regexp)) 4 | :config 5 | (setq delete-by-moving-to-trash t) 6 | ;; mark symlinks 7 | (setq dired-ls-F-marks-symlinks t) 8 | ;; fix `ls' for macOS. 9 | (when (memq window-system '(mac ns)) 10 | (setq insert-directory-program "gls" dired-use-ls-dired t)) 11 | ;; Never prompt for recursive copies of a directory 12 | (setq dired-recursive-copies 'always) 13 | ;; Never prompt for recursive deletes of a directory 14 | (setq dired-recursive-deletes 'always) 15 | 16 | ;; makes dired guess the target directory 17 | (setq dired-dwim-target t) 18 | 19 | ;; Dired listing switches 20 | ;; -a : Do not ignore entries starting with . 21 | ;; -l : Use long listing format. 22 | ;; -G : Do not print group names like 'users' 23 | ;; -h : Human-readable sizes like 1K, 234M, .. 24 | ;; -v : Do natural sort .. so the file names starting with . will show up first. 25 | ;; -F : Classify filenames by appending '*' to executables, 26 | ;; '/' to directories, etc. 27 | ;; default value for dired: "-al" 28 | (setq dired-listing-switches "-alGhvF --group-directories-first") 29 | 30 | ;; auto-revert dired 31 | (setq dired-auto-revert-buffer t) 32 | 33 | (defun rag/dired-rename-buffer-name () 34 | "Rename the dired buffer name to distinguish it from file buffers. 35 | It added extra strings at the front and back of the default dired buffer name." 36 | (let ((name (buffer-name))) 37 | (if (not (string-match "/$" name)) 38 | (rename-buffer (concat "*Dired* " name "/") t)))) 39 | 40 | (add-hook 'dired-mode-hook #'rag/dired-rename-buffer-name) 41 | 42 | ;; filter dired lists by regexp, fuzzy matching or string 43 | ;; https://github.com/Fuco1/dired-hacks#dired-filter 44 | (use-package dired-narrow) 45 | 46 | ;; a hydra to sort files in dired easily 47 | ;; Press `S' to invoke dired-quick-sort hydra 48 | ;; https://gitlab.com/xuhdev/dired-quick-sort 49 | (use-package dired-quick-sort 50 | :config (dired-quick-sort-setup)) 51 | 52 | ;; dired-ranger: copy paste like in GUI applications 53 | ;; https://github.com/Fuco1/dired-hacks#dired-ranger 54 | ;; (use-package dired-ranger 55 | ;; :ensure t 56 | ;; :bind (:map dired-mode-map 57 | ;; ("C" . dired-ranger-copy) 58 | ;; ("R" . dired-ranger-move) 59 | ;; ("Y" . dired-ranger-paste))) 60 | 61 | ;; dired-x - to hide uninteresting files in dired 62 | (use-package dired-x :ensure nil 63 | :config 64 | (progn 65 | (setq dired-omit-verbose nil) 66 | ;; hide backup, autosave, *.*~ files 67 | ;; omit mode can be toggled using `C-x M-o' in dired buffer. 68 | (add-hook 'dired-mode-hook #'dired-omit-mode) 69 | (setq dired-omit-files 70 | (concat dired-omit-files "\\|^.DS_STORE$\\|^.projectile$\\|^.git$"))))) 71 | 72 | (provide 'config-dired) 73 | -------------------------------------------------------------------------------- /config/config-org.el: -------------------------------------------------------------------------------- 1 | (use-package org 2 | :custom 3 | (org-catch-invisible-edits 'show-and-error) 4 | (org-todo-keywords 5 | '( 6 | (sequence "IDEA(i)" "TODO(t)" "PENDING(p)" "STARTED(s)" "|" "POSTPONED(l)" "DONE(d)" "CANCELED(c)") 7 | )) 8 | 9 | (org-todo-keyword-faces 10 | '(("TODO" . (:foreground "#41728e" :weight bold)) 11 | ("STARTED" . (:foreground "#81a2be" :weight bold)) 12 | ("PENDING" . (:foreground "#8abeb7" :slant italic)) 13 | ("CANCELED" . (:foreground "white" :background "#4d4d4d" :weight bold :strike-through)) 14 | ("POSTPONED" . (:foreground "#008080" :slant italic)))) 15 | 16 | (org-directory "~/Documents/org-mode") 17 | 18 | (org-agenda-files (list "~/Documents/org-mode/inbox.org" 19 | "~/Documents/org-mode/projects.org" 20 | "~/Documents/org-mode/ideas.org" 21 | "~/Documents/org-mode/learning.org")) 22 | 23 | (org-refile-targets '(("~/Documents/org-mode/projects.org" :maxlevel . 2) 24 | ("~/Documents/org-mode/ideas.org" :maxlevel . 2) 25 | ("~/Documents/org-mode/learning.org" :maxlevel . 2))) 26 | 27 | (org-default-notes-file (concat org-directory "/todo.org")) 28 | (org-confirm-babel-evaluate nil) 29 | (org-src-fontify-natively t) 30 | (org-adapt-indentation nil) 31 | (org-capture-templates 32 | '(("t" "Todo" entry (file+headline "~/Documents/org-mode/inbox.org" "Tasks") 33 | "* TODO %?\nAdded: %U\n" :prepend t :kill-buffer t) 34 | ("i" "Idea" entry (file+headline "~/Documents/org-mode/ideas.org" "Ideas") 35 | "* IDEA %?\nAdded: %U\n" :prepend t :kill-buffer t) 36 | ("l" "Learnings" entry (file+headline "~/Documents/org-mode/learning.org" "What i learned") 37 | "* Learned %?\nAdded: %U\n" :prepend t :kill-buffer t) 38 | )) 39 | 40 | :config 41 | (org-babel-do-load-languages 42 | 'org-babel-load-languages '((python . t) 43 | (shell . t) 44 | (emacs-lisp . t) 45 | (lisp . t))) 46 | :hook 47 | (org-finalize-agenda . (lambda () 48 | (setq org-agenda-tags-column (- 6 (window-width))) 49 | (org-agenda-align-tags))) 50 | :bind 51 | ("\C-c o l" . org-store-link) 52 | ("\C-c o a" . org-agenda) 53 | ("\C-c o c" . org-capture)) 54 | 55 | 56 | (use-package org-alert 57 | :config 58 | (if (memq window-system '(mac ns)) 59 | (setq alert-default-style 'osx-notifier) 60 | (setq alert-default-style 'libnotify)) 61 | (org-alert-enable)) 62 | 63 | (use-package org-projectile 64 | :config 65 | (org-projectile-per-project) 66 | (setq org-projectile-per-project-filepath "notes.org" 67 | org-agenda-files (append org-agenda-files (org-projectile-todo-files))) 68 | :bind 69 | ("C-c o p" . org-projectile-capture-for-current-project)) 70 | 71 | (use-package org-bullets 72 | :custom 73 | (org-hide-leading-stars t) 74 | :hook 75 | (org-mode . (lambda () (org-bullets-mode t)))) 76 | 77 | (use-package org-super-agenda 78 | :config 79 | (org-super-agenda-mode)) 80 | 81 | (provide 'config-org) 82 | -------------------------------------------------------------------------------- /custom_keys.org: -------------------------------------------------------------------------------- 1 | * Keys to Remember 2 | 3 | | App | Function | Shortcut | 4 | |------------------+----------------------------+-------------------| 5 | | Emacs | M-x | C-x C-m | 6 | | Emacs | Remove Empty Line | C-x C-o | 7 | | Emacs | Delete Indentation | M-\ | 8 | | Emacs | Initial Caps for words | M-c | 9 | | Emacs | Just one space | M-space | 10 | | Emacs | Show *Messages* | C-h e | 11 | | Emacs | Add Bookmark | C-x r m | 12 | | Emacs | Go to bookmark | C-x r b | 13 | | | | | 14 | | Projectile | helm-projectile-grep | C-c p s g | 15 | | | | | 16 | | Wgrep | Change Grep or Ag to Wgrep | C-c C-p | 17 | | Wgrep | Write Changes | C-x C-s | 18 | | | | | 19 | | Multiple-Cursors | Mark next line like this | C-> | 20 | | Multiple-Cursors | Mark prev line like this | C-< | 21 | | Multiple-Cursors | Mark all lines like this | C-c C-< | 22 | | | | | 23 | | Magit | Checkout | C-x g x | 24 | | Magit | Commit | C-x g c | 25 | | Magit | Status | C-x g s | 26 | | Magit | Push | C-x g p | 27 | | Magit | Pull (Update) | C-x g u | 28 | | Magit | Resolve conflicts | C-x g e | 29 | | Magit | Rebase interactive | | 30 | | | | | 31 | | Helm | Show kill Ring | C-x c k | 32 | | Helm | Show definitions | C-x c i | 33 | | Helm | Occur | C-x c o | 34 | | Helm | Find in project | C-x c p | 35 | | Helm | Swoop | C-x c s | 36 | | Helm | Swoop resume | C-x c b | 37 | | | | | 38 | | Acejump | Activate mode | C-c Space | 39 | | | | | 40 | | | | | 41 | | expand-region | Expand region | C-= | 42 | | | | | 43 | | Python | Pyenv switch current env | C-x p | 44 | | | | | 45 | | Org | Expand All | C-u C-u C-u | 46 | | Org | Agenda | C-c a | 47 | -------------------------------------------------------------------------------- /config/config-ui.el: -------------------------------------------------------------------------------- 1 | ;; `window-divider-mode' gives us finer control over the border between windows. 2 | ;; The native border "consumes" a pixel of the fringe on righter-most splits (in 3 | ;; Yamamoto's emacs-mac at least), window-divider does not. You can also control 4 | ;; vertical borders between windows (introduced in Emacs 25.1+) 5 | (when (boundp 'window-divider-mode) 6 | (setq window-divider-default-places t 7 | window-divider-default-bottom-width 1 8 | window-divider-default-right-width 1) 9 | (window-divider-mode +1)) 10 | 11 | (use-package all-the-icons) 12 | 13 | (use-package all-the-icons-dired 14 | :ensure t 15 | :config 16 | (add-hook 'dired-mode-hook #'all-the-icons-dired-mode)) 17 | 18 | (use-package doom-themes 19 | :config 20 | (load-theme 'doom-tomorrow-night t) 21 | (doom-themes-org-config)) 22 | 23 | (use-package doom-modeline 24 | :ensure t 25 | :defer t 26 | :hook (after-init . doom-modeline-init) 27 | :custom 28 | (doom-modeline-env-command "pyenv local") 29 | (doom-modeline-buffer-file-name-style 'relative-from-project) 30 | (doom-modeline-icon t) 31 | (doom-modeline-major-mode-icon t) 32 | (doom-modeline-major-mode-color-icon t) 33 | (doom-modeline-minor-modes nil) 34 | (doom-modeline-buffer-state-icon t) 35 | (doom-modeline-buffer-modification-icon t) 36 | (doom-modeline-vcs-max-length 30) 37 | (doom-modeline-env-enable-python t) 38 | (doom-modeline-env-enable-go t) 39 | 40 | :config 41 | (remove-hook 'focus-in-hook #'doom-modeline-update-env) 42 | (remove-hook 'find-file-hook #'doom-modeline-update-env) 43 | (doom-modeline-def-modeline 'main 44 | '(bar window-number matches buffer-info remote-host buffer-position parrot selection-info) 45 | '(debug minor-modes input-method major-mode process vcs checker)) 46 | (defun setup-custom-doom-modeline () 47 | (doom-modeline-set-modeline 'main 'default)) 48 | 49 | (add-hook 'doom-modeline-mode-hook 'setup-custom-doom-modeline)) 50 | 51 | (use-package solaire-mode 52 | :config 53 | ;; brighten buffers (that represent real files) 54 | (add-hook 'after-change-major-mode-hook #'turn-on-solaire-mode) 55 | ;; To enable solaire-mode unconditionally for certain modes: 56 | (add-hook 'ediff-prepare-buffer-hook #'solaire-mode) 57 | 58 | ;; ...if you use auto-revert-mode: 59 | (add-hook 'after-revert-hook #'turn-on-solaire-mode) 60 | 61 | ;; highlight the minibuffer when it is activated: 62 | (add-hook 'minibuffer-setup-hook #'solaire-mode-in-minibuffer) 63 | 64 | ;; if the bright and dark background colors are the wrong way around, use this 65 | ;; to switch the backgrounds of the `default` and `solaire-default-face` faces. 66 | ;; This should be used *after* you load the active theme! 67 | ;; 68 | ;; NOTE: This is necessary for themes in the doom-themes package! 69 | (solaire-mode-swap-bg)) 70 | 71 | (use-package git-gutter-fringe) 72 | 73 | (use-package git-gutter 74 | :config 75 | (require 'git-gutter-fringe) 76 | (global-git-gutter-mode +1) 77 | ;; places the git gutter outside the margins. 78 | (setq-default fringes-outside-margins t) 79 | ;; thin fringe bitmaps 80 | (fringe-helper-define 'git-gutter-fr:added '(center repeated) 81 | "XXX.....") 82 | (fringe-helper-define 'git-gutter-fr:modified '(center repeated) 83 | "XXX.....") 84 | (fringe-helper-define 'git-gutter-fr:deleted 'bottom 85 | "X......." 86 | "XX......" 87 | "XXX....." 88 | "XXXX....") 89 | 90 | (add-hook 'focus-in-hook 'git-gutter:update-all-windows)) 91 | 92 | (use-package powerline) 93 | 94 | ;; Custom line number stuff 95 | (set-face-attribute 'fringe nil) 96 | 97 | (setq org-fontify-whole-heading-line t 98 | org-fontify-done-headline t 99 | org-fontify-quote-and-verse-blocks t) 100 | 101 | (when (display-graphic-p) 102 | ;; standardize fringe width 103 | (push (cons 'left-fringe '4) default-frame-alist) 104 | (push (cons 'right-fringe '4) default-frame-alist) 105 | ;; no fringe in the minibuffer 106 | (set-window-fringes (minibuffer-window) 0 0 nil)) 107 | 108 | ;; because git-gutter is in the left fringe 109 | (setq flycheck-indication-mode 'right-fringe) 110 | ;; A non-descript, left-pointing arrow 111 | (fringe-helper-define 'flycheck-fringe-bitmap-double-arrow 'center 112 | "...X...." 113 | "..XX...." 114 | ".XXX...." 115 | "XXXX...." 116 | ".XXX...." 117 | "..XX...." 118 | "...X....") 119 | 120 | (provide 'config-ui) 121 | -------------------------------------------------------------------------------- /lang/lang-c.el: -------------------------------------------------------------------------------- 1 | ;; C-IDE based on https://github.com/tuhdo/emacs-c-ide-demo 2 | (use-package cc-mode 3 | :config 4 | ;; Available C style: 5 | ;; "gnu": The default style for GNU projects 6 | ;; "k&r": What Kernighan and Ritchie, the authors of C used in their book 7 | ;; "bsd": What BSD developers use, aka "Allman style" after Eric Allman. 8 | ;; "whitesmith": Popularized by the examples that came with Whitesmiths C, an early commercial C compiler. 9 | ;; "stroustrup": What Stroustrup, the author of C++ used in his book 10 | ;; "ellemtel": Popular C++ coding standards as defined by "Programming in C++, Rules and Recommendations," Erik Nyquist and Mats Henricson, Ellemtel 11 | ;; "linux": What the Linux developers use for kernel development 12 | ;; "python": What Python developers use for extension modules 13 | ;; "java": The default style for java-mode (see below) 14 | ;; "user": When you want to define your own style 15 | (setq c-default-style "gnu") ;; set style to "linux" 16 | (setq gdb-many-windows t ;; use gdb-many-windows by default 17 | gdb-show-main t 18 | c-basic-offset 4 19 | tab-width 4 20 | indent-tabs-mode t)) 21 | 22 | (use-package cmake-ide 23 | :config 24 | (add-hook 'c++-mode-hook '(lambda() 25 | (cmake-ide-setup)))) 26 | 27 | ;; (use-package semantic 28 | ;; :config 29 | ;; (semanticdb-enable-gnu-global-databases 'c-mode t) 30 | ;; (semanticdb-enable-gnu-global-databases 'c++-mode t) 31 | 32 | ;; (defun my-inhibit-semantic-p () 33 | ;; (not (equal major-mode 'python-mode))) 34 | 35 | ;; (add-to-list 'semantic-inhibit-functions #'my-inhibit-semantic-p) 36 | 37 | ;; (setq semanticdb-default-save-directory (expand-file-name "semanticdb/" temp-dir)) 38 | 39 | ;; (let ((semantic-submodes '(global-semantic-decoration-mode 40 | ;; global-semantic-idle-local-symbol-highlight-mode 41 | ;; global-semantic-highlight-func-mode 42 | ;; global-semanticdb-minor-mode 43 | ;; global-semantic-mru-bookmark-mode 44 | ;; global-semantic-idle-summary-mode 45 | ;; global-semantic-stickyfunc-mode 46 | ;; ))) 47 | ;; (setq semantic-default-submodes (append semantic-default-submodes semantic-submodes) 48 | ;; semantic-idle-scheduler-idle-time 1)) 49 | 50 | ;; (add-hook 'c-mode-common-hook (lambda () (semantic-mode 1)))) 51 | 52 | (use-package irony 53 | :config 54 | ;; replace the `completion-at-point' and `complete-symbol' bindings in 55 | ;; irony-mode's buffers by irony-mode's function 56 | (add-hook 'c++-mode-hook 'irony-mode) 57 | (add-hook 'c-mode-hook 'irony-mode) 58 | (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)) 59 | 60 | (use-package irony-eldoc 61 | :config 62 | (add-hook 'irony-mode-hook 'irony-eldoc)) 63 | 64 | (use-package company-irony 65 | :config 66 | (add-to-list 'company-backends 'company-keywords) 67 | (add-to-list 'company-backends 'company-irony)) 68 | 69 | (use-package company-irony-c-headers 70 | :config 71 | (add-to-list 'company-backends 'company-irony-c-headers)) 72 | 73 | 74 | (use-package flycheck-irony 75 | :after flycheck-mode 76 | :config 77 | (add-hook 'flycheck-mode-hook #'flycheck-irony-setup)) 78 | 79 | ;; company-c-headers 80 | (use-package company-c-headers 81 | :config 82 | (add-to-list 'company-backends 'company-c-headers)) 83 | 84 | (defun me/rtags () 85 | "Rtags configuration. 86 | Used only for nevigation." 87 | (interactive) 88 | (rtags-start-process-unless-running) 89 | (setq rtags-display-result-backend 'ivy) 90 | (add-hook 'kill-emacs-hook 'rtags-quit-rdm)) 91 | 92 | (use-package rtags 93 | :commands rtags-start-process-unless-running 94 | :bind (("M-." . rtags-find-symbol-at-point) 95 | ("M-?" . rtags-find-references-at-point) 96 | ("M-," . rtags-location-stack-back) 97 | ("C-," . rtags-location-stack-forward) 98 | ("C-c r r" . rtags-rename-symbolrtags-next-match)) 99 | :config 100 | (setq rtags-completions-enabled t) 101 | (add-hook 'c++-mode 'me/rtags) 102 | (add-hook 'c-mode 'me/rtags) 103 | (message "Rtags loaded")) 104 | 105 | (use-package company-rtags 106 | :after rtags 107 | :config 108 | (add-to-list 'company-backends 'company-rtags)) 109 | 110 | (use-package clang-format 111 | :config 112 | (defun c-mode-before-save-hook () 113 | (when (or (eq major-mode 'c++-mode) (eq major-mode 'c-mode)) 114 | (call-interactively 'clang-format))) 115 | 116 | (add-hook 'before-save-hook #'c-mode-before-save-hook)) 117 | 118 | 119 | 120 | 121 | (provide 'lang-c) 122 | -------------------------------------------------------------------------------- /lang/lang-python.el: -------------------------------------------------------------------------------- 1 | ;;; package --- python configs 2 | ;;; Commentary: 3 | ;;; Contains my python configs 4 | 5 | ;;; Code: 6 | 7 | (require 'f) 8 | 9 | (defvar pyenv-current-version nil nil) 10 | 11 | (defvar pyenv-current-version nil nil) 12 | 13 | (use-package python 14 | :mode ("\\.py" . python-mode) 15 | :config 16 | (setq python-indent-offset 4) 17 | (setq python-mode-map (make-sparse-keymap)) 18 | :hook 19 | (python-mode . anaconda-mode) 20 | (python-mode . anaconda-eldoc-mode)) 21 | 22 | (use-package anaconda-mode 23 | :config 24 | (add-to-list 'company-backends 'company-yasnippet) 25 | :bind (:map anaconda-mode-map 26 | ("M-[" . python-nav-backward-block) 27 | ("M-]" . python-nav-forward-block) 28 | ("M-J" . indent-rigidly-left-to-tab-stop) 29 | ("M-L" . indent-rigidly-right-to-tab-stop) 30 | ("M-'" . anaconda-mode-find-references) 31 | ("M-." . anaconda-mode-find-definitions) 32 | ("M-," . pop-tag-mark) 33 | ("DEL" . python-dedent-or-remove))) 34 | 35 | (use-package company-anaconda 36 | :config 37 | (eval-after-load "company" 38 | '(add-to-list 'company-backends 'company-anaconda))) 39 | 40 | 41 | (use-package pip-requirements 42 | :config 43 | (add-hook 'pip-requirements-mode-hook #'pip-requirements-auto-complete-setup)) 44 | 45 | (use-package py-autopep8) 46 | 47 | (use-package pyenv-mode 48 | :init 49 | (add-to-list 'exec-path "~/.pyenv/shims") 50 | (setenv "WORKON_HOME" "~/.pyenv/versions/") 51 | :bind (:map pyenv-mode-map 52 | ("C-c C-s" . nil) 53 | ("C-c C-u" . nil) 54 | ("C-c m v s" . pyenv-mode-set) 55 | ("C-c m v u" . pyenv-mode-unset) 56 | ("C-c m v e" . pyenv-activate-current-project)) 57 | :config 58 | (pyenv-mode)) 59 | 60 | (use-package py-isort 61 | :config 62 | (defun python-mode-before-save-hook () 63 | (when (eq major-mode 'python-mode) (eq major-mode 'c-mode) 64 | (py-isort-before-save))) 65 | 66 | (add-hook 'before-save-hook 'python-mode-before-save-hook)) 67 | 68 | 69 | (defun pyenv-init() 70 | "Initialize pyenv's current version to the global one." 71 | (let ((global-pyenv (replace-regexp-in-string "\n" "" (shell-command-to-string "pyenv global")))) 72 | (message (concat "Setting pyenv version to " global-pyenv)) 73 | (pyenv-mode-set global-pyenv) 74 | (setq pyenv-current-version global-pyenv))) 75 | 76 | (defun pyenv-activate-current-project () 77 | "Automatically activates pyenv version if .python-version file exists." 78 | (interactive) 79 | (let ((python-version-directory (locate-dominating-file (buffer-file-name) ".python-version"))) 80 | (if python-version-directory 81 | (let* ((pyenv-version-path (f-expand ".python-version" python-version-directory)) 82 | (pyenv-current-version (s-trim (f-read-text pyenv-version-path 'utf-8)))) 83 | (pyvenv-workon pyenv-current-version) 84 | (pyenv-mode-set pyenv-current-version) 85 | (setq python-shell-interpreter (expand-file-name (concat "~/.pyenv/versions/" pyenv-current-version "/bin/python"))) 86 | (setq importmagic-python-interpreter python-shell-interpreter) 87 | (setq doom-modeline-env-version pyenv-current-version) 88 | (message (concat "Setting virtualenv to " pyenv-current-version)))))) 89 | 90 | (add-hook 'after-init-hook 'pyenv-init) 91 | (add-hook 'projectile-after-switch-project-hook 'pyenv-activate-current-project) 92 | 93 | (defun jsonify-python-output () 94 | "Convert the output of a logged/printed dict into a pretty JSON format." 95 | (interactive) 96 | (let* ((min (if (region-active-p) (region-beginning) (point-min))) 97 | (max (if (region-active-p) (region-end) (point-max))) 98 | (max-altered max)) 99 | (goto-char min) 100 | (while (re-search-forward "Decimal(\"\\\([0-9.]+\\\)\")" max t) 101 | (replace-match "\\1") 102 | (setq max-altered (- max-altered 11))) 103 | 104 | (replace-in-buffer "'" "\"" min max) 105 | (replace-in-buffer "None" "null" min max) 106 | (replace-in-buffer "True" "true" min max) 107 | (replace-in-buffer "False" "false" min max) 108 | 109 | (json-pretty-print min max-altered))) 110 | 111 | (defun replace-in-buffer (search replace start end) 112 | "Replace all occurances of a SEARCH with REPLACE in buffer from START to END." 113 | (goto-char start) 114 | (while (search-forward search end t) 115 | (replace-match replace t))) 116 | 117 | (defun python-dedent-or-remove () 118 | "Delete region if selected, otherwise, dedent." 119 | (interactive) 120 | (if (region-active-p) 121 | (delete-region (region-beginning) (region-end)) 122 | (call-interactively #'python-indent-dedent-line-backspace 0))) 123 | 124 | (provide 'lang-python) 125 | ;;; python.el ends here 126 | -------------------------------------------------------------------------------- /config/config-base.el: -------------------------------------------------------------------------------- 1 | (package-initialize) 2 | (add-to-list 'package-archives 3 | '("melpa" . "https://melpa.org/packages/")) 4 | 5 | (when (not package-archive-contents) 6 | (package-refresh-contents)) 7 | 8 | (unless (package-installed-p 'use-package) 9 | (package-install 'use-package)) 10 | (eval-when-compile (require 'use-package)) 11 | 12 | (defconst private-dir (expand-file-name "private" user-emacs-directory)) 13 | (defconst temp-dir 14 | (format "%s/cache" private-dir) 15 | "Hostname-based elisp temp directories") 16 | 17 | ;; Core settings 18 | ;; UTF-8 please 19 | (set-charset-priority 'unicode) 20 | (setq locale-coding-system 'utf-8) ; pretty 21 | (set-terminal-coding-system 'utf-8) ; pretty 22 | (set-keyboard-coding-system 'utf-8) ; pretty 23 | (set-selection-coding-system 'utf-8) ; please 24 | (prefer-coding-system 'utf-8) ; with sugar on top 25 | (setq default-process-coding-system '(utf-8-unix . utf-8-unix)) 26 | 27 | (fset 'yes-or-no-p 'y-or-n-p) 28 | (global-auto-revert-mode t) 29 | 30 | (setq-default indent-tabs-mode nil 31 | truncate-lines t) 32 | 33 | (setq 34 | confirm-kill-emacs 'y-or-n-p 35 | confirm-nonexistent-file-or-buffer t 36 | save-interprogram-paste-before-kill t 37 | mouse-yank-at-point t 38 | require-final-newline nil 39 | visible-bell nil 40 | ring-bell-function 'ignore 41 | custom-file "~/.emacs.d/.custom.el" 42 | ;; http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html 43 | minibuffer-prompt-properties 44 | '(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt) 45 | ;; persistent bookmarks 46 | bookmark-save-flag t 47 | bookmark-default-file (concat temp-dir "/bookmarks") 48 | ;; Disable backups (that's what git/dropbox are for) 49 | history-length 1000 50 | auto-save-default nil 51 | auto-save-list-file-name (concat temp-dir "/autosave") 52 | make-backup-files nil 53 | create-lockfiles nil 54 | backup-directory-alist `((".*" . ,(concat temp-dir "/backup/"))) 55 | auto-save-file-name-transforms `((".*" ,(concat temp-dir "/auto-save-list/") t)) 56 | ;; Disable non selected window highlight 57 | cursor-in-non-selected-windows nil 58 | highlight-nonselected-windows nil 59 | ;; PATH 60 | exec-path (append exec-path '("/usr/local/bin/")) 61 | ;; Backups disabled 62 | backup-inhibited t 63 | make-backup-files nil 64 | indent-tabs-mode nil 65 | inhibit-startup-message t 66 | fringes-outside-margins t 67 | x-select-enable-clipboard t 68 | use-package-always-ensure t 69 | vc-follow-symlinks t 70 | auto-revert-check-vc-info nil 71 | frame-resize-pixelwise t) 72 | 73 | ;; Disable toolbar & menubar 74 | (menu-bar-mode -1) 75 | (when (fboundp 'tool-bar-mode) 76 | (tool-bar-mode -1)) 77 | (when (fboundp 'scroll-bar-mode) 78 | (scroll-bar-mode -1)) 79 | 80 | (setq-default display-line-numbers-current-absolute t 81 | display-line-numbers-width 1 82 | display-line-numbers-widen t) 83 | 84 | (add-hook 'prog-mode-hook #'display-line-numbers-mode) 85 | 86 | (put 'narrow-to-region 'disabled nil) 87 | 88 | ;; Env vars 89 | (setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin/")) 90 | (setenv "SHELL" "/bin/zsh") 91 | 92 | (show-paren-mode 1) 93 | (desktop-save-mode 0) 94 | 95 | (if (eq system-type 'darwin) 96 | (set-default-font "-*-Hack-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1" t t) 97 | ;(set-default-font "Hack 13" t t) 98 | (set-frame-font "Hack 12" t t)) 99 | 100 | ;; Delete trailing whitespace before save 101 | (add-hook 'before-save-hook 'delete-trailing-whitespace) 102 | 103 | (use-package emacs 104 | :init 105 | (global-unset-key (kbd "C-w")) 106 | ;; (global-unset-key (kbd "C-x +")) 107 | ;; (global-unset-key (kbd "C-x -")) 108 | ;; (global-unset-key (kbd "C-x 0")) 109 | ;; (global-unset-key (kbd "C-x 1")) 110 | ;; (global-unset-key (kbd "C-x 2")) 111 | ;; (global-unset-key (kbd "C-x 3")) 112 | ;; (global-unset-key (kbd "C-x 4")) 113 | ;; (global-unset-key (kbd "C-x 5") 114 | :bind 115 | ("C-x C-x" . kill-region) 116 | ("C-c t +" . text-scale-increase) 117 | ("C-c t -" . text-scale-decrease) 118 | ("C-c t =" . text-scale-adjust) 119 | ("C-c g g" . goto-line) 120 | ("C-w =" . balance-windows) 121 | ("C-w -" . shrink-window-if-larger-than-buffer) 122 | ("C-w 0" . delete-window) 123 | ("C-w 1" . delete-other-windows) 124 | ("C-w 2" . delete-window-below-and-switch) 125 | ("C-w 3" . delete-window-right-and-switch) 126 | ("C-w 5 0" . delete-frame) 127 | ("C-w 5 1" . delete-other-frames) 128 | ("C-w 5 2" . make-frame) 129 | ("C-w 5 o" . other-frame) 130 | ("C-w }" . shrink-window-horizontally) 131 | ("C-w {" . enlarge-window-horizontally)) 132 | 133 | 134 | 135 | (provide 'config-base) 136 | ;;; core ends here 137 | -------------------------------------------------------------------------------- /config/config-shell.el: -------------------------------------------------------------------------------- 1 | ;; Term mode 2 | (setq explicit-shell-file-name "/bin/bash") 3 | (setq multi-term-program "/bin/bash") 4 | (setq term-buffer-maximum-size 10000) 5 | (setq show-trailing-whitespace nil) 6 | (setq comint-prompt-read-only t) 7 | 8 | (defvar my-local-shells 9 | '("*shell0*" "*shell1*" "*shell2*" "*shell3*")) 10 | (defvar my-remote-shells 11 | '("*snarfed*" "*heaven0*" "*heaven1*" "*heaven2*" "*heaven3*")) 12 | (defvar my-shells (append my-local-shells my-remote-shells)) 13 | 14 | (require 'tramp) 15 | 16 | (custom-set-variables 17 | '(tramp-default-method "ssh") ; uses ControlMaster 18 | '(comint-scroll-to-bottom-on-input t) ; always insert at the bottom 19 | '(comint-scroll-to-bottom-on-output nil) ; always add output at the bottom 20 | '(comint-scroll-show-maximum-output t) ; scroll to show max possible output 21 | ;; '(comint-completion-autolist t) ; show completion list when ambiguous 22 | '(comint-input-ignoredups t) ; no duplicates in command history 23 | '(comint-completion-addsuffix t) ; insert space/slash after file completion 24 | '(comint-buffer-maximum-size 20000) ; max length of the buffer in lines 25 | '(comint-prompt-read-only t) ; if this is t, it breaks shell-command 26 | '(comint-get-old-input (lambda () "")) ; what to run when i press enter on a 27 | ; line above the current prompt 28 | '(comint-input-ring-size 5000) ; max shell history size 29 | '(protect-buffer-bury-p nil) 30 | ) 31 | 32 | (setenv "PAGER" "cat") 33 | 34 | (add-to-list 'comint-output-filter-functions 'ansi-color-process-output) 35 | 36 | (add-hook 'shell-mode-hook 'set-scroll-conservatively) 37 | ;; make it harder to kill my shell buffers 38 | (add-hook 'shell-mode-hook 'protect-process-buffer-from-kill-mode) 39 | (add-hook 'comint-output-filter-functions 'make-my-shell-output-read-only) 40 | (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) 41 | (add-hook 'shell-mode-hook 'my-dirtrack-mode) 42 | (add-hook 'comint-output-filter-functions 'comint-truncate-buffer) 43 | (add-hook 'term-mode-hook (lambda() 44 | (setq yas-dont-activate t))) 45 | 46 | ;; truncate buffers continuously 47 | 48 | (defun make-my-shell-output-read-only (text) 49 | "Add to comint-output-filter-functions to make stdout read only in my shells." 50 | (if (member (buffer-name) my-shells) 51 | (let ((inhibit-read-only t) 52 | (output-end (process-mark (get-buffer-process (current-buffer))))) 53 | (put-text-property comint-last-output-start output-end 'read-only t)))) 54 | 55 | (defun my-dirtrack-mode () 56 | "Add to shell-mode-hook to use dirtrack mode in my shell buffers." 57 | (when (member (buffer-name) my-shells) 58 | (shell-dirtrack-mode 0) 59 | (set-variable 'dirtrack-list '("^.*[^ ]+:\\(.*\\)>" 1 nil)) 60 | (dirtrack-mode 1))) 61 | 62 | ; interpret and use ansi color codes in shell output windows 63 | (defun set-scroll-conservatively () 64 | "Add to shell-mode-hook to prevent jump-scrolling on newlines in shell buffers." 65 | (set (make-local-variable 'scroll-conservatively) 10)) 66 | 67 | (defun make-comint-directory-tracking-work-remotely () 68 | "Add this to comint-mode-hook to make directory tracking work 69 | while sshed into a remote host, e.g. for remote shell buffers 70 | started in tramp. (This is a bug fix backported from Emacs 24: 71 | http://comments.gmane.org/gmane.emacs.bugs/39082" 72 | (set (make-local-variable 'comint-file-name-prefix) 73 | (or (file-remote-p default-directory) ""))) 74 | (add-hook 'comint-mode-hook 'make-comint-directory-tracking-work-remotely) 75 | 76 | (defun enter-again-if-enter () 77 | "Make the return key select the current item in minibuf and shell history isearch. 78 | An alternate approach would be after-advice on isearch-other-meta-char." 79 | (when (and (not isearch-mode-end-hook-quit) 80 | (equal (this-command-keys-vector) [13])) ; == return 81 | (cond ((active-minibuffer-window) (minibuffer-complete-and-exit)) 82 | ((member (buffer-name) my-shells) (comint-send-input))))) 83 | (add-hook 'isearch-mode-end-hook 'enter-again-if-enter) 84 | 85 | (defadvice comint-previous-matching-input 86 | (around suppress-history-item-messages activate) 87 | "Suppress the annoying 'History item : NNN' messages from shell history isearch. 88 | If this isn't enough, try the same thing with 89 | comint-replace-by-expanded-history-before-point." 90 | (let ((old-message (symbol-function 'message))) 91 | (unwind-protect 92 | (progn (fset 'message 'ignore) ad-do-it) 93 | (fset 'message old-message)))) 94 | 95 | ;;(defadvice comint-send-input (around go-to-end-of-multiline activate) 96 | ;; "When I press enter, jump to the end of the *buffer*, instead of the end of 97 | ;;the line, to capture multiline input. (This only has effect if 98 | ;;`comint-eol-on-send' is non-nil." 99 | ;; (flet ((end-of-line () (end-of-buffer))) 100 | ;; ad-do-it)) 101 | 102 | ;; not sure why, but comint needs to be reloaded from the source (*not* 103 | ;; compiled) elisp to make the above advise stick. 104 | (load "comint.el.gz") 105 | 106 | ;; for other code, e.g. emacsclient in TRAMP ssh shells and automatically 107 | ;; closing completions buffers, see the links above. 108 | 109 | (provide 'config-shell) 110 | -------------------------------------------------------------------------------- /config/config-hydra.el: -------------------------------------------------------------------------------- 1 | ;; mc/num-cursors is not autoloaded 2 | (require 'multiple-cursors) 3 | 4 | (use-package hydra 5 | :defer 0.5 6 | :bind ( 7 | ("C-c h p" . hydra-projectile/body) 8 | ("C-c h c" . hydra-multiple-cursors/body) 9 | ("C-c h b" . hydra-buffer/body) 10 | ("C-c h f" . hydra-flycheck/body) 11 | ("C-c h m" . hydra-magit/body) 12 | ("C-c h o" . hydra-org/body) 13 | ("C-c h y" . hydra-yasnippet/body) 14 | ("C-c h w" . hydra-windows/body))) 15 | 16 | (defhydra hydra-multiple-cursors (:color blue :hint nil) 17 | " 18 | Up^^ Down^^ Miscellaneous % 2(mc/num-cursors) cursor%s(if (> (mc/num-cursors) 1) \"s\" \"\") 19 | ------------------------------------------------------------------ 20 | [_p_] Next [_n_] Next [_l_] Edit lines [_0_] Insert numbers 21 | [_P_] Skip [_N_] Skip [_a_] Mark all [_A_] Insert letters 22 | [_M-p_] Unmark [_M-n_] Unmark [_s_] Search 23 | [Click] Cursor at point [_q_] Quit" 24 | ("l" mc/edit-lines :exit t) 25 | ("a" mc/mark-all-like-this :exit t) 26 | ("n" mc/mark-next-like-this :exit nil) 27 | ("N" mc/skip-to-next-like-this :exit nil) 28 | ("M-n" mc/unmark-next-like-this :exit nil) 29 | ("p" mc/mark-previous-like-this :exit nil) 30 | ("P" mc/skip-to-previous-like-this :exit nil) 31 | ("M-p" mc/unmark-previous-like-this :exit nil) 32 | ("s" mc/mark-all-in-region-regexp :exit t) 33 | ("0" mc/insert-numbers :exit t) 34 | ("A" mc/insert-letters :exit t) 35 | ("" mc/add-cursor-on-click) 36 | ;; Help with click recognition in this hydra 37 | ("" ignore) 38 | ("" ignore) 39 | ("q" nil)) 40 | 41 | (defhydra hydra-buffer (:color blue) 42 | " 43 | ^ 44 | ^Buffer^ ^Do^ 45 | ^──────^─────────────^──^────────── 46 | _q_ quit _k_ kill 47 | ^^ _l_ list 48 | ^^ _n_ next 49 | ^^ _p_ previous 50 | ^^ ^^ 51 | " 52 | ("q" nil) 53 | ("k" kill-buffer) 54 | ("l" ibuffer) 55 | ("n" next-buffer) 56 | ("p" previous-buffer)) 57 | 58 | 59 | (defhydra hydra-magit (:color blue) 60 | " 61 | ^ 62 | ^Magit^ ^Do^ 63 | ^─────^─────────────^──^──────── 64 | _q_ quit _b_ blame 65 | ^^ _c_ clone 66 | ^^ _i_ init 67 | ^^ _s_ status 68 | ^^ ^^ 69 | " 70 | ("q" nil) 71 | ("b" magit-blame) 72 | ("c" magit-clone) 73 | ("i" magit-init) 74 | ("s" magit-status)) 75 | 76 | 77 | (defhydra hydra-flycheck (:color blue) 78 | " 79 | ^ 80 | ^Flycheck^ ^Errors^ ^Checker^ 81 | ^────────^──────────^──────^────────────^───────^───── 82 | _q_ quit _<_ previous _?_ describe 83 | _M_ manual _>_ next _d_ disable 84 | _v_ verify setup _f_ check _m_ mode 85 | ^^ _l_ list _s_ select 86 | ^^ ^^ ^^ 87 | " 88 | ("q" nil) 89 | ("<" flycheck-previous-error :color pink) 90 | (">" flycheck-next-error :color pink) 91 | ("?" flycheck-describe-checker) 92 | ("M" flycheck-manual) 93 | ("d" flycheck-disable-checker) 94 | ("f" flycheck-buffer) 95 | ("l" flycheck-list-errors) 96 | ("m" flycheck-mode) 97 | ("s" flycheck-select-checker) 98 | ("v" flycheck-verify-setup)) 99 | 100 | 101 | (defhydra hydra-org (:color blue) 102 | " 103 | ^ 104 | ^Org^ ^Do^ 105 | ^───^─────────────^──^───────────── 106 | _q_ quit _a_ agenda 107 | ^^ _c_ capture 108 | ^^ _d_ decrypt 109 | ^^ _i_ insert-link 110 | ^^ _k_ cut-subtree 111 | ^^ _o_ open-link 112 | ^^ _r_ refile 113 | ^^ _s_ store-link 114 | ^^ _t_ todo-tree 115 | ^^ ^^ 116 | " 117 | ("q" nil) 118 | ("a" org-agenda) 119 | ("c" org-capture) 120 | ("d" org-decrypt-entry) 121 | ("k" org-cut-subtree) 122 | ("i" org-insert-link-global) 123 | ("o" org-open-at-point-global) 124 | ("r" org-refile) 125 | ("s" org-store-link) 126 | ("t" org-show-todo-tree)) 127 | 128 | (defhydra hydra-projectile (:color blue) 129 | " 130 | ^ 131 | ^Projectile^ ^Buffers^ ^Find^ ^Search^ 132 | ^──────────^────────^───────^───────────^────^──────────────^──────^──────────── 133 | _q_ quit _b_ list _d_ directory _r_ replace 134 | _i_ reset cache _K_ kill all _D_ root _R_ regexp replace 135 | ^^ _S_ save all _f_ file _s_ ag 136 | ^^ ^^ _p_ project ^^ 137 | ^^ ^^ ^^ ^^ 138 | " 139 | ("q" nil) 140 | ("b" counsel-projectile-switch-to-buffer) 141 | ("d" counsel-projectile-find-dir) 142 | ("D" projectile-dired) 143 | ("f" counsel-projectile-find-file) 144 | ("i" projectile-invalidate-cache :color red) 145 | ("K" projectile-kill-buffers) 146 | ("p" counsel-projectile-switch-project) 147 | ("r" projectile-replace) 148 | ("R" projectile-replace-regexp) 149 | ("s" counsel-projectile-rg) 150 | ("S" projectile-save-project-buffers)) 151 | 152 | (defhydra hydra-yasnippet (:color blue) 153 | " 154 | ^ 155 | ^YASnippet^ ^Do^ 156 | ^─────────^──────────^──^──────── 157 | _q_ quit _i_ insert 158 | ^^ _m_ mode 159 | ^^ _n_ new 160 | ^^ ^^ 161 | " 162 | ("q" nil) 163 | ("i" ivy-yasnippet) 164 | ("m" yas-minor-mode) 165 | ("n" yas-new-snippet)) 166 | 167 | 168 | (defhydra hydra-windows (:color pink) 169 | " 170 | ^ 171 | ^Windows^ ^Window^ ^Zoom^ 172 | ^───────^───────────^──────^────────────^────^────── 173 | _q_ quit _b_ balance _-_ out 174 | ^^ _i_ heighten _+_ in 175 | ^^ _j_ narrow _=_ reset 176 | ^^ _k_ lower ^^ 177 | ^^ _l_ widen ^^ 178 | ^^ _s_ swap ^^ 179 | ^^ ^^ ^^ 180 | " 181 | ("q" nil) 182 | ("b" balance-windows) 183 | ("i" enlarge-window) 184 | ("j" shrink-window-horizontally) 185 | ("k" shrink-window) 186 | ("l" enlarge-window-horizontally) 187 | ("s" switch-window-then-swap-buffer :color blue) 188 | ("-" text-scale-decrease) 189 | ("+" text-scale-increase) 190 | ("=" (text-scale-increase 0)) 191 | ("J" buf-move-left) 192 | ("K" buf-move-down) 193 | ("I" buf-move-up) 194 | ("L" buf-move-right)) 195 | 196 | 197 | 198 | (provide 'config-hydra) 199 | -------------------------------------------------------------------------------- /config/config-functions.el: -------------------------------------------------------------------------------- 1 | (require 'cl) 2 | (require 'imenu) 3 | (require 'counsel) 4 | (require 'magit-git) 5 | (require 'magit-process) 6 | (require 'projectile) 7 | 8 | (defun core-project-root (&optional strict-p) 9 | "Get the path to the root of your project." 10 | (let ((projectile-require-project-root strict-p)) 11 | (ignore-errors (projectile-project-root)))) 12 | 13 | (defun core*project-root (&rest _) 14 | "An advice function used to replace project-root-detection functions in other 15 | libraries." 16 | (core-project-root)) 17 | 18 | ;; Delete words 19 | (defun delete-word (arg) 20 | "Delete characters forward until encountering the end of a word. 21 | With argument, do this that many times." 22 | (interactive "p") 23 | (delete-region (point) (progn (forward-word arg) (point)))) 24 | 25 | (defun backward-delete-word (arg) 26 | "Delete characters backward until encountering the end of a word. 27 | With argument, do this that many times." 28 | (interactive "p") 29 | (delete-word (- arg))) 30 | 31 | 32 | ;; COPY / PASTE on OSX 33 | (defun copy-from-osx () 34 | (shell-command-to-string "pbpaste")) 35 | 36 | (defun paste-to-osx (text &optional push) 37 | (let ((process-connection-type nil)) 38 | (let ((proc (start-process "pbcopy" "*Messages*" "pbcopy"))) 39 | (process-send-string proc text) 40 | (process-send-eof proc)))) 41 | 42 | (when (memq window-system '(mac ns)) 43 | (setq interprogram-cut-function 'paste-to-osx) 44 | (setq interprogram-paste-function 'copy-from-osx)) 45 | 46 | (defun copy-file-name-to-clipboard () 47 | "Copy the current buffer file name to the clipboard." 48 | (interactive) 49 | (let ((filename (if (equal major-mode 'dired-mode) 50 | default-directory 51 | (buffer-file-name)))) 52 | (when filename 53 | (kill-new filename) 54 | (message "Copied buffer file name '%s' to the clipboard." filename)))) 55 | 56 | (defun smart-beginning-of-line () 57 | "Move point to first non-whitespace character or beginning-of-line. 58 | Move point to the first non-whitespace character on this line. 59 | If point was already at that position, move point to beginning of line." 60 | (interactive) 61 | (let ((oldpos (point))) 62 | (back-to-indentation) 63 | (and (= oldpos (point)) 64 | (beginning-of-line)))) 65 | 66 | (defun bookmark-jump-or-find-file (bookmark) 67 | "Jump to BOOKMARK, but if it's a directory, start a 'find-file' from there." 68 | (interactive 69 | (list (bookmark-completing-read "Jump to bookmark"))) 70 | (if (file-directory-p (bookmark-get-filename bookmark)) 71 | (let ((default-directory (bookmark-get-filename bookmark))) 72 | (counsel-find-file)) 73 | (bookmark-jump bookmark))) 74 | 75 | (defun beginning-of-buffer-record () 76 | "Record the current position in buffer and move to beginning." 77 | (point-to-register 9) 78 | (beginning-of-buffer)) 79 | 80 | (defun end-of-buffer-record () 81 | "Record the current position in buffer and move to end." 82 | (point-to-register 9) 83 | (end-of-buffer)) 84 | 85 | (defun go-back-to-point () 86 | "Go back to the point before navigating to beginning or end of buffer." 87 | (interactive) 88 | (jump-to-register 9)) 89 | 90 | (defun split-window-below-and-switch () 91 | "Split the window horizontally, then switch to the new pane." 92 | (interactive) 93 | (split-window-below) 94 | (other-window 1)) 95 | 96 | (defun split-window-right-and-switch () 97 | "Split the window vertically, then switch to the new pane." 98 | (interactive) 99 | (split-window-right) 100 | (other-window 1)) 101 | 102 | (defun iterm-focus () 103 | (interactive) 104 | (do-applescript 105 | " do shell script \"open -a iTerm\"\n" 106 | )) 107 | 108 | (defun close-all-buffers () 109 | (interactive) 110 | (mapc 'kill-buffer (buffer-list))) 111 | 112 | (defun get-root () 113 | (let ((current-project (projectile-project-name))) 114 | (if (not current-project) 115 | (return "") 116 | current-project))) 117 | 118 | (defun rename-current-buffer-file () 119 | "Renames current buffer and file it is visiting." 120 | (interactive) 121 | (let ((name (buffer-name)) 122 | (filename (buffer-file-name))) 123 | (if (not (and filename (file-exists-p filename))) 124 | (error "Buffer '%s' is not visiting a file!" name) 125 | (let ((new-name (read-file-name "New name: " filename))) 126 | (if (get-buffer new-name) 127 | (error "A buffer named '%s' already exists!" new-name) 128 | (rename-file filename new-name 1) 129 | (rename-buffer new-name) 130 | (set-visited-file-name new-name) 131 | (set-buffer-modified-p nil) 132 | (message "File '%s' successfully renamed to '%s'" 133 | name (file-name-nondirectory new-name))))))) 134 | 135 | (defun codenav-imenu-candidates () 136 | "Get the candidates list from imenu." 137 | (let* ((items (imenu--make-index-alist)) 138 | (items (delete (assoc "*Rescan*" items) items))) 139 | items)) 140 | 141 | (defun codenav-flatten-candidates (candidates) 142 | "Flatten CANDIDATES of imenu list." 143 | (let (result) 144 | (dolist (candidate candidates result) 145 | (if (imenu--subalist-p candidate) 146 | (setq result (append result (codenav-flatten-candidates (cdr candidate)))) 147 | (add-to-list 'result candidate))) 148 | result)) 149 | 150 | (defun codenav-sort-candidates (candidates) 151 | (sort candidates (lambda (a b) (< (cdr a) (cdr b))))) 152 | 153 | 154 | (defun codenav-test-flatten-candidates () 155 | (interactive) 156 | (let* ((imenu-candidates (codenav-imenu-candidates)) 157 | (names-and-pos (codenav-sort-candidates (codenav-flatten-candidates imenu-candidates)))) 158 | (let ((a (nth 0 imenu-candidates))) 159 | (message "First element") 160 | (message "%s" a) 161 | (message "%s" (nth 1 a))) 162 | (message "\n\nRESULT:%s\n\n" names-and-pos))) 163 | 164 | 165 | (defun codenav-current-symbol (names-and-pos) 166 | "Figure out current definition by checking positions of NAMES-AND-POS against current position." 167 | (interactive) 168 | (let ((list-length (length names-and-pos)) 169 | (current-pos (point)) 170 | (current-index 0) 171 | (next-index 0)) 172 | (dolist (symbol names-and-pos) 173 | ;; If we reaches the end, just return the last element 174 | ;; instead of returning index+1 175 | (setq next-index (if (< next-index (1- list-length)) 176 | (1+ current-index) 177 | current-index)) 178 | (let* ((current-symbol-pos (marker-position (cdr symbol))) 179 | (next-symbol-pos (marker-position (cdr (nth next-index names-and-pos))))) 180 | (if (and (= current-index 0) (< current-pos current-symbol-pos)) 181 | (return 0)) 182 | (if (and (>= current-pos current-symbol-pos) (< current-pos next-symbol-pos)) 183 | (return current-index))) 184 | (setq current-index (1+ current-index))) 185 | ;; If last item, decrement index 186 | (if (eq current-index (length names-and-pos)) 187 | (1- current-index) 188 | current-index))) 189 | 190 | 191 | (defun codenav-next-definition () 192 | "Navigate to next function/class definition." 193 | (interactive) 194 | (let* ((imenu-candidates (codenav-imenu-candidates)) 195 | (names-and-pos (codenav-sort-candidates (codenav-flatten-candidates imenu-candidates))) 196 | (current-symbol (codenav-current-symbol names-and-pos)) 197 | (next-symbol-index (if (>= (1+ current-symbol) (length names-and-pos)) 0 198 | (1+ current-symbol))) 199 | (next-symbol (nth next-symbol-index names-and-pos))) 200 | (imenu next-symbol))) 201 | 202 | 203 | (defun codenav-prev-definition () 204 | "Navigate to previous function/class definition." 205 | (interactive) 206 | (let* ((imenu-candidates (codenav-imenu-candidates)) 207 | (names-and-pos (codenav-sort-candidates (codenav-flatten-candidates imenu-candidates))) 208 | (current-symbol (codenav-current-symbol names-and-pos)) 209 | (prev-symbol-index (if (< (1- current-symbol) 0) (1- (length names-and-pos)) 210 | (1- current-symbol))) 211 | (prev-symbol (nth prev-symbol-index names-and-pos))) 212 | (imenu prev-symbol))) 213 | 214 | 215 | (defun my-compile-goto-error-same-window () 216 | (interactive) 217 | (let ((display-buffer-overriding-action 218 | '((display-buffer-reuse-window 219 | display-buffer-in-previous-window) 220 | (inhibit-same-window . nil)))) 221 | (call-interactively #'compile-goto-error))) 222 | 223 | (defun my-compilation-mode-hook () 224 | (local-set-key (kbd "ENTER") #'my-compile-goto-error-same-window)) 225 | 226 | (add-hook 'compilation-mode-hook #'my-compilation-mode-hook) 227 | 228 | (provide 'config-functions) 229 | -------------------------------------------------------------------------------- /emacs-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml 287 | -------------------------------------------------------------------------------- /config/config-extensions.el: -------------------------------------------------------------------------------- 1 | (eval-after-load 'grep 2 | '(progn 3 | (add-to-list 'grep-find-ignored-directories "local") 4 | (add-to-list 'grep-find-ignored-directories "build") 5 | (add-to-list 'grep-find-ignored-directories "media"))) 6 | (add-hook 'grep-mode-hook (lambda() (toggle-truncate-lines 1))) 7 | 8 | (use-package ag) 9 | 10 | (use-package auto-highlight-symbol 11 | :config 12 | (global-auto-highlight-symbol-mode t) 13 | (setq ahs-case-fold-search nil)) 14 | 15 | (use-package anzu 16 | :config 17 | (global-anzu-mode +1) 18 | (global-set-key [remap query-replace] 'anzu-query-replace) 19 | (global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp)) 20 | 21 | (use-package avy 22 | :bind 23 | ("C-c j j" . avy-goto-char-timer) 24 | ("C-c j w" . avy-goto-word-1) 25 | ("C-c j l" . avy-goto-line)) 26 | 27 | (use-package buffer-move) 28 | 29 | (use-package company 30 | :bind 31 | ("M-TAB" . company-complete) 32 | ("M-;" . company-yasnippet) 33 | :custom 34 | (company-begin-commands '(self-insert-command)) 35 | (company-idle-delay .1) 36 | (company-minimum-prefix-length 2) 37 | (company-show-numbers t) 38 | (company-tooltip-align-annotations 't) 39 | :config 40 | (define-key company-active-map (kbd "C-n") (lambda () (interactive) (company-complete-common-or-cycle 1))) 41 | (define-key company-active-map (kbd "C-p") (lambda () (interactive) (company-complete-common-or-cycle -1))) 42 | (add-to-list 'company-backends 'company-yasnippet) 43 | (add-to-list 'company-backends 'company-dabbrev-code) 44 | :hook 45 | (after-init . global-company-mode)) 46 | 47 | (use-package company-statistics 48 | :config 49 | (company-statistics-mode)) 50 | 51 | (use-package counsel 52 | :custom 53 | (counsel-find-file-ignore-regexp ".*\.egg-info\\|__pycache__\\|.cache") 54 | :bind 55 | ("M-x" . counsel-M-x) 56 | ("C-x C-m" . counsel-M-x) 57 | ("C-x m" . counsel-M-x) 58 | ("C-x C-f" . counsel-find-file) 59 | ("C-x c k" . counsel-yank-pop) 60 | ("C-c j i" . counsel-imenu)) 61 | 62 | (use-package counsel-projectile 63 | :bind 64 | ("C-c p f" . counsel-projectile) 65 | ("C-c s p" . counsel-projectile-rg) 66 | :config 67 | (counsel-projectile-mode)) 68 | 69 | (use-package diffview 70 | :config 71 | ;; scroll-all-mode doesn't work with mouse. 72 | ;; WORKAROUND: https://www.emacswiki.org/emacs/ScrollAllMode 73 | (defun mwheel-scroll-all-function-all (func &optional arg) 74 | (if (and scroll-all-mode arg) 75 | (save-selected-window 76 | (walk-windows 77 | (lambda (win) 78 | (select-window win) 79 | (condition-case nil 80 | (funcall func arg) 81 | (error nil))))) 82 | (funcall func arg))) 83 | 84 | (defun mwheel-scroll-all-scroll-up-all (&optional arg) 85 | (mwheel-scroll-all-function-all 'scroll-up arg)) 86 | 87 | (defun mwheel-scroll-all-scroll-down-all (&optional arg) 88 | (mwheel-scroll-all-function-all 'scroll-down arg)) 89 | 90 | (setq mwheel-scroll-up-function 'mwheel-scroll-all-scroll-up-all) 91 | (setq mwheel-scroll-down-function 'mwheel-scroll-all-scroll-down-all) 92 | ;; Activate scoll-all-mode when in diffview mode 93 | (add-hook 'diffview-mode (lambda() (scroll-all-mode))) 94 | ) 95 | 96 | (use-package dired-single) 97 | 98 | (use-package dired-subtree 99 | :config 100 | (define-key dired-mode-map "i" 'dired-subtree-insert) 101 | (define-key dired-mode-map ";" 'dired-subtree-remove)) 102 | 103 | (use-package dockerfile-mode) 104 | 105 | (use-package dumb-jump 106 | :config 107 | (setq dumb-jump-force-searcher 'rg) 108 | (dumb-jump-mode)) 109 | 110 | (use-package ediff 111 | :custom 112 | (ediff-window-setup-function 'ediff-setup-windows-plain) 113 | (ediff-diff-options "-w") 114 | :config 115 | (setq-default ediff-highlight-all-diffs 'nil)) 116 | 117 | (use-package editorconfig 118 | :ensure t 119 | :config 120 | (editorconfig-mode 1)) 121 | 122 | (use-package erc 123 | :custom 124 | (erc-autojoin-channels-alist '(("freenode.net" "#qutebrowser" "#emacs"))) 125 | (erc-autojoin-timing 'ident) 126 | (erc-fill-function 'erc-fill-static) 127 | (erc-fill-static-center 22) 128 | (erc-hide-list '("JOIN" "PART" "QUIT")) 129 | (erc-lurker-hide-list '("JOIN" "PART" "QUIT")) 130 | (erc-lurker-threshold-time 43200) 131 | (erc-prompt-for-nickserv-password nil) 132 | (erc-server-reconnect-attempts 5) 133 | (erc-server-reconnect-timeout 3) 134 | (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT" 135 | "324" "329" "332" "333" "353" "477")) 136 | :config 137 | (add-to-list 'erc-modules 'notifications) 138 | (add-to-list 'erc-modules 'spelling) 139 | (erc-services-mode 1) 140 | (erc-update-modules)) 141 | 142 | (use-package exec-path-from-shell 143 | :config 144 | ;; Add GOPATH to shell 145 | (exec-path-from-shell-copy-env "GOPATH") 146 | (exec-path-from-shell-copy-env "PYTHONPATH") 147 | (exec-path-from-shell-copy-env "TERM") 148 | (exec-path-from-shell-initialize)) 149 | 150 | (use-package expand-region 151 | :bind 152 | ("C-=" . er/expand-region)) 153 | 154 | (use-package f) 155 | 156 | (use-package flycheck 157 | :init 158 | (setq flycheck-keymap-prefix (kbd "C-c e")) 159 | :custom 160 | (flycheck-indication-mode 'right-fringe) 161 | ;; Removed checks on idle/change for snappiness 162 | (flycheck-check-syntax-automatically '(save mode-enabled)) 163 | (flycheck-highlighting-mode 'symbols) 164 | (flycheck-disabled-checkers '(emacs-lisp emacs-lisp-checkdoc make)) 165 | ;; `flycheck-pos-tip' 166 | (flycheck-pos-tip-timeout 10) 167 | (flycheck-display-errors-delay 0.5) 168 | (flycheck-display-errors-function #'flycheck-display-error-messages-unless-error-list) 169 | :config 170 | (add-to-list 'display-buffer-alist 171 | `(,(rx bos "*Flycheck errors*" eos) 172 | (display-buffer-reuse-window 173 | display-buffer-in-side-window) 174 | (side . bottom) 175 | (reusable-frames . visible) 176 | (window-height . 0.23))) 177 | (when (eq window-system 'mac) 178 | (require 'flycheck-pos-tip) 179 | (flycheck-pos-tip-mode +1)) 180 | (global-flycheck-mode 1)) 181 | 182 | (use-package flycheck-pos-tip 183 | :config 184 | (flycheck-pos-tip-mode)) 185 | 186 | (use-package forge) 187 | 188 | (use-package git-gutter) 189 | 190 | (use-package git-link 191 | :config 192 | (setq git-link-open-in-browser t 193 | git-link-use-commit t)) 194 | 195 | ;; (use-package hl-line 196 | ;; :config 197 | ;; ;; Doesn't seem to play nice in emacs 25+ 198 | ;; (setq hl-line-sticky-flag nil 199 | ;; global-hl-line-sticky-flag nil) 200 | 201 | ;; (defvar-local current-hl-line-mode nil) 202 | ;; (defun hl-line-on () (if current-hl-line-mode (hl-line-mode +1))) 203 | ;; (defun hl-line-off () (if current-hl-line-mode (hl-line-mode -1))) 204 | ;; ;;(add-hook hl-line-mode (lambda () (if current-hl-line-mode (setq current-hl-line-mode t)))) 205 | ;; (global-hl-line-mode)) 206 | 207 | (use-package hungry-delete 208 | :config 209 | (global-hungry-delete-mode)) 210 | 211 | (use-package iedit 212 | :bind 213 | ("C-;" . iedit-mode)) 214 | 215 | (use-package imenu-list 216 | :custom 217 | (imenu-list-focus-after-activation t) 218 | (imenu-list-size 0.2) 219 | (imenu-list-auto-resize nil)) 220 | 221 | (use-package keyfreq 222 | :config 223 | (keyfreq-mode 1) 224 | (keyfreq-autosave-mode 1)) 225 | 226 | (use-package kill-or-bury-alive 227 | :bind 228 | ("C-c b x" . kill-or-bury-alive) 229 | ("C-c b k" . kill-buffer)) 230 | 231 | (use-package ledger-mode) 232 | 233 | (use-package magit 234 | :custom 235 | (magit-completing-read-function 'ivy-completing-read) 236 | :config 237 | (global-magit-file-mode -1) 238 | (setq magit-prefer-remote-upstream "origin") 239 | :bind 240 | ;; Magic 241 | ("C-c g s" . magit-status) 242 | ("C-c g x" . magit-checkout) 243 | ("C-c g c" . magit-commit) 244 | ("C-c g p" . magit-push) 245 | ("C-c g u" . magit-pull) 246 | ("C-c g e" . magit-ediff-resolve) 247 | ("C-c g r" . magit-rebase-interactive) 248 | ("C-c g b" . magit-blame)) 249 | 250 | (use-package magit-todos) 251 | 252 | (use-package magit-popup) 253 | 254 | (use-package markdown-mode) 255 | 256 | (use-package multiple-cursors 257 | :bind 258 | ("C-c s ." . mc/mark-next-like-this) 259 | ("C-c s ," . mc/mark-previous-like-this) 260 | ("C-c s >" . mc/mark-all-like-this) 261 | ("C-c s ;" . mc/skip-to-next-like-this) 262 | :custom 263 | (mc/list-file (concat temp-dir "/.mc-lists.el"))) 264 | 265 | (use-package page-break-lines) 266 | 267 | (use-package perspective 268 | :config 269 | (persp-mode) 270 | (setf (cdr persp-mode-map) nil)) 271 | 272 | (use-package persp-projectile 273 | :bind 274 | ("C-c p l" . projectile-persp-switch-project)) 275 | 276 | (use-package persistent-scratch 277 | :config 278 | (persistent-scratch-setup-default)) 279 | 280 | (use-package projectile 281 | :custom 282 | (projectile-enable-caching t) 283 | (projectile-cache-file (expand-file-name "projectile.cache" temp-dir)) 284 | (projectile-known-projects-file (expand-file-name "projectile-bookmarks.eld" temp-dir)) 285 | (projectile-completion-system 'ivy) 286 | (projectile-indexing-method 'native) 287 | (projectile-sort-order 'recently-active) 288 | :config 289 | (add-to-list 'projectile-globally-ignored-directories "node_modules") 290 | (add-to-list 'projectile-globally-ignored-directories "data/postgres") 291 | (add-to-list 'projectile-globally-ignored-directories "data/solr") 292 | (add-to-list 'projectile-globally-ignored-directories "data/mysql") 293 | (projectile-mode) 294 | :bind 295 | ("C-x c a" . projectile-ripgrep) 296 | ("C-c p k" . projectile-kill-buffers)) 297 | 298 | (use-package dashboard 299 | :load-path "~/.emacs.d/vendor/emacs-dashboard" 300 | :custom 301 | (dashboard-items '((recents . 10) 302 | (projects . 15) 303 | (bookmarks . 15) 304 | (registers . 10))) 305 | :config 306 | (setq dashboard-set-init-info t) 307 | (setq dashboard-set-navigator t) 308 | (setq dashboard-set-heading-icons t) 309 | (setq dashboard-set-file-icons t) 310 | (setq dashboard-center-content t) 311 | (setq dashboard-footer "Enjoy!") 312 | (setq dashboard-footer-icon 313 | (all-the-icons-octicon "dashboard" 314 | :height 1.1 315 | :v-adjust -0.05 316 | :face 'font-lock-keyword-face)) 317 | (dashboard-setup-startup-hook)) 318 | 319 | (if (memq window-system '(mac ns)) 320 | (use-package dash-at-point 321 | :bind 322 | ("C-c j x" . dash-at-point)) 323 | (use-package zeal-at-point 324 | :bind 325 | ("C-c j x" . zeal-at-point))) 326 | 327 | (use-package recentf 328 | :config 329 | (setq recentf-exclude '("/elpa/" ;; ignore all files in elpa directory 330 | ".*?autoloads.el$" 331 | "/tmp/" ;; ignore temporary files 332 | "*/.elfeed/index" 333 | "company-statistics-cache.el" 334 | ".gitignore" 335 | "*/Documents/org-mode" 336 | ) 337 | recentf-save-file (recentf-expand-file-name "~/.emacs.d/private/cache/recentf")) 338 | (recentf-mode 1)) 339 | 340 | (use-package resize-window 341 | :bind 342 | ("C-w /" . resize-window)) 343 | 344 | (use-package restclient 345 | :custom 346 | (restclient-log-request t) 347 | (restclient-same-buffer-response t)) 348 | 349 | (use-package rotate 350 | :bind 351 | ("C-w r w" . rotate-window) 352 | ("C-w r l" . rotate-layout)) 353 | 354 | (use-package smartparens 355 | :config 356 | (require 'smartparens-config)) 357 | 358 | (use-package smex 359 | :custom 360 | (smex-save-file (expand-file-name "smex-items" temp-dir))) 361 | 362 | (use-package sql 363 | :config 364 | (add-to-list 'auto-mode-alist '("\\.psql$" . sql-mode))) 365 | 366 | (use-package syntax-subword 367 | :config 368 | (syntax-subword-mode) 369 | :bind 370 | ("M-j" . syntax-subword-backward) 371 | ("M-l" . syntax-subword-forward)) 372 | 373 | (use-package undo-tree 374 | :config 375 | (global-undo-tree-mode 1) 376 | :custom 377 | ;; Remember undo history 378 | (undo-tree-auto-save-history nil) 379 | (undo-tree-history-directory-alist `(("." . ,(concat temp-dir "/undo/"))))) 380 | 381 | (use-package window-purpose 382 | :config 383 | (purpose-x-magit-single-on)) 384 | 385 | (use-package which-key 386 | :config 387 | (which-key-add-key-based-replacements 388 | "C-c b" "Buffers") 389 | (which-key-add-key-based-replacements 390 | "C-c e" "Errors") 391 | (which-key-add-key-based-replacements 392 | "C-c g" "Magit") 393 | (which-key-add-key-based-replacements 394 | "C-c h" "Hydras") 395 | (which-key-add-key-based-replacements 396 | "C-c j" "Jump") 397 | (which-key-add-key-based-replacements 398 | "C-c C-m" "Menu") 399 | (which-key-add-key-based-replacements 400 | "C-c m" "Major mode keys") 401 | (which-key-add-key-based-replacements 402 | "C-c o" "Org") 403 | (which-key-add-key-based-replacements 404 | "C-c p" "Projectile") 405 | (which-key-add-key-based-replacements 406 | "C-c r" "Resume") 407 | (which-key-add-key-based-replacements 408 | "C-c s" "Search") 409 | (which-key-add-key-based-replacements 410 | "C-c t" "Text") 411 | (which-key-add-key-based-replacements 412 | "C-c y" "Snippets") 413 | (which-key-add-key-based-replacements 414 | "C-w 5" "Frames") 415 | (which-key-mode)) 416 | 417 | (use-package winner 418 | :bind 419 | ("C-w u" . winner-undo) 420 | ("C-w r" . winner-redo) 421 | :config 422 | (winner-mode 1)) 423 | 424 | (use-package windmove 425 | :bind 426 | ("C-w C-w" . other-window) 427 | ("C-w w" . other-window) 428 | ("C-w i" . windmove-up) 429 | ("C-w k" . windmove-down) 430 | ("C-w j" . windmove-left) 431 | ("C-w l" . windmove-right)) 432 | 433 | (use-package wgrep) 434 | 435 | (use-package yaml-mode) 436 | 437 | (use-package yasnippet 438 | :bind (:map yas-minor-mode-map 439 | ("C-c &" . nil) 440 | ("C-c y i" . yas-insert-snippet) 441 | ("C-c y n" . yas-new-snippet) 442 | ("C-c y v" . yas-visit-snippet-file) 443 | ("C-c y s" . yas-insert-snippet) 444 | ("C-c y v" . yas-visit-snippet-file)) 445 | :config 446 | (yas-global-mode 1)) 447 | 448 | (use-package yasnippet-snippets) 449 | 450 | (use-package zoom-window 451 | :bind 452 | ("C-w z" . zoom-window-zoom) 453 | :custom 454 | (zoom-window-mode-line-color "#22252c")) 455 | 456 | (use-package diminish 457 | :config 458 | (defmacro diminish-minor-mode (filename mode &optional abbrev) 459 | `(eval-after-load (symbol-name ,filename) 460 | '(diminish ,mode ,abbrev))) 461 | 462 | (defmacro diminish-major-mode (mode-hook abbrev) 463 | `(add-hook ,mode-hook 464 | (lambda () (setq mode-name ,abbrev)))) 465 | 466 | (diminish-minor-mode 'abbrev 'abbrev-mode) 467 | (diminish-minor-mode 'company 'company-mode) 468 | (diminish-minor-mode 'eldoc 'eldoc-mode) 469 | (diminish-minor-mode 'flycheck 'flycheck-mode) 470 | (diminish-minor-mode 'flyspell 'flyspell-mode) 471 | (diminish-minor-mode 'projectile 'projectile-mode) 472 | (diminish-minor-mode 'undo-tree 'undo-tree-mode) 473 | (diminish-minor-mode 'yasnippet 'yas-minor-mode) 474 | (diminish-minor-mode 'magit 'auto-revert-mode) 475 | (diminish-minor-mode 'Git-Gutter 'git-gutter-mode) 476 | (diminish-minor-mode 'Which-Key 'which-key-mode) 477 | (diminish-minor-mode 'ivy 'ivy-mode) 478 | (diminish-major-mode 'emacs-lisp-mode-hook "el") 479 | (diminish-major-mode 'python-mode-hook "Py")) 480 | 481 | (provide 'config-extensions) 482 | --------------------------------------------------------------------------------