company/ivy/prescient suck. back to corfu/vertico.

This commit is contained in:
Levi Neely 2024-08-31 15:07:54 +02:00
parent ecefa0f8c0
commit d18b3d6698
2 changed files with 167 additions and 142 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/emacs/eln-cache/
/emacs/url/
/emacs/recentf
/emacs/history

View File

@ -55,10 +55,10 @@
(get-text-property 0 'org-hd-marker item)))
(line (when marker
(org-with-point-at marker
(buffer-substring (line-beginning-position) (line-end-position)))))
(buffer-substring (line-beginning-position) (line-end-position)))))
(todo-keyword (when marker
(org-with-point-at marker
(org-get-todo-state))))
(org-get-todo-state))))
(truncated-line (when line
(replace-regexp-in-string "^\\[#[A-Z]\\] " "" line))))
(if truncated-line
@ -81,33 +81,36 @@
(defun my/org-config ()
(setq org-agenda-inhibit-startup t
org-todo-keywords '((sequence "HOLD(h)"
"TODO(t)"
"|"
"DONE(d)"
"CNCL(x)"))
org-todo-keyword-faces '(("HOLD" . (:foreground "orange" :weight bold))
("TODO" . (:foreground "red" :weight bold))
("DONE" . (:foreground "green" :weight bold))
("CNCL" . (:foreground "gray" :weight bold)))
org-agenda-files (append
(list "~/TODO.org")
(directory-files-recursively "~/notes" "\\.org$"))
org-todo-keywords
'((sequence "HOLD(h)" "TODO(t)" "|"
"DONE(d)" "CNCL(x)"))
org-todo-keyword-faces
'(("HOLD" . (:foreground "orange" :weight bold))
("TODO" . (:foreground "red" :weight bold))
("DONE" . (:foreground "green" :weight bold))
("CNCL" . (:foreground "gray" :weight bold)))
org-agenda-files
(append (list "~/TODO.org")
(directory-files-recursively "~/notes"
"\\.org$"))
org-agenda-prefix-format '((agenda . " %i ")
(todo . " %i ")
(tags . " %i ")
(search . " %i "))
org-agenda-hide-tags-regexp "."
org-agenda-todo-keyword-format "%s")
(advice-add 'org-agenda-format-item-line :filter-return #'my-org-agenda-format-item)
(advice-add 'org-agenda-format-item :filter-return #'my-org-agenda-format-item))
(advice-add 'org-agenda-format-item-line
:filter-return #'my-org-agenda-format-item)
(advice-add 'org-agenda-format-item
:filter-return #'my-org-agenda-format-item))
(defun my/org-refile-config ()
(setq org-refile-targets '((nil :maxlevel . 9)
("~/TODO.org" :maxlevel . 9)))
(setq org-refile-use-outline-path 'file)
(setq org-outline-path-complete-in-steps nil)
(setq org-refile-allow-creating-parent-nodes 'confirm))
(setq org-refile-targets
'((nil :maxlevel . 9)
("~/TODO.org" :maxlevel . 9))
org-refile-use-outline-path 'file
org-outline-path-complete-in-steps nil
org-refile-allow-creating-parent-nodes 'confirm))
(defun my/org-capture-config ()
(setq org-capture-templates
@ -126,30 +129,44 @@
(tool-bar-mode -1)
(require 'server)
(unless (server-running-p) (server-start))
(setq gc-cons-threshold 100000000
read-process-output-max (* 1024 1024)
custom-file (concat user-emacs-directory "custom.el")
(setq backup-by-copying t
completion-cycle-threshold 3
create-lockfiles nil
tab-always-indent 'complete
mac-command-modifier 'super
backup-directory-alist `((".*" . ,(concat user-emacs-directory "backup")))
custom-file (concat user-emacs-directory "custom.el")
delete-old-versions t
enable-recursive-minibuffers t
focus-follows-mouse t
inhibit-startup-screen t
kept-new-versions 20
kept-old-versions 2
version-control t
delete-old-versions t
backup-by-copying t
focus-follows-mouse t
minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt)
mouse-autoselect-window t
enable-recursive-minibuffers t
warning-minimum-level :emergency
inhibit-startup-screen t
completion-cycle-threshold 3
text-mode-ispell-word-completion nil
text-mode-ispell-word-completion nil
read-extended-command-predicate #'command-completion-default-include-p
read-extended-command-predicate #'command-completion-default-include-p
minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt))
read-process-output-max (* 1024 1024)
tab-always-indent 'complete
text-mode-ispell-word-completion nil
version-control t
warning-minimum-level :emergency
backup-directory-alist `((".*" . ,(concat user-emacs-directory "backup")))
read-extended-command-predicate #'command-completion-default-include-p
text-mode-ispell-word-completion nil
gc-cons-threshold 100000000)
(defun crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator)
(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)
(load-theme 'misterioso)
@ -161,6 +178,8 @@
(put 'widen 'disabled nil)
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
(with-eval-after-load 'ibuffer
(define-key ibuffer-mode-map (kbd "TAB") nil))
(setq hippie-expand-try-functions-list
'(try-expand-dabbrev
@ -347,6 +366,7 @@
(setq eglot-autoshutdown t)
(setq eglot-sync-connect 1)
(setq eglot-connect-timeout 10)
(setq eglot-confirm-server-initiated-edits nil)
(setq eglot-autoreconnect t)
(setq completion-category-defaults nil)
(setq completion-category-overrides '((eglot (styles orderless))))
@ -373,119 +393,123 @@
;; ===
(use-package plz :ensure t)
;; force recompiling init.el
;; ===
(defun my-compile-init-file ()
"Compile the init file."
(let ((init-file (file-truename user-init-file)))
(when (string= (buffer-file-name) init-file)
(byte-compile-file init-file))))
(add-hook 'after-save-hook #'my-compile-init-file)
;; search & narrow
;; ===
(use-package ivy
:ensure t
:config
(setq ivy-re-builders-alist
'((swiper . ivy--regex-plus)
(t . orderless-ivy-re-builder)))
(setq ivy-initial-inputs-alist nil)
(setq orderless-matching-styles '(orderless-flex orderless-literal orderless-regexp)))
(use-package counsel
:ensure t
:after ivy
:config
(counsel-mode 1)
(setq counsel-grep-base-command
"rg -i -M 120 --no-heading --line-number --color never '%s' %s")
(setq counsel-rg-base-command
"rg -i -M 120 --no-heading --line-number --color never %s .")
;; Replace vanilla commands with Counsel versions
:bind (("C-x C-f" . counsel-find-file)
("M-x" . counsel-M-x)
("C-x b" . counsel-switch-buffer)
("C-x C-b" . counsel-ibuffer)
("C-h f" . counsel-describe-function)
("C-h v" . counsel-describe-variable)
("C-h l" . counsel-find-library)
("C-h i" . counsel-info-lookup-symbol)
("C-x r b" . counsel-bookmark)
("C-c g" . counsel-git)
("C-c j" . counsel-git-grep)
("C-c k" . counsel-ag)
("C-c r" . counsel-rg)
("C-x 8 RET" . counsel-unicode-char)
("C-c s" . counsel-grep-or-swiper)
:map minibuffer-local-map
("C-r" . counsel-minibuffer-history)))
(use-package projectile
:ensure t
:diminish projectile-mode
:init
(projectile-mode)
:config
(setq projectile-completion-system 'ivy
projectile-enable-caching t
projectile-indexing-method 'hybrid)
(when (executable-find "fd")
(setq projectile-generic-command
(format "%s . -0 --type f --color=never" (executable-find "fd"))))
:bind-keymap
("C-x p" . projectile-command-map))
(use-package counsel-projectile
:ensure t
:after (counsel projectile)
:config
(counsel-projectile-mode 1)
:bind
(:map projectile-command-map
("f" . counsel-projectile-find-file)
("g" . counsel-projectile-grep)
("s" . counsel-projectile-switch-project)
("b" . counsel-projectile-switch-to-buffer)
("d" . projectile-dired)
("/" . counsel-projectile-rg)
("4 b" . counsel-projectile-switch-to-buffer-other-window)
("4 d" . projectile-dired-other-window)
("5 b" . counsel-projectile-switch-to-buffer-other-frame)
("5 d" . projectile-dired-other-frame)))
(use-package ivy-prescient
:ensure t
:after counsel
:config
(ivy-prescient-mode 1)
(prescient-persist-mode 1)
(setq ivy-prescient-enable-filtering nil)
(setq ivy-prescient-enable-sorting t))
;; fuzzy find
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
;; completion
;; ===
(use-package company
:ensure t
:hook (after-init . global-company-mode)
(completion-category-overrides '((file (styles . (partial-completion)))))
(orderless-matching-styles '(orderless-flex orderless-prefixes orderless-initialism))
:config
(setq company-idle-delay 0.1
company-minimum-prefix-length 1
company-tooltip-align-annotations t
company-tooltip-limit 10
company-tooltip-flip-when-above t
company-require-match nil
company-dabbrev-downcase nil
company-dabbrev-ignore-case t))
(setq orderless-component-separator #'orderless-escapable-split-on-space))
(use-package company-box
;; better minibuffer
(use-package vertico
:ensure t
:hook (company-mode . company-box-mode))
:init
(vertico-mode)
:custom
(vertico-cycle t)
(vertico-count 13)
:config
(setq read-file-name-completion-ignore-case t
read-buffer-completion-ignore-case t
completion-ignore-case t
completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
(use-package swiper
;; it's like ace-jump in a vertico minibuffer
(use-package vertico-quick
:after vertico
:bind (:map vertico-map
("C-q" . vertico-quick-insert)
("M-q" . vertico-quick-exit)))
(use-package savehist
:ensure t
:after ivy
:bind (("C-s" . swiper)
("C-r" . swiper-backward)
:map swiper-map
("M-%" . swiper-query-replace)))
:init
(savehist-mode))
(use-package corfu
:ensure t
:custom
(corfu-auto t) ;; Enable auto completion
(corfu-separator ?\s) ;; Orderless field separator
(corfu-quit-at-boundary nil) ;; Never quit at completion boundary
(corfu-quit-no-match nil) ;; Never quit, even if there is no match
(corfu-preview-current nil) ;; Disable current candidate preview
(corfu-on-exact-match nil) ;; Configure handling of exact matches
(corfu-echo-documentation nil) ;; Disable documentation in the echo area
(corfu-scroll-margin 5) ;; Use scroll margin
:init
(global-corfu-mode)
:config
;; Enable Orderless for Corfu
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles . (partial-completion)))))
;; Set up hippie-expand
(setq hippie-expand-try-functions-list
'(try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
;; Bind hippie-expand to M-/
(global-set-key (kbd "M-/") 'hippie-expand)
;; Add Cape for additional completion sources
(use-package cape
:ensure t
: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-elisp-block)
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
;;(add-to-list 'completion-at-point-functions #'cape-history)
;;(add-to-list 'completion-at-point-functions #'cape-keyword)
;;(add-to-list 'completion-at-point-functions #'cape-tex)
;;(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-dict)
;;(add-to-list 'completion-at-point-functions #'cape-symbol)
;;(add-to-list 'completion-at-point-functions #'cape-line)
))
;; Optionally, add a function to use hippie-expand with Corfu
(defun my-hippie-expand-corfu ()
"Try to expand text before point, using the default hippie-expand function."
(interactive)
(let ((completion-at-point-functions '(hippie-expand)))
(completion-at-point)))
;; Bind this function to a key if you want to use it within Corfu
(define-key corfu-map (kbd "C-M-/") #'my-hippie-expand-corfu)