Switching to vertico, corfu, orderless instead of sel, comp, presc.

This commit is contained in:
Chris Cochrun 2022-03-01 09:47:53 -06:00
parent 940d93d262
commit 2ea83b0a00
7 changed files with 515 additions and 112 deletions

View file

@ -52,7 +52,6 @@
This init section tangles out to =init.el=. We'll do most of our configuring here. This init section tangles out to =init.el=. We'll do most of our configuring here.
** Startup Performance ** Startup Performance
Let's create a message that will tell us how long it takes emacs to load in order to keep an eye on performance. Let's create a message that will tell us how long it takes emacs to load in order to keep an eye on performance.
#+begin_src emacs-lisp #+begin_src emacs-lisp
;;; init.el -*- lexical-binding: t; -*- ;;; init.el -*- lexical-binding: t; -*-
@ -529,7 +528,7 @@ My completion framework is a combination of packages so that everything remains
*** SELECTRUM *** SELECTRUM
I prefer selectrum over Ivy or Helm for completions. It is using the basic completing read system and therefore it is more inline with basic emacs. Also, let's add prescient to be able to filter selectrum well. We'll add some keybindings too for easier navigation on the home row. I prefer selectrum over Ivy or Helm for completions. It is using the basic completing read system and therefore it is more inline with basic emacs. Also, let's add prescient to be able to filter selectrum well. We'll add some keybindings too for easier navigation on the home row.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp :tangle no
(use-package selectrum (use-package selectrum
:init :init
(selectrum-mode +1) (selectrum-mode +1)
@ -565,14 +564,14 @@ vertically."
#+END_SRC #+END_SRC
We need prescient so we can have smarter sorting and filtering by default. Ontop of that, setting persistance in prescient makes it get better over time. We need prescient so we can have smarter sorting and filtering by default. Ontop of that, setting persistance in prescient makes it get better over time.
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle no
(use-package prescient (use-package prescient
:config :config
(prescient-persist-mode +1) (prescient-persist-mode +1)
:after selectrum) :after selectrum)
#+end_src #+end_src
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp :tangle no
(use-package selectrum-prescient (use-package selectrum-prescient
:init :init
(selectrum-prescient-mode +1) (selectrum-prescient-mode +1)
@ -581,7 +580,7 @@ We need prescient so we can have smarter sorting and filtering by default. Ontop
#+BEGIN_SRC elisp :tangle no #+BEGIN_SRC elisp :tangle no
;; enable company use of prescient ;; enable company use of prescient
(company-prescient-mode +1) ;; (company-prescient-mode +1)
;; enable magit to read with prescient ;; enable magit to read with prescient
(setq magit-completing-read-function #'selectrum-completing-read) (setq magit-completing-read-function #'selectrum-completing-read)
@ -639,17 +638,86 @@ This is similar but using mini-frame. Mini-frame works well, but not if using ex
*** VERTICO *** VERTICO
Vertico is an alternative to Selectrum. Maybe using it will give me an even better experience over selectrum. Vertico is an alternative to Selectrum. Maybe using it will give me an even better experience over selectrum.
#+BEGIN_SRC emacs-lisp
(use-package vertico
:init
(vertico-mode)
;; Different scroll margin
;; (setq vertico-scroll-margin 0)
;; Show more candidates
(setq vertico-count 10)
;; Grow and shrink the Vertico minibuffer
(setq vertico-resize t)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t)
:general
(general-def 'vertico-map
"C-j" 'vertico-next
"C-k" 'vertico-previous)
)
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))
;; A few more useful configurations...
(use-package emacs
:init
;; Add prompt indicator to `completing-read-multiple'.
;; Alternatively try `consult-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)
;; Emacs 28: Hide commands in M-x which do not work in the current mode.
;; Vertico commands are hidden in normal buffers.
;; (setq read-extended-command-predicate
;; #'command-completion-default-include-p)
;; Enable recursive minibuffers
(setq enable-recursive-minibuffers t))
#+END_SRC
*** CONSULT *** CONSULT
Consult has a lot of nice functions like Ivy's Counsel functions (enhanced searching functions), lets set some of them in the keymap so they are easily used. Consult has a lot of nice functions like Ivy's Counsel functions (enhanced searching functions), lets set some of them in the keymap so they are easily used.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package consult (use-package consult
:after selectrum :after vertico
:config :config
(setq consult-narrow-key "'" (setq consult-narrow-key "'"
consult-project-root-function 'projectile-project-root) consult-project-root-function 'projectile-project-root)
(defun chris/consult-ripgrep-file (defun chris/consult-ripgrep-for-stepdata ()
(interactive "P")) "Make ripgrep search hidden files for stepdata"
(interactive)
(let ((consult-ripgrep-args
(concat "rg "
"--null "
"--line-buffered "
"--color=never "
"--max-columns=1000 "
"--path-separator / "
"--no-heading "
"--line-number "
;; adding these to default
"--smart-case "
"--hidden "
;; defaults
"."
)))
(consult-ripgrep)))
:general :general
(chris/leader-keys (chris/leader-keys
:states 'normal :states 'normal
@ -679,12 +747,12 @@ Marginalia makes for some great decoration to our minibuffer completion items. W
(marginalia-mode) (marginalia-mode)
;; When using Selectrum, ensure that Selectrum is refreshed when cycling annotations. ;; When using Selectrum, ensure that Selectrum is refreshed when cycling annotations.
(advice-add #'marginalia-cycle :after ;; (advice-add #'marginalia-cycle :after
(lambda () (when (bound-and-true-p selectrum-mode) (selectrum-exhibit)))) ;; (lambda () (when (bound-and-true-p selectrum-mode) (selectrum-exhibit))))
;; Prefer richer, more heavy, annotations over the lighter default variant. ;; Prefer richer, more heavy, annotations over the lighter default variant.
(setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) (setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil))
:after selectrum :after vertico
:config :config
(setq marginalia--cache-size 60000)) (setq marginalia--cache-size 60000))
@ -694,18 +762,58 @@ Marginalia makes for some great decoration to our minibuffer completion items. W
Embark or do something. Embark or do something.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package embark (use-package embark
:after selectrum :ensure t
:general :general
('selectrum-minibuffer-map ('vertico-map
"C-'" 'embark-act) "C-'" 'embark-act)
('normal ('normal 'org-mode-map
"C-'" 'embark-act)) "C-'" 'embark-act)
:config
(defun embark-which-key-indicator ()
"An embark indicator that displays keymaps using which-key.
The which-key help message will show the type and value of the
current target followed by an ellipsis if there are further
targets."
(lambda (&optional keymap targets prefix)
(if (null keymap)
(which-key--hide-popup-ignore-command)
(which-key--show-keymap
(if (eq (plist-get (car targets) :type) 'embark-become)
"Become"
(format "Act on %s '%s'%s"
(plist-get (car targets) :type)
(embark--truncate-target (plist-get (car targets) :target))
(if (cdr targets) "…" "")))
(if prefix
(pcase (lookup-key keymap prefix 'accept-default)
((and (pred keymapp) km) km)
(_ (key-binding prefix 'accept-default)))
keymap)
nil nil t (lambda (binding)
(not (string-suffix-p "-argument" (cdr binding))))))))
(setq embark-indicators
'(embark-which-key-indicator
embark-highlight-indicator
embark-isearch-highlight-indicator))
(defun embark-hide-which-key-indicator (fn &rest args)
"Hide the which-key indicator immediately when using the completing-read prompter."
(which-key--hide-popup-ignore-command)
(let ((embark-indicators
(remq #'embark-which-key-indicator embark-indicators)))
(apply fn args)))
(advice-add #'embark-completing-read-prompter
:around #'embark-hide-which-key-indicator)
)
(use-package embark-consult) (use-package embark-consult)
#+END_SRC #+END_SRC
*** Company *** Company
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle no
(use-package company (use-package company
:config :config
(global-company-mode +1) (global-company-mode +1)
@ -724,11 +832,122 @@ Embark or do something.
;; :hook (company-mode . company-box-mode)) ;; :hook (company-mode . company-box-mode))
#+end_src #+end_src
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle no
(use-package company-dict (use-package company-dict
:after company) :after company)
#+end_src #+end_src
*** Corfu
Trying out corfu instead of company
#+BEGIN_SRC emacs-lisp
(use-package corfu
:ensure t
;; Optional customizations
:custom
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
(corfu-auto t) ;; Enable auto completion
(corfu-separator ?\s) ;; Orderless field separator
(corfu-quit-no-match 'separator) ;; Never quit, even if there is no match
(corfu-preview-current 'insert) ;; Enable current candidate preview
(corfu-preselect-first nil) ;; Enable candidate preselection
(corfu-on-exact-match 'insert) ;; Configure handling of exact matches
(corfu-echo-documentation '(1.0 . 0.2)) ;; Disable documentation in the echo area
(corfu-scroll-margin 5) ;; Use scroll margin
(corfu-count 15)
(corfu-auto-prefix 2)
;; You may want to enable Corfu only for certain modes.
;; :hook ((prog-mode . corfu-mode)
;; (shell-mode . corfu-mode)
;; (eshell-mode . corfu-mode))
;; Recommended: Enable Corfu globally.
;; This is recommended since dabbrev can be used globally (M-/).
:init
(corfu-global-mode)
:general
('corfu-map
"C-j" 'corfu-next
"C-k" 'corfu-previous
"M-SPC" 'corfu-insert-separator))
;; Optionally use the `orderless' completion style. See `+orderless-dispatch'
;; in the Consult wiki for an advanced Orderless style dispatcher.
;; Enable `partial-completion' for files to allow path expansion.
;; You may prefer to use `initials' instead of `partial-completion'.
(use-package orderless
:ensure t
:init
;; Configure a custom style dispatcher (see the Consult wiki)
;; (setq orderless-style-dispatchers '(+orderless-dispatch)
;; orderless-component-separator #'orderless-escapable-split-on-space)
(setq completion-styles '(orderless)
completion-category-defaults nil
completion-category-overrides '((file (styles . (partial-completion)))))
(defun flex-if-twiddle (pattern _index _total)
(when (string-suffix-p "~" pattern)
`(orderless-flex . ,(substring pattern 0 -1))))
(defun first-initialism (pattern index _total)
(if (= index 0) 'orderless-initialism))
(defun without-if-bang (pattern _index _total)
(cond
((equal "!" pattern)
'(orderless-literal . ""))
((string-prefix-p "!" pattern)
`(orderless-without-literal . ,(substring pattern 1)))))
(setq orderless-matching-styles '(orderless-literal orderless-regexp)
orderless-style-dispatchers '(flex-if-twiddle
without-if-bang))
)
;; Use dabbrev with Corfu!
(use-package dabbrev
:after corfu
;; Swap M-/ and C-M-/
:bind (("M-/" . dabbrev-completion)
("C-M-/" . dabbrev-expand)))
(use-package cape
:ensure t
;; Bind dedicated completion commands
:bind (("C-c p p" . completion-at-point) ;; capf
("C-c p t" . complete-tag) ;; etags
("C-c p d" . cape-dabbrev) ;; or dabbrev-completion
("C-c p f" . cape-file)
("C-c p k" . cape-keyword)
("C-c p s" . cape-symbol)
("C-c p a" . cape-abbrev)
("C-c p i" . cape-ispell)
("C-c p l" . cape-line)
("C-c p w" . cape-dict)
("C-c p \\" . cape-tex)
("C-c p _" . cape-tex)
("C-c p ^" . cape-tex)
("C-c p &" . cape-sgml)
("C-c p r" . cape-rfc1345))
:init
;; Add `completion-at-point-functions', used by `completion-at-point'.
(add-to-list 'completion-at-point-functions #'cape-file)
;; (add-to-list 'completion-at-point-functions #'cape-tex)
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-keyword)
;;(add-to-list 'completion-at-point-functions #'cape-sgml)
;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
(add-to-list 'completion-at-point-functions #'cape-ispell)
;;(add-to-list 'completion-at-point-functions #'cape-dict)
;; (add-to-list 'completion-at-point-functions #'cape-symbol)
;;(add-to-list 'completion-at-point-functions #'cape-line)
:config
(setq cape-dabbrev-min-length 2)
)
#+END_SRC
** YASnippet ** YASnippet
YASnippet is a templating system. It's powerful. YASnippet is a templating system. It's powerful.
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -884,9 +1103,16 @@ LSP is useful...
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package lsp-mode (use-package lsp-mode
:commands (lsp lsp-deferred) :commands (lsp lsp-deferred)
:hook ((c++-mode qml-mode) . lsp-deferred) :custom
(lsp-completion-provider :none)
:hook
(c++-mode . lsp-deferred)
(lsp-completion-mode . my/lsp-mode-setup-completion)
:init :init
(setq lsp-keymap-prefix "C-c l") (setq lsp-keymap-prefix "C-c l")
(defun my/lsp-mode-setup-completion ()
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
'(flex)))
:config :config
(setq lsp-lens-enable t (setq lsp-lens-enable t
lsp-signature-auto-activate nil lsp-signature-auto-activate nil
@ -969,25 +1195,23 @@ It's probably smart to have markdown.
*** QML *** QML
I make some apps in Qt 5 so QML is a needed language although the support in Emacs is lacking. I make some apps in Qt 5 so QML is a needed language although the support in Emacs is lacking.
#+begin_src emacs-lisp :tangle yes #+begin_src emacs-lisp
(use-package qml-mode (use-package qml-mode
:mode ("\\.qml\\'" . qml-mode) :mode ("\\.qml\\'" . qml-mode))
:config
(setq company-idle-delay 0.1))
(use-package company-qml ;; (use-package company-qml
:after qml-mode ;; :after qml-mode
:config ;; :config
;; (add-to-list 'company-backends 'company-qml) ;; ;; (add-to-list 'company-backends 'company-qml)
) ;; )
;; (setq company-backends ;; (setq company-backends
;; '(company-bbdb company-semantic company-cmake company-capf company-clang company-files ;; '(company-bbdb company-semantic company-cmake company-capf company-clang company-files
;; (company-dabbrev-code company-gtags company-etags company-keywords) ;; (company-dabbrev-code company-gtags company-etags company-keywords)
;; company-oddmuse company-dabbrev)) ;; company-oddmuse company-dabbrev))
(use-package qt-pro-mode ;; (use-package qt-pro-mode
:after qml-mode) ;; :after qml-mode)
#+end_src #+end_src
*** CSV *** CSV
@ -1065,7 +1289,8 @@ I'm making a small function in here to open files in the appropriate program usi
"oD" '(dired :which-key "open dired select")) "oD" '(dired :which-key "open dired select"))
(general-def 'normal dired-mode-map (general-def 'normal dired-mode-map
"q" 'kill-this-buffer "q" 'kill-this-buffer
"C-<return>" 'chris/dired-open-xdg)) "C-<return>" 'chris/dired-open-xdg
"C-'" 'embark-act))
#+end_src #+end_src
We need a function to copy the full filename to kill-ring We need a function to copy the full filename to kill-ring

318
init.el
View file

@ -300,57 +300,81 @@
(use-package toc-org (use-package toc-org
:after org) :after org)
(use-package selectrum (use-package vertico
:init :init
(selectrum-mode +1) (vertico-mode)
:config
(setq selectrum-max-window-height 8)
(add-hook 'selectrum-mode-hook 'selectrum-exhibit)
;; We need to fix selectrums minibuffer handling for Emacs 28 ;; Different scroll margin
(defun selectrum--set-window-height (window &optional height) ;; (setq vertico-scroll-margin 0)
"Set window height of WINDOW to HEIGHT pixel.
If HEIGHT is not given WINDOW will be updated to fit its content
vertically."
(let* ((lines (length
(split-string
(overlay-get selectrum--candidates-overlay 'after-string)
"\n" t)))
(dheight (or height
(* lines selectrum--line-height)))
(wheight (window-pixel-height window))
(window-resize-pixelwise t))
(window-resize
window (- dheight wheight) nil nil 'pixelwise)))
;; Show more candidates
(setq vertico-count 10)
;; Grow and shrink the Vertico minibuffer
(setq vertico-resize t)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t)
:general :general
('selectrum-minibuffer-map (general-def 'vertico-map
"C-j" 'selectrum-next-candidate "C-j" 'vertico-next
"C-k" 'selectrum-previous-candidate "C-k" 'vertico-previous)
"C-S-j" 'selectrum-goto-end )
"C-S-k" 'selectrum-goto-beginning
"TAB" 'selectrum-insert-current-candidate)
:commands completing-read)
(use-package prescient ;; Persist history over Emacs restarts. Vertico sorts by history position.
:config (use-package savehist
(prescient-persist-mode +1)
:after selectrum)
(use-package selectrum-prescient
:init :init
(selectrum-prescient-mode +1) (savehist-mode))
:after selectrum)
;; A few more useful configurations...
(use-package emacs
:init
;; Add prompt indicator to `completing-read-multiple'.
;; Alternatively try `consult-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)
;; Emacs 28: Hide commands in M-x which do not work in the current mode.
;; Vertico commands are hidden in normal buffers.
;; (setq read-extended-command-predicate
;; #'command-completion-default-include-p)
;; Enable recursive minibuffers
(setq enable-recursive-minibuffers t))
(use-package consult (use-package consult
:after selectrum :after vertico
:config :config
(setq consult-narrow-key "'" (setq consult-narrow-key "'"
consult-project-root-function 'projectile-project-root) consult-project-root-function 'projectile-project-root)
(defun chris/consult-ripgrep-file (defun chris/consult-ripgrep-for-stepdata ()
(interactive "P")) "Make ripgrep search hidden files for stepdata"
(interactive)
(let ((consult-ripgrep-args
(concat "rg "
"--null "
"--line-buffered "
"--color=never "
"--max-columns=1000 "
"--path-separator / "
"--no-heading "
"--line-number "
;; adding these to default
"--smart-case "
"--hidden "
;; defaults
"."
)))
(consult-ripgrep)))
:general :general
(chris/leader-keys (chris/leader-keys
:states 'normal :states 'normal
@ -375,44 +399,170 @@ vertically."
(marginalia-mode) (marginalia-mode)
;; When using Selectrum, ensure that Selectrum is refreshed when cycling annotations. ;; When using Selectrum, ensure that Selectrum is refreshed when cycling annotations.
(advice-add #'marginalia-cycle :after ;; (advice-add #'marginalia-cycle :after
(lambda () (when (bound-and-true-p selectrum-mode) (selectrum-exhibit)))) ;; (lambda () (when (bound-and-true-p selectrum-mode) (selectrum-exhibit))))
;; Prefer richer, more heavy, annotations over the lighter default variant. ;; Prefer richer, more heavy, annotations over the lighter default variant.
(setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) (setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil))
:after selectrum :after vertico
:config :config
(setq marginalia--cache-size 60000)) (setq marginalia--cache-size 60000))
(use-package embark (use-package embark
:after selectrum :ensure t
:general :general
('selectrum-minibuffer-map ('vertico-map
"C-'" 'embark-act) "C-'" 'embark-act)
('normal ('normal 'org-mode-map
"C-'" 'embark-act)) "C-'" 'embark-act)
:config
(defun embark-which-key-indicator ()
"An embark indicator that displays keymaps using which-key.
The which-key help message will show the type and value of the
current target followed by an ellipsis if there are further
targets."
(lambda (&optional keymap targets prefix)
(if (null keymap)
(which-key--hide-popup-ignore-command)
(which-key--show-keymap
(if (eq (plist-get (car targets) :type) 'embark-become)
"Become"
(format "Act on %s '%s'%s"
(plist-get (car targets) :type)
(embark--truncate-target (plist-get (car targets) :target))
(if (cdr targets) "" "")))
(if prefix
(pcase (lookup-key keymap prefix 'accept-default)
((and (pred keymapp) km) km)
(_ (key-binding prefix 'accept-default)))
keymap)
nil nil t (lambda (binding)
(not (string-suffix-p "-argument" (cdr binding))))))))
(setq embark-indicators
'(embark-which-key-indicator
embark-highlight-indicator
embark-isearch-highlight-indicator))
(defun embark-hide-which-key-indicator (fn &rest args)
"Hide the which-key indicator immediately when using the completing-read prompter."
(which-key--hide-popup-ignore-command)
(let ((embark-indicators
(remq #'embark-which-key-indicator embark-indicators)))
(apply fn args)))
(advice-add #'embark-completing-read-prompter
:around #'embark-hide-which-key-indicator)
)
(use-package embark-consult) (use-package embark-consult)
(use-package company (use-package corfu
:config :ensure t
(global-company-mode +1) ;; Optional customizations
:custom :custom
(company-dabbrev-other-buffers t) (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
(company-minimum-prefix-length 1) (corfu-auto t) ;; Enable auto completion
(company-idle-delay 0.1) (corfu-separator ?\s) ;; Orderless field separator
(corfu-quit-no-match 'separator) ;; Never quit, even if there is no match
(corfu-preview-current 'insert) ;; Enable current candidate preview
(corfu-preselect-first nil) ;; Enable candidate preselection
(corfu-on-exact-match 'insert) ;; Configure handling of exact matches
(corfu-echo-documentation '(1.0 . 0.2)) ;; Disable documentation in the echo area
(corfu-scroll-margin 5) ;; Use scroll margin
(corfu-count 15)
(corfu-auto-prefix 2)
;; You may want to enable Corfu only for certain modes.
;; :hook ((prog-mode . corfu-mode)
;; (shell-mode . corfu-mode)
;; (eshell-mode . corfu-mode))
;; Recommended: Enable Corfu globally.
;; This is recommended since dabbrev can be used globally (M-/).
:init
(corfu-global-mode)
:general :general
(general-def '(normal insert) company-active-map ('corfu-map
"TAB" 'company-complete-selection "C-j" 'corfu-next
"RET" 'company-complete-selection) "C-k" 'corfu-previous
(general-def '(normal insert) lsp-mode-map "M-SPC" 'corfu-insert-separator))
"TAB" 'company-indent-or-complete-common))
;; (use-package company-box ;; Optionally use the `orderless' completion style. See `+orderless-dispatch'
;; :hook (company-mode . company-box-mode)) ;; in the Consult wiki for an advanced Orderless style dispatcher.
;; Enable `partial-completion' for files to allow path expansion.
;; You may prefer to use `initials' instead of `partial-completion'.
(use-package orderless
:ensure t
:init
;; Configure a custom style dispatcher (see the Consult wiki)
;; (setq orderless-style-dispatchers '(+orderless-dispatch)
;; orderless-component-separator #'orderless-escapable-split-on-space)
(setq completion-styles '(orderless)
completion-category-defaults nil
completion-category-overrides '((file (styles . (partial-completion)))))
(use-package company-dict (defun flex-if-twiddle (pattern _index _total)
:after company) (when (string-suffix-p "~" pattern)
`(orderless-flex . ,(substring pattern 0 -1))))
(defun first-initialism (pattern index _total)
(if (= index 0) 'orderless-initialism))
(defun without-if-bang (pattern _index _total)
(cond
((equal "!" pattern)
'(orderless-literal . ""))
((string-prefix-p "!" pattern)
`(orderless-without-literal . ,(substring pattern 1)))))
(setq orderless-matching-styles '(orderless-literal orderless-regexp)
orderless-style-dispatchers '(flex-if-twiddle
without-if-bang))
)
;; Use dabbrev with Corfu!
(use-package dabbrev
:after corfu
;; Swap M-/ and C-M-/
:bind (("M-/" . dabbrev-completion)
("C-M-/" . dabbrev-expand)))
(use-package cape
:ensure t
;; Bind dedicated completion commands
:bind (("C-c p p" . completion-at-point) ;; capf
("C-c p t" . complete-tag) ;; etags
("C-c p d" . cape-dabbrev) ;; or dabbrev-completion
("C-c p f" . cape-file)
("C-c p k" . cape-keyword)
("C-c p s" . cape-symbol)
("C-c p a" . cape-abbrev)
("C-c p i" . cape-ispell)
("C-c p l" . cape-line)
("C-c p w" . cape-dict)
("C-c p \\" . cape-tex)
("C-c p _" . cape-tex)
("C-c p ^" . cape-tex)
("C-c p &" . cape-sgml)
("C-c p r" . cape-rfc1345))
:init
;; Add `completion-at-point-functions', used by `completion-at-point'.
(add-to-list 'completion-at-point-functions #'cape-file)
;; (add-to-list 'completion-at-point-functions #'cape-tex)
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-keyword)
;;(add-to-list 'completion-at-point-functions #'cape-sgml)
;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
(add-to-list 'completion-at-point-functions #'cape-ispell)
;;(add-to-list 'completion-at-point-functions #'cape-dict)
;; (add-to-list 'completion-at-point-functions #'cape-symbol)
;;(add-to-list 'completion-at-point-functions #'cape-line)
:config
(setq cape-dabbrev-min-length 2)
)
(use-package yasnippet (use-package yasnippet
:config :config
@ -514,9 +664,16 @@ vertically."
(use-package lsp-mode (use-package lsp-mode
:commands (lsp lsp-deferred) :commands (lsp lsp-deferred)
:hook ((c++-mode qml-mode) . lsp-deferred) :custom
(lsp-completion-provider :none)
:hook
(c++-mode . lsp-deferred)
(lsp-completion-mode . my/lsp-mode-setup-completion)
:init :init
(setq lsp-keymap-prefix "C-c l") (setq lsp-keymap-prefix "C-c l")
(defun my/lsp-mode-setup-completion ()
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
'(flex)))
:config :config
(setq lsp-lens-enable t (setq lsp-lens-enable t
lsp-signature-auto-activate nil lsp-signature-auto-activate nil
@ -566,6 +723,23 @@ vertically."
:config :config
(setq markdown-fontify-code-blocks-natively t)) (setq markdown-fontify-code-blocks-natively t))
(use-package qml-mode
:mode ("\\.qml\\'" . qml-mode))
;; (use-package company-qml
;; :after qml-mode
;; :config
;; ;; (add-to-list 'company-backends 'company-qml)
;; )
;; (setq company-backends
;; '(company-bbdb company-semantic company-cmake company-capf company-clang company-files
;; (company-dabbrev-code company-gtags company-etags company-keywords)
;; company-oddmuse company-dabbrev))
;; (use-package qt-pro-mode
;; :after qml-mode)
(use-package csv-mode (use-package csv-mode
:mode ("\\.csv\\'" . csv-mode)) :mode ("\\.csv\\'" . csv-mode))
@ -619,7 +793,8 @@ vertically."
"oD" '(dired :which-key "open dired select")) "oD" '(dired :which-key "open dired select"))
(general-def 'normal dired-mode-map (general-def 'normal dired-mode-map
"q" 'kill-this-buffer "q" 'kill-this-buffer
"C-<return>" 'chris/dired-open-xdg)) "C-<return>" 'chris/dired-open-xdg
"C-'" 'embark-act))
(defun chris/dired-yank-filename () (defun chris/dired-yank-filename ()
"Get the full filename from file at point and put into kill-ring" "Get the full filename from file at point and put into kill-ring"
@ -1775,18 +1950,3 @@ interfere with the default `bongo-playlist-buffer'."
gcmh-verbose nil)) gcmh-verbose nil))
(setq warning-suppress-types '((comp))) (setq warning-suppress-types '((comp)))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(pdf-misc-print-program "/usr/bin/lpr" t)
'(pdf-misc-print-program-args '("-o media=Letter" "-o fitplot") t)
'(safe-local-variable-values
'((eval org-odt-styles-file "/home/chris/org/tfcexpenses2020.odt"))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

View file

@ -0,0 +1,5 @@
# -*- mode: eshell-mode -*-
# name: for
# key: for
# --
for f in ${1:*} { ${2:echo} "$f"; $3} $0

View file

@ -0,0 +1,5 @@
# -*- mode: eshell-mode -*-
# name: unless
# key: un
# --
unless { $1 } { $2 }

View file

@ -1,4 +1,4 @@
# -*- mode: snippet -*- # -*- mode: org-mode -*-
# name: Demo # name: Demo
# key: <el # key: <el
# -- # --

View file

@ -1,4 +1,4 @@
# -*- mode: snippet -*- # -*- mode: org-mode -*-
# name: Quote # name: Quote
# key: <q # key: <q
# -- # --

View file

@ -0,0 +1,8 @@
# -*- mode: org-mode -*-
# name: title
# key: <t
# --
#+TITLE: ${1:title}
#+AUTHOR: Chris Cochrun
$0