summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2023-04-23 13:29:31 +0100
committerGrégoire Duchêne <gduchene@awhk.org>2023-04-23 13:29:31 +0100
commitfa31c0fa45e2540be5ac18324db42a06a8cb6ece (patch)
tree675a65e592b7c59efc12634c0261ea69695e8351 /emacs
parent4ce77a1309b6cd4e967fed623760715914d8b4cc (diff)
emacs: Switch to Vertico, Consult, and Marginalia
Diffstat (limited to 'emacs')
-rw-r--r--emacs/functions.el12
-rw-r--r--emacs/init.el23
-rw-r--r--emacs/package-list.el3
3 files changed, 22 insertions, 16 deletions
diff --git a/emacs/functions.el b/emacs/functions.el
index d23e412..fcf8b66 100644
--- a/emacs/functions.el
+++ b/emacs/functions.el
@@ -19,17 +19,6 @@ is active."
(isearch-yank-string (buffer-substring-no-properties
(region-beginning) (region-end)))))
-(defun my/swiper (&optional swiper-all)
- "Call ‘swiper’ (‘swiper-all’ when prefixed) with the contents
-of the region if it is active."
- (interactive "P")
- (if (use-region-p)
- (let ((initial-input (buffer-substring-no-properties
- (region-beginning) (region-end))))
- (deactivate-mark)
- (if swiper-all (swiper-all initial-input) (swiper initial-input)))
- (if swiper-all (swiper-all) (swiper))))
-
;; Theme Functions
@@ -92,6 +81,7 @@ enabled."
(defun my/eglot-organize-imports ()
"Interactively call ‘eglot-code-action-organize-imports’."
+ (interactive)
(call-interactively #'eglot-code-action-organize-imports))
(defmacro my/with-add-hook (hook &rest body)
diff --git a/emacs/init.el b/emacs/init.el
index 741c6f8..dd8cda8 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -40,6 +40,8 @@
uniquify-buffer-name-style 'post-forward-angle-brackets
vc-follow-symlinks nil)
+(add-to-list 'completion-styles 'flex)
+
(put 'list-timers 'disabled nil)
(add-hook 'after-init-hook #'my/display-startup-time)
@@ -52,6 +54,7 @@
(display-time-mode (if (getenv "TMUX") -1 1))
(electric-indent-mode -1)
(global-auto-revert-mode 1)
+(marginalia-mode 1)
(global-set-key (kbd "C-c q") #'electric-quote-local-mode)
@@ -80,13 +83,12 @@
;; Search and Completion Management
-(ivy-mode 1)
-(diminish 'ivy-mode)
+(vertico-mode 1)
-(counsel-mode 1)
-(diminish 'counsel-mode)
+(setq completion-ignore-case t
+ completion-in-region-function #'consult-completion-in-region)
-(global-set-key (kbd "C-c s") #'my/swiper)
+(global-set-key (kbd "C-c s") #'consult-ripgrep)
(dolist (fn '(isearch-forward isearch-backward))
(advice-add fn :after #'my/isearch-region))
@@ -109,6 +111,14 @@
(dolist (fn '(delete-window split-window-horizontally split-window-vertically))
(advice-add fn :after #'(lambda (&rest _args) (balance-windows))))
+(advice-add #'fill-paragraph :around
+ #'(lambda (orig &rest args)
+ (let* ((offset (save-excursion
+ (back-to-indentation)
+ (current-column)))
+ (fill-column (+ offset fill-column)))
+ (apply orig args))))
+
(if (daemonp) (add-hook 'before-make-frame-hook #'my/disable-frame-modes)
(my/disable-frame-modes))
@@ -144,9 +154,12 @@
gofmt-command "goimports"))
(my/with-add-hook 'go-mode-hook
+ (setq-local auto-save-visited-mode nil)
+
(setq tab-width 2)
(when (executable-find "gopls")
+ (corfu-mode)
(eglot-ensure)
(add-hook 'before-save-hook #'my/eglot-organize-imports nil :local)
(add-hook 'before-save-hook #'eglot-format-buffer nil :local)))
diff --git a/emacs/package-list.el b/emacs/package-list.el
index 6b049e2..a58891e 100644
--- a/emacs/package-list.el
+++ b/emacs/package-list.el
@@ -1,5 +1,6 @@
(setq package-selected-packages '(bazel
clang-format
+ consult
counsel
diminish
dockerfile-mode
@@ -10,8 +11,10 @@
ivy
json-mode
magit
+ marginalia
markdown-mode
protobuf-mode
swiper
tuareg
+ vertico
yaml-mode))