init-code.el
(use-package undo-fu
:ensure t)
(use-package avy
:ensure t
:config
(avy-setup-default)
:bind
;; Follow abo-abo idea : C-. is used by emark, C-, by flyspell.
(("C-'" . avy-goto-char-timer)
("M-g f" . avy-goto-line)
("M-g w" . avy-goto-word-1)
("M-g e" . avy-goto-word-0)
))
;; Emacs 30 built-in code completion instead of corfu+cape
;; For org-mode, does not start without the hack below (thanks https://www.reddit.com/r/emacs/comments/1j0wonk/how_to_trigger_completionpreview_in_orgmode_to/)
(use-package completion-preview
:hook ((prog-mode . completion-preview-mode)
(text-mode . completion-preview-mode))
;; Bindings that take effect when the preview is shown:
;; Cycle the completion candidate that the preview shows
:bind
(:map completion-preview-active-mode-map
("M-n" . completion-preview-next-candidate)
("M-p" . completion-preview-prev-candidate))
:config
;; From the dev himself https://eshelyaron.com/posts/2023-11-17-completion-preview-in-emacs.html
;; and in \\[shell] and friends
(with-eval-after-load 'comint
(add-hook 'comint-mode-hook #'completion-preview-mode))
;; Show the preview already after two symbol characters
(setq completion-preview-minimum-symbol-length 2)
;; Non-standard commands to that should show the preview:
;; Org mode has a custom `self-insert-command'
(push 'org-self-insert-command completion-preview-commands)
;; Paredit has a custom `delete-backward-char' command
(push 'paredit-backward-delete completion-preview-commands)
)
;; ------ LSP ------
(use-package eglot
:ensure nil
:defer t
:commands (eglot
eglot-ensure
eglot-rename
eglot-format-buffer))
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(rust-mode . ("rust-analyzer"))))
(use-package nix-mode
:ensure t
:defer t
:mode "\\.nix\\'")
(use-package rust-mode
:ensure t
:defer t
:mode "\\.rs\\'"
:hook (rust-mode . eglot-ensure))
(use-package magit
:ensure t
:defer t
:init
(setq magit-define-global-key-bindings "recommended")) ; Evaluated after-init-hook
(provide 'init-code)