Update .emacs.d/config.org

This commit is contained in:
Anthony Rodriguez 2024-07-04 14:12:46 +02:00
parent 6829197014
commit 20a1e43944

View file

@ -1,5 +1,8 @@
* Emacs config #+PROPERTY: header-args:emacs-lisp :tangle init.el
** Packages initialization #+TITLE: Emacs config
#+AUTHOR: Anthony Rodriguez
* Packages initialization
Here, we're initializing MELPA, as well as package.el and use-package. Here, we're initializing MELPA, as well as package.el and use-package.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(require 'package) (require 'package)
@ -15,8 +18,7 @@ Here, we're initializing MELPA, as well as package.el and use-package.
(setq use-package-always-ensure t) (setq use-package-always-ensure t)
#+end_src #+end_src
*** vc-use-package ** vc-use-package
vc-use-package integrates package-vc-install, which allows installing packages from git repositories, into use-package. It won't be needed from Emacs 30, as it will integrate natively (hence the condition). vc-use-package integrates package-vc-install, which allows installing packages from git repositories, into use-package. It won't be needed from Emacs 30, as it will integrate natively (hence the condition).
#+begin_src emacs-lisp #+begin_src emacs-lisp
(if (< emacs-major-version 30) (if (< emacs-major-version 30)
@ -24,14 +26,22 @@ vc-use-package integrates package-vc-install, which allows installing packages f
(package-vc-install "https://github.com/slotThe/vc-use-package")) (package-vc-install "https://github.com/slotThe/vc-use-package"))
(require 'vc-use-package)) (require 'vc-use-package))
#+end_src #+end_src
** General config
*** no-littering ** Automatically tangle on save
#+begin_src emacs-lisp
(add-hook 'org-mode-hook
(lambda () (add-hook 'after-save-hook #'org-babel-tangle
:append :local)))
#+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). 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).
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package no-littering) (use-package no-littering)
#+end_src #+end_src
*** Minimal interface ** Minimal interface
We disable a lot of interface elements, to make the editor more minimal looking. We disable a lot of interface elements, to make the editor more minimal looking.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq inhibit-startup-message t) (setq inhibit-startup-message t)
@ -42,9 +52,9 @@ We disable a lot of interface elements, to make the editor more minimal looking.
(menu-bar-mode -1) (menu-bar-mode -1)
#+end_src #+end_src
*** Match fish shell's path ** Match fish shell's path
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun set-exec-path-from-shell-PATH () (defun set-exec-path-from-shell-PATH ()
"Set up Emacs' `exec-path' and PATH environment variable to match "Set up Emacs' `exec-path' and PATH environment variable to match
that used by the user's shell. that used by the user's shell.
@ -61,13 +71,13 @@ We disable a lot of interface elements, to make the editor more minimal looking.
(set-exec-path-from-shell-PATH) (set-exec-path-from-shell-PATH)
#+end_src #+end_src
*** Bell ** Bell
I don't like any visual or sound bell. I don't like any visual or sound bell.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq ring-bell-function 'ignore) (setq ring-bell-function 'ignore)
#+end_src #+end_src
*** Font ** Font
I use two different fonts in Emacs : my sans serif font for anything where variable fonts wouldn't matter, and monospace for fixed width text (such as code, org blocks and org tables). I like to use the generic sans-serif and monospace fonts, as it allows me to define them system-wide, which I highly prefer. I use two different fonts in Emacs : my sans serif font for anything where variable fonts wouldn't matter, and monospace for fixed width text (such as code, org blocks and org tables). I like to use the generic sans-serif and monospace fonts, as it allows me to define them system-wide, which I highly prefer.
Besides the font settings, I use the package fixed-pitch, which sets up hooks automatically for all the modes that require fixed width fonts. This allows me to have my sans serif everywhere else but in Besides the font settings, I use the package fixed-pitch, which sets up hooks automatically for all the modes that require fixed width fonts. This allows me to have my sans serif everywhere else but in
@ -87,7 +97,7 @@ Besides the font settings, I use the package fixed-pitch, which sets up hooks au
:vc ( :fetcher github :repo cstby/fixed-pitch-mode)) :vc ( :fetcher github :repo cstby/fixed-pitch-mode))
#+end_src #+end_src
**** Ligatures ** Ligatures
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package ligature (use-package ligature
:config :config
@ -108,13 +118,13 @@ Besides the font settings, I use the package fixed-pitch, which sets up hooks au
(global-ligature-mode t)) (global-ligature-mode t))
#+end_src #+end_src
*** Visual mode ** Visual mode
We turn on visual mode, so that lines can wrap nicely and do go beyond my Emacs buffer size. We turn on visual mode, so that lines can wrap nicely and do go beyond my Emacs buffer size.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(global-visual-line-mode t) (global-visual-line-mode t)
#+end_src #+end_src
*** Theme ** Theme
I use catppuccin as my theme, as I find it comfortable to work with (the Frappe flavor). I use catppuccin as my theme, as I find it comfortable to work with (the Frappe flavor).
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package catppuccin-theme (use-package catppuccin-theme
@ -124,67 +134,66 @@ I use catppuccin as my theme, as I find it comfortable to work with (the Frappe
(load-theme 'catppuccin :no-confirm)) (load-theme 'catppuccin :no-confirm))
#+end_src #+end_src
*** Modeline ** Modeline
I use doom-modeline as my modeline, as I find it really clean and minimal. I use doom-modeline as my modeline, as I find it really clean and minimal.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package doom-modeline (use-package doom-modeline
:ensure t :ensure t
:init (doom-modeline-mode 1) :init (doom-modeline-mode 1)
:config :config
(setq doom-modeline-height 30) (setq doom-modeline-height 30))
(setq nerd-icons-font-family "monospace"))
#+end_src #+end_src
*** Completion ** 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. 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 #+begin_src emacs-lisp
(use-package vertico (use-package vertico
:init :init
(vertico-mode) (vertico-mode)
;; Different scroll margin ;; Different scroll margin
;; (setq vertico-scroll-margin 0) ;; (setq vertico-scroll-margin 0)
;; Show more candidates ;; Show more candidates
;; (setq vertico-count 20) ;; (setq vertico-count 20)
;; Grow and shrink the Vertico minibuffer ;; Grow and shrink the Vertico minibuffer
(setq vertico-resize t) (setq vertico-resize t)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'. ;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t)) (setq vertico-cycle t))
;; Persist history over Emacs restarts. Vertico sorts by history position. ;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist (use-package savehist
:init :init
(savehist-mode)) (savehist-mode))
;; A few more useful configurations... ;; A few more useful configurations...
(use-package emacs (use-package emacs
:init :init
;; Add prompt indicator to `completing-read-multiple'. ;; Add prompt indicator to `completing-read-multiple'.
;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma. ;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
(defun crm-indicator (args) (defun crm-indicator (args)
(cons (format "[CRM%s] %s" (cons (format "[CRM%s] %s"
(replace-regexp-in-string (replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator) crm-separator)
(car args)) (car args))
(cdr args))) (cdr args)))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator) (advice-add #'completing-read-multiple :filter-args #'crm-indicator)
;; Do not allow the cursor in the minibuffer prompt ;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties (setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt)) '(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
;; Support opening new minibuffers from inside existing minibuffers. ;; Support opening new minibuffers from inside existing minibuffers.
(setq enable-recursive-minibuffers t) (setq enable-recursive-minibuffers t)
;; Emacs 28 and newer: Hide commands in M-x which do not work in the current ;; 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 ;; mode. Vertico commands are hidden in normal buffers. This setting is
;; useful beyond Vertico. ;; useful beyond Vertico.
(setq read-extended-command-predicate #'command-completion-default-include-p)) (setq read-extended-command-predicate #'command-completion-default-include-p))
(use-package orderless (use-package orderless
:ensure t :ensure t
@ -193,7 +202,7 @@ I use vertico as my completion framework. It's minimal, fast and tells me all I
(completion-category-overrides '((file (styles basic partial-completion))))) (completion-category-overrides '((file (styles basic partial-completion)))))
#+end_src #+end_src
*** which-key ** which-key
which-key is a nice little package that allows to have a minibuffer showing which keybinds are available under prefixes. which-key is a nice little package that allows to have a minibuffer showing which keybinds are available under prefixes.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package which-key (use-package which-key
@ -201,22 +210,24 @@ which-key is a nice little package that allows to have a minibuffer showing whic
(which-key-mode)) (which-key-mode))
#+end_src #+end_src
*** Discord presence ** Discord presence
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package elcord (use-package elcord
:config :config
(elcord-mode)) (elcord-mode))
#+end_src #+end_src
** Org mode
*** Pretty bullets and headlines * Org mode
** Pretty bullets and headlines
I use org-superstar-mode, as it makes headlines and bullets look really nice. I use org-superstar-mode, as it makes headlines and bullets look really nice.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package org-superstar (use-package org-superstar
:hook (org-mode . org-superstar-mode)) :hook (org-mode . org-superstar-mode))
#+end_src #+end_src
** Programming * Programming
*** Eglot ** Eglot
Eglot is a built in LSP client for Emacs. I prefer it to LSP as it's more lightweight and more straightforward to setup correctly.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package eglot (use-package eglot
:bind (:map eglot-mode-map :bind (:map eglot-mode-map
@ -235,7 +246,7 @@ I use org-superstar-mode, as it makes headlines and bullets look really nice.
(eglot-booster-mode)) (eglot-booster-mode))
#+end_src #+end_src
*** Autocompletion ** Autocompletion
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package corfu (use-package corfu
:custom :custom
@ -246,7 +257,7 @@ I use org-superstar-mode, as it makes headlines and bullets look really nice.
(corfu-popupinfo-mode)) (corfu-popupinfo-mode))
#+end_src #+end_src
*** Snippets ** Snippets
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package yasnippet (use-package yasnippet
:ensure t :ensure t
@ -256,15 +267,21 @@ I use org-superstar-mode, as it makes headlines and bullets look really nice.
("C-c C-e" . yas-expand))) ("C-c C-e" . yas-expand)))
#+end_src #+end_src
*** Magit ** Magit
Magit is a git client in Emacs. Magit is a git client in Emacs.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package magit) (use-package magit)
#+end_src #+end_src
*** Languages ** Docker
**** tree-sitter #+begin_src emacs-lisp
Tree-sitter is a built-in Emacs package that allows us to have extremely well integrated language. Here, we're setting up the list of sources, most of them being on tree-sitter's official GitHub, as well as hooking up the languages to their different modes. (use-package docker
:ensure t
:bind ("C-c d" . docker))
#+end_src
** Languages
*** tree-sitter
Tree-sitter is a built-in Emacs package that allows us to have extremely well integrated language grammar. Here, we're setting up the list of sources, most of them being on tree-sitter's official GitHub, as well as hooking up the languages to their different modes.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq treesit-language-source-alist (setq treesit-language-source-alist
'((bash "https://github.com/tree-sitter/tree-sitter-bash") '((bash "https://github.com/tree-sitter/tree-sitter-bash")
@ -287,11 +304,7 @@ Tree-sitter is a built-in Emacs package that allows us to have extremely well in
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode)) (add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode))
#+end_src #+end_src
#+begin_src sh *** Alapheia
npm install -g typescript-language-server
#+end_src
**** Alapheia
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package apheleia (use-package apheleia
:ensure t :ensure t
@ -304,21 +317,14 @@ Tree-sitter is a built-in Emacs package that allows us to have extremely well in
(use-package dtrt-indent) (use-package dtrt-indent)
#+end_src #+end_src
**** expand-region ** expand-region
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package expand-region (use-package expand-region
:bind ("C-=" . er/expand-region)) :bind ("C-=" . er/expand-region))
#+end_src #+end_src
** Mail * Mail
#+begin_src emacs-lisp #+begin_src emacs-lisp
(autoload 'notmuch "notmuch" "notmuch mail" t) (autoload 'notmuch "notmuch" "notmuch mail" t)
(use-package notmuch) (use-package notmuch)
#+end_src #+end_src
*** SMTP
#+begin_src emacs-lisp
(setq send-mail-function 'sendmail-query-once)
#+end_src