From ecefa0f8c0d59238046cc1dedd08c20d63dbb456 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sat, 31 Aug 2024 13:50:51 +0200 Subject: [PATCH] tweaks --- emacs/custom.el | 2 +- emacs/init.el | 54 +++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/emacs/custom.el b/emacs/custom.el index 3521e46..1b670ba 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 - '(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)) + '(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 715b2c1..bc35fe8 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -6,6 +6,18 @@ ;; helper functions ;; ===== +(defun my/format-elisp-buffer () + "Format the whole elisp buffer." + (interactive) + (save-excursion + (indent-region (point-min) (point-max)))) + +(defun my/setup-elisp-formatting-key () + "Set up the formatting key for Emacs Lisp buffers." + (local-set-key (kbd "C-c f") 'my/format-elisp-buffer)) + +(add-hook 'emacs-lisp-mode-hook #'my/setup-elisp-formatting-key) + (defun my/swiper-query-replace () "Run `query-replace-regexp' on Swiper results." (interactive) @@ -147,9 +159,21 @@ (put 'narrow-to-defun 'disabled nil) (put 'narrow-to-page 'disabled nil) (put 'widen 'disabled nil) - + (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) + (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) @@ -165,7 +189,6 @@ (global-set-key (kbd "C-x E n f") #'narrow-to-defun) (global-set-key (kbd "C-x E n r") #'narrow-to-region) (global-set-key (kbd "C-x E w") #'widen) - (when (file-exists-p custom-file) (load custom-file))) @@ -343,8 +366,8 @@ ;; navigation ;; === (use-package ace-jump-mode :ensure t :defer t - :bind (("C-x j j" . ace-jump-mode) - ("C-x j p" . 'ace-jump-mode-pop-mark))) + :bind (("C-x j j" . ace-jump-mode) + ("C-x j p" . 'ace-jump-mode-pop-mark))) ;; api testing ;; === @@ -356,7 +379,7 @@ (use-package ivy :ensure t :config - (setq ivy-re-builders-alist + (setq ivy-re-builders-alist '((swiper . ivy--regex-plus) (t . orderless-ivy-re-builder))) (setq ivy-initial-inputs-alist nil) @@ -370,7 +393,26 @@ (setq counsel-grep-base-command "rg -i -M 120 --no-heading --line-number --color never '%s' %s") (setq counsel-rg-base-command - "rg -i -M 120 --no-heading --line-number --color never %s .")) + "rg -i -M 120 --no-heading --line-number --color never %s .") + + ;; Replace vanilla commands with Counsel versions + :bind (("C-x C-f" . counsel-find-file) + ("M-x" . counsel-M-x) + ("C-x b" . counsel-switch-buffer) + ("C-x C-b" . counsel-ibuffer) + ("C-h f" . counsel-describe-function) + ("C-h v" . counsel-describe-variable) + ("C-h l" . counsel-find-library) + ("C-h i" . counsel-info-lookup-symbol) + ("C-x r b" . counsel-bookmark) + ("C-c g" . counsel-git) + ("C-c j" . counsel-git-grep) + ("C-c k" . counsel-ag) + ("C-c r" . counsel-rg) + ("C-x 8 RET" . counsel-unicode-char) + ("C-c s" . counsel-grep-or-swiper) + :map minibuffer-local-map + ("C-r" . counsel-minibuffer-history))) (use-package projectile :ensure t