Commit b71ab4f99809

Vincent Demeester <vincent@sbr.pm>
2025-03-18 20:23:30
tools/emacs: add more general-leader bindings
Still trying to make sure if it's the way I want to do it (or with a global minor mode ?) and if it's the right binding. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 49c7776
tools/emacs/config/config-completion.el
@@ -43,11 +43,37 @@
   ("M-s M-g" . consult-grep)
   ("M-s M-r" . consult-ripgrep)
   ("M-s M-h" . consult-history)
-  ("M-s M-i" . consult-imenu)
   ("M-s M-l" . consult-line)
   ("M-s M-m" . consult-mark)
   ("M-s M-y" . consult-yank-pop)
-  ("M-s M-s" . consult-outline))
+  ("M-s M-s" . consult-outline)
+  :config
+  (general-leader
+    "y"  #'(consult-yank-pop :which-key "Clipboard history")
+    "b"  '(:ignore t :which-key "buffer")
+    "bb" #'(consult-buffer :which-key "switch buffer")
+    "bd" #'(kill-current-buffer :which-key "kill buffer")
+    "bD" #'((lambda ()(interactive)(kill-current-buffer)(tab-close)) :wk "Kill buffer and tab")
+    "bn" #'(next-buffer :which-key "next buffer")
+    "bp" #'(previous-buffer :which-key "previous buffer")
+    "s"  '(:ignore t :which-key "search")
+    "sg" #'(consult-grep :which-key "Consult grep in current directory")
+    "sR" #'(consult-ripgrep :which-key "Consult ripgrep in current directory")
+    "sr" '(:ignore t :which-key "rg.el")'
+    "srp" #'(rg-project :which-key "rg.el in current project")
+    "srs" #'(rg-dwim :which-key "rg.el Do What I Mean")
+    "sh"  #'(Info-goto-emacs-command-node :wk "Search help")
+    "sc"  #'(consult-mode-command :wk "Mode Command")
+    "s/"  #'(consult-isearch-history :wk "Consult Isearch history")
+    "g"  '(:ignore t :which-key "go")
+    "gu" #'(ffap-next-url :which-key "next url")
+    "gd" #'(xref-find-definitions :which-key "find definition")
+    "gD" #'(xref-find-definitions-other-window :which-key "find definition (other window)")))
+
+(use-package consult-imenu
+  :after (consult)
+  :bind
+  ("M-s M-i" . consult-imenu))
 
 (use-package consult-xref
   :config
@@ -259,11 +285,12 @@ Useful for prompts such as `eval-expression' and `shell-command'."
 
   (add-hook 'minibuffer-setup-hook #'contrib/corfu-enable-always-in-minibuffer 1))
 
-(use-package corfu-candidate-overlay
-  :after corfu
-  :bind (("C-<tab>" . corfu-candidate-overlay-complete-at-point))
-  :config
-  (corfu-candidate-overlay-mode +1))
+;; Seems like it is a bit impacting the performance somehow.
+;; (use-package corfu-candidate-overlay
+;;   :after corfu
+;;   :bind (("C-<tab>" . corfu-candidate-overlay-complete-at-point))
+;;   :config
+;;   (corfu-candidate-overlay-mode +1))
 
 (use-package cape
   :bind (("C-c p f" . cape-file)
tools/emacs/config/config-keybindings.el
@@ -19,48 +19,24 @@
   (general-def "C-M-<SPC>" 'cycle-spacing)
 
   (general-leader
-   "f"   '(:ignore t :wk "File")
-   "ff"  #'(project-find-file :wk "Find in Project")
+    "z"   #'(repeat :which-key "Repeat")
+    "u"   #'(universal-argument :which-key "Universal argument")
+    "e"   #'(dired-jump :which-key "Dired")
+    "x"   #'(execute-extended-command :which-key "M-x")
+    "f"   '(:ignore t :which-key "File")
+    "SPC" #'((lambda()(interactive)
+               (let ((consult-buffer-filter))
+                 (add-to-list 'consult-buffer-filter "\\*")
+                 (call-interactively 'consult-buffer))) :wk "Switch to Buffer")
+    ":"   #'(eval-expression :wk "Eval expression")
+    "ff"  #'(project-find-file :which-key "Find in Project")
+    "fo"  #'(ffap :which-key "Find with context")
+    "fq"  #'(read-only-mode :which-key "Toggle Read Only")
+    "fr"  #'(consult-recent-file :which-key "Recent File")
+    "q"   #'(:ignore t :wk "Quit")
+    "qq"  #'(save-buffers-kill-terminal :wk "Quit Emacs")
    ))
 
-;; (use-package general
-;;   :config
-;;   (general-define-key
-;;    :states '(normal visual insert emacs)
-;;    :prefix "SPC"
-;;    :non-normal-prefix "M-SPC"
-;;    "SPC" '(counsel-M-x :which-key "M-x")
-;;    "TAB" '(switch-to-prev-buffer :which-key "previous buffer")
-;;    "b" '(:ignore t :which-key "buffer")
-;;    "bb" '(counsel-switch-buffer :which-key "switch buffer")
-;;    "bd" '(kill-current-buffer :which-key "kill buffer")
-;;    "bn" '(next-buffer :which-key "next buffer")
-;;    "bp" '(previous-buffer :which-key "previous buffer")
-;;    "e" '(:ignore t :which-key "edit")
-;;    "ee" '(eval-last-sexp :which-key "eval last sexp")
-;;    "f" '(:ignore t :which-key "file")
-;;    "ff" '(counsel-find-file :which-key "find file")
-;;    "fs" '(save-buffer :which-key "save file")
-;;    "g" '(:ignore t :which-key "git")
-;;    "gs" '(magit-status :which-key "magit status")
-;;    "h" '(:ignore t :which-key "help")
-;;    "hf" '(describe-function :which-key "describe function")
-;;    "hk" '(describe-key :which-key "describe key")
-;;    "hv" '(describe-variable :which-key "describe variable")
-;;    "p" '(:ignore t :which-key "project")
-;;    "pf" '(counsel-projectile-find-file :which-key "find file")
-;;    "pp" '(counsel-projectile-switch-project :which-key "switch project")
-;;    "q" '(:ignore t :which-key "quit")
-;;    "qq" '(save-buffers-kill-terminal :which-key "quit emacs")
-;;    "s" '(:ignore t :which-key "search")
-;;    "ss" '(swiper :which-key "swiper")
-;;    "w" '(:ignore t :which-key "window")
-;;    "wd" '(delete-window :which-key "delete window")
-;;    "wh" '(windmove-left :which-key "move left")
-;;    "wj" '(windmove-down :which-key "move down")
-;;    "wk" '(windmove-up :which-key "move up")
-;;    "wl" '(windmove-right :which-key )))
-
 ;; 
 (provide 'config-keybindings)
 ;;; config-keybindings.el ends here
tools/emacs/config/config-projects.el
@@ -96,7 +96,19 @@ switch to it. Otherwise, create a new vterm shell."
       (when command
         (vterm-send-string command)
         (vterm-send-return))))
-  )
+  :config
+  (general-leader
+    "p"  '(:ignore :which-key "Project")
+    "pp"  #'(my-switch-to-project-dired :wk "Switch to Project")
+    "ps"  #'(my-switch-to-project-search :wk "Grep in Project")
+    "pf"  #'(project-find-file :wk "Find in Project")
+    "pd"  #'(project-dired :wk "Dired in Project")
+    "pc"  #'(project-compile :wk "Compile in Project")
+    "pb"  #'(project-switch-to-buffer :wk "Switch to Project Buffer")
+    "pk"  #'(project-kill-buffers :wk "Kill Project Buffers")
+    "pr"  #'(my-find-recent-file-in-project :wk "List Recentf in Project")
+    "ps"  #'(vde-project-vterm :which-key "Start a vterm in Project")
+    "px"  #'(vde-project-run-in-vterm :which-key "Execute command in vterm in Project")))
 
 (use-package conner
   :bind (("C-x p C" . conner-run-project-command))