From 3e09f26891710c1a9a9cc597ab314acb977ddbaa Mon Sep 17 00:00:00 2001 From: Alexandre LUCAZEAU Date: Fri, 23 Jun 2023 19:49:21 +0200 Subject: [PATCH] ADD emacs config modules --- modules/configs/init.el | 216 ++++++++++++++++++++++++++++++++++++++++ modules/emacs.nix | 50 ++++++++++ 2 files changed, 266 insertions(+) create mode 100644 modules/configs/init.el create mode 100644 modules/emacs.nix diff --git a/modules/configs/init.el b/modules/configs/init.el new file mode 100644 index 0000000..90f5292 --- /dev/null +++ b/modules/configs/init.el @@ -0,0 +1,216 @@ +;; Keyboard-centric user interface +(setq inhibit-startup-message t) +(scroll-bar-mode -1) +(tool-bar-mode -1) +(menu-bar-mode -1) + +(require 'package) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) +;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities` +;; and `package-pinned-packages`. Most users will not need or want to do this. +;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) +(package-initialize) + + +(column-number-mode 't) ; show current column in status bar +(add-hook 'text-mode-hook 'turn-on-auto-fill) +(set-fringe-mode 10) + +;; Use 4 spaces for one tab visually. +(setq tab-width 4) + +(show-paren-mode t) ; highlight matching open and close parentheses +(global-hl-line-mode) ; highlight current line +(global-visual-line-mode t) ; wrap long lines +(setq split-window-preferred-function + 'visual-fill-column-split-window-sensibly) ; wrap at window boundary + +(global-whitespace-mode) ; enable whitespace handling by default +(setq + whitespace-style ; see (apropos 'whitespace-style) + '(face ; viz via faces + trailing ; trailing blanks visualized + lines-tail ; lines beyond whitespace-line-column visualized + space-before-tab + space-after-tab + newline ; lines with only blanks visualized + indentation ; spaces used for indent when config wants tabs + empty ; empty lines at beginning or end or buffer + ) + whitespace-line-column 150) ; column at which whitespace-mode says the line is too long +;;(set-face-attribute 'default nil :font "JetBrains Mono" :height 150) + +;; themes +(use-package doom-themes + :init (load-theme 'doom-nord t) + :init (doom-themes-org-config)) +(setq disabled-command-function nil) +(setq inhibit-startup-screen t) +(setq visible-bell t) + +;; Only y/n answers +(defalias 'yes-or-no-p 'y-or-n-p) + +;; Save what you enter into minibuffer prompts +(setq history-length 25) +(savehist-mode 1) + +;; Remember and restore the last cursor location of opened files +(save-place-mode 1) + +;; Backup + +(setq version-control t ;; Use version numbers for backups. + kept-new-versions 10 ;; Number of newest versions to keep. + kept-old-versions 0 ;; Number of oldest versions to keep. + delete-old-versions t ;; Don't ask to delete excess backup versions. + backup-by-copying t) ;; Copy all files, don't rename them. +(setq vc-make-backup-files t) +(setq backup-directory-alist '(("" . "~/.emacs.d/backup"))) +(defvar emacs-autosave-directory + (concat user-emacs-directory "autosaves/") + "This variable dictates where to put auto saves. It is set to a + directory called autosaves located wherever your .emacs.d/ is + located.") + +;; Sets all files to be backed up and auto saved in a single directory. +(setq backup-directory-alist + `((".*" . ,emacs-autosave-directory)) + auto-save-file-name-transforms + `((".*" ,emacs-autosave-directory t))) + + +(setq calendar-week-start-day 1) + + +(use-package nix-mode + :mode ("\\.nix\\'" . nix-mode) + :hook (nix-mode . lsp-deferred)) + +(use-package magit) +(setq magit-fetch-modules-jobs 16); fetch 16 modules in parallel + +(use-package which-key + :init (which-key-mode) + :config (setq which-key-idle-delay 0.5)) + +(autoload 'markdown-mode "markdown-mode" + "Major mode for editing Markdown files" t) +(add-to-list 'auto-mode-alist + '("\\.\\(?:md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)\\'" . markdown-mode)) + +(autoload 'gfm-mode "markdown-mode" + "Major mode for editing GitHub Flavored Markdown files" t) +(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode)) + +;; org-mode +(require 'org) +(require 'org-mouse) +(setq org-startup-folded t + org-pretty-entities t + org-hide-emphasis-markers t + org-startup-with-inline-images t + org-agenda-include-deadlines t + org-image-actual-width '(300)) +;; files with ".org" open in org-mode +(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) +(setq org-agenda-files '("/home/alexandre/Nextcloud/PRIVE/13_Org/backlog.org" "/home/alexandre/Nextcloud/PRIVE/13_Org/notes")) +(setq org-directory (concat (getenv "HOME") "/Nextcloud/PRIVE/13_Org/notes")) +(setq org-default-notes-file "~/Nextcloud/PRIVE/13_Org/backlog.org") +(setq org-todo-keywords '((type "TODO" "En cours" "WAIT" "CANCELED" "DONE"))) +(setf org-todo-keyword-faces '(("TODO" . (:foreground "cyan" :background "steelblue" :bold t :weight bold)) + ("En cours" . (:foreground "yellow" :background "red" :bold t :weight bold)) + ("En attente de réponse" . (:foreground "yellow" :background "magenta2" :bold t :weight bold)) + ("CANCELED" . (:foreground "gray" :background "dime grey" :bold t :weight bold)) + ("DONE" . (:foreground "gray50" :background "gray30")))) + +;; tags +(setq org-tag-alist '(("DEVIS" . ?d) ("PROJETS" . ?p) ("CLIENT" . ?c) ("PROSPECT" . ?o) ("INTERNE" . ?i) ("AO" . ?a) ("PJ" . ?z) ("AVV" . ?v) ("LEGACY" . ?l) ("ROC" . ?r))) + +(setq org-tag-faces + '( + ("DEVIS" . (:foreground "OrangeRed" :weight bold)) + ("ROC" . (:foreground "OrangeRed" :weight bold)) + ("PJ" . (:foreground "brightyellow" :weight bold)) + ("PROJET" . (:foreground "IndianRed1" :weight bold)) + ("INTERNE" . (:foreground "LimeGreen" :weight bold)) + ("LEGACY" . (:foreground "LimeGreen" :weight bold)) + ("CLIENT" . (:foreground "Orange" :weight bold)) + ("PROSPECT" . (:foreground "MediumPurple3" :weight bold)) + ("AO" . (:foreground "HotPink2" :weight bold)) + ) +) +;; org-capture use to add note to backlog file. At the end of day, use org-refile to dispatch to good note +;; https://sachachua.com/blog/2014/11/using-org-mode-keep-process-journal/ + +(setq org-capture-templates + '(("t" "TODO" entry (file+datetree "~/Nextcloud/PRIVE/13_Org/backlog.org") + "* TODO %? %^G \n %U" :empty-lines 1) + ("s" "Scheduled TODO" entry (file+datetree "~/Nextcloud/PRIVE/13_Org/backlog.org") + "* TODO %? %^G \nSCHEDULED: %^t\n %U" :empty-lines 1) + ("l" "Link" entry (file "~/Nextcloud/PRIVE/13_Org/backlog.org") + "* TODO %a %? %^G\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n") + ("j" "Journal entry" plain + (file+datetree+prompt "~/Nextcloud/PRIVE/13_Org/journal.org") + "%K ****** %a\n%i\n%?\n") + ("n" "Note dans le journal" entry (file "~/Nextcloud/PRIVE/13_Org/journal.org") + "* %? %^G\n%U" :empty-lines 1))) + +;; Org-Roam basic configuration +(use-package org-roam + :after org + :init + (setq org-roam-v2-ack t) ;; Acknowledge V2 upgrade + :custom + (org-roam-directory (file-truename org-directory)) + (org-roam-completion-everywhere t) + :bind (("C-c n l" . org-roam-buffer-toggle) + ("C-c n f" . org-roam-node-find) + ("C-c n o" . org-open-at-point) + ("C-c n j" . org-roam-dailies-capture-today) + ("C-c n i" . org-roam-node-insert)) + :config + (org-roam-setup) + (org-roam-db-autosync-mode) + ) + +;; caldav +;;(setq org-caldav-url "https://next20.produhost.net/remote.php/dav/alexandre") +;;(setq org-caldav-calendars +;; '((:calendar-id "alexandre-dri" +;; :files ("~/Nextcloud/PRIVE/13_Org/calendar/alexandre-dri.org") +;; :inbox "~/Nextcloud/PRIVE/13_Org/calendar/alexandre-dri-inbox.org"))) +;;(setq org-icalendar-include-todo 'all +;; org-caldav-sync-todo t) +;; +(use-package org-journal + :ensure t + :defer t + :init + ;; Change default prefix key; needs to be set before loading org-journal + (setq org-journal-prefix-key "C-c j ") + :config + (setq org-journal-file-type=weekly + org-journal-date-format "%A, %d %B %Y")) + +;;;; Index org file and backlog file +(defvar org-gtd-file "~/Nextcloud/PRIVE/13_Org/DRI.org") +(defvar org-backlog-file "~/Nextcloud/PRIVE/13_Org/backlog.org") + +;; Open DRI.org when I hit C-c g +(defun gtd () + "Open the GTD file." + (interactive) + (find-file org-gtd-file)) + +;; Open backlog.org when I hit file hit C-c b +(defun gtb () + "Open the backlog file." + (interactive) + (find-file org-backlog-file)) + +;; keybinding +(global-set-key "\C-cl" 'org-store-link) +(global-set-key "\C-ca" 'org-agenda) +(global-set-key "\C-cg" 'gtd) +(global-set-key "\C-cb" 'gtb) diff --git a/modules/emacs.nix b/modules/emacs.nix new file mode 100644 index 0000000..83fb028 --- /dev/null +++ b/modules/emacs.nix @@ -0,0 +1,50 @@ +{ pkgs, ... }: + +{ +home.packages = with pkgs; [ + multimarkdown + ]; + services.emacs.enable = true; + programs.emacs = { + enable = true; + extraPackages = (epkgs: + (with epkgs; [ + use-package + dash + doom-themes + lsp-mode + web-mode + nix-mode + rust-mode + ledger-mode + direnv + company + yasnippet + prettier-js + smartparens + org + org-journal + org-roam + org-msg + org-caldav + magit + evil + bbdb + projectile + flycheck + ivy + counsel + counsel-projectile + lsp-ivy + which-key + elpaPackages.org + markdown-mode + ])); + }; + + home.file = { + ".emacs.d/init.el" = { + source = ./configs/init.el; + }; + }; +}