diff options
author | David Morgan <djm_uk@protonmail.com> | 2021-07-07 16:52:35 +0100 |
---|---|---|
committer | David Morgan <djm_uk@protonmail.com> | 2021-07-07 16:52:35 +0100 |
commit | 64ca29b76b7f265ab2d5f5a88452118da40aa4c8 (patch) | |
tree | faf2f048f7b5406a186044255734439f4f336cbb /emacs-prelude/personal/lisp | |
parent | 3fbaf487183e7b7e3785628ab8ed6290ddd94fd7 (diff) | |
download | dotfiles-64ca29b76b7f265ab2d5f5a88452118da40aa4c8.tar.gz |
Update emacs prelude config (vertico, corfu, consult, etc)
Diffstat (limited to 'emacs-prelude/personal/lisp')
-rw-r--r-- | emacs-prelude/personal/lisp/init-completion.el | 228 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-dashboard.el | 1 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-git.el | 22 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-hydra.el | 3 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-ivy.el | 53 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-lsp.el | 8 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-misc.el | 6 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-modeline.el | 12 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-prelude.el | 10 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-projectile.el | 9 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-ui.el | 10 | ||||
-rw-r--r-- | emacs-prelude/personal/lisp/init-use-package.el | 4 |
12 files changed, 262 insertions, 104 deletions
diff --git a/emacs-prelude/personal/lisp/init-completion.el b/emacs-prelude/personal/lisp/init-completion.el index 213a91a..e5f13cc 100644 --- a/emacs-prelude/personal/lisp/init-completion.el +++ b/emacs-prelude/personal/lisp/init-completion.el @@ -1,36 +1,206 @@ -(setq tab-always-indent 'complete) +(use-package emacs + :init + ;; for corfu + (setq completion-cycle-threshold 3) + (setq tab-always-indent 'complete) + + ;; for vertico + ;; Add prompt indicator to `completing-read-multiple'. + (defun crm-indicator (args) + (cons (concat "[CRM] " (car args)) (cdr args))) + (advice-add #'completing-read-multiple :filter-args #'crm-indicator) + ;; Do not allow the cursor in the minibuffer prompt + (setq minibuffer-prompt-properties + '(read-only t cursor-intangible t face minibuffer-prompt)) + (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) + (setq enable-recursive-minibuffers t)) + +;; orderless is used by corfu and vertico +(prelude-require-package 'orderless) +(use-package orderless + :bind (:map minibuffer-local-completion-map + ("C-l" . my/match-components-literally)) + :init + (setq completion-styles '(orderless) + completion-category-defaults nil + completion-category-overrides '((file (styles . (partial-completion))))) ;; TODO initials instead of partial-completion? + (defun my/match-components-literally () + "Components match literally for the rest of the session." + (interactive) + (setq-local orderless-matching-styles '(orderless-literal) + orderless-style-dispatchers nil))) + +(use-package savehist + :init + (savehist-mode)) + + +;; code completion - corfu +(prelude-require-package 'corfu) +(use-package corfu + ;; Optional customizations + :custom + (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' + :bind (:map corfu-map + ("TAB" . corfu-next) + ([tab] . corfu-next) + ("S-TAB" . corfu-previous) + ([backtab] . corfu-previous)) + :init + (corfu-global-mode)) + +(use-package dabbrev + :bind (("M-/" . dabbrev-completion) + ("C-M-/" . dabbrev-expand))) + + +;; minibuffer completion - vertico et al +(prelude-require-package 'vertico) +(use-package vertico + :init + (vertico-mode) + (setq vertico-cycle t)) + +(prelude-require-package 'consult) +(use-package consult + :after projectile + :bind (;; C-c bindings (mode-specific-map) + ("C-c h" . consult-history) + ("C-c m" . consult-mode-command) + ("C-c b" . consult-bookmark) + ("C-c k" . consult-kmacro) + ;; C-x bindings (ctl-x-map) + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x b" . consult-buffer) ;; orig. switch-to-buffer + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ;; Custom M-# bindings for fast register access + ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("C-M-#" . consult-register) + ;; Other custom bindings + ("C-S" . consult-line) + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ("<help> a" . consult-apropos) ;; orig. apropos-command + ;; M-g bindings (goto-map) + ("M-g e" . consult-compile-error) + ("M-g f" . consult-flycheck) + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ("M-g m" . consult-mark) + ("M-g k" . consult-global-mark) + ("M-g i" . consult-imenu) + ("M-g I" . consult-project-imenu) + ;; C-c c bindings (search-map) + ("C-c c C-f" . consult-recent-file) + ("C-c c f" . consult-find) + ("C-c c L" . consult-locate) + ("C-c c g" . consult-grep) + ("C-c c G" . consult-git-grep) + ("C-c c r" . consult-ripgrep) + ("C-c c l" . consult-line) + ("C-c c m" . consult-multi-occur) + ("C-c c k" . consult-keep-lines) + ("C-c c u" . consult-focus-lines) + ;; Isearch integration + ("C-c c e" . consult-isearch) + :map isearch-mode-map + ("M-e" . consult-isearch) ;; orig. isearch-edit-string + ("C-c c e" . consult-isearch) ;; orig. isearch-edit-string + ("C-c c l" . consult-line)) ;; needed by consult-line to detect isearch + + :init + + ;; Optionally configure the register formatting. This improves the register + ;; preview for `consult-register', `consult-register-load', + ;; `consult-register-store' and the Emacs built-ins. + (setq register-preview-delay 0 + register-preview-function #'consult-register-format) + + ;; Optionally tweak the register preview window. + ;; This adds thin lines, sorting and hides the mode line of the window. + (advice-add #'register-preview :override #'consult-register-window) + + ;; Use Consult to select xref locations with preview + (setq xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref) -(use-package company - :bind (("M-/" . company-complete)) - :hook (after-init . company-tng-mode) - :config - (global-company-mode) - (setq ;company-idle-delay 0.3 - company-selection-wrap-around t - company-show-numbers t - company-tooltip-align-annotations t - company-require-match nil)) - -(prelude-require-package 'company-quickhelp) -(use-package company-quickhelp - :diminish - :hook (global-company-mode . company-quickhelp-mode)) - -(prelude-require-package 'company-box) -(use-package company-box - :diminish - :hook (company-mode . company-box-mode) :config - (setq company-box-backends-colors nil ;; TODO why? - ;company-box-doc-delay 0.3 - )) -(prelude-require-package 'company-prescient) -(use-package company-prescient - :diminish + ;; Optionally configure preview. The default value + ;; is 'any, such that any key triggers the preview. + ;; (setq consult-preview-key 'any) + ;; (setq consult-preview-key (kbd "M-.")) + ;; (setq consult-preview-key (list (kbd "<S-down>") (kbd "<S-up>"))) + ;; For some commands and buffer sources it is useful to configure the + ;; :preview-key on a per-command basis using the `consult-customize' macro. + (consult-customize + consult-theme + :preview-key '(:debounce 0.2 any) + consult-ripgrep consult-git-grep consult-grep + consult-bookmark consult-recent-file consult-xref + consult--source-file consult--source-project-file consult--source-bookmark + :preview-key (kbd "M-.")) + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; (kbd "C-+") + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) + + (autoload 'projectile-project-root "projectile") + (setq consult-project-root-function #'projectile-project-root)) + +(prelude-require-package 'consult-flycheck) +(use-package consult-flycheck) + +(prelude-require-package 'consult-lsp) +(use-package consult-lsp + :bind (:map lsp-mode-map + ([remap xref-find-apropos] . consult-lsp-symbols))) + +(prelude-require-package 'marginalia) +(use-package marginalia + :bind (("M-A" . marginalia-cycle) + :map minibuffer-local-map + ("M-A" . marginalia-cycle)) + ;:custom + ;(marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) + :init + (marginalia-mode)) + +(prelude-require-package 'embark) +(use-package embark + :bind + (("C-." . embark-act) + ("C-;" . embark-dwim) + ("C-c C-o" . embark-export) + ("C-h B" . embark-bindings)) + :init + ;; Optionally replace the key help with a completing-read interface + (setq prefix-help-command #'embark-prefix-help-command) :config - (company-prescient-mode 1) - (prescient-persist-mode +1)) + ;; Hide the mode line of the Embark live/completions buffers + (add-to-list 'display-buffer-alist + '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" + nil + (window-parameters (mode-line-format . none))))) + +(prelude-require-package 'embark-consult) +(use-package embark-consult + :after (embark consult) + :demand t ; only necessary if you have the hook below + ;; if you want to have consult previews as you move around an + ;; auto-updating embark collect buffer + :hook + (embark-collect-mode . consult-preview-at-point-mode)) + +(use-package consult-projectile + :after (consult projectile) + :quelpa (consult-projectile :fetcher gitlab :repo "OlMon/consult-projectile")) (provide 'init-completion) diff --git a/emacs-prelude/personal/lisp/init-dashboard.el b/emacs-prelude/personal/lisp/init-dashboard.el index 2c44ac6..68dbed6 100644 --- a/emacs-prelude/personal/lisp/init-dashboard.el +++ b/emacs-prelude/personal/lisp/init-dashboard.el @@ -3,6 +3,7 @@ :init (setq dashboard-center-content t dashboard-set-footer nil + dashboard-projects-backend 'projectile dashboard-items '((recents . 15) (bookmarks . 5) (projects . 5) diff --git a/emacs-prelude/personal/lisp/init-git.el b/emacs-prelude/personal/lisp/init-git.el index 5cb0b78..7bc19f1 100644 --- a/emacs-prelude/personal/lisp/init-git.el +++ b/emacs-prelude/personal/lisp/init-git.el @@ -1,13 +1,23 @@ -(defun magit-set-upstream () - (interactive) - (magit-shell-command-topdir "git upstream")) - (use-package magit :after key-chord + :init + (defun my/magit-set-upstream () + (interactive) + (magit-shell-command-topdir "git upstream")) :config - (key-chord-define-global "UU" 'magit-set-upstream)) -; :bind (("C-c g y" . magit-upstream))) ;; TODO + (key-chord-define-global "UU" 'my/magit-set-upstream) + ;; prevent the git info on the modeline from becoming stale (based on code removed from doom modeline) + :hook (magit-post-refresh . + (lambda () + (dolist (buf (buffer-list)) + (when (and (not (buffer-modified-p buf)) + (buffer-file-name buf) + (file-exists-p (buffer-file-name buf)) + (file-in-directory-p (buffer-file-name buf) (magit-toplevel))) + (with-current-buffer buf + (vc-refresh-state))))))) +(prelude-require-package 'forge) (use-package forge :after magit) diff --git a/emacs-prelude/personal/lisp/init-hydra.el b/emacs-prelude/personal/lisp/init-hydra.el index 706df45..666a147 100644 --- a/emacs-prelude/personal/lisp/init-hydra.el +++ b/emacs-prelude/personal/lisp/init-hydra.el @@ -1,7 +1,4 @@ (prelude-require-package 'hydra) (use-package hydra) -;(prelude-require-package 'ivy-hydra) -;(use-package ivy-hydra) - (provide 'init-hydra) diff --git a/emacs-prelude/personal/lisp/init-ivy.el b/emacs-prelude/personal/lisp/init-ivy.el deleted file mode 100644 index 44f53ac..0000000 --- a/emacs-prelude/personal/lisp/init-ivy.el +++ /dev/null @@ -1,53 +0,0 @@ -(prelude-require-package 'ivy-prescient) -(use-package ivy-prescient - :diminish - :config - (ivy-prescient-mode 1)) - -(prelude-require-package 'ivy-rich) -(use-package ivy-rich - :config - (setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line) - (ivy-rich-mode 1)) - -(use-package counsel - :diminish ivy-mode counsel-mode - :config - (setq ;counsel-grep-base-command "rg -i -M 120 --no-heading --line-number --color never '%s' %s" - counsel-rg-base-command "rg -S -M 120 --no-heading --line-number --color never %s .") - :bind (("C-c h" . counsel-command-history) - ;("C-c i" . counsel-git) - ;("C-c j" . counsel-git-grep) - ("C-c c g" . counsel-grep) - ("C-c c r" . counsel-rg) - ("C-c c o" . counsel-outline) - ("C-c z" . counsel-fzf) - ("C-c c z" . counsel-fzf) - ("C-c c a" . counsel-apropos) - ("C-c c f" . counsel-recentf) - ("C-c C-f" . counsel-recentf) - :map counsel-mode-map - ([remap swiper] . counsel-grep-or-swiper) - ([remap swiper-backward] . counsel-grep-or-swiper-backward) - ;([remap recentf-open-files] . counsel-recentf) - ([remap dired] . counsel-dired)) - :hook ((after-init . ivy-mode) - (ivy-mode . counsel-mode))) - -(defun counsel-projectile-rg-glob () - (interactive) - (let ((glob (ivy-completing-read "Glob?: " '("*.cljs" - "*.clj" - "*.md" - "*.css")))) - (counsel-projectile-rg (concat "--glob " glob)))) - -(prelude-require-package 'counsel-projectile) -(use-package counsel-projectile - :config - (counsel-projectile-mode) - :bind (:map projectile-mode-map - ("C-c p s R" . counsel-projectile-rg-glob))) - -(provide 'init-ivy) - diff --git a/emacs-prelude/personal/lisp/init-lsp.el b/emacs-prelude/personal/lisp/init-lsp.el index 875bc9c..6568229 100644 --- a/emacs-prelude/personal/lisp/init-lsp.el +++ b/emacs-prelude/personal/lisp/init-lsp.el @@ -1,9 +1,10 @@ (use-package lsp-mode + :diminish + :after key-chord :hook (clojure-mode . lsp) :config (setq gc-cons-threshold (* 100 1024 1024) read-process-output-max (* 1024 1024) - treemacs-space-between-root-nodes nil lsp-ui-doc-delay 1 lsp-lens-enable nil lsp-ui-doc-enable t @@ -13,13 +14,14 @@ lsp-enable-symbol-highlighting t lsp-ui-sideline-show-diagnostics t lsp-ui-sideline-show-code-actions nil - lsp-modeline-code-actions-enable nil ;; TODO this causes errors in *Messages* if t + lsp-modeline-code-actions-enable nil lsp-modeline-diagnostics-enable nil lsp-ui-doc-position 'top ;; user cider for indendation and completion instead lsp-enable-indentation nil lsp-completion-enable nil) - (key-chord-define-global "QQ" 'lsp-find-references)) ;; TODO? + (key-chord-define-global "QQ" 'lsp-find-references) + (key-chord-define-global "GG" 'lsp-find-definition)) (provide 'init-lsp) diff --git a/emacs-prelude/personal/lisp/init-misc.el b/emacs-prelude/personal/lisp/init-misc.el index c146e9b..fd1396c 100644 --- a/emacs-prelude/personal/lisp/init-misc.el +++ b/emacs-prelude/personal/lisp/init-misc.el @@ -9,6 +9,12 @@ :config (rg-enable-default-bindings)) +(prelude-require-package 'restclient) +(use-package restclient) + +(prelude-require-package 'es-mode) +(use-package es-mode + :mode "\.es\'") (provide 'init-misc) diff --git a/emacs-prelude/personal/lisp/init-modeline.el b/emacs-prelude/personal/lisp/init-modeline.el index 159bdb5..4a727d7 100644 --- a/emacs-prelude/personal/lisp/init-modeline.el +++ b/emacs-prelude/personal/lisp/init-modeline.el @@ -1,7 +1,17 @@ (prelude-require-package 'simple-modeline) (use-package simple-modeline - :hook (after-init . simple-modeline-mode)) + :hook (after-init . simple-modeline-mode) + :custom + (simple-modeline-segments + '((simple-modeline-segment-modified + simple-modeline-segment-buffer-name + simple-modeline-segment-position) + (simple-modeline-segment-minor-modes + simple-modeline-segment-vc + simple-modeline-segment-misc-info + simple-modeline-segment-process + simple-modeline-segment-major-mode)))) (prelude-require-package 'flycheck-indicator) (use-package flycheck-indicator diff --git a/emacs-prelude/personal/lisp/init-prelude.el b/emacs-prelude/personal/lisp/init-prelude.el index 65fc870..c857e16 100644 --- a/emacs-prelude/personal/lisp/init-prelude.el +++ b/emacs-prelude/personal/lisp/init-prelude.el @@ -10,9 +10,6 @@ (use-package whitespace :diminish) -(use-package projectile - :diminish) - (use-package smartparens :diminish) @@ -26,9 +23,10 @@ ((t (:foreground "white" :background "red" :weight bold :height 2.5 :box (:line-width 10 :color "red")))))) -;; allow other things to use C-c s -(define-key prelude-mode-map (kbd "C-c s") nil) -(define-key prelude-mode-map (kbd "C-c S") 'crux-swap-windows) +(use-package crux + ;; allow other things to use C-c s + :init (unbind-key "C-c s" prelude-mode-map) + :bind (:map prelude-mode-map ("C-c S" . crux-swap-windows))) (diminish 'prelude-mode) diff --git a/emacs-prelude/personal/lisp/init-projectile.el b/emacs-prelude/personal/lisp/init-projectile.el new file mode 100644 index 0000000..caa12d3 --- /dev/null +++ b/emacs-prelude/personal/lisp/init-projectile.el @@ -0,0 +1,9 @@ +(use-package projectile + :diminish) + +(prelude-require-packages '(perspective persp-projectile)) +(use-package persp-projectile + :init (persp-mode)) + +(provide 'init-projectile) + diff --git a/emacs-prelude/personal/lisp/init-ui.el b/emacs-prelude/personal/lisp/init-ui.el index fefd637..0bdebfa 100644 --- a/emacs-prelude/personal/lisp/init-ui.el +++ b/emacs-prelude/personal/lisp/init-ui.el @@ -6,17 +6,16 @@ (prelude-require-package 'solarized-theme) (load-theme 'solarized-dark t) -;(set-face-background 'hi-yellow "yellow") (setq whitespace-line-column 120) (require 'hi-lock) -(defun toggle-highlight-symbol-at-point () +(defun my/toggle-highlight-symbol-at-point () (interactive) (if hi-lock-interactive-patterns (unhighlight-regexp (car (car hi-lock-interactive-patterns))) (highlight-symbol-at-point))) -(global-set-key (kbd "s-.") 'toggle-highlight-symbol-at-point) +(global-set-key (kbd "s-.") 'my/toggle-highlight-symbol-at-point) (use-package paren :config @@ -28,5 +27,10 @@ :commands minibuffer-edit :init (miniedit-install)) +(prelude-require-package 'ctrlf) +(use-package ctrlf + :config + (ctrlf-mode +1)) + (provide 'init-ui) diff --git a/emacs-prelude/personal/lisp/init-use-package.el b/emacs-prelude/personal/lisp/init-use-package.el index 35280f5..c735ba3 100644 --- a/emacs-prelude/personal/lisp/init-use-package.el +++ b/emacs-prelude/personal/lisp/init-use-package.el @@ -3,5 +3,9 @@ (setq use-package-always-ensure t) +(prelude-require-packages '(quelpa quelpa-use-package)) +(use-package quelpa) +(use-package quelpa-use-package) + (provide 'init-use-package) |