From 7197cd031e6fe12a3efcc98a1ec0c3eb9c986e89 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Thu, 14 Mar 2024 12:00:32 -0700 Subject: add stuff --- config/emacs.el | 136 +++++++++++++++++++++++++++------ config/emacs.org | 226 +++++++++++++++++++++++++++++++++++++++---------------- config/nix.org | 9 ++- 3 files changed, 278 insertions(+), 93 deletions(-) (limited to 'config') diff --git a/config/emacs.el b/config/emacs.el index 03eefef..b5b3525 100644 --- a/config/emacs.el +++ b/config/emacs.el @@ -1,3 +1,5 @@ +(pixel-scroll-precision-mode 1) +(setq scroll-conservatively 101) (display-battery-mode 1) (setq display-time-24hr-format t) (display-time-mode 1) @@ -5,6 +7,7 @@ (scroll-bar-mode -1) (tool-bar-mode -1) (load-theme 'catppuccin :no-confirm) +(setq display-line-numbers-type 'relative) (add-hook 'prog-mode-hook #'display-line-numbers-mode) (add-hook 'org-mode-hook #'display-line-numbers-mode) (set-face-attribute 'default nil :height 120) @@ -12,11 +15,33 @@ (setq make-backup-files nil) (setq org-export-with-broken-links t) (setq org-src-fontify-natively t) -(setq org-highlight-latex-and-related '(latex script entities)) +;; (setq org-highlight-latex-and-related '(latex script entities)) (setq warning-minimum-level :emergency) (add-hook 'text-mode-hook 'visual-line-mode) +(and window-system (server-start)) (setq debug-ignored-errors - (cons 'remote-file-error debug-ignored-errors)) + (cons 'remote-file-error debug-ignored-errors)) +(set-face-attribute 'default nil :font "Iosevka Nerd Font" :height 140) +(setq prettify-symbols-alist + '(("#+begin_src" . ?) + ("#+BEGIN_SRC" . ?) + ("#+end_src" . ?) + ("#+END_SRC" . ?) + ("#+begin_example" . ?) + ("#+BEGIN_EXAMPLE" . ?) + ("#+end_example" . ?) + ("#+END_EXAMPLE" . ?) + ("#+header:" . ?) + ("#+HEADER:" . ?) + ("#+name:" . ?﮸) + ("#+NAME:" . ?﮸) + ("#+results:" . ?) + ("#+RESULTS:" . ?) + ("#+call:" . ?) + ("#+CALL:" . ?) + (":PROPERTIES:" . ?) + (":properties:" . ?))) +(prettify-symbols-mode 1) (set-frame-parameter nil 'alpha-background 90) (add-to-list 'default-frame-alist '(alpha-background . 90)) @@ -72,11 +97,26 @@ Otherwise, just insert the typed character." (define-key org-mode-map "[" 'electric-pair) (define-key org-mode-map "{" 'electric-pair))) +(add-hook 'nix-mode-hook + (lambda () + (define-key org-mode-map "\"" 'electric-pair) + (define-key org-mode-map "(" 'electric-pair) + (define-key org-mode-map "[" 'electric-pair) + (define-key org-mode-map "{" 'electric-pair))) + +(add-hook 'emacs-lisp-mode-hook + (lambda () + (define-key org-mode-map "\"" 'electric-pair) + (define-key org-mode-map "(" 'electric-pair) + (define-key org-mode-map "[" 'electric-pair) + (define-key org-mode-map "{" 'electric-pair))) + (add-hook 'after-init-hook 'global-company-mode) (org-babel-do-load-languages 'org-babel-load-languages '( - (shell . t) + (shell . t) + (python . t) ) ) @@ -87,6 +127,7 @@ Otherwise, just insert the typed character." :config (evil-mode 1) (evil-set-undo-system 'undo-redo)) + (use-package evil-collection :init (setq evil-want-keybinding nil) @@ -96,9 +137,11 @@ Otherwise, just insert the typed character." (define-key evil-motion-state-map (kbd "SPC") nil) (define-key evil-motion-state-map (kbd "RET") nil) (define-key evil-motion-state-map (kbd "TAB") nil)) + (use-package evil-commentary :config (evil-commentary-mode)) + (use-package evil-org :after org :hook (org-mode . (lambda () evil-org-mode)) @@ -109,6 +152,7 @@ Otherwise, just insert the typed character." (use-package which-key :config (which-key-mode)) + (use-package page-break-lines :init (page-break-lines-mode)) @@ -192,31 +236,68 @@ Otherwise, just insert the typed character." (use-package magit) +(setq + erc-nick "prestonpan" + erc-user-full-name "Preston Pan") + +(defun prestonpan () + (interactive) + (erc-tls :server "nullring.xyz" + :port "6697")) + +(defun matrix-org () + (interactive) + (ement-connect :uri-prefix "http://localhost:8009")) + +(use-package gptel + :init + (setq gptel-default-mode 'org-mode) + (setq-default + gptel-model "zephyr:latest" + gptel-backend (gptel-make-ollama "Ollama" + :host "localhost:11434" + :stream t + :models '("zephyr:latest")))) + (use-package general :config (general-create-definer leader-key :prefix "SPC") (leader-key 'normal - "o a" 'org-agenda - "c b" 'counsel-bookmark - "o c" 'org-capture - "n j j" 'org-journal-new-entry - "n r f" 'org-roam-node-find - "n r i" 'org-roam-node-insert - "n r g" 'org-roam-graph - "r s s" 'elfeed - "." 'counsel-find-file - "g c /" 'magit-dispatch - "g c c" 'magit-commit - "o t" 'vterm-other-window - "o e" 'eshell - "o m" 'mu4e - "e w" 'eww - "p w" 'ivy-pass - "m P p" 'org-publish - "s e" 'sudo-edit - "m m" 'emms - "f f" 'eglot-format + "o a" '(org-agenda :wk "Open agenda") + "o c" '(org-capture :wk "Capture") + "n j j" '(org-journal-new-entry :wk "Make new journal entry") + "n r f" '(org-roam-node-find :wk "Find roam node") + "n r i" '(org-roam-node-insert :wk "Insert roam node") + "n r g" '(org-roam-graph :wk "Graph roam database") + "r s s" '(elfeed "rss feed") + "." '(counsel-find-file :wk "find file") + "g /" '(magit-dispatch :wk "git commands") + "g P" '(magit-push :wk "git push") + "g c" '(magit-commit :wk "git commit") + "g p" '(magit-pull :wk "Pull from git") + "o t" '(vterm :wk "Terminal") + "o e" '(eshell :wk "Elisp Interpreter") + "o m" '(mu4e :wk "Email") + "e w w" '(eww :wk "web browser") + "e c c" '(ellama-chat :wk "Chat with Ollama") + "e a b" '(ellama-ask-about :wk "Ask Ollama") + "e s" '(ellama-summarize :wk "Summarize text with Ollama") + "e c r" '(ellama-code-review :wk "Review code with Ollama") + "e c C" '(ellama-code-complete :wk "Complete code with Ollama") + "e c a" '(ellama-code-add :wk "Add code with Ollama") + "e c e" '(ellama-code-edit :wk "Edit code with Ollama") + "e w i" '(ellama-improve-wording :wk "Improve wording with Ollama") + "e g i" '(ellama-improve-grammar :wk "Improve grammar with Ollama") + "g s" '(gptel-send :wk "Send to Ollama") + "g e" '(gptel :wk "Ollama interface") + "p w" '(ivy-pass :wk "Password manager interface") + "m P p" '(org-publish :wk "Publish website components") + "s e" '(sudo-edit :wk "Edit file with sudo") + "m m" '(emms :wk "Music player") + "o p" '(treemacs :wk "Project Drawer") + "f f" '(eglot-format :wk "Format code buffer") + "i c" '(prestonpan :wk "Connect to my IRC server") "h m" '(woman :wk "Manual") "h r r" '(lambda () (interactive) (org-babel-load-file (expand-file-name "~/org/website/config/emacs.org"))) )) @@ -265,6 +346,9 @@ Otherwise, just insert the typed character." (setq TeX-PDF-mode t) (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5)) (setq org-return-follows-link t) +(use-package latex-preview-pane + :config + (latex-preview-pane-enable)) ;; SMTP settings: (setq user-mail-address "preston@nullring.xyz") @@ -304,7 +388,7 @@ Otherwise, just insert the typed character." :init (emms-all) (setq emms-source-file-default-directory (expand-file-name "~/music/")) - (setq emms-player-mpd-music-directory "/home/preston/music/") + (setq emms-player-mpd-music-directory (expand-file-name "~/music/")) (setq emms-player-mpd-server-name "localhost") (setq emms-player-mpd-server-port "6600") (setq emms-player-list '(emms-player-mpd)) @@ -315,3 +399,7 @@ Otherwise, just insert the typed character." (use-package stem-mode) (add-to-list 'auto-mode-alist '("\\.stem\\'" . stem-mode)) + +;; (use-package treesit-auto +;; :config +;; (global-treesit-auto-mode)) diff --git a/config/emacs.org b/config/emacs.org index ffd2d3a..7e94c3c 100644 --- a/config/emacs.org +++ b/config/emacs.org @@ -12,6 +12,8 @@ emacs-lisp language only to configure variables for said packages, for the most This section contains important UI elements and starting customization variables to make emacs work in a semi-sane way and make it not look completely ugly: #+begin_src emacs-lisp + (pixel-scroll-precision-mode 1) + (setq scroll-conservatively 101) (display-battery-mode 1) (setq display-time-24hr-format t) (display-time-mode 1) @@ -19,6 +21,7 @@ emacs work in a semi-sane way and make it not look completely ugly: (scroll-bar-mode -1) (tool-bar-mode -1) (load-theme 'catppuccin :no-confirm) + (setq display-line-numbers-type 'relative) (add-hook 'prog-mode-hook #'display-line-numbers-mode) (add-hook 'org-mode-hook #'display-line-numbers-mode) (set-face-attribute 'default nil :height 120) @@ -26,11 +29,33 @@ emacs work in a semi-sane way and make it not look completely ugly: (setq make-backup-files nil) (setq org-export-with-broken-links t) (setq org-src-fontify-natively t) - (setq org-highlight-latex-and-related '(latex script entities)) + ;; (setq org-highlight-latex-and-related '(latex script entities)) (setq warning-minimum-level :emergency) (add-hook 'text-mode-hook 'visual-line-mode) + (and window-system (server-start)) (setq debug-ignored-errors - (cons 'remote-file-error debug-ignored-errors)) + (cons 'remote-file-error debug-ignored-errors)) + (set-face-attribute 'default nil :font "Iosevka Nerd Font" :height 140) + (setq prettify-symbols-alist + '(("#+begin_src" . ?) + ("#+BEGIN_SRC" . ?) + ("#+end_src" . ?) + ("#+END_SRC" . ?) + ("#+begin_example" . ?) + ("#+BEGIN_EXAMPLE" . ?) + ("#+end_example" . ?) + ("#+END_EXAMPLE" . ?) + ("#+header:" . ?) + ("#+HEADER:" . ?) + ("#+name:" . ?﮸) + ("#+NAME:" . ?﮸) + ("#+results:" . ?) + ("#+RESULTS:" . ?) + ("#+call:" . ?) + ("#+CALL:" . ?) + (":PROPERTIES:" . ?) + (":properties:" . ?))) + (prettify-symbols-mode 1) #+end_src * Transparency My NixOS configuration uses Hyprland to make things transparent: @@ -101,6 +126,20 @@ what electric-pair does based on the mode. (define-key org-mode-map "(" 'electric-pair) (define-key org-mode-map "[" 'electric-pair) (define-key org-mode-map "{" 'electric-pair))) + + (add-hook 'nix-mode-hook + (lambda () + (define-key org-mode-map "\"" 'electric-pair) + (define-key org-mode-map "(" 'electric-pair) + (define-key org-mode-map "[" 'electric-pair) + (define-key org-mode-map "{" 'electric-pair))) + + (add-hook 'emacs-lisp-mode-hook + (lambda () + (define-key org-mode-map "\"" 'electric-pair) + (define-key org-mode-map "(" 'electric-pair) + (define-key org-mode-map "[" 'electric-pair) + (define-key org-mode-map "{" 'electric-pair))) #+end_src * Completion Company-mode! We need this to do autocomplete stuff. @@ -110,11 +149,12 @@ Company-mode! We need this to do autocomplete stuff. * Org Babel For some reason, org-babel doesn't load these languages by default: #+begin_src emacs-lisp -(org-babel-do-load-languages 'org-babel-load-languages - '( - (shell . t) - ) -) + (org-babel-do-load-languages 'org-babel-load-languages + '( + (shell . t) + (python . t) + ) + ) #+end_src * Packages First, some small configurations and some evil-mode initilaization because I like vim keybindings: @@ -126,6 +166,7 @@ First, some small configurations and some evil-mode initilaization because I lik :config (evil-mode 1) (evil-set-undo-system 'undo-redo)) + (use-package evil-collection :init (setq evil-want-keybinding nil) @@ -135,9 +176,11 @@ First, some small configurations and some evil-mode initilaization because I lik (define-key evil-motion-state-map (kbd "SPC") nil) (define-key evil-motion-state-map (kbd "RET") nil) (define-key evil-motion-state-map (kbd "TAB") nil)) + (use-package evil-commentary :config (evil-commentary-mode)) + (use-package evil-org :after org :hook (org-mode . (lambda () evil-org-mode)) @@ -148,6 +191,7 @@ First, some small configurations and some evil-mode initilaization because I lik (use-package which-key :config (which-key-mode)) + (use-package page-break-lines :init (page-break-lines-mode)) @@ -254,36 +298,79 @@ Ivy is a pretty cool general program for displaying stuff: #+begin_src emacs-lisp (use-package magit) #+end_src +** IRC +#+begin_src emacs-lisp + (setq + erc-nick "prestonpan" + erc-user-full-name "Preston Pan") + + (defun prestonpan () + (interactive) + (erc-tls :server "nullring.xyz" + :port "6697")) +#+end_src +** Matrix +#+begin_src emacs-lisp + (defun matrix-org () + (interactive) + (ement-connect :uri-prefix "http://localhost:8009")) +#+end_src +** LLMs +#+begin_src emacs-lisp + (use-package gptel + :init + (setq gptel-default-mode 'org-mode) + (setq-default + gptel-model "zephyr:latest" + gptel-backend (gptel-make-ollama "Ollama" + :host "localhost:11434" + :stream t + :models '("zephyr:latest")))) +#+end_src ** Keybindings #+begin_src emacs-lisp - (use-package general - :config - (general-create-definer leader-key - :prefix "SPC") - (leader-key 'normal - "o a" 'org-agenda - "c b" 'counsel-bookmark - "o c" 'org-capture - "n j j" 'org-journal-new-entry - "n r f" 'org-roam-node-find - "n r i" 'org-roam-node-insert - "n r g" 'org-roam-graph - "r s s" 'elfeed - "." 'counsel-find-file - "g c /" 'magit-dispatch - "g c c" 'magit-commit - "o t" 'vterm-other-window - "o e" 'eshell - "o m" 'mu4e - "e w" 'eww - "p w" 'ivy-pass - "m P p" 'org-publish - "s e" 'sudo-edit - "m m" 'emms - "f f" 'eglot-format - "h m" '(woman :wk "Manual") - "h r r" '(lambda () (interactive) (org-babel-load-file (expand-file-name "~/org/website/config/emacs.org"))) - )) + (use-package general + :config + (general-create-definer leader-key + :prefix "SPC") + (leader-key 'normal + "o a" '(org-agenda :wk "Open agenda") + "o c" '(org-capture :wk "Capture") + "n j j" '(org-journal-new-entry :wk "Make new journal entry") + "n r f" '(org-roam-node-find :wk "Find roam node") + "n r i" '(org-roam-node-insert :wk "Insert roam node") + "n r g" '(org-roam-graph :wk "Graph roam database") + "r s s" '(elfeed "rss feed") + "." '(counsel-find-file :wk "find file") + "g /" '(magit-dispatch :wk "git commands") + "g P" '(magit-push :wk "git push") + "g c" '(magit-commit :wk "git commit") + "g p" '(magit-pull :wk "Pull from git") + "o t" '(vterm :wk "Terminal") + "o e" '(eshell :wk "Elisp Interpreter") + "o m" '(mu4e :wk "Email") + "e w w" '(eww :wk "web browser") + "e c c" '(ellama-chat :wk "Chat with Ollama") + "e a b" '(ellama-ask-about :wk "Ask Ollama") + "e s" '(ellama-summarize :wk "Summarize text with Ollama") + "e c r" '(ellama-code-review :wk "Review code with Ollama") + "e c C" '(ellama-code-complete :wk "Complete code with Ollama") + "e c a" '(ellama-code-add :wk "Add code with Ollama") + "e c e" '(ellama-code-edit :wk "Edit code with Ollama") + "e w i" '(ellama-improve-wording :wk "Improve wording with Ollama") + "e g i" '(ellama-improve-grammar :wk "Improve grammar with Ollama") + "g s" '(gptel-send :wk "Send to Ollama") + "g e" '(gptel :wk "Ollama interface") + "p w" '(ivy-pass :wk "Password manager interface") + "m P p" '(org-publish :wk "Publish website components") + "s e" '(sudo-edit :wk "Edit file with sudo") + "m m" '(emms :wk "Music player") + "o p" '(treemacs :wk "Project Drawer") + "f f" '(eglot-format :wk "Format code buffer") + "i c" '(prestonpan :wk "Connect to my IRC server") + "h m" '(woman :wk "Manual") + "h r r" '(lambda () (interactive) (org-babel-load-file (expand-file-name "~/org/website/config/emacs.org"))) + )) #+end_src ** RSS Feed I use really simple syndication (RSS) in order to read news. As a result, I use @@ -340,47 +427,50 @@ Set up pinentry so that I can use emacs as my pinentry frontend: :init (setq epa-pinentry-mode `loopback) :config (pinentry-start)) #+end_src -** Auctex +** LaTeX Make LaTeX a litle better: #+begin_src emacs-lisp (setq TeX-PDF-mode t) (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5)) (setq org-return-follows-link t) + (use-package latex-preview-pane + :config + (latex-preview-pane-enable)) #+end_src ** Email Email in emacs can be done with Mu4e. #+begin_src emacs-lisp - ;; SMTP settings: - (setq user-mail-address "preston@nullring.xyz") - (setq user-full-name "Preston Pan") - (setq sendmail-program "msmtp" - send-mail-function 'smtpmail-send-it - message-sendmail-f-is-evil t - message-sendmail-extra-arguments '("--read-envelope-from") - message-send-mail-function 'message-send-mail-with-sendmail) + ;; SMTP settings: + (setq user-mail-address "preston@nullring.xyz") + (setq user-full-name "Preston Pan") + (setq sendmail-program "msmtp" + send-mail-function 'smtpmail-send-it + message-sendmail-f-is-evil t + message-sendmail-extra-arguments '("--read-envelope-from") + message-send-mail-function 'message-send-mail-with-sendmail) - (require 'smtpmail) - (use-package mu4e - :init - (setq mu4e-drafts-folder "/Drafts") - (setq mu4e-sent-folder "/Sent") - (setq mu4e-trash-folder "/Trash") - (setq mu4e-attachment-dir "~/Downloads") - (setq mu4e-view-show-addresses 't) - (setq mu4e-confirm-quit nil) + (require 'smtpmail) + (use-package mu4e + :init + (setq mu4e-drafts-folder "/Drafts") + (setq mu4e-sent-folder "/Sent") + (setq mu4e-trash-folder "/Trash") + (setq mu4e-attachment-dir "~/Downloads") + (setq mu4e-view-show-addresses 't) + (setq mu4e-confirm-quit nil) - (setq message-kill-buffer-on-exit t) - (setq mu4e-compose-dont-reply-to-self t) - (setq mu4e-change-filenames-when-moving t) - (setq mu4e-get-mail-command "mbsync prestonpan") - (setq mu4e-compose-reply-ignore-address '("no-?reply" "preston@nullring.xyz")) - (setq mu4e-html2text-command "w3m -T text/html" ; how to hanfle html-formatted emails - mu4e-update-interval 300 ; seconds between each mail retrieval - mu4e-headers-auto-update t ; avoid to type `g' to update - mu4e-view-show-images t ; show images in the view buffer - mu4e-compose-signature-auto-include nil ; I don't want a message signature - mu4e-use-fancy-chars t)) + (setq message-kill-buffer-on-exit t) + (setq mu4e-compose-dont-reply-to-self t) + (setq mu4e-change-filenames-when-moving t) + (setq mu4e-get-mail-command "mbsync prestonpan") + (setq mu4e-compose-reply-ignore-address '("no-?reply" "preston@nullring.xyz")) + (setq mu4e-html2text-command "w3m -T text/html" ; how to hanfle html-formatted emails + mu4e-update-interval 300 ; seconds between each mail retrieval + mu4e-headers-auto-update t ; avoid to type `g' to update + mu4e-view-show-images t ; show images in the view buffer + mu4e-compose-signature-auto-include nil ; I don't want a message signature + mu4e-use-fancy-chars t)) #+end_src ** Password Manager I use ~pass~ in order to manage my passwords on linux, and this is an ivy frontend for it: @@ -394,7 +484,7 @@ Set up emms in order to play music from my music directory: :init (emms-all) (setq emms-source-file-default-directory (expand-file-name "~/music/")) - (setq emms-player-mpd-music-directory "/home/preston/music/") + (setq emms-player-mpd-music-directory (expand-file-name "~/music/")) (setq emms-player-mpd-server-name "localhost") (setq emms-player-mpd-server-port "6600") (setq emms-player-list '(emms-player-mpd)) @@ -409,3 +499,9 @@ My own programming language. (use-package stem-mode) (add-to-list 'auto-mode-alist '("\\.stem\\'" . stem-mode)) #+end_src +** Syntax +#+begin_src emacs-lisp + ;; (use-package treesit-auto + ;; :config + ;; (global-treesit-auto-mode)) +#+end_src diff --git a/config/nix.org b/config/nix.org index 5c481fb..1ff0e0a 100644 --- a/config/nix.org +++ b/config/nix.org @@ -70,6 +70,8 @@ #media-session.enable = true; }; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + # Enable touchpad support (enabled default in most desktopManager). # services.xserver.libinput.enable = true; home-manager.users.preston = { @@ -85,7 +87,6 @@ pkgs.wget pkgs.neofetch pkgs.cowsay - pkgs.starship pkgs.kitty pkgs.ffmpeg pkgs.hyprland @@ -123,6 +124,7 @@ pkgs.yt-dlp pkgs.mpv pkgs.python3 + pkgs.ungoogled-chromium (pkgs.nerdfonts.override { fonts = [ "Iosevka" ]; }) (pkgs.discord.override { withOpenASAR = true; @@ -130,7 +132,7 @@ }) pkgs.vesktop ]; - + allowUnfree = true; fonts.fontconfig.enable = true; xsession.enable = true; home.stateVersion = "23.11"; @@ -158,7 +160,6 @@ } ''; }; - programs.wofi = { enable = true; settings = { @@ -1022,7 +1023,7 @@ epkgs.ement epkgs.rustic epkgs.chatgpt-shell - + epkgs.znc ]; }; -- cgit