From dbbf80472609f5044b2fd84a5ca4a1708792b2f6 Mon Sep 17 00:00:00 2001 From: Max Regan Date: Tue, 19 Feb 2019 17:22:40 +0000 Subject: [PATCH] Update '.emacs.d/init.org" --- .emacs.d/init.org | 133 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 103 insertions(+), 30 deletions(-) diff --git a/.emacs.d/init.org b/.emacs.d/init.org index 85c4952..298ee7b 100644 --- a/.emacs.d/init.org +++ b/.emacs.d/init.org @@ -28,7 +28,6 @@ configuration that isn't in described this file. Configure some startup parameters. #+BEGIN_SRC emacs-lisp - (set-background-color "#000000") (line-number-mode t) (column-number-mode t) (setq inhibit-splash-screen t) @@ -49,7 +48,22 @@ Winner-mode keeps a history of window configurations. Handy when magit decides to blow away, or I hit the wrong key and blow away my windows. #+BEGIN_SRC emacs-lisp - (winner-mode t) +(use-package winner + :init + (winner-mode)) +#+END_SRC + +Add Purpose for binding a "purpose" to a window, such as "terminal" or +"edit", so only buffers with that purpose may end up in that +window. This helps keep things organized without too much manual +tweaking. You can also save and load window layouts and purposes. + +#+BEGIN_SRC emacs-lisp + (use-package window-purpose + :bind (("C-c p s" . purpose-set-window-purpose)) + :init (purpose-mode t) + ;(purpose-x-kill-setup) ;; This seems to cause slowness in helm + (purpose-x-magit-multi-on)) #+END_SRC By default, if you a region selected and hit "backspace" it does not @@ -80,7 +94,9 @@ Install magit, and explicitly call out with-editor as well, even though its a requirement for magit. #+BEGIN_SRC emacs-lisp - (use-package magit) + (use-package magit + :config (setq magit-bury-buffer-function 'magit-mode-quit-window)) + (use-package with-editor) #+END_SRC @@ -114,14 +130,6 @@ Multi-term is useful for having multiple terminal buffers. (add-to-list 'term-bind-key-alist bind))))) #+END_SRC -Eyebrowse is a package for managing multiple simultaneous window -configurations. - -#+BEGIN_SRC emacs-lisp - (use-package eyebrowse - :config (eyebrowse-mode t)) -#+END_SRC - Install helm, a completion framework, and install its functions over some of the usual emacs keybinds. @@ -129,10 +137,10 @@ some of the usual emacs keybinds. (use-package helm :config (helm-mode) :bind (("M-x" . helm-M-x) - ("C-c b" . helm-mini) + ("C-x b" . helm-mini) ("C-x C-b" . helm-buffers-list) - ("C-x b" . helm-buffers-list) - ("M-y" . helm-show-kill-ring))) + ("M-y" . helm-show-kill-ring)) + :init (setq helm-split-window-inside-p t)) #+END_SRC Install projectile for managing buffers within projects. @@ -164,6 +172,11 @@ Add helm-swoop for searching across multiple buffers. (use-package helm-swoop) #+END_SRC +#+BEGIN_SRC emacs-lisp + (use-package helm-purpose + :bind (("C-c b" . helm-purpose-switch-buffer-with-purpose))) +#+END_SRC + Use ws-butler to automatically clean up any trailing whitespace I leave behind. Other lines are left untouched. @@ -180,10 +193,10 @@ bottom of the window. :config (smooth-scrolling-mode t)) #+END_SRC -Tango dark is my standard of the last few years. +Monokai theme is my theme of choice. #+BEGIN_SRC emacs-lisp - (load-theme 'tango-dark) + (use-package monokai-theme) #+END_SRC Don't use the arrow keys, try to stay on the home row. @@ -192,31 +205,49 @@ Don't use the arrow keys, try to stay on the home row. (mapc 'global-unset-key '([left] [right] [up] [down] [C-down] [C-up] [C-right] [C-left])) #+END_SRC -Disable the mouse too. I don't really need it. +Use zoom-window to enable full-screening a single window, briefly. #+BEGIN_SRC emacs-lisp - (use-package disable-mouse - :config (global-disable-mouse-mode)) + (use-package zoom-window + :bind* ("C-c z z" . zoom-window-zoom)) #+END_SRC #+BEGIN_SRC emacs-lisp (use-package ace-window :bind* ("C-x o" . ace-window) - :init (progn - (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) - (setq aw-scope 'frame))) + :init (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) + (setq aw-scope 'frame)) #+END_SRC C-mode configurations. Set tab width to 4, since that's what I'm used to. #+BEGIN_SRC emacs-lisp - (setq c-default-style "linux" c-basic-offset 4) - (setq-default c-basic-offset 4 - tab-width 4 - indent-tabs-mode nil) - (add-hook 'c-mode-hook (lambda () - (setq c-hungry-delete-key t))) + (defun my-c-common-hook() + (setq c-hungry-delete-key t) + (adaptive-wrap-prefix-mode t) + (toggle-word-wrap t)) + + (add-hook 'c-mode-common-hook 'my-c-common-hook) +#+END_SRC + +#+BEGIN_SRC emacs-lisp + (setq-default c-basic-offset 4 + tab-width 4 + indent-tabs-mode nil) +#+END_SRC + +#+BEGIN_SRC emacs-lisp + (defconst my-cc-style + '("linux" + (c-offsets-alist . ((innamespace . [0]))))) + + (c-add-style "my-cc-style" my-cc-style) +#+END_SRC + +#+BEGIN_SRC emacs-lisp + (use-package highlight-doxygen + :init (highlight-doxygen-global-mode)) #+END_SRC Add the ability to toggle a buffer as dedicated to its window, to @@ -266,7 +297,7 @@ Boring buffers can still be found via helm/ibuffer. #+BEGIN_SRC emacs-lisp (defun buffer-is-boring (buffer) (or - (string-match-p "^\*" (buffer-name buffer)) + (and (string-match-p "^\*" (buffer-name buffer))) (string-match-p "^magit" (buffer-name buffer)))) (defun buffer-iterate (iter-fun) @@ -312,9 +343,51 @@ Boring buffers can still be found via helm/ibuffer. #+BEGIN_SRC emacs-lisp (use-package clang-format - :commands clang-format clang-format-buffer clang-format-region + :commands clang-format clang-format-buffer clang-format-region) #+END_SRC #+BEGIN_SRC emacs-lisp (add-to-list 'auto-mode-alist '("\\.ino\\'" . c++-mode)) + (add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode)) +#+END_SRC + +#+BEGIN_SRC emacs-lisp + (use-package yaml-mode) + (use-package markdown-mode) +#+END_SRC + + +#+BEGIN_SRC emacs-lisp + (use-package adaptive-wrap) +#+END_SRC + +Add cquery for completions. This requires. + +1. The cquery is checked out into ~/software/cquery/ and built. +2. The project has a .cquery file at its root, which specifies all of the includes paths. + +#+BEGIN_SRC emacs-lisp + (defun cquery//enable () + (condition-case nil + (lsp) + (user-error nil))) + + (use-package cquery + :commands lsp + :after (:any c-mode c++-mode objc-mode) + :config (setq cquery-executable "~/software/cquery/build/release/bin/cquery") + (add-hook 'c-mode-hook #'cquery//enable) + (add-hook 'c++-mode-hook #'cquery//enable) + ;; Do not use projectile for root-matching, since we have multiple git projects that are compiled together + (setq cquery-project-root-matchers '(cquery-project-roots-matcher "compile_commands.json" ".cquery" "build/compile_commands.json")) + (push 'company-lsp company-backends) + ) + + (use-package company + :init (add-hook 'c-mode-hook company-mode) + (add-hook 'c++-mode-hook company-mode) + ) + + (use-package company-lsp + :init (push 'company-lsp company-backends)) #+END_SRC