forked from FG42/FG42
1
0
Fork 0

Replace vertico with fido on WM mode

This commit is contained in:
Sameer Rahmani 2024-04-29 12:50:03 +01:00
parent 9342a251d7
commit 09e32cc5a5
Signed by: lxsameer
GPG Key ID: 8741FACBF412FFA5
6 changed files with 228 additions and 206 deletions

View File

@ -58,27 +58,27 @@
};
fg42 = app.drv;
fg42-wm = pkgs.callPackage ./nix/fg42
{
inherit nixpkgs;
modules = [
./nix/modules/editor
./nix/modules/elisp
./nix/modules/graphics
./nix/modules/noether
./nix/modules/wm
];
extraPackages = {
noether = inputs.noether.outputs.packages.${system}.default;
};
}.drv;
# fg42-wm = pkgs.callPackage ./nix/fg42
# {
# inherit nixpkgs;
# modules = [
# ./nix/modules/editor
# ./nix/modules/elisp
# ./nix/modules/graphics
# ./nix/modules/noether
# ./nix/modules/wm
# ];
# extraPackages = {
# noether = inputs.noether.outputs.packages.${system}.default;
# };
# }.drv;
run-test-wm = pkgs.writeShellApplication {
name = "run-test-wm";
runtimeInputs = [ fg42-wm ];
runtimeInputs = [ fg42 ];
text = ''
DISPLAY=:1 ${fg42-wm}/bin/fg42-wm
DISPLAY=:1 ${fg42}/bin/fg42-wm
'';
};
@ -86,12 +86,12 @@
{
packages = app.emacsPkgs // {
default = fg42;
wm = fg42-wm;
wm = fg42;
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = [ fg42 fg42-wm pkgs.fish test-x run-test-wm ];
buildInputs = [ fg42 fg42-wm ];
nativeBuildInputs = [ fg42 pkgs.fish test-x run-test-wm ];
buildInputs = [ fg42 ];
};
apps.wm = {

View File

@ -46,7 +46,7 @@
"Set the default font of `FG42' to FONT-NAME and FONT-SIZE."
(let ((name (fg42/config-get font-name))
(size (fg42/config-get font-size)))
(add-to-list 'default-frame-alist
(cons 'font (format "%s-%d" name size)))
@ -253,14 +253,9 @@ contextual information."
(scroll-bar-mode -1))
(defalias 'yes-or-no-p 'y-or-n-p)
;; It only applies to toolkit=no
(set-mouse-color (get-base16-color-or :base07 "#eeeeec"))
;; Switch from `dabbrev-expand' to `hippie-expand'
(global-set-key [remap dabbrev-expand] 'hippie-expand)
(column-number-mode t)
@ -268,11 +263,9 @@ contextual information."
(electric-pair-mode 1)
;; Rectangular select
(cua-selection-mode t)
;; Yank the region on type
(delete-selection-mode 1)
;; Deletel extra trailing white spaces on save
@ -290,7 +283,8 @@ contextual information."
;; Activating the WM mode
(exwm-enable)
(exwm-systemtray-enable)
(exwm-randr-enable))
(exwm-randr-enable)
(fido-mode))
(message "[FG42]: Use `fg42-help' to get help."))

View File

@ -31,6 +31,8 @@ let
ctrlf
consult
marginalia
] ++ lib.optionals (cfg.floating) [
vertico-posframe
]);
drv = makeFG42Drv {
@ -39,13 +41,26 @@ let
buildInputs = deps;
src = ./.;
};
floatingDocString = "nt";
in
{
options.fg42.minibuffer.vertico.enable = mkAndEnableOption "vertico";
options.fg42.minibuffer.vertico = {
enable = mkAndEnableOption "vertico";
floating = mkOption {
type = types.bool;
default = false;
description = floatingDocString;
};
};
config = mkIf cfg.enable {
fg42.elispPackages = [ drv ] ++ deps;
fg42.requires = [ drv.pname ];
fg42.vars = [
(defVar "floating-vertico" cfg.floating floatingDocString)
];
};
}

View File

@ -25,193 +25,205 @@
(require 'fpkg)
(require 'fg42/config))
(use! vertico
"Vertico provides a performant and minimalistic vertical completion UI
;; We don't want vertico in wm mode. Since it serves no purpose really.
(when-not-wm
(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)
: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
(vertico-mode)
(vertico-multiform-mode)
;; Configure the display per command.
;; Use a buffer with indices for imenu
(setq vertico-multiform-commands
'((t flat)))
'((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 flat)))))
'((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
(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)))))
: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))
(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-<down>" "S-<up>"))
;; 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)))
(with-config "graphics"
(use! nerd-icons-completion
"Nerd icons in marginalia"
:after marginalia
(when-not-wm
(use! ctrlf
"Single buffer text search."
:config
(nerd-icons-completion-mode)
(add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)))
(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-<down>" "S-<up>"))
;; 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)))
(with-config "graphics"
(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)))
(with-config "floating-vertico"
(use! vertico-posframe
"This is an vertico extension, which lets vertico use posframe to show
its candidate menu."
:hook (emacs-startup . vertico-posframe-mode)
:config
(setq vertico-posframe-parameters
'((left-fringe . 1)
(right-fringe . 1)
(border . 1))))))
(provide 'fg42/minibuffer-vertico)
;;; minibuffer-vertico.el ends here

View File

@ -85,6 +85,5 @@ to Emacs modeline."
;; TODO: Fix `fg42/minimal-exwm' to pop up on every workspace
(setq-default noether-views nil)))
(provide 'fg42/noether)
;;; noether.el ends here

View File

@ -45,6 +45,10 @@
;; (start-process-shell-command
;; "xrandr" nil "xrandr --output HDMI-1 --above eDP-1 --mode 1920x1080")))
(defun fg42/run (command)
"Start a new process by executing the given COMMAND."
(interactive (list (read-shell-command "$ ")))
(start-process-shell-command command nil command))
(when-wm
(use! exwm-randr
@ -121,9 +125,7 @@
(number-sequence 0 9))
;; Bind "s-&" to launch applications ('M-&' also works if the output
;; buffer does not bother you).
([?\s-d] . (lambda (command)
(interactive (list (read-shell-command "$ ")))
(start-process-shell-command command nil command)))
([?\s-d] . #'fg42/run)
;; Bind "s-<f2>" to "slock", a simple X display locker.
([s-f2] . (lambda ()
(interactive)