From 0ded2313a350c65d9c734c0ae17577b039614d33 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:31:18 +0200 Subject: [PATCH] tweaks --- emacs/custom.el | 2 +- emacs/init.el | 181 +++++++++++++++++++++++++++--------------------- 2 files changed, 103 insertions(+), 80 deletions(-) diff --git a/emacs/custom.el b/emacs/custom.el index 1b670ba..74cfecc 100644 --- a/emacs/custom.el +++ b/emacs/custom.el @@ -10,7 +10,7 @@ '(indent-tabs-mode nil) '(mac-option-modifier '(:ordinary meta :function meta :mouse meta)) '(package-selected-packages - '(go-mode company-box company ivy-prescient flx counsel-projectile counsel ivy python-mode rainbow-mode language-detection jiralib2 request ox-jira ejira jirascope winner-mode fzf prescient doom-modeline emms denote-explore denote multi-vterm ox-hugo plz flycheck-projectile ob-go devil realgud projectile dash async yasnippet ace-jump ace-jump-mode async-status cape corfu dired-git dired-git-info embark eshell-toggle eshell-vterm fic-mode flycheck git-lens git-link go-projectile go-scratch graphviz-dot-mode json-mode kotlin-mode lsp-mode magit mmm-mode multi-web-mode multifiles multiple-cursors multishell nerd-icons-completion nerd-icons-corfu nerd-icons-dired nerd-icons-ibuffer orderless org-ai org-context org-dashboard persistent-scratch php-mode plantuml-mode project-explorer projectile-ripgrep protobuf-mode quelpa-use-package rego-mode unicode-fonts vertico vterm-toggle wgrep which-key yaml-mode)) + '(consult kind-icon go-mode company-box company ivy-prescient flx counsel-projectile counsel ivy python-mode rainbow-mode language-detection jiralib2 request ox-jira ejira jirascope winner-mode fzf prescient doom-modeline emms denote-explore denote multi-vterm ox-hugo plz flycheck-projectile ob-go devil realgud projectile dash async yasnippet ace-jump ace-jump-mode async-status cape corfu dired-git dired-git-info embark eshell-toggle eshell-vterm fic-mode flycheck git-lens git-link go-projectile go-scratch graphviz-dot-mode json-mode kotlin-mode lsp-mode magit mmm-mode multi-web-mode multifiles multiple-cursors multishell nerd-icons-completion nerd-icons-corfu nerd-icons-dired nerd-icons-ibuffer orderless org-ai org-context org-dashboard persistent-scratch php-mode plantuml-mode project-explorer projectile-ripgrep protobuf-mode quelpa-use-package rego-mode unicode-fonts vertico vterm-toggle wgrep which-key yaml-mode)) '(tab-width 4) '(tool-bar-mode nil) '(use-short-answers t)) diff --git a/emacs/init.el b/emacs/init.el index dc6e1f0..078eb76 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -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 @@ -166,8 +166,6 @@ '(read-only t cursor-intangible t face minibuffer-prompt)) (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) - - (load-theme 'misterioso) (put 'upcase-region 'disabled nil) @@ -180,23 +178,12 @@ (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 - 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)) (global-unset-key (kbd "C-x n")) (global-set-key (kbd "") 'speedbar) - (global-set-key (kbd "M-/") 'hippie-expand) + (global-set-key (kbd "M-/") 'dabbrev-expand) + (with-eval-after-load 'swiper (define-key swiper-map (kbd "M-%") #'my/swiper-query-replace)) (global-set-key (kbd "C-=") 'multi-vterm-dedicated-toggle) @@ -393,7 +380,7 @@ ;; === (use-package plz :ensure t) - + ;; force recompiling init.el ;; === (defun my-compile-init-file () @@ -404,9 +391,6 @@ (add-hook 'after-save-hook #'my-compile-init-file) -;; search & narrow -;; === - ;; fuzzy find (use-package orderless :ensure t @@ -440,76 +424,115 @@ ("C-q" . vertico-quick-insert) ("M-q" . vertico-quick-exit))) +;; save history (use-package savehist :ensure t :init (savehist-mode)) +;; inline completion (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 + :bind + (us + (:map global-map + ("C-." . completion-at-point)) + :custom + (corfu-auto nil) ;; 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) + :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)) + :config + ;; Enable Orderless for Corfu + (setq completion-styles '(orderless basic) + completion-category-defaults nil + completion-at-point-functions nil + completion-category-overrides '((file (styles . (partial-completion))))) + + ;; Set up dabbrev as the primary completion source + (setq-local completion-at-point-functions '(dabbrev-completion)) - ;; Bind hippie-expand to M-/ - (global-set-key (kbd "M-/") 'hippie-expand) + ;; Enable kind-icon + (use-package kind-icon + :ensure t + :after corfu + :custom + (kind-icon-default-face 'corfu-default) ; to compute blended backgrounds correctly + :config + (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)) - ;; Add Cape for additional completion sources - (use-package cape + ;; 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) + ))) + + ;; better search + (use-package consult :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) - )) + :bind (("C-s" . consult-line) + ("C-r" . consult-line-multi) + ("C-c h" . consult-history) + ("C-c m" . consult-mode-command) + ("C-c k" . consult-kmacro) + ("C-c C-h" . consult-mode-histories) + ;; Add keybindings for ripgrep-related commands + ("C-c s" . consult-ripgrep) + ("C-c C-s" . consult-ripgrep-multi)) + :custom + (consult-preview-key nil) ; Disable preview + + :config + ;; Configure ripgrep for consult + (setq consult-ripgrep-command "rg --null --line-buffered --color=ansi --max-columns=1000 --no-heading --line-number . -e ARG OPTS") + + ;; Use ripgrep for `consult-grep` as well + (setq consult-grep-command "rg --null --line-buffered --color=ansi --max-columns=1000 --no-heading --line-number . -e ARG OPTS") + + ;; Configure mode-specific histories + (setq consult-mode-histories + '((comint-mode . comint-input-ring) + (eshell-mode . eshell-history-ring) + (geiser-repl-mode . geiser-repl--history) + (inferior-python-mode . comint-input-ring) + (minibuffer-local-map . consult-history))) -;; 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))) + (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-bookmark consult--source-recent-file + consult--source-project-recent-file + :preview-key '(:debounce 0.4 any)) -;; 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) + ;; Configure async search for better performance + (setq consult-async-min-input 2) + (setq consult-async-refresh-delay 0.15) + (setq consult-async-input-throttle 0.2) + (setq consult-async-input-debounce 0.1) - - + ;; Use Consult to select xref locations with preview + (setq xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref))