From c25d060033f3bcd8f88df0ac919a9dc5e8868996 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sun, 8 May 2022 06:24:57 -0500 Subject: [PATCH] making emacs work better under nixos --- README.org | 58 ++++++++++------ init.el | 191 ++++++----------------------------------------------- recentf | 2 +- templates | 2 + 4 files changed, 62 insertions(+), 191 deletions(-) diff --git a/README.org b/README.org index 47041f24..8dcae0d9 100644 --- a/README.org +++ b/README.org @@ -6,6 +6,7 @@ - [[#startup-performance][Startup Performance]] - [[#set-basic-ui-config][Set basic UI config]] - [[#lets-bootstrap-straightel][Let's bootstrap straight.el]] + - [[#fix-nixos][Fix NixOS]] - [[#keep-folders-clean][Keep Folders Clean]] - [[#ligatures][Ligatures]] - [[#keybindings][Keybindings]] @@ -73,9 +74,6 @@ Let's also set the =gc-cons-threshold= variable to a high setting for the remain (setq gc-cons-threshold 50000000) #+end_src -#+RESULTS: -: 50000000 - ** Set basic UI config Let's start by making some basic ui changes like turning off the scrollbar, toolbar, menu, tooltips, and setting our font and some things. #+begin_src emacs-lisp @@ -94,8 +92,6 @@ Let's start by making some basic ui changes like turning off the scrollbar, tool (setq comp-deferred-compilation-deny-list nil) #+end_src -#+RESULTS: - In order to have this config work on both my desktop with regular joe-schmoe monitors and my laptop with new-hotness HiDPI monitor, I will set the font size if my system is the laptop to much higher. #+begin_src emacs-lisp (if (string-equal (system-name) "syl") @@ -115,18 +111,18 @@ In order to have this config work on both my desktop with regular joe-schmoe mon (defun chris/set-transparency () "Set the frame to be transparent on Wayland compositors" - (if (string-search "wayland" x-display-name) - '((set-frame-parameter (selected-frame) 'alpha '(100 . 100)) - (add-to-list 'default-frame-alist '(alpha . (100 . 100))) - (add-to-list 'initial-frame-alist '(alpha . (100 . 100)))))) + (set-frame-parameter (selected-frame) 'alpha '(100 . 100)) + (add-to-list 'default-frame-alist '(alpha . (100 . 100))) + (add-to-list 'initial-frame-alist '(alpha . (100 . 100)))) (if (daemonp) (add-hook 'after-make-frame-functions (lambda (frame) (with-selected-frame frame - (chris/set-font-faces))) + (chris/set-font-faces) + (chris/set-transparency) + (tool-bar-mode -1))) (chris/set-font-faces))) - #+end_src Then let's make sure line-numbers are relative and on. And let's turn on visual-line-mode globally. @@ -287,11 +283,7 @@ Let's make parens and other delimiters easier to tell apart by making nested one (use-package aggressive-indent :defer 1 :config -<<<<<<< HEAD (aggressive-indent-mode -1)) -======= -) ->>>>>>> 2338cd74 (adding temel stuff) #+end_src #+begin_src emacs-lisp @@ -307,6 +299,19 @@ Let's make parens and other delimiters easier to tell apart by making nested one :defer 1) #+end_src +** Fix NixOS +I am currently using NixOS. In order for emacs to have access to certain programs, we need to set some environment variables +#+begin_src emacs-lisp +(add-to-list 'exec-path "/home/chris/.nix-profile/bin") +(add-to-list 'exec-path "/run/current-system/sw/bin") +(setenv "NIX_CONF_DIR" "/etc/nix") +(setenv "NIX_OTHER_STORES" "/run/nix/remote-stores/*/nix") +(setenv "NIX_PATH" "nixpkgs=%h/nixpkgs:nixos=%h/nixpkgs/nixos:nixos-config=/etc/nixos/configuration.nix") +(setenv "NIX_PROFILES" "${pkgs.lib.concatStringsSep " " config.environment.profiles}") +(setenv "NIX_REMOTE" "daemon") +(setenv "NIX_USER_PROFILE_DIR" "/nix/var/nix/profiles/per-user/%u") +#+end_src + ** Keep Folders Clean Let's use =no-littering= in order to stop emacs from filling all our folders with junk. @@ -539,8 +544,7 @@ Part of this config includes some special capture templates for my work as a you '((emacs-lisp . t) (python . t) (ditaa . t) - (shell . t) - (restclient . t))) + (shell . t))) (setq org-ditaa-jar-path "/usr/bin/ditaa") @@ -858,6 +862,7 @@ Org-Superstar makes the stars at the beginning of the line in =org-mode= a lot p (custom-set-faces '(org-modern-tag ((t :background "#9aedfe" :foreground "#282a36"))) ) + (global-org-modern-mode +1) ) #+END_SRC @@ -1540,7 +1545,7 @@ Trying out corfu instead of company ;; Recommended: Enable Corfu globally. ;; This is recommended since dabbrev can be used globally (M-/). :init - (corfu-global-mode) + (global-corfu-mode) :general ('corfu-map "C-j" 'corfu-next @@ -1833,6 +1838,13 @@ Let's also set =hl-line-mode= to be on for comint and prog modes (add-hook 'prog-mode-hook 'hs-minor-mode) #+END_SRC +*** Tree Sitter +I'm gonna try this to speed up emacs and make it nicer +#+begin_src emacs-lisp :tangle no +(use-package tree-sitter) +(use-package tree-sitter-langs) +#+end_src + *** C++ In c++ I just want to make sure lsp is called when enter c++-mode #+BEGIN_SRC emacs-lisp @@ -1846,6 +1858,13 @@ Since I use the Awesome WM I thought it'd be good to have lua around. It's also :mode ("\\.lua\\'" . lua-mode)) #+end_src +*** Nix +I've been transitioning more of my OS to NixOS. Let's get =nix-mode= working. +#+begin_src emacs-lisp +(use-package nix-mode + :mode "\\.nix\\'") +#+end_src + *** LSP LSP is useful... #+begin_src emacs-lisp @@ -2164,7 +2183,7 @@ Ledger mode #+end_src ** MU4E -#+begin_src emacs-lisp +#+begin_src emacs-lisp :tangle no (use-package mu4e :ensure nil :config @@ -2323,7 +2342,6 @@ Ledger mode (general-def 'normal mu4e-view-mode-map "ga" 'mu4e-view-save-attachments)) - #+end_src # (use-package org-mime diff --git a/init.el b/init.el index d7638318..a9f86353 100644 --- a/init.el +++ b/init.el @@ -38,16 +38,17 @@ (defun chris/set-transparency () "Set the frame to be transparent on Wayland compositors" - (if (string-search "wayland" x-display-name) - '((set-frame-parameter (selected-frame) 'alpha '(100 . 100)) - (add-to-list 'default-frame-alist '(alpha . (100 . 100))) - (add-to-list 'initial-frame-alist '(alpha . (100 . 100)))))) + (set-frame-parameter (selected-frame) 'alpha '(100 . 100)) + (add-to-list 'default-frame-alist '(alpha . (100 . 100))) + (add-to-list 'initial-frame-alist '(alpha . (100 . 100)))) (if (daemonp) (add-hook 'after-make-frame-functions (lambda (frame) (with-selected-frame frame - (chris/set-font-faces))) + (chris/set-font-faces) + (chris/set-transparency) + (tool-bar-mode -1))) (chris/set-font-faces))) (setq display-line-numbers-type 'relative) @@ -126,11 +127,7 @@ (use-package aggressive-indent :defer 1 :config -<<<<<<< HEAD (aggressive-indent-mode -1)) -======= -) ->>>>>>> 2338cd74 (adding temel stuff) (use-package adaptive-wrap :defer t) @@ -141,6 +138,15 @@ (which-key-mode) :defer 1) +(add-to-list 'exec-path "/home/chris/.nix-profile/bin") +(add-to-list 'exec-path "/run/current-system/sw/bin") +(setenv "NIX_CONF_DIR" "/etc/nix") +(setenv "NIX_OTHER_STORES" "/run/nix/remote-stores/*/nix") +(setenv "NIX_PATH" "nixpkgs=%h/nixpkgs:nixos=%h/nixpkgs/nixos:nixos-config=/etc/nixos/configuration.nix") +(setenv "NIX_PROFILES" "${pkgs.lib.concatStringsSep " " config.environment.profiles}") +(setenv "NIX_REMOTE" "daemon") +(setenv "NIX_USER_PROFILE_DIR" "/nix/var/nix/profiles/per-user/%u") + (use-package no-littering) ;; no-littering doesn't set this by default so we must place @@ -341,8 +347,7 @@ '((emacs-lisp . t) (python . t) (ditaa . t) - (shell . t) - (restclient . t))) + (shell . t))) (setq org-ditaa-jar-path "/usr/bin/ditaa") @@ -611,6 +616,7 @@ (custom-set-faces '(org-modern-tag ((t :background "#9aedfe" :foreground "#282a36"))) ) + (global-org-modern-mode +1) ) (defun chris/org-dwim-at-point (&optional arg) @@ -1047,7 +1053,7 @@ targets." ;; Recommended: Enable Corfu globally. ;; This is recommended since dabbrev can be used globally (M-/). :init - (corfu-global-mode) + (global-corfu-mode) :general ('corfu-map "C-j" 'corfu-next @@ -1289,6 +1295,9 @@ targets." (use-package lua-mode :mode ("\\.lua\\'" . lua-mode)) +(use-package nix-mode + :mode "\\.nix\\'") + (use-package lsp-mode :commands (lsp lsp-deferred) :custom @@ -1475,164 +1484,6 @@ targets." (use-package ledger-mode) -(use-package mu4e - :ensure nil - :config - (setq mail-user-agent 'mu4e-user-agent) - (setq mu4e-maildir "~/Maildir" - user-full-name "Chris Cochrun" - mu4e-change-filenames-when-moving t - mu4e-get-mail-command "mbsync -a" - mu4e-update-interval (* 15 60) - mu4e-attachment-dir "/home/chris/nextcloud/home/Documents/attachments" - mu4e-completing-read-function #'completing-read) - - (setq mu4e-contexts - (list - (make-mu4e-context - :name "work" - :match-func - (lambda (msg) - (when msg - (string-prefix-p "/office" (mu4e-message-field msg :maildir)))) - :vars '((user-mail-address . "chris@tfcconnection.org") - (mu4e-sent-folder . "/office/Sent Items/") - (mu4e-drafts-folder . "/office/Drafts") - (mu4e-trash-folder . "/office/Deleted Items") - (mu4e-refile-folder . "/office/Archive") - (smtpmail-smtp-user . "chris@tfcconnection.org") - (smtpmail-starttls-credentials . '(("smtp.office365.com" 587 nil nil))) - (smtpmail-auth-credentials . '(("smtp.office365.com" 587 "chris@tfcconnection.org" nil))) - (smtpmail-smtp-server . "smtp.office365.com") - (mu4e-compose-signature . "Praising God in all things,\nChris Cochrun"))) - (make-mu4e-context - :name "outlook" - :match-func - (lambda (msg) - (when msg - (string-prefix-p "/outlook" (mu4e-message-field msg :maildir)))) - :vars '((user-mail-address . "chris.cochrun@outlook.com") - (mu4e-sent-folder . "/outlook/Sent/") - (mu4e-drafts-folder . "/outlook/Drafts") - (mu4e-trash-folder . "/outlook/Deleted") - (mu4e-refile-folder . "/outlook/Archive") - (smtpmail-smtp-user . "chris.cochrun@outlook.com") - (mu4e-compose-signature . "Praising God in all things,\nChris Cochrun"))) - (make-mu4e-context - :name "personal" - :match-func - (lambda (msg) - (when msg - (string-prefix-p "/cochrun" (mu4e-message-field msg :maildir)))) - :vars '((user-mail-address . "chris@cochrun.xyz") - (mu4e-sent-folder . "/cochrun/Sent/") - (mu4e-drafts-folder . "/cochrun/Drafts") - (mu4e-trash-folder . "/cochrun/Trash") - (mu4e-refile-folder . "/cochrun/Archive") - (smtpmail-smtp-user . "chris@cochrun.xyz") - (smtpmail-starttls-credentials . '(("mail.cochrun.xyz" 587 nil nil))) - (smtpmail-auth-credentials . '(("mail.cochrun.xyz" 587 "chris@cochrun.xyz" nil))) - (smtpmail-smtp-server . "mail.cochrun.xyz") - (mu4e-compose-signature . "Praising God in all things,\nChris Cochrun"))) - (make-mu4e-context - :name "gmail" - :match-func - (lambda (msg) - (when msg - (string-prefix-p "/gmail" (mu4e-message-field msg :maildir)))) - :vars '((user-mail-address . "ccochrun21@gmail.com") - (mu4e-sent-folder . "/gmail/[Gmail].Sent Mail/") - (smtpmail-smtp-user . "ccochrun21@gmail.com") - (mu4e-compose-signature . "Praising God in all things,\nChris Cochrun"))))) - - ;; Add the ability to send email - (setq message-send-mail-function 'smtpmail-send-it - starttls-use-gnutls t - smtpmail-default-smtp-server "mail.cochrun.xyz" - smtpmail-smtp-service 587) - - ;; shortcuts in the jumplist by pressing "J" in the mu4e buffer - (setq mu4e-maildir-shortcuts - '((:maildir "/office/Archive" :key ?a) - (:maildir "/office/INBOX" :key ?i) - (:maildir "/cochrun/INBOX" :key ?p) - (:maildir "/outlook/INBOX" :key ?l) - (:maildir "/office/Junk Email" :key ?j) - (:maildir "/office/INBOX/Website Forms" :key ?f) - (:maildir "/gmail/INBOX" :key ?g) - (:maildir "/office/Sent Items" :key ?s))) - - ;; (add-to-list mu4e-headers-actions ("org capture message" . mu4e-org-store-and-capture)) - - (setq mu4e-bookmarks - '((:name "Unread messages" - :query "flag:unread AND NOT flag:trashed AND NOT maildir:\"/outlook/Junk\" AND NOT maildir:\"/office/Junk Email\" AND NOT maildir:\"/outlook/Deleted\" AND NOT maildir:\"/office/Deleted Items\"" - :key 117) - (:name "Today's messages" - :query "date:today..now" - :key 116) - (:name "Last 7 days" - :query "date:7d..now" - :hide-unread t - :key 119) - (:name "Messages with images" - :query "mime:image/*" - :key 112))) - - (setq mu4e-mu-binary "/usr/bin/mu" - mu4e-view-prefer-html nil - shr-color-visible-luminance-min 80) - - (setq mu4e-use-fancy-chars t - mu4e-headers-draft-mark '("D" . "") - mu4e-headers-flagged-mark '("F" . "") - mu4e-headers-new-mark '("N" . " ") - mu4e-headers-passed-mark '("P" . "") - mu4e-headers-replied-mark '("R" . "") - mu4e-headers-seen-mark '("S" . " ") - mu4e-headers-trashed-mark '("T" . " ") - mu4e-headers-attach-mark '("a" . " ") - mu4e-headers-encrypted-mark '("x" . "") - mu4e-headers-signed-mark '("s" . " ") - mu4e-headers-unread-mark '("u" . " ")) - - (setq mu4e-headers-fields - '((:human-date . 12) - (:flags . 6) - (:from . 22) - (:subject))) - - (setq mu4e-view-actions - '(("capture message" . mu4e-action-capture-message) - ("view in browser" . mu4e-action-view-in-browser) - ("show this thread" . mu4e-action-show-thread))) - - (defun chris/setup-mu4e-headers () - (toggle-truncate-lines +1) - (display-line-numbers-mode -1)) - - - (defun chris/setup-mu4e-view () - (display-line-numbers-mode -1) - (toggle-truncate-lines +1) - (setq visual-fill-column-center-text t) - (setq visual-fill-column-width 100) - (visual-fill-column-mode +1)) - - (remove-hook 'mu4e-main-mode-hook '(display-line-numbers-mode -1)) - (add-hook 'mu4e-headers-mode-hook #'chris/setup-mu4e-headers) - (add-hook 'mu4e-view-mode-hook #'chris/setup-mu4e-view) - - - (mu4e t) - :general - (chris/leader-keys - :states 'normal - :keymaps 'override - "om" 'mu4e) - (general-def 'normal mu4e-view-mode-map - "ga" 'mu4e-view-save-attachments)) - (use-package org-msg :hook (mu4e-compose-mode . org-msg-edit-mode) :config diff --git a/recentf b/recentf index 8d65f374..aa66d94e 100644 --- a/recentf +++ b/recentf @@ -1,4 +1,4 @@ -;;; Automatically generated by ‘recentf’ on Thu Apr 28 05:37:57 2022. +;;; Automatically generated by ‘recentf’ on Thu May 5 06:02:29 2022. (setq recentf-list 'nil) diff --git a/templates b/templates index e9ebaf53..d4b927a7 100644 --- a/templates +++ b/templates @@ -85,3 +85,5 @@ org-mode (src "#+begin_src " p n> r> n> "#+end_src") (elisp "#+begin_src emacs-lisp" n> r> n "#+end_src" :post (progn (tempel-done) (org-edit-src-code))) +(nix "#+begin_src nix" n> r> n "#+end_src" + :post (progn (tempel-done) (org-edit-src-code)))