Split Emacs configuration in modules
This commit is contained in:
89
emacs/.emacs.d/lisp/misc/custom-functions.el
Normal file
89
emacs/.emacs.d/lisp/misc/custom-functions.el
Normal file
@@ -0,0 +1,89 @@
|
||||
;;functions to support syncing .elfeed between machines
|
||||
;;makes sure elfeed reads index from disk before launching
|
||||
(defun fscotto/elfeed-load-db-and-open ()
|
||||
"Wrapper to load the elfeed db from disk before opening URL https://pragmaticemacs.wordpress.com/2016/08/17/read-your-rss-feeds-in-emacs-with-elfeed/
|
||||
Created: 2016-08-17
|
||||
Updated: 2025-06-13"
|
||||
(interactive)
|
||||
(elfeed)
|
||||
(elfeed-db-load)
|
||||
;; (elfeed-search-update--force)
|
||||
(elfeed-update)
|
||||
(elfeed-db-save))
|
||||
|
||||
(defun fscotto/project-root ()
|
||||
"Return projectile project root or fallback to default-directory."
|
||||
(if (featurep 'projectile)
|
||||
(or (projectile-project-root) default-directory)
|
||||
default-directory))
|
||||
|
||||
(defun fscotto/project-vterm ()
|
||||
"Open vterm in project root."
|
||||
(interactive)
|
||||
(let ((default-directory (fscotto/project-root)))
|
||||
(vterm)))
|
||||
|
||||
(defun fscotto/project-magit-status ()
|
||||
"Open magit-status in project root."
|
||||
(interactive)
|
||||
(let ((default-directory (fscotto/project-root)))
|
||||
(magit-status)))
|
||||
|
||||
(defun fscotto/magit-dispatch ()
|
||||
"Load Magit if necessary and open magit-dispatch."
|
||||
(interactive)
|
||||
(require 'magit)
|
||||
(call-interactively #'magit-dispatch))
|
||||
|
||||
(defun fscotto/disable-c-formatting ()
|
||||
(setq-local lsp-enable-on-type-formatting nil))
|
||||
|
||||
;; Golang development support functions
|
||||
(defun fscotto/go-format-on-save ()
|
||||
"Format Go buffers on save using gofmt."
|
||||
(add-hook 'before-save-hook #'lsp-format-buffer nil t))
|
||||
|
||||
(defun fscotto/go-mod-tidy ()
|
||||
"Esegue go mod tidy nella root del progetto."
|
||||
(interactive)
|
||||
(let ((default-directory (project-root (project-current t))))
|
||||
(compile "go mod tidy")))
|
||||
|
||||
(defun fscotto/go-mod-download ()
|
||||
"Scarica i moduli Go."
|
||||
(interactive)
|
||||
(let ((default-directory (project-root (project-current t))))
|
||||
(compile "go mod download")))
|
||||
|
||||
(defun fscotto/go-mod-after-save ()
|
||||
(when (and (eq major-mode 'go-mod-ts-mode)
|
||||
(lsp-workspaces))
|
||||
(lsp-restart-workspace)))
|
||||
|
||||
(defun fscotto/go-test-package ()
|
||||
"Run `go test` in the current package."
|
||||
(interactive)
|
||||
(let ((default-directory (project-root (project-current t))))
|
||||
(compile "go test")))
|
||||
|
||||
(defun fscotto/go-test-module ()
|
||||
"Run `go test ./...` in the current Go module."
|
||||
(interactive)
|
||||
(let ((default-directory (project-root (project-current t))))
|
||||
(compile "go test ./...")))
|
||||
|
||||
(defun fscotto/go-test-current-test ()
|
||||
"Run `go test -run` for the test at point."
|
||||
(interactive)
|
||||
(let* ((test-name (thing-at-point 'symbol t))
|
||||
(default-directory (project-root (project-current t))))
|
||||
(unless test-name
|
||||
(user-error "No test name at point"))
|
||||
(compile (format "go test -run '^%s$'" test-name))))
|
||||
|
||||
(defun fscotto/go-test-at-point ()
|
||||
"Return Go test name at point."
|
||||
(let ((sym (thing-at-point 'symbol t)))
|
||||
(unless (and sym (string-prefix-p "Test" sym))
|
||||
(user-error "No Go test at point"))
|
||||
sym))
|
||||
9
emacs/.emacs.d/lisp/misc/doom-modeline.el
Normal file
9
emacs/.emacs.d/lisp/misc/doom-modeline.el
Normal file
@@ -0,0 +1,9 @@
|
||||
;;; doom-modeline.el -*-
|
||||
|
||||
(use-package doom-modeline
|
||||
:ensure t
|
||||
:config
|
||||
(setq doom-modeline-height 25
|
||||
doom-modeline-bar-width 3
|
||||
doom-modeline-project-detection 'projectile)
|
||||
:init (doom-modeline-mode 1))
|
||||
53
emacs/.emacs.d/lisp/misc/email.el
Normal file
53
emacs/.emacs.d/lisp/misc/email.el
Normal file
@@ -0,0 +1,53 @@
|
||||
;;; email.el -*-
|
||||
|
||||
(use-package mu4e
|
||||
:ensure nil
|
||||
;; :load-path "/usr/share/emacs/site-lisp/mu4e/"
|
||||
:defer 20 ; Wait until 20 seconds after startup
|
||||
:bind (:map global-map ("C-c o m" . mu4e))
|
||||
:config
|
||||
|
||||
;; This is set to 't' to avoid mail syncing issues when using mbsync
|
||||
(setq mu4e-change-filenames-when-moving t)
|
||||
|
||||
;; Refresh mail using isync every 10 minutes
|
||||
(setq mu4e-update-interval (* 10 60))
|
||||
(setq mu4e-get-mail-command "~/.emacs.d/scripts/email_sync.sh")
|
||||
(setq mu4e-maildir "~/Maildir")
|
||||
|
||||
;; Configure email accounts
|
||||
(setq mu4e-contexts
|
||||
(list
|
||||
;; Protonmail Account
|
||||
(make-mu4e-context
|
||||
:name "Protonmail"
|
||||
:match-func
|
||||
(lambda (msg)
|
||||
(when msg
|
||||
(string-prefix-p "/ProtonMailAccount" (mu4e-message-field msg :maildir))))
|
||||
:vars '((user-mail-address . "fscottodisantolo@protonmail.com")
|
||||
(user-full-name . "Fabio Scotto di Santolo")
|
||||
(mu4e-drafts-folder . "/ProtonMailAccount/Drafts")
|
||||
(mu4e-sent-folder . "/ProtonMailAccount/Sent")
|
||||
(mu4e-refile-folder . "/ProtonMailAccount/All Mail")
|
||||
(mu4e-trash-folder . "/ProtonMailAccount/Trash")))
|
||||
|
||||
;; iCloud Account
|
||||
(make-mu4e-context
|
||||
:name "iCloud Mail"
|
||||
:match-func
|
||||
(lambda (msg)
|
||||
(when msg
|
||||
(string-prefix-p "/iCloudAccount" (mu4e-message-field msg :maildir))))
|
||||
:vars '((user-mail-address . "fscottodisantolo@icloud.com")
|
||||
(user-full-name . "Fabio Scotto di Santolo")
|
||||
(mu4e-drafts-folder . "/iCloudAccount/Drafts")
|
||||
(mu4e-sent-folder . "/iCloudAccount/Sent Messages")
|
||||
(mu4e-refile-folder . "/iCloudAccount/INBOX")
|
||||
(mu4e-trash-folder . "/iCloudAccount/Junk")))))
|
||||
|
||||
(setq sendmail-program "/usr/bin/msmtp"
|
||||
send-mail-function 'sendmail-send-it
|
||||
message-sendmail-f-is-evil t
|
||||
message-sendmail-extra-arguments '("--read-envelope-from")
|
||||
message-send-mail-function 'message-send-mail-with-sendmail))
|
||||
3
emacs/.emacs.d/lisp/misc/epub.el
Normal file
3
emacs/.emacs.d/lisp/misc/epub.el
Normal file
@@ -0,0 +1,3 @@
|
||||
(use-package nov
|
||||
:ensure t
|
||||
:mode ("\\.epub\\'" . nov-mode))
|
||||
2
emacs/.emacs.d/lisp/misc/i3-config.el
Normal file
2
emacs/.emacs.d/lisp/misc/i3-config.el
Normal file
@@ -0,0 +1,2 @@
|
||||
(use-package i3wm-config-mode
|
||||
:ensure t)
|
||||
4
emacs/.emacs.d/lisp/misc/pdf.el
Normal file
4
emacs/.emacs.d/lisp/misc/pdf.el
Normal file
@@ -0,0 +1,4 @@
|
||||
(use-package pdf-tools
|
||||
:ensure t
|
||||
:config
|
||||
(pdf-tools-install))
|
||||
39
emacs/.emacs.d/lisp/misc/rss.el
Normal file
39
emacs/.emacs.d/lisp/misc/rss.el
Normal file
@@ -0,0 +1,39 @@
|
||||
;;; rss.el -*-
|
||||
|
||||
(use-package elfeed
|
||||
:ensure t
|
||||
:custom
|
||||
(elfeed-enclosure-default-dir "~/Downloads/")
|
||||
(elfeed-search-remain-on-entry t)
|
||||
(elfeed-search-title-max-width 100)
|
||||
(elfeed-search-title-min-width 30)
|
||||
(elfeed-search-trailing-width 25)
|
||||
(elfeed-show-truncate-long-urls t)
|
||||
(elfeed-sort-order 'descending)
|
||||
(elfeed-search-filter "+unread")
|
||||
:bind
|
||||
("C-c o f" . fscotto/elfeed-load-db-and-open)
|
||||
(:map elfeed-search-mode-map
|
||||
("w" . elfeed-search-yank)
|
||||
("R" . elfeed-update)
|
||||
("q" . elfeed-kill-buffer))
|
||||
(:map elfeed-show-mode-map
|
||||
("S" . elfeed-show-new-live-search) ; moved to free up 's'
|
||||
("c" . (lambda () (interactive) (org-capture nil "capture")))
|
||||
("e" . email-elfeed-entry)
|
||||
("f" . elfeed-show-fetch-full-text)
|
||||
("w" . elfeed-show-yank))
|
||||
:hook
|
||||
(elfeed-show-mode . visual-line-mode))
|
||||
|
||||
(use-package elfeed-org
|
||||
:ensure t
|
||||
:after elfeed
|
||||
:custom
|
||||
;; Optionally specify a number of files containing elfeed
|
||||
;; configuration. If not set then the location below is used.
|
||||
;; Note: The customize interface is also supported.
|
||||
(rmh-elfeed-org-files (list "~/.emacs.d/elfeed.org")))
|
||||
|
||||
(with-eval-after-load 'elfeed
|
||||
(elfeed-org))
|
||||
7
emacs/.emacs.d/lisp/misc/terminal.el
Normal file
7
emacs/.emacs.d/lisp/misc/terminal.el
Normal file
@@ -0,0 +1,7 @@
|
||||
;;; terminal.el -*-
|
||||
|
||||
(use-package vterm
|
||||
:ensure t
|
||||
:bind (:map global-map
|
||||
("C-c o T" . vterm)
|
||||
("C-c C-t" . vterm-copy-mode)))
|
||||
12
emacs/.emacs.d/lisp/misc/vcs.el
Normal file
12
emacs/.emacs.d/lisp/misc/vcs.el
Normal file
@@ -0,0 +1,12 @@
|
||||
(use-package magit
|
||||
:ensure t
|
||||
:commands (magit-status magit-log)
|
||||
:init
|
||||
;; Entry point principale
|
||||
(setq magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
|
||||
:config
|
||||
;; Performance & UX
|
||||
(setq magit-refresh-status-buffer nil)
|
||||
(setq magit-repository-directories
|
||||
'(("~/Projects" . 2)
|
||||
("~/Work" . 2))))
|
||||
161
emacs/.emacs.d/lisp/misc/which-key.el
Normal file
161
emacs/.emacs.d/lisp/misc/which-key.el
Normal file
@@ -0,0 +1,161 @@
|
||||
;;; which-key.el -*-
|
||||
|
||||
(use-package which-key
|
||||
:ensure t
|
||||
:defer 1
|
||||
:config
|
||||
(which-key-mode)
|
||||
(setq which-key-idle-delay 0.45
|
||||
which-key-idle-secondary-delay 0.05
|
||||
which-key-max-display-columns 3
|
||||
which-key-max-description-length 45))
|
||||
|
||||
(with-eval-after-load 'which-key
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Top-level prefixes
|
||||
;; --------------------------------------------------------------------------
|
||||
(which-key-add-key-based-replacements
|
||||
"C-c !" "Analyze"
|
||||
"C-c o" "Open"
|
||||
"C-c v" "Version control"
|
||||
"C-c l" "LSP"
|
||||
"C-c t" "TODO / Annotations"
|
||||
"C-c b" "Buffers"
|
||||
"C-c p" "Project"
|
||||
"C-c d" "Debug"
|
||||
"C-c g" "Git"
|
||||
"C-c e" "Email / Elfeed")
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Open (C-c o …)
|
||||
;; --------------------------------------------------------------------------
|
||||
(which-key-add-key-based-replacements
|
||||
"C-c o f" "RSS (Elfeed)"
|
||||
"C-c o m" "mu4e (Email Client)"
|
||||
"C-c o T" "Terminal (vterm)")
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Version control
|
||||
;; --------------------------------------------------------------------------
|
||||
(which-key-add-key-based-replacements
|
||||
"C-c v g" "Magit status (legacy)")
|
||||
|
||||
(which-key-add-key-based-replacements
|
||||
;; Core
|
||||
"C-c g g" "Status"
|
||||
"C-c g s" "Status"
|
||||
;; "C-c g b" "Branch"
|
||||
;; "C-c g c" "Commit"
|
||||
"C-c g p" "Push / Pull"
|
||||
"C-c g f" "Fetch"
|
||||
"C-c g l" "Log"
|
||||
"C-c g S" "Stash"
|
||||
|
||||
;; Files
|
||||
"C-c g d" "Diff"
|
||||
"C-c g D" "Diff (cached)"
|
||||
"C-c g B" "Blame"
|
||||
|
||||
;; Rebase / Reset
|
||||
"C-c g r" "Rebase"
|
||||
"C-c g R" "Reset"
|
||||
|
||||
;; Remote
|
||||
"C-c g y" "Show refs"
|
||||
"C-c g o" "Browse remote")
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Buffers
|
||||
;; --------------------------------------------------------------------------
|
||||
(which-key-add-key-based-replacements
|
||||
"C-x C-b" "ibuffer")
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; TODO / hl-todo
|
||||
;; --------------------------------------------------------------------------
|
||||
(which-key-add-key-based-replacements
|
||||
"C-t" "hl-todo"
|
||||
"C-t p" "Previous TODO"
|
||||
"C-t n" "Next TODO"
|
||||
"C-t o" "Occur (list)"
|
||||
"C-t i" "Insert TODO")
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; LSP (C-c l …)
|
||||
;; --------------------------------------------------------------------------
|
||||
(which-key-add-key-based-replacements
|
||||
;; Navigation
|
||||
"C-c l d" "Go to definition"
|
||||
"C-c l D" "Go to type definition"
|
||||
"C-c l i" "Go to implementation"
|
||||
|
||||
;; Symbols / diagnostics
|
||||
"C-c l s" "Workspace symbols"
|
||||
"C-c l e" "Diagnostics"
|
||||
|
||||
;; Actions
|
||||
"C-c l a" "Code actions"
|
||||
"C-c l r" "Rename symbol"
|
||||
"C-c l f" "Format buffer"
|
||||
|
||||
;; Control
|
||||
"C-c l R" "Restart workspace")
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Elfeed modes
|
||||
;; --------------------------------------------------------------------------
|
||||
(which-key-add-key-based-replacements
|
||||
"w" "Yank"
|
||||
"R" "Update feeds"
|
||||
"q" "Quit")
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Debug / DAP
|
||||
;; --------------------------------------------------------------------------
|
||||
(which-key-add-key-based-replacements
|
||||
"C-c d d" "Start debug session"
|
||||
"C-c d b" "Toggle breakpoint")
|
||||
;; "C-c d c" "Continue"
|
||||
;; "C-c d n" "Next"
|
||||
;; "C-c d i" "Step in"
|
||||
;; "C-c d o" "Step out")
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Project (future)
|
||||
;; --------------------------------------------------------------------------
|
||||
(which-key-add-key-based-replacements
|
||||
;; Core
|
||||
"C-c p p" "Switch project"
|
||||
"C-c p f" "Find file"
|
||||
"C-c p d" "Find directory"
|
||||
"C-c p b" "Switch buffer"
|
||||
"C-c p k" "Kill project buffers"
|
||||
"C-c p r" "Recent files"
|
||||
|
||||
;; Search
|
||||
"C-c p s" "Search"
|
||||
"C-c p s g" "Grep (ripgrep)"
|
||||
"C-c p s r" "Replace in project"
|
||||
|
||||
;; Actions
|
||||
"C-c p c" "Compile"
|
||||
"C-c p t" "Test"
|
||||
"C-c p v" "Open term in project"
|
||||
"C-c p e" "Edit project config"
|
||||
"C-c p g" "Project Git status"
|
||||
"C-c p x" "Open Terminal"
|
||||
"C-c p 4" "Other Window"
|
||||
"C-c p 5" "Other Frame"
|
||||
"C-c p x 4" "Other Window"
|
||||
|
||||
;; Cache
|
||||
"C-c p i" "Invalidate cache")
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Cleanup annoying +prefix
|
||||
;; --------------------------------------------------------------------------
|
||||
(which-key-add-key-based-replacements
|
||||
"+prefix" "Prefix"
|
||||
"+lsp" "LSP"
|
||||
"+debug" "Debug"
|
||||
"+project" "Project"))
|
||||
Reference in New Issue
Block a user