9.5 KiB
My Emacs' configuration
This is my Emacs configuration, it's written as literate programming using org-mode's Babel. All the settings are enclosed inside this single file named /aciceri/emacs/src/commit/627707f13dafc3fc320d80994fe3806f6f9a65f3/README.org, the reason of this choice is that many services (like GitHub) automatically looks for these names. The configuration of different Emacs' aspects are kept divided in different paragraphs.
This file must be considered part of the Git repository to which it belongs and it may not work properly without the other files. Despite I mainly use NixOS I chose to keep my Emacs configuration detached from my Nix files, this way I should be able get my Emacs' settings in a non-Nix environment.
However the installing process of the required packages is not managed
by this configuration; for example on my NixOS system I use the
emacs-overlay which automatically parses this file looking for the
(use-package <package>)
declarations and then downloads and builds
the latest versions from MELPA.
I preferred to maintain this agnostic approach in order to don't make
this already dense file even more complex.
Indeed, as it's configured, use-package
should ensure that the
packages are installed, and if this is not the case it should install
them.
I use EXWM (i.e. Emacs X Window Manager) but since I wanted to keep the possibility to use this configuration also on different systems (maybe without X.org) I tried to isolate its settings. So, even if I never tried, it should be easy to disable it without consequences.
General settings
This snippet contatins different things that I wasn't able to gather better. Hopefully, in a future, this section won't exist anymore.
(setq create-lockfiles nil)
(setq backup-directory-alist '((".*" . "~/.emacs-saves/")))
(setq auto-save-file-name-transforms '((".*" "~/.emacs-saves/" t)))
(setq backup-by-copying t)
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
(defalias 'yes-or-no-p 'y-or-n-p)
(setq use-dialog-box nil)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(fringe-mode 1)
(setq display-time-format "%H:%M")
(display-time-mode 1)
(setq mouse-autoselect-window 't)
(setq inhibit-startup-screen t)
(setq async-shell-command-buffer 'new-buffer)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(add-hook 'prog-mode-hook 'hl-line-mode)
(add-hook 'org-mode-hook 'auto-fill-mode)
(set-fill-column 80)
(add-to-list 'default-frame-alist '(font . "Fira Code-12"))
(set-face-attribute 'default t :font "Fira Code-12")
(setq show-paren-delay 0)
(set-face-background 'show-paren-match "#111")
(set-face-attribute 'show-paren-match nil :weight 'extra-bold)
(show-paren-mode 1)
(add-hook 'text-mode-hook
(lambda () (set-input-method "italian-postfix")))
Theming
I'm using the doom-one
theme from the doom-themes
package.
In addition it's loaded the all-the-icons
fonts and a special
modeline from doom-modeline
.
(use-package doom-themes
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-one t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
(setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config)
)
(set-frame-parameter (selected-frame) 'alpha '(98 . 98))
(add-to-list 'default-frame-alist '(alpha . (98 . 98)))
(use-package all-the-icons)
(use-package doom-modeline
:init (doom-modeline-mode 1))
(use-package fira-code-mode
:hook prog-mode
:config (setq fira-code-mode-disabled-ligatures '("x")))
Evil
In a future I think I'll try the Emacs keybindings, but for now I prefer the Vim keybindings, at least for the text editing. Since I use small keyboards I think it's better to use a modal editor, however for everything that is not text editing I use the normal Emacs keybindings.
(use-package evil
:init
(setq evil-want-keybinding nil)
:config
(progn
(evil-mode 1) ; globally enable evil-mode except for the following modes
(mapcar (lambda (mode) (evil-set-initial-state mode 'emacs))
'(vterm-mode
eshell-mode
dired-mode
))))
(use-package evil-collection
:after (evil company-mode vterm)
:config
(evil-collection-init))
(use-package org-evil)
Org configuration
(require 'org-protocol)
(setq org-default-notes-file (concat org-directory "~/notes.org"))
(setq org-capture-templates `(
("p" "Protocol" entry (file+headline ,(concat org-directory "notes.org") "Inbox")
"* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?")
("L" "Protocol Link" entry (file+headline ,(concat org-directory "notes.org") "Inbox")
"* %? [[%:link][%:description]] \nCaptured On: %U")
))
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)))
(setq safe-local-variable-values '((eval add-hook 'after-save-hook 'org-icalendar-export-to-ics nil t)))
(setq org-agenda-files '("~/nas/syncthing/orgzly/Agenda.org" "~/nas/syncthing/orgzly/Lavoro.org"))
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.6))
;;(use-package org-fragtog
;; :hook (org-mode org-fragtog))
Helm
Unfortunately this is currently unmantained (there was only a mantainer, who devoted himself to it for years) but I hope that someone in the near future will pick up the project. However this is really stable and I never had problems.
(use-package helm
:init
(progn
(require 'helm-config)
(setq helm-autoresize-max-height 0)
(setq helm-autoresize-min-height 20)
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))
(when (executable-find "ack")
(setq helm-grep-default-command "ack -Hn --no-group --no-color %e %p %f"
helm-grep-default-recurse-command "ack -H --no-group --no-color %e %p %f"))
(setq helm-semantic-fuzzy-match t
helm-imenu-fuzzy-match t
helm-M-x-fuzzy-match t ;; optional fuzzy matching for helm-M-x
helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t
helm-split-window-in-side-p t
helm-buffer-max-length nil)
(helm-mode 1)
(helm-autoresize-mode 1))
:bind
(("C-c h" . helm-command-prefix)
:map helm-command-map
("b" . helm-buffers-list)
("f" . helm-find-files)
("m" . helm-mini)
("o" . helm-imenu))
:bind
(("M-x" . helm-M-x)
("M-y" . helm-show-kill-ring)
("C-x b" . helm-mini)
("C-x C-f" . helm-find-files)))
Programming
FlyCheck
(use-package flycheck
:init (global-flycheck-mode))
(use-package company
:init (global-company-mode))
(use-package company-quickhelp
:straight t
:config
(company-quickhelp-mode))
(use-package company-try-hard
:straight t
:bind
(("C-<tab>" . company-try-hard)
:map company-active-map
("C-<tab>" . company-try-hard)))
Git
(use-package magit)
Solidity
(use-package solidity-flycheck
:init (setq solidity-flycheck-solc-checker-active t)) ;requires solc in PATH
Python
(use-package elpy
:init (elpy-enable)
:config :config
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
)
(use-package blacken)
(use-package python-flycheck
:init (setq elpy-modules (delq 'elpy-module-flymake elpy-modules)))
(use-package company-jedi)
LSP
(use-package lsp-mode
:init
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "C-c l")
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
(XXX-mode . lsp)
;; if you want which-key integration
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp)
;; optionally
(use-package lsp-ui :commands lsp-ui-mode)
;; if you are helm user
(use-package helm-lsp :commands helm-lsp-workspace-symbol)
;; optionally if you want to use debugger
(use-package dap-mode)
;; (use-package dap-LANGUAGE) to load the dap adapter for your language
;; optional if you want which-key integration
(use-package which-key
:config
(which-key-mode))
(add-hook 'haskell-mode-hook #'lsp)
(add-hook 'haskell-literate-mode-hook #'lsp)
Haskell
(use-package haskell-mode)
(use-package lsp-haskell)
(use-package dap-haskell)
Nix
(use-package nix-mode
:mode "\\.nix\\'")
;;(use-package company-nixos-options
;; :after company
;; :config
;; (progn
;; (add-to-list 'company-backends 'company-nixos-options)))
(use-package helm-nixos-options)
Notmuch
(use-package notmuch)
(use-package org-notmuch)
SMTP settings
(setq smtpmail-smtp-server "smtp.autistici.org"
smtpmail-smtp-service 587
smtpmail-local-domain "")