diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2019-12-24 20:48:26 +0000 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2019-12-24 20:48:26 +0000 |
commit | 06176839808fa7a9b30fce0f44abb58658909af0 (patch) | |
tree | 741aa4034087ee8a8a9bb6c14dfb2b3053cd361a | |
parent | b8c97cd89c1472355fb3a2a337ef0b22c7268428 (diff) |
Massive changes to emacs config - basing a lot on https://github.com/MatthewZMD/.emacs.d/blob/master/README.md#orgcfd324a
Diffstat (limited to '')
-rw-r--r-- | custom-settings.el | 13 | ||||
-rw-r--r-- | init.el | 369 |
2 files changed, 277 insertions, 105 deletions
diff --git a/custom-settings.el b/custom-settings.el index 5295a47..45fd95c 100644 --- a/custom-settings.el +++ b/custom-settings.el @@ -35,13 +35,19 @@ ("FIXME" . "#dc752f") ("XXX+" . "#dc752f") ("\\?\\?\\?+" . "#dc752f")))) + '(ivy-count-format "【%d/%d】") + '(ivy-height 10) + '(ivy-magic-slash-non-match-action (quote ivy-magic-slash-non-match-create)) + '(ivy-on-del-error-function nil) + '(ivy-use-virtual-buffers t) + '(ivy-wrap t) '(nrepl-message-colors (quote ("#CC9393" "#DFAF8F" "#F0DFAF" "#7F9F7F" "#BFEBBF" "#93E0E3" "#94BFF3" "#DC8CC3"))) '(org-sort-agenda-notime-is-late nil) '(package-selected-packages (quote - (monokai-theme color-theme-monokai color-theme-sanityinc-tomorrow dracula-theme evil-mode yasnippet-snippets highlight-symbol rainbow-delimiters git-gutter Ivy org-caldav which-key-mode org-plus-contrib use-package ac-cider magit blacken py-autopep8 flycheck elpy yasnippet company-lsp company lsp-ui go-autocomplete lsp-mode go-mode markdown-mode gruvbox-theme helm org cider slime evil))) + (ace-window discover-my-major popup-kill-ring amx gnu-elpa-keyring-update auto-package-update monokai-theme color-theme-monokai color-theme-sanityinc-tomorrow dracula-theme evil-mode yasnippet-snippets highlight-symbol rainbow-delimiters git-gutter Ivy org-caldav which-key-mode org-plus-contrib use-package ac-cider magit blacken py-autopep8 flycheck elpy yasnippet company-lsp company lsp-ui go-autocomplete lsp-mode go-mode markdown-mode gruvbox-theme helm org cider slime evil))) '(pdf-view-midnight-colors (quote ("#fdf4c1" . "#282828"))) '(pos-tip-background-color "#36473A") '(pos-tip-foreground-color "#FFFFC8") @@ -66,7 +72,10 @@ (320 . "#8CD0D3") (340 . "#94BFF3") (360 . "#DC8CC3")))) - '(vc-annotate-very-old-color "#DC8CC3")) + '(vc-annotate-very-old-color "#DC8CC3") + '(winner-boring-buffers + (quote + ("*Completions*" "*Compile-Log*" "*inferior-lisp*" "*Fuzzy Completions*" "*Apropos*" "*Help*" "*cvs*" "*Buffer List*" "*Ibuffer*" "*esh command on file*")))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. @@ -28,15 +28,44 @@ (require 'use-package-ensure) (setq use-package-always-ensure t) -;; Themes -;; (use-package monokai-theme) - -;; Highlight line -;;(setq set-face-background hl-line-face "pale goldenrod") -;;(hl-line-mode 1) +;; auto package update +(use-package auto-package-update + :if (not (daemonp)) + :custom + (auto-package-update-interval 7) ;; in days + (auto-package-update-prompt-before-update t) + (auto-package-update-delete-old-versions t) + (auto-package-update-hide-results t) + :config + (auto-package-update-maybe)) + +;; remove certain minor modes from the mode line +(use-package diminish) + +;; use new GNU Elpa Key update +(use-package gnu-elpa-keyring-update) + +;; ID information +(setq user-full-name "Matthew Lemon") +(setq user-mail-address "matt@matthewlemon.com") + +;; Core bindings +;; Unbind unneeded keys +(global-set-key (kbd "C-z") nil) +(global-set-key (kbd "M-z") nil) +(global-set-key (kbd "C-x C-z") nil) +(global-set-key (kbd "M-/") nil) +;; Use iBuffer instead of Buffer List +(global-set-key (kbd "C-x C-b") #'ibuffer) +;; Truncate lines +(global-set-key (kbd "C-x C-l") #'toggle-truncate-lines) +;; Adjust font size like web browsers +(global-set-key (kbd "C-+") #'text-scale-increase) +(global-set-key (kbd "C--") #'text-scale-decrease) +;; Move up/down paragraph +(global-set-key (kbd "M-n") #'forward-paragraph) +(global-set-key (kbd "M-p") #'backward-paragraph) -;; Region colour -(set-face-attribute 'region nil :background "#633" :foreground "#ffffff") ;; Deal with history (setq savehist-file "~/.emacs.d/savehist") @@ -47,6 +76,18 @@ search-ring regexp-search-ring)) +;; popup kill-ring +(use-package popup-kill-ring + :bind ("M-y" . popup-kill-ring)) + +;; Disover my major +(use-package discover-my-major + :bind ("C-h C-m" . discover-my-major)) + +;; Ace Window +(use-package ace-window + :bind ("C-x C-o" . ace-window)) + ;; Some basics (setq auto-save-default nil) (global-set-key (kbd "M-o") 'other-window) @@ -57,25 +98,32 @@ (setq calendar-week-start-day 1) (setq calendar-date-style (quote european)) -;; TRAMP stuff -;; using sshx as default as it works better than ssh -(setq tramp-default-method "sshx") - ;; remap M-x to something else ;; https://sites.google.com/site/steveyegge2/effective-emacs -(global-set-key "\C-x\C-m" 'execute-extended-command) -(global-set-key "\C-c\C-m" 'execute-extended-command) +;; (global-set-key "\C-x\C-m" 'execute-extended-command) +;; (global-set-key "\C-c\C-m" 'execute-extended-command) ;; Remapping killing ;; https://sites.google.com/site/steveyegge2/effective-emacs -(global-set-key "\C-w" 'backward-kill-word) -(global-set-key "\C-x\C-k" 'kill-region) -(global-set-key "\C-c\C-k" 'kill-region) +;; (global-set-key "\C-w" 'backward-kill-word) +;; (global-set-key "\C-x\C-k" 'kill-region) +;; (global-set-key "\C-c\C-k" 'kill-region) ;; mu4e ;; the exact path may differ --- check it (add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e") (require 'mu4e) + +;; deal with horrible grey backgrounds in HTML backgrounds +(require 'mu4e-contrib) +(setq mu4e-html2text-command 'mu4e-shr2text) +(setq shr-color-visible-luminance-min 60) +(setq shr-color-visible-distance-min 5) +(setq shr-use-colors nil) +(advice-add #'shr-colorize-region :around (defun shr-no-colourise-region (&rest ignore))) + + +;; email settings (setq mu4e-maildir "~/.mail/matt-matthewlemon.com") (setq message-send-mail-function 'smtpmail-send-it) (setq mu4e-contexts @@ -103,11 +151,26 @@ ;; recentf (use-package recentf - :config - (setq recentf-auto-cleanup 'never + :hook (after-init . recentf-mode) + :custom + (recentf-auto-cleanup "05:00am") + (recentf-exclude '((expand-file-name package-user-dir) + ".cache" + ".cask" + ".elfeed" + "bookmarks" + "cache" + "ido.*" + "persp-confs" + "recentf" + "undo-tree-hist" + "url" + "COMMIT_EDITMSG\\'")) + (setq recentf-auto-cleanup 'never recentf-max-saved-items 1000 recentf-save-file (concat user-emacs-directory ".recentf")) - (recentf-mode t)) + (recentf-mode t)) + ;; Basic magit (use-package magit @@ -145,16 +208,6 @@ :config (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)) -;; (use-package highlight-symbol -;; :config -;; (add-hook 'prog-mode-hook 'highlight-symbol-mode) -;; (set-face-background 'highlight-symbol-face "#a45bad") -;; (set-face-foreground 'highlight-symbol-face "#ffffff") -;; (setq highlight-symbol-idle-delay 0.5) -;; :bind (("M-n" . highlight-symbol-next) -;; ("M-p" . highlight-symbol-prev))) - - ;; Evil mode ;; (use-package evil ;; :config @@ -191,18 +244,18 @@ (menu-bar-mode -1) -;; org-caldav -(use-package org-caldav - :config - ;; (setq org-caldav-url "https://ronver.xyz/remote.php/dav/calendars/mrlemon") - ;; (setq org-caldav-calendar-id "org-home") - (setq org-caldav-oauth2-client-id "697419293432-p84jei88v7g6lu9qomk1404o86kim3uj.apps.googleusercontent.com") - (setq org-caldav-oauth2-client-secret "cwHIENs3tghyb6tEKatxULS_") - (setq org-caldav-calendar-id "matthew.lemon@gmail.com") - (setq org-caldav-url 'google) - (setq org-caldav-sync-direction 'cal->org) - (setq org-caldav-inbox "~/Nextcloud/org/inbox_cal.org") - (setq org-caldav-files `("~/Nextcloud/org/cal.org"))) +;; ;; org-caldav - not currently used +;; (use-package org-caldav +;; :config +;; ;; (setq org-caldav-url "https://ronver.xyz/remote.php/dav/calendars/mrlemon") +;; ;; (setq org-caldav-calendar-id "org-home") +;; (setq org-caldav-oauth2-client-id "HERE" +;; (setq org-caldav-oauth2-client-secret "HERE") +;; (setq org-caldav-calendar-id "matthew.lemon@gmail.com") +;; (setq org-caldav-url 'google) +;; (setq org-caldav-sync-direction 'cal->org) +;; (setq org-caldav-inbox "~/Nextcloud/org/inbox_cal.org") +;; (setq org-caldav-files `("~/Nextcloud/org/cal.org"))) ;; fonts ;; (when (eq system-type 'gnu/linux) @@ -234,12 +287,36 @@ (setq confirm-kill-emacs 'y-or-n-p) ;; dired config -;; use current buffer with "a" instead of RET -(put 'dired-find-alternate-file 'disabled nil) - ;; human readable (setq-default dired-listing-switches "-alh") +;; Dired main config +(use-package dired + :ensure nil + :bind + (("C-x C-j" . dired-jump) + ("C-x j" . dired-jump-other-window)) + :custom + ;; Always delete and copy recursively + (dired-recursive-deletes 'always) + (dired-recursive-copies 'always) + ;; Auto refresh Dired, but be quiet about it + (global-auto-revert-non-file-buffers t) + (auto-revert-verbose nil) + ;; Quickly copy/move file in Dired + (dired-dwim-target t) + ;; Move files to trash when deleting + (delete-by-moving-to-trash t) + :config + ;; Reuse same dired buffer, to prevent numerous buffers while navigating in dired + (put 'dired-find-alternate-file 'disabled nil) + :hook + (dired-mode . (lambda () + (local-set-key (kbd "<mouse-2>") #'dired-find-alternate-file) + (local-set-key (kbd "RET") #'dired-find-alternate-file) + (local-set-key (kbd "^") + (lambda () (interactive) (find-alternate-file "..")))))) + ;; recursively copy by default (setq dired-recursive-copies 'always) @@ -264,27 +341,39 @@ (setq-default save-place t) (require 'saveplace) +;; Don't lock files +(setq-default create-lockfiles nil) + ;; Windmove - use Shift and arrow keys to move in windows (when (fboundp 'windmove-default-keybindings) (windmove-default-keybindings)) ;; Winner mode - undo and redo changes in window config ;; with C-c left and C-c right - (when (fboundp 'winner-mode) - (winner-mode 1)) +(use-package winner + :ensure nil + :custom + (winner-boring-buffers + '("*Completions*" + "*Compile-Log*" + "*inferior-lisp*" + "*Fuzzy Completions*" + "*Apropos*" + "*Help*" + "*cvs*" + "*Buffer List*" + "*Ibuffer*" + "*esh command on file*")) + :config + (winner-mode 1)) ;; Don't ring the system bell (setq visible-bell t) + ;; Use a separation file for custom commands (setq custom-file "~/.emacs.d/custom-settings.el") (load custom-file t) -;; Basic auto-complete -(use-package auto-complete - :config - (ac-config-default)) - - ;; Handling tabs (for programming) (setq-default tab-width 2) (setq-default tab-width 2 indent-tabs-mode nil) @@ -323,34 +412,36 @@ (display-line-numbers-mode)))) ;; Ivy -(use-package counsel - :config +;; from https://github.com/MatthewZMD/.emacs.d/blob/master/README.md#orgcfd324a +(use-package ivy + :diminish + :init + (use-package amx :defer t) + (use-package counsel :diminish :config (counsel-mode 1)) + (use-package swiper :defer t) (ivy-mode 1) - ;; (global-set-key (kbd "C-s") 'swiper-isearch) - ;; (global-set-key (kbd "M-x") 'counsel-M-x) - ;; (global-set-key (kbd "C-x C-f") 'counsel-find-file) - (global-set-key (kbd "M-y") 'counsel-yank-pop) - (global-set-key (kbd "<f1> f") 'counsel-describe-function) - (global-set-key (kbd "<f1> v") 'counsel-describe-variable) - (global-set-key (kbd "<f1> l") 'counsel-find-library) - (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol) - (global-set-key (kbd "<f2> u") 'counsel-unicode-char) - (global-set-key (kbd "<f2> j") 'counsel-set-variable) - ;; (global-set-key (kbd "C-x b") 'ivy-switch-buffer) - (global-set-key (kbd "C-c v") 'ivy-push-view) - (global-set-key (kbd "C-c V") 'ivy-pop-view) - (global-set-key (kbd "C-c g") 'counsel-git) - (global-set-key (kbd "C-c j") 'counsel-git-grep) - (global-set-key (kbd "C-c L") 'counsel-git-log) - (global-set-key (kbd "C-c k") 'counsel-rg) - (global-set-key (kbd "C-c m") 'counsel-linux-app) - (global-set-key (kbd "C-c n") 'counsel-fzf) - (global-set-key (kbd "C-x l") 'counsel-locate) - (global-set-key (kbd "C-c J") 'counsel-file-jump) - (global-set-key (kbd "C-S-o") 'counsel-rhythmbox) - (global-set-key (kbd "C-c w") 'counsel-wmctrl) - (setq ivy-height 5) - ) + :bind + (("C-s" . swiper-isearch) + ("C-z s" . counsel-rg) + ("C-z b" . counsel-buffer-or-recentf) + ("C-z C-b" . counsel-ibuffer) + (:map ivy-minibuffer-map + ("C-r" . ivy-previous-line-or-history) + ("M-RET" . ivy-immediate-done)) + (:map counsel-find-file-map + ("C-~" . counsel-goto-local-home))) + :custom + (ivy-use-virtual-buffers t) + (ivy-height 10) + (ivy-on-del-error-function nil) + (ivy-magic-slash-non-match-action 'ivy-magic-slash-non-match-create) + (ivy-count-format "【%d/%d】") + (ivy-wrap t) + :config + (defun counsel-goto-local-home () + "Go to the $HOME of the local machine." + (interactive) + (ivy--cd "~/"))) ;; org mode config (use-package org @@ -439,6 +530,8 @@ ;; Which key (use-package which-key :hook ((org-mode . which-key-mode) + (go-mode . which-key-mode) + (python-mode .which-key-mode) (cider-mode . which-key-mode))) ;; Python programming @@ -456,9 +549,6 @@ (setq elpy-modules (delq 'elpy-module-flymake elpy-modules)) (add-hook 'elpy-mode-hook 'flycheck-mode))) -;; Make sure auto-complete works in python-mode -;; (add-to-list 'ac-modes 'python-mode) - ;; Go programming (use-package lsp-mode :hook (go-mode . lsp-deferred) @@ -467,40 +557,113 @@ :config (add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))) +;; lsp-ui (use-package lsp-ui - :hook (lsp-mode . lsp-ui-mode) + :after lsp-mode + :diminish :commands lsp-ui-mode - :init) + :custom-face + (lsp-ui-doc-background ((t (:background nil)))) + (lsp-ui-doc-header ((t (:inherit (font-lock-string-face italic))))) + :bind (:map lsp-ui-mode-map + ([remap xref-find-definitions] . lsp-ui-peek-find-definitions) + ([remap xref-find-references] . lsp-ui-peek-find-references) + ("C-c u" . lsp-ui-imenu)) + :custom + (lsp-ui-doc-enable t) + (lsp-ui-doc-header t) + (lsp-ui-doc-include-signature t) + (lsp-ui-doc-position 'top) + (lsp-ui-doc-border (face-foreground 'default)) + (lsp-ui-sideline-enable nil) + (lsp-ui-sideline-ignore-duplicate t) + (lsp-ui-sideline-show-code-actions nil) + :config + + ;; WORKAROUND Hide mode-line of the lsp-ui-imenu buffer + ;; https://github.com/emacs-lsp/lsp-ui/issues/243 + (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate) + (setq mode-line-format nil))) + -;; Make sure auto-complete works in go-mode -;; (add-to-list 'ac-modes 'go-mode) +;; Yasnippet (use-package yasnippet - :commands yas-minor-mode + :diminish yas-minor-mode + :init + (use-package yasnippet-snippets :after yasnippet) + :hook ((prog-mode LaTeX-mode org-mode) . yas-minor-mode) + :bind + (:map yas-minor-mode-map ("C-c C-n" . yas-expand-from-trigger-key)) + (:map yas-keymap + (("TAB" . smarter-yas-expand-next-field) + ([(tab)] . smarter-yas-expand-next-field))) :config - (define-key yas-minor-mode-map (kbd "C-c y") #'yas-expand) - :hook (go-mode . yas-minor-mode) - :hook (python-mode . yas-minor-mode)) - -(use-package yasnippet-snippets) + (use-package yasnippet-snippets) + (yas-reload-all) + (defun smarter-yas-expand-next-field () + "Try to `yas-expand' then `yas-next-field' at current cursor position." + (interactive) + (let ((old-point (point)) + (old-tick (buffer-chars-modified-tick))) + (yas-expand) + (when (and (eq old-point (point)) + (eq old-tick (buffer-chars-modified-tick))) + (ignore-errors (yas-next-field)))))) ;;Company mode is a standard completion package that works well with lsp-mode. ;;company-lsp integrates company mode completion with lsp-mode. ;;completion-at-point also works out of the box but doesn't support snippets. +;; (use-package company +;; :config +;; (setq company-idle-delay 0) +;; (setq company-minimum-prefix-length 1)) + +;; (use-package company-lsp +;; :commands company-lsp) + + +;; this config works better with yasnippet (use-package company + :diminish company-mode + :hook ((prog-mode LaTeX-mode latex-mode ess-r-mode) . company-mode) + :bind + (:map company-active-map + ([tab] . smarter-yas-expand-next-field-complete) + ("TAB" . smarter-yas-expand-next-field-complete)) + :custom + (company-minimum-prefix-length 1) + (company-tooltip-align-annotations t) + (company-begin-commands '(self-insert-command)) + (company-require-match 'never) + ;; Don't use company in the following modes + (company-global-modes '(not shell-mode eaf-mode)) + ;; Trigger completion immediately. + (company-idle-delay 0.1) + ;; Number the candidates (use M-1, M-2 etc to select completions). + (company-show-numbers t) :config - (setq company-idle-delay 0) - (setq company-minimum-prefix-length 1)) - -(use-package company-lsp - :commands company-lsp) + ;; clangd variable not present which was a problem +;; (unless *clangd* (delete 'company-clang company-backends)) + (global-company-mode 1) + (defun smarter-yas-expand-next-field-complete () + "Try to `yas-expand' and `yas-next-field' at current cursor position. + +If failed try to complete the common part with `company-complete-common'" + (interactive) + (if yas-minor-mode + (let ((old-point (point)) + (old-tick (buffer-chars-modified-tick))) + (yas-expand) + (when (and (eq old-point (point)) + (eq old-tick (buffer-chars-modified-tick))) + (ignore-errors (yas-next-field)) + (when (and (eq old-point (point)) + (eq old-tick (buffer-chars-modified-tick))) + (company-complete-common)))) + (company-complete-common)))) -(setq lsp-ui-doc-enable nil - lsp-ui-peek-enable t - lsp-ui-sideline-enable t - lsp-ui-imenu-enable t - lsp-ui-flycheck-enable t) (setq lsp-gopls-staticcheck t) (setq lsp-eldoc-render-all t) |