-
-
Save spac3unit/9eacd03061994c7b5bd8fbc0d9780c3b to your computer and use it in GitHub Desktop.
Complete Emacs for C++ development with cquery for symbol nav and autocomplete (company)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;; Commentary: | |
| ;; Emacs configuration clean, fast-loading, optimized for development | |
| ;; reference: https://sriramkswamy.github.io/dotemacs/ | |
| ;; cquery | |
| ;; helm | |
| ;; swiper | |
| ;; counsel | |
| ;; neo-tree (vcs-intgration) | |
| ;; flycheck | |
| ;; google-style (cpplint) | |
| ;; magit | |
| ;; projectile | |
| ;; Colors set for dark background. See FACE CUSTOMIZATION section. | |
| ;; SYSTEM SETUP RECOMMENDATIONS | |
| ;; Emacs aliases | |
| ;; alias ec-kill-emacs='emacsclient -e "(kill-emacs)"' | |
| ;; alias ec="emacsclient -t -a ''" | |
| ;; Tmux support | |
| ;; make a ~/.tmux.conf file | |
| ;; put this in it: | |
| ;; #set-window-option -g xterm-keys on | |
| ;; set -g xterm-keys on | |
| ;; set -g default-terminal "xterm-256color" | |
| ;; set -g terminal-overrides "xterm*:kLFT2=\eOD:kRIT2=\eOC:kUP2=\eOA:kDN2=\eOB:smkx@:rmkx@" | |
| ;; PREREQUISITES: | |
| ;; 1. Install clang-3.9 (along with clang-format) or higher | |
| ;; 1. Install the latest version of cquery: https://github.com/cquery-project/cquery | |
| ;; 2. Ensure that cquery is in the $PATH | |
| ;; 3. Install cpplint: pip install cpplint | |
| ;; 4. Set the path to cpplint in your file_system below | |
| ;; 5. Install pyflakes: pip install pyflakes | |
| ;; 6. Install tern: npm i -g tern | |
| ;; 7. Install these: | |
| ;; pip install rope | |
| ;; pip install jedi | |
| ;; pip install flake8 | |
| ;; pip install importmagic | |
| ;; pip instsall epc | |
| ;; pip insall virtualenv | |
| ;; 8. Install these | |
| ;; silversearcher: https://github.com/ggreer/the_silver_searcher#installing | |
| ;; ack: sudo apt-get install ack-grep | |
| ;; 9. Add your ~/.agignore | |
| ;; **/log/ | |
| ;; **/logs/ | |
| ;; **/images/ | |
| ;; **/javascripts/ | |
| ;; **/stylesheets/ | |
| ;; **/tmp/ | |
| ;; **/vendor/ | |
| ;; **/build/ | |
| ;; **/_build/ | |
| ;; **/deps/ | |
| ;; **/node_modules/ | |
| ;; *.sql | |
| ;; *.tags* | |
| ;; *.gemtags* | |
| ;; *.csv | |
| ;; *.tsv | |
| ;; *.tmp* | |
| ;; *.css | |
| ;; *.scss | |
| ;; *.old | |
| ;; *.json | |
| ;; *.xml | |
| ;; *.html | |
| ;; *.plist | |
| ;; *.md | |
| ;; *.log | |
| ;; 10. Install the flake8 config | |
| ;; add this to ~/.config/flake8 | |
| ;; [flake8] | |
| ;; ignore = E221,E501,E203,E202,E272,E251,E211,E222,E701 | |
| ;; max-line-length = 160 | |
| ;; exclude = tests/* | |
| ;; max-complexity = 10 | |
| ;; KEY BINDINGS | |
| ;; helm prefix: C-x c | |
| ;; helm find-files: C-x c f | |
| ;; move up one directory in helm find files: C-l | |
| ;; helm find-files with grep: C-x c f C-s | |
| ;; helm find-files with grep recursive: Cx c f C-u C-s | |
| ;; jump to previous cursor position: C-u C-SPC | |
| ;; jump to next cursor position: C-x C-SPC | |
| ;; projectile prefix: C-c p | |
| ;; projectile switch projects: C-c p p | |
| ;; projectile find file: C-c p f | |
| ;; projectile helm: C-c p h | |
| ;; projectile search grep: C-p s g | |
| ;; projectile search agg (silversearcher): C-p s s | |
| ;;; Code: | |
| ;; make escape default cancel key | |
| ;; (define-key key-translation-map (kbd "ESC") (kbd "C-g")) | |
| (setq inhibit-startup-message t) | |
| (setq initial-scratch-message "") | |
| ;; trim whitespaces | |
| (add-hook 'before-save-hook 'delete-trailing-whitespace) | |
| ;; enable line numbers | |
| (global-linum-mode t) | |
| (setq linum-format "%3d\u2502 ") | |
| (line-number-mode t) | |
| (column-number-mode t) | |
| (size-indication-mode t) | |
| ;; no hard tabs | |
| (setq indent-tabs-mode nil) | |
| ;; buffers reflect external file changes | |
| (global-auto-revert-mode t) | |
| ;; motd | |
| (add-hook 'emacs-startup-hook | |
| (lambda () | |
| (when (string= (buffer-name) "*scratch*") | |
| (progn | |
| (animate-string ";; Let's make something amazing!" (/ (frame-height) 2))) | |
| (goto-char (point-min))))) | |
| ;; evaluate temporary-file-directory in scratch to see what it is set to for your os | |
| ;; Save all tempfiles in $TMPDIR/emacs-$UID/ | |
| (defconst emacs-tmp-dir (format "%s%s%s/" temporary-file-directory "emacs-" (user-login-name))) | |
| (setq backup-directory-alist | |
| `((".*" . ,(format "%s/%s" emacs-tmp-dir "backed-up-files")))) | |
| (setq auto-save-file-name-transforms | |
| `((".*" ,(format "%s/%s" emacs-tmp-dir "auto-saved-files") t))) | |
| (setq auto-save-list-file-prefix (format "%s/%s" emacs-tmp-dir "auto-saved-files")) | |
| ;; backup file control configuration | |
| (setq make-backup-files t ; backup of a file the first time it is saved. | |
| backup-by-copying t ; don't clobber symlinks | |
| version-control t ; version numbers for backup files | |
| delete-old-versions t ; delete excess backup files silently | |
| delete-by-moving-to-trash t | |
| kept-old-versions 6 ; oldest versions to keep when a new numbered backup is made (default: 2) | |
| kept-new-versions 9 ; newest versions to keep when a new numbered backup is made (default: 2) | |
| auto-save-default t ; auto-save every buffer that visits a file | |
| auto-save-timeout 20 ; number of seconds idle time before auto-save (default: 30) | |
| auto-save-interval 200 ; number of keystrokes between auto-saves (default: 300) | |
| ) | |
| ;; Save place in files | |
| ;; (require 'saveplace) | |
| (if (fboundp #'save-place-mode) | |
| (save-place-mode +1) | |
| (setq-default save-place t)) | |
| ;; disable the annoying bell ring | |
| (setq ring-bell-function 'ignore) | |
| ;; auto-revert any buffers that change on disk if not dirty | |
| global-auto-revert-mode | |
| ;; don't blink the cursor | |
| (blink-cursor-mode 0) | |
| ;; nice scrolling | |
| (setq scroll-margin 0 | |
| scroll-conservatively 100000 | |
| scroll-preserve-screen-position 1) | |
| ;; no text wrapping | |
| (setq-default truncate-lines t) | |
| ;; set threshold for large files | |
| (setq large-file-warning-threshold (* 15 1024 1024)) | |
| ;; gdb configuration | |
| (setq gdb-many-windows t | |
| gdb-show-main t) | |
| ;; save command history | |
| (savehist-mode) | |
| ;; PACKAGE INSTALLATION AND CONFIGURATION | |
| ;; set up package sources | |
| (require 'package) | |
| (setq package-enable-at-startup nil) | |
| (add-to-list 'package-archives | |
| '("melpa" . "https://melpa.org/packages/")) | |
| (package-initialize) | |
| ;; Bootstrap `use-package' | |
| (unless (package-installed-p 'use-package) | |
| (package-refresh-contents) | |
| (package-install 'use-package)) | |
| ;; small interface tweaks | |
| (setq inhibit-startup-message t) | |
| (tool-bar-mode -1) | |
| (fset 'yes-or-no-p 'y-or-n-p) | |
| (global-set-key (kbd "<f5>") 'revert-buffer) | |
| ;; recent files | |
| (require 'recentf) | |
| (setq recentf-max-saved-items 200 | |
| recentf-max-menu-items 15) | |
| (recentf-mode) | |
| ;; windmove setup | |
| (defun ignore-error-wrapper (fn) | |
| "Funtion return new function that ignore errors. | |
| The function wraps a function with `ignore-errors' macro." | |
| (let ((fn fn)) | |
| (lambda () | |
| (interactive) | |
| (ignore-errors | |
| (funcall fn))))) | |
| (when (fboundp 'windmove-default-keybindings) | |
| (progn | |
| (windmove-default-keybindings) | |
| (global-set-key [s-left] (ignore-error-wrapper 'windmove-left)) | |
| (global-set-key [s-right] (ignore-error-wrapper 'windmove-right)) | |
| (global-set-key [s-up] (ignore-error-wrapper 'windmove-up)) | |
| (global-set-key [s-down] (ignore-error-wrapper 'windmove-down)))) | |
| ;; enable winner-mode | |
| (when (fboundp 'winner-mode) | |
| (winner-mode 1)) | |
| ;; source control should follow symlinks | |
| (setq vc-follow-symlinks t) | |
| ;; electric pairs | |
| (electric-pair-mode 1) | |
| (show-paren-mode 1) | |
| (setq show-paren-delay 0) | |
| ;;; Packages | |
| ;; ;; use neotree | |
| ;; (use-package neotree | |
| ;; :ensure t | |
| ;; :defer t | |
| ;; :init | |
| ;; (progn | |
| ;; (global-set-key [f8] 'neotree-toggle) | |
| ;; ;; every time when the neotree window is opened, it will try to find current | |
| ;; ;; file and jump to node. | |
| ;; (setq-default neo-smart-open t) | |
| ;; ;; set to desired width | |
| ;; (setq neo-window-width 40) | |
| ;; ;; (setq neo-window-fixed-size nil) | |
| ;; (setq neo-theme 'nerd) ; 'classic, 'nerd, 'ascii, 'arrow | |
| ;; ;; autorefresh | |
| ;; (setq neo-autorefresh t) | |
| ;; ;; automatically switch project root to where file that is opened without prompting | |
| ;; (setq neo-force-change-root t) | |
| ;; ;; automatically indent to arrow of nerd theme | |
| ;; (custom-set-variables | |
| ;; '(neo-auto-indent-point t)) | |
| ;; ;; enable source control state tracking | |
| ;; (progn | |
| ;; (setq neo-vc-integration '(face char)) | |
| ;; ;; patch to fix vc integration | |
| ;; (defun neo-vc-for-node (node) | |
| ;; (let* ((backend (vc-backend node)) | |
| ;; (vc-state (when backend (vc-state node backend)))) | |
| ;; ;; (message "%s %s %s" node backend vc-state) | |
| ;; (cons (cdr (assoc vc-state neo-vc-state-char-alist)) | |
| ;; (cl-case vc-state | |
| ;; (up-to-date neo-vc-up-to-date-face) | |
| ;; (edited neo-vc-edited-face) | |
| ;; (needs-update neo-vc-needs-update-face) | |
| ;; (needs-merge neo-vc-needs-merge-face) | |
| ;; (unlocked-changes neo-vc-unlocked-changes-face) | |
| ;; (added neo-vc-added-face) | |
| ;; (removed neo-vc-removed-face) | |
| ;; (conflict neo-vc-conflict-face) | |
| ;; (missing neo-vc-missing-face) | |
| ;; (ignored neo-vc-ignored-face) | |
| ;; (unregistered neo-vc-unregistered-face) | |
| ;; (user neo-vc-user-face) | |
| ;; (t neo-vc-default-face)))))))) | |
| ;; use treemacs | |
| (use-package treemacs | |
| :ensure t | |
| :commands (treemacs) | |
| :config | |
| (setq treemacs-change-root-without-asking t | |
| treemacs-follow-after-init t | |
| treemacs-no-png-images t | |
| treemacs-project-follow-cleanup t | |
| treemacs-recenter-after-file-follow t | |
| treemacs-git-integration t | |
| treemacs-width 40) | |
| (setq treemacs-icon-open-text (propertize "📂 " 'face 'treemacs-directory-face) | |
| treemacs-icon-closed-text (propertize "📁 " 'face 'treemacs-directory-face) | |
| treemacs-icon-tag-leaf-text (propertize "● " 'face 'treemacs-term-node-face) | |
| treemacs-icon-tag-node-open-text (propertize "💿 " 'face 'treemacs-tags-face) | |
| treemacs-icon-tag-node-closed-text (propertize "📀 " 'face 'treemacs-tags-face) | |
| treemacs-icon-text (propertize "📄 " 'face 'treemacs-file-face)) | |
| (define-key treemacs-mode-map [mouse-1] #'treemacs-doubleclick-action) | |
| (treemacs-git-mode 'simple) | |
| :bind ("<f1> <f1>" . treemacs-select-window) | |
| ("<s-kp-decimal>" . treemacs-select-window) | |
| ("<s-S-kp-decimal>" . treemacs-find-file) | |
| ("<S-f1> <S-f1>" . treemacs-find-file)) | |
| (use-package treemacs-projectile :ensure t | |
| :commands (treemacs-projectile)) | |
| ;; on the fly syntax checking | |
| (use-package flycheck | |
| :ensure t | |
| :init | |
| (global-flycheck-mode t)) | |
| ;; snippets and snippet expansion | |
| (use-package yasnippet | |
| :ensure t | |
| :init (add-hook 'prog-mode-hook #'yas-minor-mode) | |
| :config (yas-reload-all)) | |
| (use-package yasnippet-snippets | |
| :ensure t) | |
| (use-package hydra | |
| :ensure t) | |
| (use-package multiple-cursors | |
| :ensure t | |
| :bind* (("C-c m c" . mc/edit-lines))) | |
| (use-package ws-butler | |
| :ensure t | |
| :diminish ws-butler-mode | |
| :config | |
| (ws-butler-global-mode)) | |
| (use-package highlight-symbol | |
| :ensure t | |
| :bind (("M-n" . highlight-symbol-next) | |
| ("M-p" . highlight-symbol-prev)) | |
| :config | |
| (highlight-symbol-nav-mode)) | |
| (use-package volatile-highlights | |
| :ensure t | |
| :demand t | |
| :diminish volatile-highlights-mode | |
| :config | |
| (volatile-highlights-mode t)) | |
| (use-package helm | |
| :diminish helm-mode | |
| :ensure t | |
| :config | |
| (progn | |
| (setq helm-split-window-in-side-p t) ; open helm buffer inside current window, not occupy whole other window | |
| (defun spacemacs//helm-hide-minibuffer-maybe () | |
| (when (with-helm-buffer helm-echo-input-in-header-line) | |
| (let ((ov (make-overlay (point-min) (point-max) nil nil t))) | |
| (overlay-put ov 'window (selected-window)) | |
| (overlay-put ov 'face | |
| (let ((bg-color (face-background 'default nil))) | |
| `(:background ,bg-color :foreground ,bg-color))) | |
| (setq-local cursor-type nil)))) | |
| ;; set helm height | |
| (add-hook 'helm-minibuffer-set-up-hook | |
| 'spacemacs//helm-hide-minibuffer-maybe) | |
| (setq helm-autoresize-max-height 0) | |
| (setq helm-autoresize-min-height 40) | |
| (helm-autoresize-mode 1)) | |
| :init | |
| (progn | |
| ;;(require 'helm-config) | |
| (setq helm-candidate-number-limit 100) | |
| ;; From https://gist.github.com/antifuchs/9238468 | |
| (setq helm-idle-delay 0.0 ; update fast sources immediately (doesn't). | |
| helm-input-idle-delay 0.01 ; this actually updates things | |
| ; reeeelatively quickly. | |
| helm-yas-display-key-on-candidate t | |
| helm-quick-update t | |
| helm-M-x-requires-pattern nil | |
| helm-ff-skip-boring-files t) | |
| ;; what sources will we show in helm-mini | |
| (setq helm-mini-default-sources | |
| '(helm-source-buffers-list | |
| ;; helm-source-bookmarks | |
| helm-source-recentf | |
| helm-source-buffer-not-found)) | |
| ;; suppress headerline | |
| (setq helm-display-header-line nil) ;; t by default | |
| (setq helm-echo-input-in-header-line t) | |
| ;; suppress modline while in helm | |
| (helm-mode) | |
| ;; make helms grepping recursive by default - MAY HAVE UNINTENTIONAL SIDE-EFFECTS ON DIRS GREPPED | |
| (eval-after-load 'helm-grep | |
| '(setq helm-grep-default-command helm-grep-default-recurse-command)) | |
| ;; turn on helm mode | |
| (progn | |
| ;; 1. Collect bottom buffers | |
| (defvar bottom-buffers nil | |
| "List of bottom buffers before helm session. | |
| Its element is a pair of `buffer-name' and `mode-line-format'.") | |
| (defun bottom-buffers-init () | |
| (when bottom-buffers | |
| (bottom-buffers-show-mode-line)) | |
| (setq bottom-buffers | |
| (cl-loop for w in (window-list) | |
| when (window-at-side-p w 'bottom) | |
| collect (with-current-buffer (window-buffer w) | |
| (cons (buffer-name) mode-line-format))))) | |
| (add-hook 'helm-before-initialize-hook #'bottom-buffers-init) | |
| ;; 2. Hide mode line | |
| (defun bottom-buffers-hide-mode-line () | |
| (mapc (lambda (elt) | |
| (with-current-buffer (car elt) | |
| (setq-local mode-line-format nil))) | |
| bottom-buffers)) | |
| (add-hook 'helm-after-initialize-hook #'bottom-buffers-hide-mode-line) | |
| ;; 3. Restore mode line | |
| (defun bottom-buffers-show-mode-line () | |
| (when bottom-buffers | |
| (mapc (lambda (elt) | |
| (with-current-buffer (car elt) | |
| (setq-local mode-line-format (cdr elt)))) | |
| bottom-buffers) | |
| (setq bottom-buffers nil))) | |
| (add-hook 'helm-exit-minibuffer-hook #'bottom-buffers-show-mode-line) | |
| (defun helm-keyboard-quit-advice (orig-func &rest args) | |
| (bottom-buffers-show-mode-line) | |
| (apply orig-func args)) | |
| (advice-add 'helm-keyboard-quit :around #'helm-keyboard-quit-advice)) | |
| ) | |
| :bind ( | |
| ("C-x c b" . helm-buffers-list) | |
| ("C-x c f" . helm-find-files) | |
| ("C-x c m" . helm-mini) | |
| ("C-x c o" . helm-imenu) | |
| ("C-h a" . helm-apropos) | |
| ("C-x C-b" . helm-buffers-list) | |
| ;;("C-x b" . helm-buffers-list) ;; belongs to ivy | |
| ("M-y" . helm-show-kill-ring) | |
| ("M-x" . helm-M-x) | |
| ("C-x c o" . helm-occur) | |
| ("C-x c s" . helm-swoop) | |
| ("C-x c y" . helm-yas-complete) | |
| ("C-x c Y" . helm-yas-create-snippet-on-region) | |
| ("C-x c SPC" . helm-all-mark-rings)) | |
| ) | |
| (use-package spaceline | |
| :ensure t | |
| :demand t | |
| :init | |
| (setq powerline-default-separator 'arrow-fade) | |
| :config | |
| (require 'spaceline-config) | |
| (spaceline-spacemacs-theme) | |
| (spaceline-helm-mode)) | |
| ;; use this if you want to see where you've exceeded column width | |
| ;; (use-package column-enforce-mode | |
| ;; :ensure t | |
| ;; :diminish column-enforce-mode | |
| ;; :init | |
| ;; (setq column-enforce-column 80) | |
| ;; :config | |
| ;; (progn | |
| ;; (add-hook 'prog-mode-hook 'column-enforce-mode))) | |
| (use-package undo-tree | |
| :ensure t | |
| :config | |
| (global-undo-tree-mode 1)) | |
| (use-package origami | |
| :ensure t | |
| :commands (origami-toggle-node)) | |
| (use-package git-timemachine | |
| :ensure t | |
| :commands (git-timemachine-toggle | |
| git-timemachine-switch-branch)) | |
| (use-package smex | |
| :ensure t | |
| :config | |
| (smex-initialize)) | |
| (use-package flx-ido | |
| :ensure t | |
| :defer t) | |
| (use-package ivy | |
| :ensure t | |
| :config | |
| (progn | |
| (require 'ivy) | |
| (ivy-mode 1))) | |
| (use-package swiper | |
| :ensure t | |
| :config | |
| (ivy-mode 1) | |
| (use-package counsel | |
| :ensure t) | |
| ;; Enable switching to the ``special'' buffers | |
| (setq ivy-use-virtual-buffers t) | |
| ;; Create and delete a view | |
| ;; (global-set-key (kbd "C-c v") 'ivy-push-view) | |
| ;; (global-set-key (kbd "C-c V") 'ivy-pop-view) | |
| (global-set-key "\C-s" 'swiper) | |
| (global-set-key (kbd "C-c C-r") 'ivy-resume) | |
| (global-set-key (kbd "M-x") 'counsel-M-x) | |
| (global-set-key (kbd "C-x C-f") 'counsel-find-file)) | |
| (use-package projectile | |
| :ensure t | |
| :init | |
| (progn | |
| ;; C-c p h to switch to it | |
| (use-package helm-projectile | |
| :ensure t)) | |
| :config | |
| (progn | |
| (projectile-global-mode) | |
| (helm-projectile-on) | |
| (add-hook 'prog-mode-hook 'projectile-mode) | |
| (setq projectile-enable-caching t) | |
| (setq projectile-completion-system 'ivy) | |
| ;; (setq projectile-switch-project-action 'neotree-projectile-action) | |
| ;; search superordinate dirs until root | |
| ;; (setq projectile-find-dir-includes-top-level t) | |
| (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) | |
| ;; use ag instread of grep for helm-projectile-grep (REQUIRES AG) | |
| ;; (define-advice helm-projectile-grep (:override (&optional dir) ag) | |
| ;; (helm-do-ag (or dir (projectile-project-root)))) | |
| ;; globally ignore certain directory and file patterns | |
| (add-to-list 'projectile-globally-ignored-directories "**/_build/") | |
| (add-to-list 'projectile-globally-ignored-directories "**/deps/") | |
| (add-to-list 'projectile-globally-ignored-directories "**/node_modules/") | |
| (add-to-list 'projectile-globally-ignored-directories "**/thirdparty/") | |
| (add-to-list 'projectile-globally-ignored-directories "**/build/") | |
| (add-to-list 'projectile-globally-ignored-directories "**/log/") | |
| (add-to-list 'projectile-globally-ignored-directories "**/logs/") | |
| (add-to-list 'projectile-globally-ignored-files "*.min.js") | |
| (add-to-list 'projectile-globally-ignored-files "**.min.js") | |
| (add-to-list 'projectile-globally-ignored-files "*/**.min.js") | |
| (add-to-list 'projectile-globally-ignored-files "**/*.min.js") | |
| ;; ignore certain directory and file patterns during grepping | |
| (add-to-list 'grep-find-ignored-directories "**/_build/") | |
| (add-to-list 'grep-find-ignored-directories "**/deps/") | |
| (add-to-list 'grep-find-ignored-directories "**/node_modules/") | |
| (add-to-list 'grep-find-ignored-directories "**/build/") | |
| (add-to-list 'grep-find-ignored-directories "**/thirdparty/") | |
| (add-to-list 'grep-find-ignored-directories "**/log/") | |
| (add-to-list 'grep-find-ignored-directories "**/logs/") | |
| (add-to-list 'grep-find-ignored-files "**/*.log") | |
| ;; use ~/.agignore in home directory when filteirng results. | |
| (setq helm-ag-command-option " -U" ) | |
| )) | |
| (use-package magit | |
| :ensure t | |
| :config (progn | |
| (defun run-projectile-invalidate-cache (&rest _args) | |
| ;; We ignore the args to `magit-checkout'. | |
| (projectile-invalidate-cache nil)) | |
| (advice-add 'magit-checkout | |
| :after #'run-projectile-invalidate-cache) | |
| (advice-add 'magit-branch-and-checkout ; This is `b c'. | |
| :after #'run-projectile-invalidate-cache) | |
| (setq magit-completing-read-function 'ivy-completing-read))) | |
| (use-package gist | |
| :ensure t) | |
| (use-package beacon | |
| :ensure t | |
| :diminish beacon-mode | |
| :config | |
| (beacon-mode 1) | |
| (setq beacon-dont-blink-commands nil) ;; always blink | |
| ;; (setq beacon-lighter '"Λ") - | |
| (add-to-list 'beacon-dont-blink-major-modes 'Man-mode) | |
| (add-to-list 'beacon-dont-blink-major-modes 'shell-mode)) | |
| ;; SEARCHING | |
| ;; Requires ack install: sudo apt-get install ack-grep | |
| (use-package ack | |
| :ensure t) | |
| ;; Requires silversearcher install: https://github.com/ggreer/the_silver_searcher#installing | |
| (use-package ag | |
| :ensure t) | |
| (use-package helm-ag | |
| :ensure t) | |
| ;; LANGUAGE CUSTOMIZATION | |
| ;; EMACS LISP | |
| (use-package emacs-lisp-mode | |
| :mode ("\\.el$" . emacs-lisp-mode) | |
| :bind (:map emacs-lisp-mode-map | |
| ("C-c I" . describe-function) | |
| ("C-c S" . find-function-at-point))) | |
| (use-package macrostep | |
| :ensure t | |
| :commands (macrostep-expand | |
| macrostep-mode)) | |
| (use-package auto-compile | |
| :ensure t) | |
| ;; C/C++ | |
| (use-package flymake-cursor | |
| :ensure t | |
| :config | |
| (setq flymake-run-in-place nil)) | |
| (use-package flymake-google-cpplint | |
| :ensure t | |
| :init | |
| :config | |
| (add-hook 'c-mode-hook 'flymake-google-cpplint-load) | |
| (add-hook 'c++-mode-hook 'flymake-google-cpplint-load) | |
| (custom-set-variables | |
| ;; MacOS | |
| ;; '(flymake-google-cpplint-command "/System/Library/Frameworks/Python.framework/Versions/2.7/bin/cpplint") | |
| ;; Linux | |
| '(flymake-google-cpplint-command "/usr/local/bin/cpplint") | |
| '(flymake-google-cpplint-verbose "--verbose=0") | |
| ;; Note that I've turned off build rules. May want those on, e.g. +build/include | |
| '(flymake-google-cpplint-filter "--filter=-whitespace/line_length,-build"))) | |
| (use-package google-c-style | |
| :ensure t | |
| :init | |
| (add-hook 'c-mode-common-hook 'google-set-c-style) | |
| (add-hook 'c-mode-common-hook 'google-make-newline-indent)) | |
| ;; PYTHON | |
| ;; (use-package python | |
| ;; :ensure t | |
| ;; :mode ("\\.py\\'" . python-mode) | |
| ;; :config | |
| ;; (setq python-shell-interpreter "ipython" | |
| ;; python-shell-interpreter-args "-i")) | |
| ;; (use-package python | |
| ;; :ensure t | |
| ;; :mode ("\\.py\\'" . python-mode)) | |
| (use-package python | |
| :ensure t | |
| :defer t | |
| :mode ("\\.py\\'" . python-mode)) | |
| (use-package elpy | |
| :ensure t | |
| :after python | |
| :config (progn | |
| (elpy-enable) | |
| (highlight-indentation-mode -1))) | |
| (defun setup-python () | |
| "Setup python dev env." | |
| (progn | |
| (setq python-shell-interpreter "jupyter" | |
| python-shell-interpreter-args "console --simple-prompt" | |
| python-shell-prompt-detect-failure-warning nil) | |
| (add-to-list 'python-shell-completion-native-disabled-interpreters | |
| "jupyter") | |
| (use-package company-jedi | |
| :ensure t | |
| :config | |
| (progn | |
| (defun company-jedi-setup () | |
| (add-to-list 'company-backends 'company-jedi)) | |
| (add-hook 'python-mode-hook 'company-jedi-setup) | |
| (setq jedi:complete-on-dot t) | |
| (add-hook 'python-mode-hook 'jedi:setup))))) | |
| (add-hook 'python-mode-hook 'setup-python) | |
| (use-package py-autopep8 | |
| :ensure t | |
| ;; :config | |
| ;; (add-hook 'python-mode-hook 'py-autopep8-enable-on-save) | |
| ) | |
| ;; ELIXIR | |
| (use-package elixir-mode | |
| :commands elixir-mode | |
| :config | |
| (add-hook 'elixir-mode-hook 'alchemist-mode)) | |
| (use-package alchemist | |
| :commands alchemist-mode | |
| :config | |
| ;; Bind some Alchemist commands to more commonly used keys. | |
| (bind-keys :map alchemist-mode-map | |
| ("C-c C-l" . (lambda () (interactive) | |
| (save-buffer) | |
| (alchemist-iex-compile-this-buffer)))) | |
| (bind-keys :map alchemist-mode-map | |
| ("C-x C-e" . alchemist-iex-send-current-line))) | |
| ;; JAVASCRIPT | |
| (use-package js3-mode | |
| :ensure t | |
| :mode ("\\.js$" . js3-mode)) | |
| (use-package tern | |
| :ensure t | |
| :diminish tern-mode | |
| :defer 2 | |
| :config | |
| (progn | |
| (add-hook 'js-mode-hook '(lambda () (tern-mode t))))) | |
| (use-package skewer-mode | |
| :ensure t | |
| :diminish skewer-mode | |
| :commands (skewer-mode | |
| skewer-html-mode | |
| skewer-css-mode | |
| run-skewer | |
| skewer-repl | |
| list-skewer-clients | |
| skewer-eval-defun | |
| skewer-eval-last-expression | |
| skewer-eval-print-last-expression | |
| skewer-load-buffer | |
| skewer-bower-load | |
| skewer-bower-refresh | |
| skewer-run-phantomjs | |
| skewer-phantomjs-kill)) | |
| (use-package nodejs-repl | |
| :ensure t | |
| :commands (nodejs-repl | |
| nodejs-repl-send-buffer | |
| nodejs-repl-switch-to-repl | |
| nodejs-repl-send-region | |
| nodejs-repl-send-last-expression | |
| nodejs-repl-execute | |
| nodejs-repl-load-file)) | |
| (use-package nvm | |
| :ensure t | |
| :commands (nvm-use | |
| nvm-use-for)) | |
| ;; JSON | |
| (use-package json-mode | |
| :ensure t | |
| :mode "\\.json$") | |
| (use-package json-snatcher | |
| :ensure t | |
| :commands (jsons-print-path)) | |
| ;; YAML | |
| (use-package yaml-mode | |
| :ensure t | |
| :mode "\\.yml$") | |
| ;; MARKDOWN | |
| (use-package markdown-mode | |
| :ensure t | |
| :mode ("\\.md\\'" . markdown-mode)) | |
| ;; COMPILATION AND DEBUGGING | |
| (setq compilation-finish-functions | |
| (lambda (buf str) | |
| (if (null (string-match ".*exited abnormally.*" str)) | |
| ;;no errors, make the compilation window go away in a few seconds | |
| (progn | |
| (run-at-time "0.4 sec" nil | |
| (lambda () | |
| (select-window (get-buffer-window (get-buffer-create "*compilation*"))) | |
| (switch-to-buffer nil))) | |
| (message "No Compilation Errors!"))))) | |
| (use-package realgud | |
| :ensure t | |
| :commands (realgud:gdb | |
| realgud:ipdb | |
| realgud:pdb)) | |
| (use-package quickrun | |
| :ensure t | |
| :commands (quickrun | |
| quickrun-region | |
| quickrun-with-arg | |
| quickrun-shell | |
| quickrun-compile-only | |
| quickrun-replace-region)) | |
| ;; clang-format can be triggered using C-c C-f | |
| ;; Install clang-format: $ apt-get install clang-format-3.9 | |
| ;; $ ln -s `which clang-format-3.9` ~/bin/clang-format | |
| ;; Create clang-format file using google style | |
| ;; clang-format -style=google -dump-config > .clang-format | |
| (use-package clang-format | |
| :ensure | |
| :config | |
| (global-set-key (kbd "C-c C-f") 'clang-format-region)) | |
| ;; CQUERY SETUP | |
| (use-package lsp-mode | |
| :ensure t | |
| :defer t | |
| :config (progn | |
| ;; (require 'lsp-flycheck) | |
| (set-face-attribute 'lsp-face-highlight-textual nil | |
| :background "#666" :foreground "#ffffff"))) | |
| ;; (with-eval-after-load 'projectile | |
| ;; (setq projectile-project-root-files-top-down-recurring | |
| ;; (append '("compile_commands.json" | |
| ;; ".cquery") | |
| ;; projectile-project-root-files-top-down-recurring))) | |
| (defun cquery//enable () | |
| (condition-case nil | |
| (lsp-cquery-enable) | |
| (user-error nil))) | |
| (use-package cquery | |
| :ensure t | |
| :commands lsp-cquery-enable | |
| :init (add-hook 'c-mode-common-hook #'cquery//enable)) | |
| ;; setup as needed for your env/projects | |
| ;; also see lsp-project-whitelist lsp-project-blacklist cquery-root-matchers | |
| (setq cquery-project-roots '("~/repo" )) | |
| ;; (setq cquery-executable "/usr/local/bin/cquery") | |
| (setq cquery-extra-args '("--log-file=/tmp/cq.log")) | |
| (setq cquery-cache-dir "~/.cache/cquery_cached_index") | |
| ;; initialization options | |
| (setq cquery-extra-init-params '(:index (:blacklist (".*/vendor/nvidia/.*" ".*\.s")) :diagnostics (:blacklist (".*\.s")))) | |
| ;; (setq cquery-extra-init-params '(:enableIndexOnDidChange t :index (:blacklist (".*/vendor/nvidia/.*" ".*\.s")) :diagnostics (:blacklist (".*\.s")))) | |
| ;; company-lsp | |
| (use-package company-lsp | |
| :ensure t | |
| :init (global-company-mode) | |
| :config | |
| (progn | |
| (push 'company-lsp company-backends))) | |
| ;; helm xref | |
| ;; comment out to use default: xref--show-xref-buffer | |
| (use-package helm-xref | |
| :ensure t | |
| :config | |
| (progn | |
| (setq xref-show-xrefs-function 'helm-xref-show-xrefs) | |
| (setq helm-xref-candidate-formatting-function 'helm-xref-format-candidate-long))) | |
| ;; additional cpp file extensions | |
| (add-hook 'after-init-hook | |
| (function (lambda() | |
| (add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode)) | |
| (add-to-list 'auto-mode-alist '("\\.inl\\'" . c++-mode)) | |
| (add-to-list 'auto-mode-alist '("\\.inc\\'" . c++-mode)) | |
| (add-to-list 'auto-mode-alist '("\\.cc\\'" . c++-mode)) | |
| ))) | |
| ;; CUSTOM SET VARIABLES | |
| (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. | |
| '(custom-safe-themes | |
| (quote | |
| ("2941526f0165b681482a7bfe61b071db10c6df090d04a530c593254ea6412054" "cd03a600a5f470994ba01dd3d1ff52d5809b59b4a37357fa94ca50a6f7f07473" "15348febfa2266c4def59a08ef2846f6032c0797f001d7b9148f30ace0d08bcf" "718fb4e505b6134cc0eafb7dad709be5ec1ba7a7e8102617d87d3109f56d9615" "3fa81193ab414a4d54cde427c2662337c2cab5dd4eb17ffff0d90bca97581eb6" "b85fc9f122202c71b9884c5aff428eb81b99d25d619ee6fde7f3016e08515f07" "081d0f8a263358308245355f0bb242c7a6726fc85f0397d65b18902ea95da591" "e9460a84d876da407d9e6accf9ceba453e2f86f8b86076f37c08ad155de8223c" "30f7c9e85d7fad93cf4b5a97c319f612754374f134f8202d1c74b0c58404b8df" "ed0b4fc082715fc1d6a547650752cd8ec76c400ef72eb159543db1770a27caa7" "6ac7c0f959f0d7853915012e78ff70150bfbe2a69a1b703c3ac4184f9ae3ae02" "bc40f613df8e0d8f31c5eb3380b61f587e1b5bc439212e03d4ea44b26b4f408a" "291588d57d863d0394a0d207647d9f24d1a8083bb0c9e8808280b46996f3eb83" "f41ecd2c34a9347aeec0a187a87f9668fa8efb843b2606b6d5d92a653abe2439" default))) | |
| '(elpy-modules | |
| (quote | |
| (elpy-module-company elpy-module-eldoc elpy-module-flymake elpy-module-pyvenv elpy-module-yasnippet elpy-module-django elpy-module-sane-defaults))) | |
| '(flymake-google-cpplint-command "/usr/local/bin/cpplint") | |
| '(flymake-google-cpplint-filter "--filter=-whitespace/line_length,-build") | |
| '(flymake-google-cpplint-verbose "--verbose=0") | |
| '(neo-auto-indent-point t) | |
| '(package-selected-packages | |
| (quote | |
| (ack ag company-jedi popwin gist swiper-helm helm-ag treemacs-projectile treemacs shackle nova-theme reverse-theme flatui-theme flatui-dark-theme atom-one-dark-theme atom-dark-theme subatomic256-theme darkburn-theme moe-theme gruvbox-theme soothe-theme klere-theme clang-format helm-xref lsp-ui company-lsp cquery lsp-mode markdown-mode default-text-scale drag-stuff elixir-mode quickrun realgud nvm nodejs-repl skewer-mode tern json-mode js3-mode cmake-ide yaml-mode git-timemachine origami spaceline ws-butler column-enforce-mode volatile-highlights highlight-symbol undo-tree smex flx-ido flymake-cursor flymake-google-cpplint google-c-style flymake-google-ccplint helm-gtags magit helm-projectile counsel-projectile yasnippet use-package neotree ggtags flycheck))) | |
| '(python-indent-offset 2) | |
| '(send-mail-function (quote mailclient-send-it))) | |
| ;; FACE CUSTOMIZATION | |
| (when (not (display-graphic-p)) | |
| (progn | |
| ;; to see all current faces colors, run | |
| ;; list-faces-display | |
| ;; selected region color | |
| ;; (set-face-attribute 'region nil :background "#666" :foreground "#ffffff") | |
| (set-face-attribute 'region nil :background "color-236") | |
| ;; highlight line | |
| (global-hl-line-mode 1) | |
| (set-face-background 'hl-line "#1c1c1c") | |
| ;; set highlight face for dark screens | |
| (set-face-background 'highlight "darkblue") | |
| (set-face-background 'secondary-selection "darkblue") | |
| ;; the background color of selection line in helm | |
| (set-face-attribute 'helm-selection nil :background "#441100") | |
| ;; helm | |
| (set-face-attribute 'helm-selection nil | |
| :background "color-236" :weight 'ultra-light) | |
| (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. | |
| '(helm-source-header ((t (:background "color-17" :foreground "black" :weight bold :height 1.3 :family "Sans Serif")))) | |
| '(neo-dir-link-face ((t (:foreground "color-26")))) | |
| '(neo-file-link-face ((t (:foreground "color-247")))) | |
| '(show-paren-match ((t (:background "brightblue")))))) | |
| (progn | |
| (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. | |
| '(neo-dir-link-face ((t (:foreground "Blue")))) | |
| '(show-paren-match ((t (:background "light sky blue"))))))) | |
| (provide '.emacs) | |
| ;;; .emacs ends here | |
| (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. | |
| '(helm-source-header ((t (:background "color-17" :foreground "black" :weight bold :height 1.3 :family "Sans Serif")))) | |
| '(neo-dir-link-face ((t (:foreground "color-26")))) | |
| '(neo-file-link-face ((t (:foreground "color-247")))) | |
| '(show-paren-match ((t (:background "brightblue"))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment