Various init file optimizations

This commit is contained in:
Jeremy Dormitzer 2020-01-07 17:04:34 -05:00
parent 12183b916a
commit c3d9832295

View File

@ -10,11 +10,6 @@ Enables lexical binding for everything in init.el:
;;; -*- lexical-binding: t; -*- ;;; -*- lexical-binding: t; -*-
#+END_SRC #+END_SRC
Requires:
#+BEGIN_SRC emacs-lisp
(require 'json)
#+END_SRC
Variables: Variables:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(setq vc-follow-symlinks t) (setq vc-follow-symlinks t)
@ -61,7 +56,8 @@ Load [[https://github.com/raxod502/straight.el][straight.el]] to manage package
Load org-mode early to [[https://github.com/raxod502/straight.el#the-wrong-version-of-my-package-was-loaded][avoid a version clash]] (but don't load it if the bootstrap file already did): Load org-mode early to [[https://github.com/raxod502/straight.el#the-wrong-version-of-my-package-was-loaded][avoid a version clash]] (but don't load it if the bootstrap file already did):
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package org (use-package org
:straight org-plus-contrib) :straight org-plus-contrib
:mode (("\\.org\\'" . org-mode)))
#+END_SRC #+END_SRC
* Doom themes * Doom themes
@ -314,11 +310,6 @@ Interfacing with Pass, the "standard Unix password manager". This should also be
#+END_SRC #+END_SRC
* Emacs Lisp * Emacs Lisp
Requires:
#+BEGIN_SRC emacs-lisp
(eval-when-compile (require 'subr-x))
#+END_SRC
** Packages ** Packages
Some helpful ELisp packages: Some helpful ELisp packages:
- [[https://github.com/kiwanami/emacs-deferred][deferred]] is an async API library - [[https://github.com/kiwanami/emacs-deferred][deferred]] is an async API library
@ -360,7 +351,8 @@ Some helpful ELisp packages:
(use-package dash) (use-package dash)
(use-package dash-functional) (use-package dash-functional)
(use-package f) (use-package f)
(use-package request) (use-package request
:commands (request request-deferred))
#+END_SRC #+END_SRC
** Editing Elisp ** Editing Elisp
@ -1401,8 +1393,8 @@ Set up evil keybindings:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package evil-org (use-package evil-org
:after (evil org) :after (evil org)
:hook (org-mode . evil-org-mode)
:config :config
(add-hook 'org-mode-hook #'evil-org-mode)
(add-hook 'evil-org-mode-hook (add-hook 'evil-org-mode-hook
(lambda () (lambda ()
(evil-org-set-key-theme (evil-org-set-key-theme
@ -1515,7 +1507,6 @@ Finally, add a helpful agenda-mode hydra:
(general-def '(normal visual motion insert emacs) org-agenda-mode-map "." 'hydra-org-agenda/body)) (general-def '(normal visual motion insert emacs) org-agenda-mode-map "." 'hydra-org-agenda/body))
#+END_SRC #+END_SRC
** Exporting ** Exporting
*** HTML *** HTML
Export to HTML: Export to HTML:
@ -1618,7 +1609,9 @@ Display inline images after executing a source block:
Enable async source block execution. Note: this execute the contents of the source block in a separate Emacs process, so blocks that rely on anything defined in init.org or the current Emacs process won't work as expected. Enable async source block execution. Note: this execute the contents of the source block in a separate Emacs process, so blocks that rely on anything defined in init.org or the current Emacs process won't work as expected.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package ob-async (use-package ob-async
:straight (ob-async :host github :repo "astahlman/ob-async")) :straight (ob-async :host github :repo "astahlman/ob-async")
:defer t
:hook (org-mode . (lambda () (require 'ob-async))))
#+END_SRC #+END_SRC
** Images ** Images
@ -2003,6 +1996,7 @@ Emacs support for the Language Server Protocol
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package lsp-mode (use-package lsp-mode
:defer t
:init :init
(defhydra hydra-lsp (:exit t :hint nil) (defhydra hydra-lsp (:exit t :hint nil)
" "
@ -2069,16 +2063,18 @@ Emacs support for the Language Server Protocol
["Misc." ["Misc."
("T" "Edit template" dap-debug-edit-template) ("T" "Edit template" dap-debug-edit-template)
("h" "Hydra" dap-hydra)]) ("h" "Hydra" dap-hydra)])
:commands (dap-mode)
:hook ((python-mode) . dap-mode)
:config :config
(add-hook 'dap-mode-hook
(lambda ()
(dap-ui-mode 1)
(dap-tooltip-mode 1)))
(require 'dap-python) (require 'dap-python)
:general :general
(leader-map "cm" 'dap-dispatch) (leader-map "cm" 'dap-dispatch)
((normal visual motion) "zd" 'dap-dispatch)) ((normal visual motion) "zd" 'dap-dispatch))
(dap-mode 1)
(dap-ui-mode 1)
(dap-tooltip-mode 1)
(with-eval-after-load 'lsp-clients (with-eval-after-load 'lsp-clients
(defun lsp-typescript-javascript-tsx-jsx-activate-p (filename major-mode) (defun lsp-typescript-javascript-tsx-jsx-activate-p (filename major-mode)
"Checks if the javascript-typescript language server should be enabled "Checks if the javascript-typescript language server should be enabled
@ -2090,34 +2086,6 @@ Emacs support for the Language Server Protocol
(string-suffix-p ".js" filename t)))))) (string-suffix-p ".js" filename t))))))
#+END_SRC #+END_SRC
* Java
LSP Java uses the Eclipse JDT Language Server as a backend to enable Java IDE features.
#+BEGIN_SRC emacs-lisp
(defun jdormit/set-up-java ()
(lsp-java-enable)
(flycheck-mode t)
(push 'company-lsp company-backends)
(company-mode t)
(lsp-ui-flycheck-enable t)
(set-variable 'c-basic-offset 2)
(lsp-ui-sideline-mode))
(use-package lsp-java
:requires (lsp-ui-flycheck lsp-ui-sideline)
:config
(add-hook 'java-mode-hook 'jdormit/set-up-java)
(setq lsp-inhibit-message t
lsp-java-import-maven-enabled t))
#+END_SRC
Configure Java project sources:
#+BEGIN_SRC emacs-lisp
(setq lsp-java--workspace-folders
(list (expand-file-name "~/src/Automation")
(expand-file-name "~/src/AutomationSharedExecution")
(expand-file-name "~/src/AutomationPlatform")))
#+END_SRC
* Python * Python
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
;; (leader-def-key "sp" #'elpy-shell-switch-to-shell) ;; (leader-def-key "sp" #'elpy-shell-switch-to-shell)
@ -2285,8 +2253,10 @@ Clj-refactor adds magical refactoring abilities:
Enable Org-mode Clojure evaluation: Enable Org-mode Clojure evaluation:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(require 'ob-clojure) (add-hook 'org-mode-hook
(setq org-babel-clojure-backend 'cider) (lambda ()
(require 'ob-clojure)
(setq org-babel-clojure-backend 'cider)))
#+END_SRC #+END_SRC
Integrate with cljfmt, the Clojure code formatter: Integrate with cljfmt, the Clojure code formatter:
@ -2694,8 +2664,9 @@ Instead of the *GNU Emacs* buffer on startup, display a cool dashboard:
dashboard-startup-banner 'official dashboard-startup-banner 'official
dashboard-set-heading-icons t dashboard-set-heading-icons t
dashboard-set-file-icons t dashboard-set-file-icons t
dashboard-set-navigator t) dashboard-set-navigator t))
(dashboard-setup-startup-hook))
(dashboard-setup-startup-hook)
#+END_SRC #+END_SRC
For some reason Emacs is starting up with the dashboard and the *scratch* buffer open in a split configuration. Not sure why, but let's put a stop to that... For some reason Emacs is starting up with the dashboard and the *scratch* buffer open in a split configuration. Not sure why, but let's put a stop to that...
@ -3296,73 +3267,6 @@ Because emojis make everything better.
(leader-def-key "te" 'emojify-mode) (leader-def-key "te" 'emojify-mode)
#+END_SRC #+END_SRC
* Mastodon
[[https://joinmastodon.org/][Mastodon]] is a federated FOSS social network similar to Twitter. Let's put it in Emacs!
First, install a dependency:
#+BEGIN_SRC emacs-lisp
(use-package discover)
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun jdormit/mastodon-setup ()
(general-def 'normal mastodon-mode-map "j" #'mastodon-tl--goto-next-toot)
(general-def 'normal mastodon-mode-map "k" #'mastodon-tl--goto-prev-toot)
(general-def 'normal mastodon-mode-map "h" #'mastodon-tl--next-tab-item)
(general-def 'normal mastodon-mode-map "l" #'mastodon-tl--previous-tab-item)
(general-def 'normal mastodon-mode-map [?\t] #'mastodon-tl--next-tab-item)
(general-def 'normal mastodon-mode-map [backtab] #'mastodon-tl--previous-tab-item)
(general-def 'normal mastodon-mode-map [?\S-\t] #'mastodon-tl--previous-tab-item)
(general-def 'normal mastodon-mode-map [?\M-\t] #'mastodon-tl--previous-tab-item)
;; Navigating to other buffers:
(general-def 'normal mastodon-mode-map "N" #'mastodon-notifications--get)
(general-def 'normal mastodon-mode-map "A" #'mastodon-profile--get-toot-author)
(general-def 'normal mastodon-mode-map "U" #'mastodon-profile--show-user)
(general-def 'normal mastodon-mode-map "F" #'mastodon-tl--get-federated-timeline)
(general-def 'normal mastodon-mode-map "H" #'mastodon-tl--get-home-timeline)
(general-def 'normal mastodon-mode-map "L" #'mastodon-tl--get-local-timeline)
(general-def 'normal mastodon-mode-map "t" #'mastodon-tl--thread)
(general-def 'normal mastodon-mode-map "T" #'mastodon-tl--get-tag-timeline)
(general-def 'normal mastodon-mode-map "q" #'kill-this-buffer)
(general-def 'normal mastodon-mode-map "Q" #'kill-buffer-and-window)
;; Actions
(general-def 'normal mastodon-mode-map "c" #'mastodon-tl--toggle-spoiler-text-in-toot)
(general-def 'normal mastodon-mode-map "g" #'undefined) ;; override special mode binding
(general-def 'normal mastodon-mode-map "n" #'mastodon-toot)
(general-def 'normal mastodon-mode-map "r" #'mastodon-toot--reply)
(general-def 'normal mastodon-mode-map "u" #'mastodon-tl--update)
(general-def 'normal mastodon-mode-map "b" #'mastodon-toot--toggle-boost)
(general-def 'normal mastodon-mode-map "f" #'mastodon-toot--toggle-favourite)
(general-def 'normal mastodon-mode-map "?" #'makey-key-mode-popup-mastodon)
(general-def 'normal mastodon-profile-mode-map "F" #'mastodon-profile--open-followers)
(general-def 'normal mastodon-profile-mode-map "f" #'mastodon-profile--open-following))
(eval-and-compile
(defun mastodon-load-path ()
(expand-file-name "~/mastodon.el/lisp")))
(if (file-exists-p (mastodon-load-path))
(use-package mastodon
:load-path (lambda () (mastodon-load-path))
:init (setq mastodon-instance-url "https://mastodon.technology")
:config
(jdormit/mastodon-setup)
:commands
(mastodon
mastodon-toot))
(use-package mastodon
:init (setq mastodon-instance-url "https://mastodon.technology")
:config
(jdormit/mastodon-setup)
:commands
(mastodon
mastodon-toot)))
(jdormit/define-prefix "aM" "mastodon")
(leader-def-key "aMm" 'mastodon)
(leader-def-key "aMt" 'mastodon-toot)
#+END_SRC
* Calc * Calc
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(leader-def-key "ac" 'calc) (leader-def-key "ac" 'calc)
@ -3456,7 +3360,7 @@ Or Gnus can read RSS feeds directly:
#+END_SRC #+END_SRC
* Dired * Dired
Set up a hydra for dired and enable [[info:dired-x#Top][Dired-X]]: Set up a hydra for dired:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package dired (use-package dired
:straight (:type built-in) :straight (:type built-in)
@ -3491,7 +3395,7 @@ Set up a hydra for dired and enable [[info:dired-x#Top][Dired-X]]:
("G" dired-do-chgrp) ("G" dired-do-chgrp)
("g" revert-buffer) ;; read all directories again (refresh) ("g" revert-buffer) ;; read all directories again (refresh)
("i" dired-maybe-insert-subdir) ("i" dired-maybe-insert-subdir)
("l" dired-do-redisplay) ;; relist the marked or singel directory ("l" dired-do-redisplay) ;; relist the marked or single directory
("M" dired-do-chmod) ("M" dired-do-chmod)
("m" dired-mark) ("m" dired-mark)
("O" dired-display-file) ("O" dired-display-file)
@ -3511,8 +3415,6 @@ Set up a hydra for dired and enable [[info:dired-x#Top][Dired-X]]:
("Z" dired-do-compress) ("Z" dired-do-compress)
("q" nil) ("q" nil)
("." nil :color blue)) ("." nil :color blue))
:config
(require 'dired-x)
:general :general
((normal visual motion insert emacs) dired-mode-map "." 'hydra-dired/body) ((normal visual motion insert emacs) dired-mode-map "." 'hydra-dired/body)
(dired-mode-map "SPC" leader-map)) (dired-mode-map "SPC" leader-map))
@ -3669,7 +3571,8 @@ An alternative minibuffer completion framework:
(use-package graphviz-dot-mode (use-package graphviz-dot-mode
:mode (("\\.dot\\'" . graphviz-dot)) :mode (("\\.dot\\'" . graphviz-dot))
:init :init
(add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))) (with-eval-after-load 'org
(add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))))
#+END_SRC #+END_SRC
** Functions ** Functions
@ -4326,16 +4229,17 @@ Some functions to make my day job easier.
** Debug configurations (dap) ** Debug configurations (dap)
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(dap-register-debug-template (with-eval-after-load 'dap-mode
"lola-server" (dap-register-debug-template
(list :type "python" "lola-server"
:args "bin/start_web.py" (list :type "python")
:cwd (expand-file-name "~/lola/lola-server") :args "bin/start_web.py"
:env (extract-vars-from-env-file (expand-file-name "~/lola/lola-server/.env")) :cwd (expand-file-name "~/lola/lola-server")
:module nil :env (extract-vars-from-env-file (expand-file-name "~/lola/lola-server/.env"))
:program nil :module nil
:request "launch" :program nil
:name "lola-server")) :request "launch"
:name "lola-server"))
#+END_SRC #+END_SRC
** AWS-MFA ** AWS-MFA
@ -4600,7 +4504,8 @@ Explore APIs from within Emacs!
(add-to-list 'company-backends 'company-restclient)) (add-to-list 'company-backends 'company-restclient))
(use-package ob-restclient (use-package ob-restclient
:after (restclient)) :defer t
:hook (org-mode . (lambda () (require 'ob-restclient))))
#+END_SRC #+END_SRC
* IMenu * IMenu