diff --git a/.emacs b/.emacs index 329df82..f73a3f9 100644 --- a/.emacs +++ b/.emacs @@ -1,3 +1,16 @@ +(add-to-list + 'package-archives + '("stable" . "https://stable.melpa.org/packages/") t) +(add-to-list + 'package-archives + '("melpa" . "https://melpa.org/packages/") t) +(customize-set-variable + 'package-archive-priorities + '(("gnu" . 99) ; prefer GNU packages + ("nongnu" . 80) ; use non-gnu packages if not found in GNU elpa + ("stable" . 70) ; prefer "released" versions from melpa + ("melpa" . 1))) ; if all else fails, get it from melpa + (use-package emacs :ensure nil :custom @@ -6,7 +19,9 @@ (elixir "https://github.com/elixir-lang/tree-sitter-elixir"))) (major-mode-remap-alist - '((elixir-mode . elixir-ts-mode)))) + '((elixir-mode . elixir-ts-mode))) + :config + (global-prettify-symbols-mode)) (use-package eglot :ensure nil @@ -53,32 +68,123 @@ :ensure nil :hook ((prog-mode . rainbow-delimiters-mode))) -(use-package projectile - :ensure t - :bind-keymap ("s-p" . projectile-command-map) +(use-package helpful :ensure t + :bind + ("C-h f" . helpful-callable) + ("C-h v" . helpful-variable) + ("C-h k" . helpful-key) + ("C-h F" . helpful-function) + ("C-h C" . helpful-command)) + +(use-package which-key :ensure t :config (which-key-mode)) + +(defun corfu-enable-in-minibuffer () + "Enable Corfu in the minibuffer if `completion-at-point' is bound." + (when (where-is-internal #'completion-at-point (list (current-local-map))) + ;; (setq-local corfu-auto nil) ;; Enable/disable auto completion + (setq-local + corfu-echo-delay nil ;; Disable automatic echo and (point)opup + corfu-popupinfo-delay nil) + (corfu-mode 1))) + +(use-package corfu :ensure t + :bind + (:map + corfu-map + ("" . corfu-quit) + ("" . corfu-insert) + ("M-n" . corfu-popupinfo-scroll-up) + ("M-p" . corfu-popupinfo-scroll-down)) + :custom + ;; Works with `indent-for-tab-command'. Make sure tab doesn't indent when you + ;; want to perform completion + (tab-always-indent 'complete) (corfu-auto nil) (corfu-auto-prefix 2) (corfu-auto-delay 0.25) + (corfu-preview-current 'insert) (corfu-preselect-first t) + :init (global-corfu-mode) (corfu-popupinfo-mode) (corfu-echo-mode) + :hook (minibuffer-setup . corfu-enable-in-minibuffer)) + +(use-package cape :ensure t + ;; Bind dedicated completion commands + ;; Alternative prefix keys: C-c p, M-p, M-+, ... + :bind + (("M-/" . completion-at-point) ;; capf + ("C-c p t" . complete-tag) ;; etags + ("C-c p d" . cape-dabbrev) ;; or dabbrev-completion + ("C-c p h" . cape-history) + ("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 - (setq projectile-mode-line-function '(lambda () (format " [%s]" (projectile-project-name)))) - :config - (projectile-mode +1)) + ;; 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-dabbrev) + (add-to-list 'completion-at-point-functions #'cape-ispell) + (advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)) -(use-package company - :ensure t - :delight company-mode - :demand t +;; Enable vertico +(use-package vertico :ensure t :init (vertico-mode)) + +(use-package consult :ensure t + :bind + ( ;; C-c bindings (mode-specific-map) + ("C-x b" . consult-buffer) ;; orig. switch-to-buffer + ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer + ("s-b" . consult-project-buffer) ;; orig. project-switch-to-buffer + ;; Other custom bindings + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g i" . consult-imenu) + ("M-g I" . consult-imenu-multi) + ;; M-s bindings (search-map) + ("M-s d" . consult-find) + ("M-s D" . consult-locate) + ("M-s g" . consult-grep) + ("M-s G" . consult-git-grep) + ("M-s r" . consult-ripgrep) + ("M-s l" . consult-line) + ("C-s" . consult-line) + ("M-s L" . consult-line-multi) + ("M-s m" . consult-multi-occur) + ("M-s u" . consult-focus-lines) + :map + isearch-mode-map + ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch + ;; Minibuffer history + :map + minibuffer-local-map + ("M-s" . consult-history) ;; orig. next-matching-history-element + ("M-r" . consult-history)) ;; orig. previous-matching-history-element + + :hook (completion-list-mode . consult-preview-at-point-mode)) + +;; Optionally use the `orderless' completion style. +(use-package orderless :ensure t :init - (setq company-idle-delay 0.1 - company-minimum-prefix-length 1) - :bind (:map company-active-map - ("C-n" . company-select-next) - ("C-p". company-select-previous)) - :config - (global-company-mode)) + (setq + completion-styles '(orderless basic) + completion-category-defaults nil + completion-category-overrides '((file (styles partial-completion))))) -(use-package paredit - :ensure t) +;; Persist history over Emacs restarts. Vertico sorts by history position. +(use-package savehist :ensure t :init (savehist-mode)) -(add-to-list 'package-archives - '("melpa" . "https://melpa.org/packages/") t) +(use-package multiple-cursors :ensure t + :bind ("C->" . 'mc/mark-next-like-this) ("C-<" . 'mc/mark-previous-like-this)) + +(use-package magit :ensure t) (custom-set-variables ;; custom-set-variables was added by Custom. @@ -89,7 +195,7 @@ '(inhibit-startup-screen t) '(initial-scratch-message nil) '(package-selected-packages - '(company projectile rainbow-delimiters exec-path-from-shell elixir-mode elixir-ts-mode paredit par-edit use-package org)) + '(magit elixir-yasnippets consult-yasnippet rainbow-delimiters exec-path-from-shell elixir-mode elixir-ts-mode paredit par-edit org)) '(scroll-bar-mode nil) '(tool-bar-mode nil)) (custom-set-faces