diff --git a/nix/modules/default.nix b/nix/modules/default.nix index eb5d9f3..8235d63 100644 --- a/nix/modules/default.nix +++ b/nix/modules/default.nix @@ -25,6 +25,7 @@ let ./editor ./elisp ./git + ./minibuffer-vertico ]; pkgsModule = { config, ... }: { diff --git a/nix/modules/editor/default.nix b/nix/modules/editor/default.nix index 6277d78..bf1c12b 100644 --- a/nix/modules/editor/default.nix +++ b/nix/modules/editor/default.nix @@ -41,11 +41,6 @@ let yasnippet yasnippet-snippets flycheck - vertico - orderless - ctrlf - consult - marginalia svg-tag-mode all-the-icons org diff --git a/nix/modules/git/default.nix b/nix/modules/git/default.nix index d6b357d..75a33f5 100644 --- a/nix/modules/git/default.nix +++ b/nix/modules/git/default.nix @@ -22,7 +22,7 @@ { lib, config, pkgs, makeFG42Drv, ... }: with lib; let - cfg = config.fg42.features.git; + cfg = config.fg42.git; deps = (with pkgs.emacsPackages; [ @@ -39,7 +39,7 @@ let }; in { - options.fg42.features.git.enable = mkAndEnableOption "git"; + options.fg42.git.enable = mkAndEnableOption "git"; config = mkIf cfg.enable { fg42.elispPackages = [ drv ] ++ deps; diff --git a/nix/modules/minibuffer-vertico/default.nix b/nix/modules/minibuffer-vertico/default.nix new file mode 100644 index 0000000..27e3f89 --- /dev/null +++ b/nix/modules/minibuffer-vertico/default.nix @@ -0,0 +1,51 @@ +# Fg42 - Emacs Editor for advance users +# +# Copyright (c) 2010-2024 Sameer Rahmani +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 2. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This is the home manager module that exposes FG42. It differs +# from FG42 modules that are structurally the same but used in +# different context + +# A list of default FG42 modules to build FG42 with. +{ lib, config, pkgs, makeFG42Drv, ... }: +with lib; +let + cfg = config.fg42.minibuffer.vertico; + + deps = + (with pkgs.emacsPackages; [ + vertico + orderless + ctrlf + consult + marginalia + ]); + + drv = makeFG42Drv { + pname = "minibuffer-vertico"; + version = config.fg42.version; + buildInputs = deps; + src = ./.; + }; +in +{ + options.fg42.minibuffer.vertico.enable = mkAndEnableOption "vertico"; + + config = mkIf cfg.enable { + fg42.elispPackages = [ drv ] ++ deps; + + fg42.requires = [ drv.pname ]; + }; +} diff --git a/nix/modules/minibuffer-vertico/lisp/fg42/minibuffer-vertico.el b/nix/modules/minibuffer-vertico/lisp/fg42/minibuffer-vertico.el new file mode 100644 index 0000000..5bc6350 --- /dev/null +++ b/nix/modules/minibuffer-vertico/lisp/fg42/minibuffer-vertico.el @@ -0,0 +1,216 @@ +;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2024 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://devheroes.codes/FG42/FG42 +;; Version: 4.0.0 +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: +;;; Code: +(eval-when-compile + (require 'fpkg) + (require 'fg42/config)) + + +(use! vertico + "Vertico provides a performant and minimalistic vertical completion UI + based on the default completion system. The focus of Vertico is to provide + a UI which behaves correctly under all circumstances." + :config + (require 'vertico-multiform) + (require 'vertico-flat) + (require 'vertico-grid) + (require 'vertico-buffer) + (require 'vertico-indexed) + (require 'vertico-quick) + (require 'vertico-repeat) + (vertico-mode) + (vertico-multiform-mode) + ;; Configure the display per command. + ;; Use a buffer with indices for imenu + (setq vertico-multiform-commands + '((imenu buffer indexed))) + + ;; Configure the display per completion category. + ;; Use the grid display for files and a buffer + ;; for the consult-grep commands. + (setq vertico-multiform-categories + '((file grid))) + + (setq vertico-count 10) + (setq vertico-cycle t) + + (when-wm + (setq vertico-multiform-commands + '((t flat))) + (setq vertico-multiform-categories + '((file flat))))) + + +(use! orderless + "This package provides an orderless completion style that divides the +pattern into space-separated components, and matches candidates that +match all of the components in any order." + :init + (setq completion-styles '(orderless basic) + completion-category-defaults nil + completion-category-overrides '((file (styles partial-completion))))) + +(use! marginalia + "Adds useful info to minibuffers completions." + :commands marginalia-mode + :hook (emacs-startup . marginalia-mode)) + + +(when-not-wm + (use! ctrlf + "Single buffer text search." + :config + (ctrlf-mode +1))) + + +(use! consult + "Consult provides search and navigation commands based on the Emacs completion + function completing-read. " + ;; C-c bindings in `mode-specific-map' + :bind (("C-c M-x" . consult-mode-command) + ("C-c h" . consult-history) + ("C-c k" . consult-kmacro) + ("C-c m" . consult-man) + ("C-c i" . consult-info) + ([remap Info-search] . consult-info) + ;; C-x bindings in `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 + ("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab + ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump + ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer + ;; 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 + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ;; M-g bindings in `goto-map' + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) + ("M-g M-g" . consult-goto-line) + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ("M-g m" . consult-mark) + ("M-g k" . consult-global-mark) + ;; M-s bindings in `search-map' + ("M-s d" . consult-fd) + ("M-s c" . consult-locate) + ("M-s g" . consult-grep) + ("M-s G" . consult-git-grep) + ("M-s r" . consult-ripgrep) + ("M-s l" . consult-line) + ("M-s L" . consult-line-multi) + ("M-s k" . consult-keep-lines) + ("M-s u" . consult-focus-lines) + ;; Isearch integration + ("M-s e" . consult-isearch-history) + :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 + + ;; Enable automatic preview at point in the *Completions* buffer. This is + ;; relevant when you use the default completion UI. + :hook (completion-list-mode . consult-preview-at-point-mode) + + :init + ;; 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.5 + register-preview-function #'consult-register-format) + + ;; 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) + + :config + (when-wm + (consult-customize + ;; Set preview for `consult-buffer' to key `M-.' + consult-buffer :preview-key nil)) + + ;; For some reason `consult's autoloads do not work + (require 'consult-xref) + ;; Use Consult to select xref locations with preview + (setq xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref) + ;; Configure preview. The default value + ;; is 'any, such that any key triggers the preview. + ;; (setq consult-preview-key 'any) + ;; (setq consult-preview-key "M-.") + ;; (setq consult-preview-key '("S-" "S-")) + ;; 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-bookmark consult--source-file-register + consult--source-recent-file consult--source-project-recent-file + ;; :preview-key "M-." + :preview-key '(:debounce 0.4 any)) + + ;; Configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; "C-+" + (autoload 'projectile-project-root "projectile") + (setq consult-project-function (lambda (_) (projectile-project-root))) + + ;; 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) + ) + +;; For some reason `consult's autoloads do not work +(use! consult-imenu + "Setup the `consult-imenu' stuff." + :after consult + :bind (("M-i" . consult-imenu) + ("M-I" . consult-imenu-multi))) + + +(use! consult-compile + "Setup the `consult-compile' stuff." + :after consult + :bind (("M-g e" . consult-compile-error))) + + +;; (use! nerd-icons-completion +;; "Nerd icons in marginalia" +;; :after marginalia +;; :config +;; (nerd-icons-completion-mode) +;; (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)) + + + +(provide 'fg42/minibuffer-vertico) +;;; minibuffer-vertico.el ends here