Update .emacs.d/config.org

Update .emacs.d/init.el
This commit is contained in:
Anthony Rodriguez 2024-07-03 16:01:51 +02:00
parent 8aa2354663
commit 9e701b8025
2 changed files with 93 additions and 91 deletions

View file

@ -12,13 +12,20 @@ Here, we're initializing MELPA, as well as package.el and use-package.
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
#+end_src
*** vc-use-package
vc-use-package integrated package-vc-install, which allows installing packages from git repositories, into use-package. It won't be needed from Emacs 30, as it integrates natively (hence the condition).
#+begin_src emacs-lisp
(if (< emacs-major-version 30)
(unless (package-installed-p 'vc-use-package)
(package-vc-install "https://github.com/slotThe/vc-use-package"))
(require 'vc-use-package))
#+end_src
** General config
*** no-littering
no-littering is a useful package that allows to put all of the autosave files and temporary files in one directory (the files ending with ~ for instance).
@ -54,7 +61,6 @@ We disable a lot of interface elements, to make the editor more minimal looking.
(setq exec-path (split-string path-from-shell path-separator))))
(set-exec-path-from-shell-PATH)
#+end_src
*** Bell
@ -120,63 +126,59 @@ I use doom-modeline as my modeline, as I find it really clean and minimal.
*** Completion
I use vertico as my completion framework. It's minimal, fast and tells me all I need to know and even sorts by history.
#+begin_src emacs-lisp
(use-package vertico
:init
(vertico-mode)
(use-package vertico
:init
(vertico-mode)
;; Different scroll margin
;; (setq vertico-scroll-margin 0)
;; Different scroll margin
;; (setq vertico-scroll-margin 0)
;; Show more candidates
;; (setq vertico-count 20)
;; Show more candidates
;; (setq vertico-count 20)
;; Grow and shrink the Vertico minibuffer
(setq vertico-resize t)
;; Grow and shrink the Vertico minibuffer
(setq vertico-resize t)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t))
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t))
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))
;; A few more useful configurations...
(use-package emacs
:init
;; Add prompt indicator to `completing-read-multiple'.
;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
(defun crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator)
(car args))
(cdr args)))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)
;; A few more useful configurations...
(use-package emacs
:init
;; Add prompt indicator to `completing-read-multiple'.
;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
(defun crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator)
(car args))
(cdr args)))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)
;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
;; Support opening new minibuffers from inside existing minibuffers.
(setq enable-recursive-minibuffers t)
;; Support opening new minibuffers from inside existing minibuffers.
(setq enable-recursive-minibuffers t)
;; Emacs 28 and newer: Hide commands in M-x which do not work in the current
;; mode. Vertico commands are hidden in normal buffers. This setting is
;; useful beyond Vertico.
(setq read-extended-command-predicate #'command-completion-default-include-p))
;; Emacs 28 and newer: Hide commands in M-x which do not work in the current
;; mode. Vertico commands are hidden in normal buffers. This setting is
;; useful beyond Vertico.
(setq read-extended-command-predicate #'command-completion-default-include-p))
;; Optionally use the `orderless' completion style.
(use-package orderless
:init
;; Configure a custom style dispatcher (see the Consult wiki)
;; (setq orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch)
;; orderless-component-separator #'orderless-escapable-split-on-space)
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
#+end_src
*** which-key
@ -187,25 +189,6 @@ which-key is a nice little package that allows to have a minibuffer showing whic
(which-key-mode))
#+end_src
*** quelpa
quelpa is a package that allows to build packages from source.
#+begin_src emacs-lisp
(unless (package-installed-p 'quelpa)
(with-temp-buffer
(url-insert-file-contents "https://raw.githubusercontent.com/quelpa/quelpa/master/quelpa.el")
(eval-buffer)
(quelpa-self-upgrade)))
#+end_src
use-package integration with quelpa.
#+begin_src emacs-lisp
(quelpa
'(quelpa-use-package
:fetcher git
:url "https://github.com/quelpa/quelpa-use-package.git"))
(require 'quelpa-use-package)
#+end_src
*** Reload org config config on save
This allows to tangle automatically when saving the config. This is mostly for convenience.
#+begin_src emacs-lisp
@ -234,24 +217,24 @@ I use org-superstar-mode, as it makes headlines and bullets look really nice.
#+end_src
** Programming
*** LSP
*** Eglot
#+begin_src emacs-lisp
(defun my-lsp-mode-setup ()
"Enable lsp-mode except in org-mode and emacs-lisp-mode."
(unless (or (derived-mode-p 'org-mode)
(derived-mode-p 'emacs-lisp-mode))
(lsp)))
(use-package eglot
:bind (:map eglot-mode-map
("C-c C-d" . eldoc)
("C-c C-e" . eglot-rename)
("C-c C-o" . python-sort-imports)
("C-c C-f" . eglot-format-buffer))
:hook ((tsx-ts-mode . eglot-ensure)
(typescript-ts-mode . eglot-ensure)))
(use-package lsp-mode
:hook (prog-mode . my-lsp-mode-setup)
(lsp-mode . lsp-enable-which-key-integration)
:init
(setq lsp-keymap-prefix "C-c l")
(setq read-process-output-max (* 1024 1024))
(setq gc-cons-threshold 100000000))
(use-package lsp-ui)
;; makes eglot faster using a rust wrapper, needs to be in PATH
(use-package eglot-booster
:vc (:fetcher github :repo jdtsmith/eglot-booster)
:after eglot
:config
(eglot-booster-mode))
#+end_src
*** Projectile
#+begin_src emacs-lisp
(use-package projectile
@ -264,9 +247,13 @@ I use org-superstar-mode, as it makes headlines and bullets look really nice.
*** Autocompletion
#+begin_src emacs-lisp
(use-package company
:config
(setq company-idle-delay 0))
(use-package corfu
:custom
(corfu-auto t)
:init
(global-corfu-mode)
(setq corfu-popupinfo-delay 0.2)
(corfu-popupinfo-mode))
#+end_src
*** Snippets
@ -311,7 +298,7 @@ Magit is a git client in Emacs.
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
(yaml "https://github.com/ikatyang/tree-sitter-yaml")))
(setq treesit-font-lock-level 4)
(add-to-list 'auto-mode-alist '("\\.ts\\'" . tsx-ts-mode))
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode))
#+end_src
@ -338,3 +325,16 @@ Magit is a git client in Emacs.
(use-package expand-region
:bind ("C-=" . er/expand-region))
#+end_src
** Mail
#+begin_src emacs-lisp
(autoload 'notmuch "notmuch" "notmuch mail" t)
(use-package notmuch)
#+end_src
*** SMTP
#+begin_src emacs-lisp
(setq send-mail-function 'sendmail-query-once)
#+end_src

View file

@ -8,8 +8,10 @@
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
'(rust-mode which-key org-superstar org-superstar-mode vertico doom-modeline catppuccin-theme)))
'(package-selected-packages '(eglot-booster))
'(package-vc-selected-packages
'((eglot-booster :vc-backend Git :url "https://github.com/jdtsmith/eglot-booster")
(vc-use-package :vc-backend Git :url "https://github.com/slotThe/vc-use-package"))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.