From 96d1a94d1796cf61fd4afe915ab62bb1c1992bc5 Mon Sep 17 00:00:00 2001 From: Marc Pohling Date: Sun, 6 May 2018 07:26:48 +0200 Subject: [PATCH] lazy loading for packages I don't need right away --- config.org | 148 +++++++++++++++++++++++++++++------------------------ 1 file changed, 82 insertions(+), 66 deletions(-) diff --git a/config.org b/config.org index b52db9a..2def06e 100644 --- a/config.org +++ b/config.org @@ -306,12 +306,14 @@ Smooth scrolling. Emacs tends to be jumpy, this should change it. #+END_SRC ** General (keymapper) I just use general.el to define keys and keymaps. With it I can set leader keys and create keymaps for them. It also integrates well with which-key. + [[https://github.com/noctuid/general.el][Source]] #+BEGIN_SRC emacs-lisp (use-package general :ensure t ) #+END_SRC + ** Custom key mappings Now some keymaps. If there is no map defined, it is considered the global key map. @@ -839,6 +841,7 @@ sudo apt install pandoc #+BEGIN_SRC emacs-lisp (unless (string-equal user-login-name "POH") (use-package notmuch + :defer t :ensure t ) ) @@ -864,22 +867,23 @@ sudo apt install pandoc Activate the beancount mode. ATTENTION: This mode is made by myself. #+BEGIN_SRC emacs-lisp - (unless (string-equal user-login-name "POH") - (load "/home/marc/.emacs.d/user-local/elisp/beancount-mode.el") ; somehow load-path in use-package doesn't work - (use-package beancount - :load-path "/home/marc/.emacs.d/elisp" - :mode ("\\.beancount$" . beancount-mode) - :init - (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) - (setenv "PATH" - (concat - "/opt/beancount/bin:" - (getenv "PATH")) - ) - :config - (setq beancount-filename-main "/home/marc/Archiv/Finanzen/transactions.beancount") - ) +(unless (string-equal user-login-name "POH") + (load "/home/marc/.emacs.d/user-local/elisp/beancount-mode.el") ; somehow load-path in use-package doesn't work + (use-package beancount + :load-path "/home/marc/.emacs.d/elisp" + :defer t + :mode ("\\.beancount$" . beancount-mode) + :init + (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) + (setenv "PATH" + (concat + "/opt/beancount/bin:" + (getenv "PATH")) + ) + :config + (setq beancount-filename-main "/home/marc/Archiv/Finanzen/transactions.beancount") ) +) #+END_SRC Installing fava for reports is strongly recommended. @@ -989,27 +993,29 @@ Highlight parens etc. for improved readability - F u git pull #+BEGIN_SRC emacs-lisp - (use-package magit - :ensure t - :init - ;; set git-path in work environment - (if (string-equal user-login-name "POH") - (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe") - ) - :defer t - :bind (("C-x g" . magit-status)) - ) +(use-package magit + :ensure t + :defer t + :init + ;; set git-path in work environment + (if (string-equal user-login-name "POH") + (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe") + ) + :defer t + :bind (("C-x g" . magit-status)) +) #+END_SRC *** Git-gutter Display line changes in gutter based on git history. Enable it everywhere [[https://github.com/syohex/emacs-git-gutter][Source]] #+BEGIN_SRC emacs-lisp - (use-package git-gutter - :ensure t - :config - (global-git-gutter-mode t) - :diminish git-gutter-mode - ) +(use-package git-gutter + :ensure t + :defer t + :config + (global-git-gutter-mode t) + :diminish git-gutter-mode +) #+END_SRC Some persistent navigation in git-gutter is nice, so here's a hydra for it: @@ -1045,9 +1051,10 @@ _l_: last hunk set start _R_evision Time machine lets me step through the history of a file as recorded in git. [[https://github.com/pidu/git-timemachine][Source]] #+BEGIN_SRC emacs-lisp - (use-package git-timemachine - :ensure t - ) +(use-package git-timemachine + :ensure t + :defer t +) #+END_SRC ** Company Mode @@ -1214,6 +1221,7 @@ Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's #+BEGIN_SRC emacs-lisp (use-package yasnippet :ensure t + :defer t :diminish yas-minor-mode :init (setq yas-snippet-dirs (concat PATH_USER_GLOBAL "snippets")) @@ -1233,6 +1241,7 @@ Add some helpers to handle and understand macros #+BEGIN_SRC emacs-lisp (use-package macrostep :ensure t + :defer t :init (define-key emacs-lisp-mode-map (kbd "C-c e") 'macrostep-expand) (define-key emacs-lisp-mode-map (kbd "C-c c") 'macrostep-collapse)) @@ -1255,17 +1264,18 @@ Add some helpers to handle and understand macros Also limit the completion backends to those which make sense in Python. #+BEGIN_SRC emacs-lisp - (use-package python - :mode ("\\.py\\'" . python-mode) - :interpreter ("python" . python-mode) - :init - (add-hook 'python-mode-hook (lambda () - 'company/python-mode-hook - (semantic-mode t) - (flycheck-select-checker 'python-pylint))) - :config - (setq python-shell-completion-native-enable nil) - ) +(use-package python + :mode ("\\.py\\'" . python-mode) + :interpreter ("python" . python-mode) + :defer t + :init + (add-hook 'python-mode-hook (lambda () + 'company/python-mode-hook + (semantic-mode t) + (flycheck-select-checker 'python-pylint))) + :config + (setq python-shell-completion-native-enable nil) +) #+END_SRC @@ -1297,6 +1307,7 @@ TODO: automatically start an inferior python process or switch to it if already #+BEGIN_SRC emacs-lisp (use-package pyvenv :ensure t + :defer t :init (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")) :config @@ -1334,7 +1345,7 @@ Depends on pyvenv (use-package auto-virtualenv :ensure t ;; :after pyvenv -;; :defer t + :defer t :init (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv) ;; activate on changing buffers @@ -1375,15 +1386,16 @@ Anaconda test - pdf-tools #+BEGIN_SRC emacs-lisp - (unless (string-equal user-login-name "POH") - (use-package pdf-tools - :ensure t - :config - (pdf-tools-install) - (setq TeX-view-program-selection '((output-pdf "pdf-tools"))) - (setq TeX-view-program-list '(("pdf-tools" "Tex-pdf-tools-sync-view"))) - ) - ) +(unless (string-equal user-login-name "POH") + (use-package pdf-tools + :ensure t + :defer t + :config + (pdf-tools-install) + (setq TeX-view-program-selection '((output-pdf "pdf-tools"))) + (setq TeX-view-program-list '(("pdf-tools" "Tex-pdf-tools-sync-view"))) + ) +) #+END_SRC For latex-preview-pane a patch might be necessary (as of 2017-10), see the issue [[https://github.com/jsinglet/latex-preview-pane/issues/37][here]] @@ -1396,18 +1408,21 @@ Anaconda test After that M-x byte-compile-file #+BEGIN_SRC emacs-lisp - (use-package latex-preview-pane - :ensure t - ) - (setq auto-mode-alist - (append '(("\\.tex$" . latex-mode)) auto-mode-alist)) - ;; one of these works - (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode) - (add-hook 'latex-mode-hook 'latex-preview-pane-mode) +(use-package latex-preview-pane + :ensure t + :defer t + :init + ;; one of these works + (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode) + (add-hook 'latex-mode-hook 'latex-preview-pane-mode) + (setq auto-mode-alist + (append '(("\\.tex$" . latex-mode)) auto-mode-alist)) +) - ;; necessary, because linum-mode isn't compatible and prints errors - (add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1))) +;; necessary, because linum-mode isn't compatible and prints errors +(add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1))) #+END_SRC + ** Markdown Major mode to edit markdown files. For previews it needs markdown installed on the system. @@ -1418,7 +1433,8 @@ Anaconda test #+BEGIN_SRC emacs-lisp (use-package markdown-mode - :ensure t) + :ensure t + :defer t) #+END_SRC ** Hydra Flycheck