nixos/config/emacs/emacs.org

1535 lines
51 KiB
Org Mode
Raw Normal View History

2023-12-29 16:01:20 +04:00
#+title: Sako's Emacs configuration
2023-12-26 14:53:46 +04:00
#+PROPERTY: header-args:emacs-lisp :tangle yes :tangle init.el
2023-09-23 16:21:42 +04:00
* Usage
M-x org-bable-tangle
2023-11-12 00:03:13 +04:00
* Lexical Binding
Should make startup faster, taken from doom-emacs
#+begin_src emacs-lisp
;; -*- lexical-binding: t; -*-
#+end_src
2023-10-02 18:34:45 +04:00
* Default Enconding
#+begin_src emacs-lisp
(setq utf-translate-cjk-mode nil) ; disable CJK coding/encoding (Chinese/Japanese/Korean characters)
(set-language-environment 'utf-8)
(set-keyboard-coding-system 'utf-8) ; For old Carbon emacs on OS X only
(setq locale-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-selection-coding-system
(if (eq system-type 'windows-nt)
'utf-16-le ;; https://rufflewind.com/2014-07-20/pasting-unicode-in-emacs-on-windows
'utf-8))
(prefer-coding-system 'utf-8)
#+end_src
2023-11-01 20:53:52 +04:00
* Put Backup Files Somewhere else
#+begin_src emacs-lisp
(setq backup-directory-alist '(("." . "~/.emacs.d/backup"))
backup-by-copying t
version-control t
delete-old-versions t
kept-new-versions 20
kept-old-versions 5)
#+end_src
2023-10-04 12:06:49 +04:00
* EmacsClient UI
#+begin_src emacs-lisp
(setq frame-resize-pixelwise t)
;; ui settings apparently go below
2023-12-14 23:53:03 +04:00
(setq default-frame-alist '((font . "JetBrainsMono NF")
2023-10-04 12:06:49 +04:00
'(vertical-scroll-bars . nil)
'(horizontal-scroll-bars . nil)))
#+end_src
2023-10-04 11:32:24 +04:00
* UI
2023-09-23 16:21:42 +04:00
#+begin_src emacs-lisp
2023-11-25 17:51:31 +04:00
;; UI/UX
(setq inhibit-splash-screen t)
;; remove useless GUI elements
(scroll-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(set-fringe-mode 10)
(menu-bar-mode -1)
;; Line Numbers
(column-number-mode)
;; Bell
2023-12-24 14:43:11 +04:00
(setq visible-bell nil)
2023-11-25 17:51:31 +04:00
;; prefer y/n
(fset 'yes-or-no-p 'y-or-n-p)
2023-12-28 23:57:47 +04:00
;; delet eseciotn
(delete-selection-mode +1)
2023-11-25 17:51:31 +04:00
;; Stop Emacs from trying to use dialog boxes.
(setq use-dialog-box nil)
2023-11-25 22:34:02 +04:00
;; idc emacs just work already
(setq warning-minimum-level :emergency)
2023-09-23 16:21:42 +04:00
#+end_src
2023-11-12 10:18:37 +04:00
* Line Numbers
#+begin_src emacs-lisp
(add-hook 'prog-mode 'display-line-numbers-mode)
(add-hook 'yaml-mode 'display-line-numbers-mode)
(add-hook 'conf-mode 'display-line-numbers-mode)
(setq display-line-numbers-width-start t)
2023-12-15 01:06:30 +04:00
(setq display-line-numbers-type 'relative)
2023-11-12 10:18:37 +04:00
#+end_src
2023-09-23 16:21:42 +04:00
* Keymaps
#+begin_src emacs-lisp
2023-10-18 20:04:35 +04:00
;; switch buffers
(global-set-key (kbd "C-M-j") 'counsel-switch-buffer)
;; instead of control-g
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; repeat keybinds
(repeat-mode)
2023-12-15 01:06:30 +04:00
;; electric pairs
(electric-pair-mode)
2023-09-23 16:21:42 +04:00
#+end_src
* Fonts
#+begin_src emacs-lisp
2024-02-12 22:03:24 +04:00
(set-face-attribute `default nil :font "JetBrainsMono NF" :height 125)
2023-11-12 00:03:13 +04:00
#+end_src
* Use-Package setup
2023-11-01 20:53:52 +04:00
#+begin_src emacs-lisp
2023-11-25 17:51:31 +04:00
(message "setting up use-package")
(require `package)
2023-11-01 20:53:52 +04:00
2023-11-25 17:51:31 +04:00
(setq package-archives `(("mepla" . "https://melpa.org/packages/")
2023-12-26 18:40:08 +04:00
("org" . "https://orgmode.org/elpa/")
("elpa" . "https://elpa.gnu.org/packages/")))
2023-11-01 20:53:52 +04:00
2023-12-29 00:04:35 +04:00
(package-initialize)
2023-11-01 20:53:52 +04:00
2023-12-29 00:04:35 +04:00
(unless (package-installed-p 'use-package)
(progn
(package-refresh-contents)
(package-install 'use-package)))
2023-12-26 18:40:08 +04:00
2023-11-25 17:51:31 +04:00
(require 'use-package)
(setq use-package-always-ensure t)
2023-11-01 20:53:52 +04:00
#+end_src
* Straight.el
We only enable Straight.el for anything other than NixOS
Cause emacs overlay lol
#+begin_src emacs-lisp
;; TODO Test this one darwin someday
(when (eq system-type 'windows-nt)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(use-package straight
:custom
(straight-use-package-by-default t))
)
#+end_src
2023-11-12 00:27:15 +04:00
* SPEED SPEED SPEED SPEED
** Avoid Garbage Collection at startup
#+begin_src emacs-lisp
(use-package gcmh
:init
2023-11-25 17:51:31 +04:00
(setq gcmh-idle-delay 5)
(setq gcmh-high-cons-threshold (* 16 1024 1024))
:config
(gcmh-mode))
2023-11-12 00:27:15 +04:00
#+end_src
** Move Garbage collection further back
#+begin_src emacs-lisp
(setq gc-cons-threshold most-positive-fixnum)
#+end_src
** Unset file-name-handler-alist temporarily
#+begin_src emacs-lisp
(defvar sakomacs--file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
;; Alternatively, restore it even later:
(add-hook 'emacs-startup-hook
(lambda ()
(setq file-name-handler-alist sakomacs--file-name-handler-alist)))
#+end_src
2023-11-25 17:51:31 +04:00
** Go back to normal GC after init
#+begin_src emacs-lisp
2023-12-06 18:31:05 +04:00
(add-hook 'emacs-startup-hook
(lambda ()
;;(setq gc-cons-threshold 16777216 ; 16mb
2024-02-04 12:57:26 +04:00
;; this could be really bad idk
(setq gc-cons-threshold 100000000
2024-02-04 13:04:51 +04:00
gc-cons-percentage 0.1)))
2023-11-25 17:51:31 +04:00
#+end_src
** Don't use GC when minibuffer is used
#+begin_src emacs-lisp
(defun doom-defer-garbage-collection-h ()
"Disable garbage collection."
(setq gc-cons-threshold most-positive-fixnum))
(defun doom-restore-garbage-collection-h ()
"Restore garbage collection."
(run-at-time
1 nil (lambda () (setq gc-cons-threshold 16777216))))
2023-11-12 00:27:15 +04:00
2023-11-25 17:51:31 +04:00
(add-hook 'minibuffer-setup-hook #'doom-defer-garbage-collection-h)
(add-hook 'minibuffer-exit-hook #'doom-restore-garbage-collection-h)
#+end_src
2023-12-06 18:31:05 +04:00
** Make Emacs read more
#+begin_src emacs-lisp
(setq read-process-output-max (* 1024 1024)) ;; 1mb
#+end_src
2023-11-25 22:34:02 +04:00
* Native Compilation
#+begin_src emacs-lisp
(setq package-native-compile t)
(setq comp-deferred-compilation t)
(setq native-comp-deferred-compilation-deny-list nil)
(setq warning-suppress-log-types '((comp)))
#+end_src
2023-12-14 23:53:03 +04:00
* Custom Modeline
#+begin_src emacs-lisp
2024-02-29 20:58:48 +04:00
;;ill continue making this later
2024-03-03 12:24:47 +04:00
;; (setq mode-line-format nil)
;; (kill-local-variable 'mode-line-format)
;; (force-mode-line-update)
;; (setq-default mode-line-format
;; '((:eval (sakoline-render
;; ;; left
;; (quote ("%e"
;; sakoline-evil-mode
;; " "
;; sakoline-buffer-name
;; " "
;; sakoline-buffer-state))
;; ;; right
;; (quote (sakoline-major-mode
;; )
;; )))))
;; (defun sakoline-render (left right)
;; "Return a string of `window-width' length.
;; Containing LEFT, and RIGHT aligned respectively."
;; (let ((available-width
;; (- (window-total-width)
;; (+ (length (format-mode-line left))
;; (length (format-mode-line right))))))
;; (append left
;; (list (format (format "%%%ds" available-width) ""))
;; right)))
;; (defvar-local sakoline-buffer-name
;; '(:eval
;; (propertize (buffer-name) 'face '(:foreground "#ffffff")))
;; "Mode line variable that shows the buffer name.")
;; (put 'sakoline-buffer-name 'risky-local-variable t)
;; (defface sakoline-major-mode-color
;; '((t :foreground "grey"))
;; "Major Mode color for sakoline.")
;; (defun sakoline--major-mode-name ()
;; "Return Capitalized Major Mode"
;; (capitalize (symbol-name major-mode)))
;; (defvar-local sakoline-major-mode
;; '(:eval
;; (propertize (sakoline--major-mode-name) 'face 'sakoline-major-mode-color)))
;; (put 'sakoline-major-mode 'risky-local-variable t)
;; (defface sakoline-evil-visual-color
;; '((t :background "#6600cc" :foreground "black"))
;; "Evil Visual Color")
;; (defface sakoline-evil-normal-color
;; '((t :background "#99ff99" :foreground "black"))
;; "Evil Visual Color")
;; (defface sakoline-evil-insert-color
;; '((t :background "#00cc66" :foreground "black"))
;; "Evil Visual Color")
;; (defface sakoline-evil-emacs-color
;; '((t :background "#9900ff" :foreground "black"))
;; "Evil Visual Color")
;; (defface sakoline-evil-operator-color
;; '((t :background "#ff3300" :foreground "black"))
;; "Evil Visual Color")
;; (defvar-local sakoline-evil-mode
;; '(:eval (cond
;; ((eq evil-state 'visual) (propertize " VISUAL " 'face 'sakoline-evil-visual-color ))
;; ((eq evil-state 'normal) (propertize " NORMAL " 'face 'sakoline-evil-normal-color ))
;; ((eq evil-state 'insert) (propertize " INSERT " 'face 'sakoline-evil-insert-color ))
;; ((eq evil-state 'emacs) (propertize " EMACS " 'face 'sakoline-evil-emacs-color ))
;; ((eq evil-state 'operator) (propertize " OPERATOR " 'face 'sakoline-evil-operator-color))
;; "Get current evil mode state")))
;; (put 'sakoline-evil-mode 'risky-local-variable t)
;; (defface sakoline-buffer-state-readonly
;; '((t :foreground "red"))
;; "Face for read-only buffer")
;; (defface sakoline-buffer-state-modified
;; '((t :foreground "orange"))
;; "Face for modified buffer")
;; (defvar-local sakoline-buffer-state
;; '(:eval
;; (cond
;; (buffer-read-only
;; (propertize ">:("
;; 'face 'sakoline-buffer-state-readonly
;; 'help-echo "buffer is read only"))
;; ((buffer-modified-p)
;; (propertize "!!!"
;; 'face 'sakoline-buffer-state-modified)))))
;; (put 'sakoline-buffer-state 'risky-local-variable t)
2023-12-17 15:55:01 +04:00
2023-12-14 23:53:03 +04:00
#+end_src
2023-11-01 20:53:52 +04:00
* Packages
2023-11-25 17:51:31 +04:00
** Log state
#+begin_src emacs-lisp
(message "setting up packages")
#+end_src
2023-11-01 20:53:52 +04:00
** Command Log Mode
#+begin_src emacs-lisp
(use-package command-log-mode
)
2023-11-01 20:53:52 +04:00
#+end_src
** Command Autocompletion Packages
#+begin_src emacs-lisp
2024-02-08 09:41:34 +04:00
;; better search
(use-package swiper
)
2024-02-08 09:41:34 +04:00
;; better commands
(use-package counsel
2024-02-08 09:47:35 +04:00
:custom
2024-02-08 09:41:34 +04:00
(counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
)
;; autocompletion on commands (?)
(use-package ivy
:diminish
:bind (("C-s" . swiper)
:map ivy-minibuffer-map
("TAB" . ivy-alt-done)
("C-l" . ivy-alt-done)
("C-j" . ivy-next-line)
("C-k" . ivy-previous-line)
:map ivy-switch-buffer-map
("C-k" . ivy-previous-line)
("C-l" . ivy-done)
("C-d" . ivy-switch-buffer-kill)
:map ivy-reverse-i-search-map
("C-k" . ivy-previous-line)
("C-d" . ivy-reverse-i-search-kill))
:demand
:config
(ivy-mode 1))
;; better ivy autocompletion
(use-package ivy-rich
:init
(ivy-rich-mode 1))
2023-11-12 00:03:13 +04:00
2024-02-08 09:41:34 +04:00
;; ivy in the middle
(use-package ivy-posframe
:init
(setq ivy-posframe-display-functions-alist '((t . ivy-posframe-display-at-frame-center)))
:config
(ivy-posframe-mode 1))
;; counsel M+X
(use-package counsel
:bind (("M-x" . counsel-M-x)
("C-x b" . counsel-ibuffer)
("C-x C-f" . counsel-find-file)
:map minibuffer-local-map
("C-r" . 'counsel-minibuffer-history))
:config
(setq ivy-inital-inputs-alist nil))
2023-11-01 20:53:52 +04:00
#+end_src
** Custom Themes
#+begin_src emacs-lisp
2024-01-12 15:07:18 +04:00
(use-package doom-themes
:ensure t
: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 the theme
2024-04-02 02:20:08 +04:00
(load-theme 'doom-badger t)
2023-12-23 00:00:18 +04:00
2024-01-12 15:07:18 +04:00
(doom-themes-org-config)
2023-12-23 00:00:18 +04:00
2024-01-12 15:07:18 +04:00
(doom-themes-treemacs-config)
2023-12-23 00:00:18 +04:00
2024-01-12 15:07:18 +04:00
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config))
2023-12-23 00:00:18 +04:00
2023-11-16 18:50:54 +04:00
#+end_src
** All the Icons (to make doom-themes happy)
#+begin_src emacs-lisp
(use-package all-the-icons)
2023-11-01 20:53:52 +04:00
#+end_src
** Nerd-Fonts (All of the Icons doesnt work for me)
#+begin_src emacs-lisp
(use-package nerd-icons
:custom
;; "Symbols Nerd Font Mono" is the default and is recommended
;; but you can use any other Nerd Font if you want
(nerd-icons-font-family "JetBrainsMono NF")
)
#+end_src
** Rainbow Delimiters
#+begin_src emacs-lisp
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
#+end_src
** Keybinding autocompletion
#+begin_src emacs-lisp
2023-11-12 00:03:13 +04:00
(use-package which-key
:init (which-key-mode)
:diminish which-key-mode
:config
(setq which-key-idle-delay 1))
2023-11-01 20:53:52 +04:00
#+end_src
** Custom Modeline
#+begin_src emacs-lisp
2024-04-02 02:20:08 +04:00
;; (use-package doom-modeline
;; :ensure t
;; ;; :hook (after-init . doom-modeline-mode)
;; :init (doom-modeline-mode 1)
;; :custom (
;; (doom-modeline-height 35)
;; (doom-modeline-bar-width 4)
;; (doom-modeline-major-mode-icon nil)
;; (doom-modeline-modal-modern-icon nil)
;; ))
(use-package telephone-line
:init
(telephone-line-mode 1))
2023-11-12 10:18:37 +04:00
#+end_src
** Hide Modeline
#+begin_src emacs-lisp
2023-11-26 14:14:26 +04:00
(use-package hide-mode-line
:hook (((treemacs-mode
eshell-mode shell-mode
term-mode vterm-mode
embark-collect-mode
lsp-ui-imenu-mode
pdf-annot-list-mode
dashboard-mode) . turn-on-hide-mode-line-mode)
(dired-mode . turn-off-hide-mode-line-mode)))
2023-11-12 10:18:37 +04:00
#+end_src
** Minor mode menu for modline
#+begin_src emacs-lisp
(use-package minions
:hook (doom-modeline-mode . minions-mode))
2023-11-01 20:53:52 +04:00
#+end_src
** Better help menu
#+begin_src emacs-lisp
(use-package helpful
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable)
:bind
([remap describe-function ] . counsel-describe-function)
([remap describe-command] . helpful-command)
([remap describe-variable] . counsel-describe-variable)
([remap describe-key] . helpful-key))
#+end_src
** General Leader Key
#+begin_src emacs-lisp
2023-12-25 22:34:57 +04:00
(use-package general
:config
(general-create-definer sakomacs/leader-keys
2023-12-25 22:36:41 +04:00
:keymaps '(normal insert visual emacs)
2023-12-25 22:34:57 +04:00
:prefix "SPC"
:global-prefix "C-SPC")
2023-12-25 23:16:56 +04:00
2023-12-25 22:34:57 +04:00
(sakomacs/leader-keys
;; code
2023-12-25 22:36:41 +04:00
"c" '(:ignore c :which-key "code")
"cc" '(compile :which-key "compile")
"cC" '(recompile :which-key "compile")
"cX" '(lsp-treeemacs-errors-list :which-ley "list errors")
2023-12-25 22:34:57 +04:00
;; toggles
2023-12-25 22:36:41 +04:00
"t" '(:ignore t :which-key "toggles")
"tt" '(counsel-load-theme :which-key "choose theme")
"ts" '(hydra-text-scale/body :which-key "scale text")
2023-12-25 22:34:57 +04:00
;; search
2023-12-25 22:36:41 +04:00
"s" '(:ignore s :which-key "search")
"sb" '(swiper :which-key "search buffer")
2023-12-25 22:34:57 +04:00
;; insert
2023-12-25 22:36:41 +04:00
"i" '(:ignore i :which-key "insert")
"ie" '(emoji-search :which-key "Emoji")
2023-12-25 22:34:57 +04:00
;; project
2023-12-25 22:36:41 +04:00
"p" '(:ignore p :which-key "projects")
"pp" '(projectile-switch-project :which-key "open project")
"pk" '(projectile-kill-buffers :which-key "close project")
"pa" '(projectile-add-known-project :which-key "add project")
"pR" '(projectile-run-project :which-key "run project")
"pt" '(magit-todos-list :which-key "list project todos")
"ps" '(projectile-save-project-buffers :which-key "save project")
"po" '(projectile-find-other-file :which-key "find other file")
"pg" '(projectile-configure-project :which-key "configure project")
"pc" '(projectile-compile-project :which-key "compile project")
2023-12-25 22:34:57 +04:00
;; open
2023-12-25 22:36:41 +04:00
"o" '(:ignore o :which-key "open")
"op" '(treemacs :which-key "treemacs")
"oP" '(treemacs-find-file :which-key "treemacs find file")
"oe" '(eshell :which-key "eshell")
"or" '(elfeed :which-key "rss")
2023-12-25 22:34:57 +04:00
;; notes
2023-12-25 22:36:41 +04:00
"n" '(:ignore o :which-key "notes")
"na" '(org-agenda :which-key "agenda")
2023-12-26 18:59:56 +04:00
"nf" '(org-roam-node-find :which-key "find node")
2024-01-12 15:57:35 +04:00
"nc" '(org-capture :which-key "capture")
2024-01-19 18:51:09 +04:00
"np" '(org-pomodoro :which-key "pomodoro")
2024-01-16 20:31:09 +04:00
"ne" '(:ignore ne :which-key "export")
"nep" '(org-latex-export-to-pdf :which-key "pdf")
2023-12-25 22:34:57 +04:00
;; quit
2023-12-25 22:36:41 +04:00
"q" '(:ignore q :which-key "quit")
"qq" '(delete-frame :which-key "close emacs")
"qK" '(kill-emacs :which-key "quit emacs")
2023-12-25 22:34:57 +04:00
;; git
2023-12-25 22:36:41 +04:00
"g" '(:ignore g :which-key "git")
"gs" '(magit-status :which-key "status")
"gc" '(:ignore gc :which-key "create")
"gcr" '(magit-init :which-key "init repo")
"gcR" '(magit-clone :which-key "clone repo")
"gcc" '(magit-commit-create :which-key "commit")
"gci" '(forge-create-issue :which-key "issue")
"gcp" '(forge-create-pullreq :which-key "pull request")))
2023-12-25 22:34:57 +04:00
2023-11-01 20:53:52 +04:00
#+end_src
2023-11-26 13:14:09 +04:00
** Dashboard
2023-11-01 20:53:52 +04:00
#+begin_src emacs-lisp
2024-02-09 08:36:06 +04:00
(use-package dashboard
:init
(setq dashboard-display-icons-p t) ;; display icons on both GUI and terminal
(setq dashboard-icon-type 'nerd-icons) ;; use `nerd-icons' package
(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")))
(setq dashboard-center-content t)
(setq dashboard-projects-backend 'projectile)
(setq dashboard-startup-banner "~/.emacs.d/dashboard.png")
(setq dashboard-footer-messages '("i think i have emacs pinky"
"why are we still using lisp again?"
"why is this running on 1/16 threads?!?!?"
"still waiting for multithreaded :)"
"any day now"
"make sure to pray today"
"im literally kanye west"
"please dont break please dont break"
"GNU/Linux/Emacs/???"
"what is a GNU/Linux ?????????????"
"done!"
"remove / for faster emacs on linux"
""))
(setq dashboard-items '((recents . 3)
(projects . 3)
(agenda . 5)))
(setq dashboard-image-banner-max-height 200)
2024-04-02 02:20:08 +04:00
;; (setq dashboard-image-banner-max-width 300)
2024-02-09 08:36:06 +04:00
(setq dashboard-page-separator "\n\n")
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
(dashboard-setup-startup-hook))
2023-11-01 20:53:52 +04:00
#+end_src
** Evil Mode (vim)
#+begin_src emacs-lisp
2023-11-12 00:03:13 +04:00
(use-package evil
:init
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
(setq evil-want-C-i-jump nil)
:demand
:config
(evil-mode 1)
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
(define-key evil-insert-state-map (kbd "C-h") `evil-delete-backward-char-and-join)
2023-11-01 20:53:52 +04:00
2023-11-12 00:03:13 +04:00
;; visual line motion
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
2023-11-01 20:53:52 +04:00
2023-11-12 00:03:13 +04:00
(evil-set-initial-state 'messages-buffer-mode 'normal)
(evil-set-initial-state 'dashboard-mode 'normal))
2023-11-01 20:53:52 +04:00
2023-11-12 00:03:13 +04:00
;; extra things for Evil
(use-package evil-collection
:after evil
:config
(evil-collection-init))
2023-11-12 10:18:37 +04:00
;; commenting
(use-package evil-commentary
:after evil
:diminish
:config (evil-commentary-mode +1))
2023-11-01 20:53:52 +04:00
#+end_src
** Hydra for scaling text
#+begin_src emacs-lisp
2023-12-25 21:23:25 +04:00
(use-package hydra)
2023-11-12 00:03:13 +04:00
(defhydra hydra-text-scale (:timeout 4)
"scale text"
("j" text-scale-increase "in")
("k" text-scale-decrease "out")
("f" nil "finished" :exit t))
2023-11-01 20:53:52 +04:00
#+end_src
** Helpful for projects
#+begin_src emacs-lisp
2023-11-12 00:03:13 +04:00
(use-package projectile
:diminish projectile-mode
:demand
:config (projectile-mode)
:custom ((projectile-completion-system 'ivy))
:bind-keymap
("C-c p" . projectile-command-map)
:init
(when (file-directory-p "~/dev")
(setq projectile-project-search-path '("~/dev")))
(setq projectile-switch-project-action #'projectile-dired))
(use-package counsel-projectile
:config (counsel-projectile-mode))
2023-11-01 20:53:52 +04:00
#+end_src
** Org-Mode
#+begin_src emacs-lisp
(use-package org
2023-11-26 17:23:22 +04:00
:hook (org-mode . org-indent-mode)
2023-11-01 20:53:52 +04:00
:config
2023-12-17 13:36:18 +04:00
(setq org-ellipsis " ↓")
2023-11-01 20:53:52 +04:00
(setq org-agenda-start-with-log-mode t)
(setq org-log-done 'time)
(setq org-log-into-drawer t)
;; org habits thing
(require 'org-habit)
(add-to-list 'org-modules 'org-habit)
(setq org-habit-graph-column 60)
;; archive thingy i forgot
2023-11-26 13:14:09 +04:00
(setq org-refile-targets
2024-01-09 21:19:56 +04:00
'(("archive.org" :maxlevel . 1)))
2023-11-01 20:53:52 +04:00
;; save org buffer before refile
(advice-add 'org-refile :after 'org-save-all-org-buffers)
;; org agenda files
2023-11-26 13:14:09 +04:00
(setq org-agenda-files
'("~/org/tasks.org"
"~/org/school.org"
"~/org/daily.org"
"~/org/irl.org"
"~/org/work.org"))
2023-11-01 20:53:52 +04:00
2023-11-26 13:14:09 +04:00
;; Following
(setq org-return-follows-link t)
2023-11-01 20:53:52 +04:00
2024-01-09 21:19:56 +04:00
;; hide stars except for leader star
2023-12-15 21:25:31 +04:00
(setq org-hide-leading-stars t)
(setq org-hide-emphasis-markers nil)
2023-12-14 20:41:03 +04:00
2023-11-01 20:53:52 +04:00
;; org mode src thing
(require 'org-tempo)
(add-to-list 'org-structure-template-alist '("sh" . "src shell"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
2023-11-26 13:14:09 +04:00
(setq org-todo-keywords
2024-01-09 21:19:56 +04:00
'((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
(sequence "BACKLOG(b)" "PLAN(p)" "READY(r)" "ACTIVE(a)" "REVIEW(v)" "WAIT(w@/!)" "HOLD(h)" "|" "COMPLETED(c)" "CANCELED(k@)")))
2023-11-26 13:14:09 +04:00
(setq org-refile-targets
2024-01-09 21:19:56 +04:00
'(("archive.org" :maxlevel . 1)
("tasks.org" :maxlevel . 1)))
2023-11-26 13:14:09 +04:00
;; Save Org buffers after refiling!
(advice-add 'org-refile :after 'org-save-all-org-buffers)
2024-01-20 12:01:08 +04:00
(setq org-startup-with-inline-images t)
2023-11-26 13:14:09 +04:00
(setq org-tag-alist
2024-01-09 21:19:56 +04:00
'((:startgroup)
; Put mutually exclusive tags here
(:endgroup)
("@errand" . ?E)
("@home" . ?H)
("@work" . ?W)
("agenda" . ?a)
("planning" . ?p)
("publish" . ?P)
("batch" . ?b)
("note" . ?n)
("idea" . ?i)))
2023-11-26 13:14:09 +04:00
;; Configure custom agenda views
(setq org-agenda-custom-commands
2024-01-09 21:19:56 +04:00
'(("d" "Dashboard"
((agenda "" ((org-deadline-warning-days 7)))
(todo "NEXT"
((org-agenda-overriding-header "Next Tasks")))
(tags-todo "agenda/ACTIVE" ((org-agenda-overriding-header "Active Projects")))))
("n" "Next Tasks"
((todo "NEXT"
((org-agenda-overriding-header "Next Tasks")))))
("W" "Work Tasks" tags-todo "+work-email")
;; Low-effort next actions
("e" tags-todo "+TODO=\"NEXT\"+Effort<15&+Effort>0"
((org-agenda-overriding-header "Low Effort Tasks")
(org-agenda-max-todos 20)
(org-agenda-files org-agenda-files)))
("w" "Workflow Status"
((todo "WAIT"
((org-agenda-overriding-header "Waiting on External")
(org-agenda-files org-agenda-files)))
(todo "REVIEW"
((org-agenda-overriding-header "In Review")
(org-agenda-files org-agenda-files)))
(todo "PLAN"
((org-agenda-overriding-header "In Planning")
(org-agenda-todo-list-sublevels nil)
(org-agenda-files org-agenda-files)))
(todo "BACKLOG"
((org-agenda-overriding-header "Project Backlog")
(org-agenda-todo-list-sublevels nil)
(org-agenda-files org-agenda-files)))
(todo "READY"
((org-agenda-overriding-header "Ready for Work")
(org-agenda-files org-agenda-files)))
(todo "ACTIVE"
((org-agenda-overriding-header "Active Projects")
(org-agenda-files org-agenda-files)))
(todo "COMPLETED"
((org-agenda-overriding-header "Completed Projects")
(org-agenda-files org-agenda-files)))
(todo "CANC"
((org-agenda-overriding-header "Cancelled Projects")
(org-agenda-files org-agenda-files)))))
("1" "Events" agenda "display deadlines and exclude scheduled" (
(org-agenda-span 'month)
(org-agenda-time-grid nil)
(org-agenda-show-all-dates nil)
(org-agenda-entry-types '(:deadline)) ;; this entry excludes :scheduled
(org-deadline-warning-days 0) ))))
2023-11-26 13:14:09 +04:00
2024-01-12 15:39:06 +04:00
;; TODO Setup template for school
2023-11-26 13:14:09 +04:00
(setq org-capture-templates
2024-01-09 21:19:56 +04:00
`(("t" "Tasks / Projects")
2024-01-12 15:25:24 +04:00
("tt" "Task" entry (file+olp "~/org/tasks.org" "captured")
2023-11-26 13:14:09 +04:00
"* TODO %?\n %U\n %a\n %i" :empty-lines 1)
2024-01-09 21:19:56 +04:00
("j" "Journal Entries")
("jj" "Journal" entry
2024-01-12 15:25:24 +04:00
(file+olp+datetree "~/org/journal.org")
2023-11-26 13:14:09 +04:00
"\n* %<%I:%M %p> - Journal :journal:\n\n%?\n\n"
;; ,(dw/read-file-as-string "~/Notes/Templates/Daily.org")
:clock-in :clock-resume
2023-11-26 18:35:48 +04:00
:empty-lines 1))))
#+end_src
** Org Mode Beautifers
*** Olivetti
#+begin_src emacs-lisp
2024-01-12 15:39:06 +04:00
(use-package olivetti
2024-01-15 22:00:05 +04:00
:hook ((org-mode . (lambda () (interactive) (olivetti-mode) (olivetti-set-width 100)))
(org-agenda-mode . (lambda () (interactive) (olivetti-mode) (olivetti-set-width 100)))))
2024-01-12 15:39:06 +04:00
#+end_src
*** Org-Modern
*** Org-super-agenda
#+begin_src emacs-lisp
2024-01-12 15:51:49 +04:00
(use-package org-super-agenda
:hook ((org-agenda-mode . org-super-agenda-mode))
:config
(setq org-super-agenda-groups
2024-01-12 15:56:16 +04:00
'((:auto-group t))))
2023-11-01 20:53:52 +04:00
#+end_src
2024-01-15 15:49:16 +04:00
*** Org Pomodoro
#+begin_src emacs-lisp
2024-01-20 12:01:08 +04:00
(use-package org-pomodoro)
2024-01-15 15:49:16 +04:00
#+end_src
2023-11-01 20:53:52 +04:00
** Org-Roam
#+begin_src emacs-lisp
(use-package org-roam
:custom
2023-12-23 12:28:09 +04:00
(org-roam-directory "~/org/notes")
:bind (("C-c n l" . org-roam-buffer-toggle)
("C-c n f" . org-roam-node-find)
("C-c n i" . org-roam-node-insert))
:config
(org-roam-setup))
2023-11-01 20:53:52 +04:00
#+end_src
2024-01-15 22:00:05 +04:00
** Org-Wild-Notifier
#+begin_src emacs-lisp
(use-package org-wild-notifier
:config
(org-wild-notifier-mode))
#+end_src
2024-01-15 15:59:51 +04:00
** Alert.el
#+begin_src emacs-lisp
;; quick and dirty fix for windows alert.el
(when (eq system-type 'windows-nt)
(use-package alert
:commands (alert)
:config (setq alert-default-style 'toast))
(use-package alert-toast
:after alert))
#+end_src
2023-11-01 20:53:52 +04:00
** Treemacs
#+begin_src emacs-lisp
(use-package treemacs
:defer t
:init
(with-eval-after-load 'winum
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
:config
(progn
(setq treemacs-collapse-dirs (if treemacs-python-executable 3 0)
treemacs-deferred-git-apply-delay 0.5
treemacs-directory-name-transformer #'identity
treemacs-display-in-side-window t
treemacs-eldoc-display 'simple
treemacs-file-event-delay 2000
treemacs-file-extension-regex treemacs-last-period-regex-value
treemacs-file-follow-delay 0.2
treemacs-file-name-transformer #'identity
treemacs-follow-after-init t
treemacs-expand-after-init t
treemacs-find-workspace-method 'find-for-file-or-pick-first
treemacs-git-command-pipe ""
treemacs-goto-tag-strategy 'refetch-index
treemacs-header-scroll-indicators '(nil . "^^^^^^")
treemacs-hide-dot-git-directory t
treemacs-indentation 2
treemacs-indentation-string " "
treemacs-is-never-other-window nil
treemacs-max-git-entries 5000
treemacs-missing-project-action 'ask
treemacs-move-forward-on-expand nil
treemacs-no-png-images nil
treemacs-no-delete-other-windows t
treemacs-project-follow-cleanup nil
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory)
treemacs-position 'left
treemacs-read-string-input 'from-child-frame
treemacs-recenter-distance 0.1
treemacs-recenter-after-file-follow nil
treemacs-recenter-after-tag-follow nil
treemacs-recenter-after-project-jump 'always
treemacs-recenter-after-project-expand 'on-distance
treemacs-litter-directories '("/node_modules" "/.venv" "/.cask")
treemacs-project-follow-into-home nil
treemacs-show-cursor nil
treemacs-show-hidden-files t
treemacs-silent-filewatch nil
treemacs-silent-refresh nil
treemacs-sorting 'alphabetic-asc
treemacs-select-when-already-in-treemacs 'move-back
treemacs-space-between-root-nodes t
treemacs-tag-follow-cleanup t
treemacs-tag-follow-delay 1.5
treemacs-text-scale nil
treemacs-user-mode-line-format nil
treemacs-user-header-line-format nil
treemacs-wide-toggle-width 70
treemacs-width 35
treemacs-width-increment 1
treemacs-width-is-initially-locked t
treemacs-workspace-switch-cleanup nil)
;; The default width and height of the icons is 22 pixels. If you are
;; using a Hi-DPI display, uncomment this to double the icon size.
;;(treemacs-resize-icons 44)
(treemacs-follow-mode t)
(treemacs-tag-follow-mode t)
(treemacs-project-follow-mode t)
(treemacs-filewatch-mode t)
(treemacs-fringe-indicator-mode 'always)
(when treemacs-python-executable
(treemacs-git-commit-diff-mode t))
(pcase (cons (not (null (executable-find "git")))
(not (null treemacs-python-executable)))
(`(t . t)
(treemacs-git-mode 'deferred))
(`(t . _)
(treemacs-git-mode 'simple)))
(treemacs-hide-gitignored-files-mode nil))
:bind
(:map global-map
("M-0" . treemacs-select-window)
("C-x t 1" . treemacs-delete-other-windows)
("C-x t d" . treemacs-select-directory)
("C-x t B" . treemacs-bookmark)
("C-x t C-t" . treemacs-find-file)
("C-x t M-t" . treemacs-find-tag)))
(use-package treemacs-evil
2023-12-25 14:36:00 +04:00
:after (treemacs evil))
2023-11-01 20:53:52 +04:00
(use-package treemacs-projectile
2023-12-25 14:36:00 +04:00
:after (treemacs projectile))
2023-11-01 20:53:52 +04:00
(use-package treemacs-magit
2023-12-25 14:36:00 +04:00
:after (treemacs magit))
2023-11-01 20:53:52 +04:00
2023-12-17 17:18:25 +04:00
(use-package treemacs-nerd-icons
:config
(treemacs-load-theme "nerd-icons"))
2023-11-01 20:53:52 +04:00
#+end_src
** Dev Packages
*** Magit (git in emacs)
#+begin_src emacs-lisp
2023-11-26 14:15:53 +04:00
(use-package magit
:custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)
)
(use-package magit-todos
:after magit
:config (magit-todos-mode 1))
2023-11-01 20:53:52 +04:00
#+end_src
*** Forge for Magit (Adds github, gitlab, etc PRs and Issues to magit)
make sure to setup authinfo
#+begin_src emacs-lisp
(use-package forge
:after magit)
(setq auth-sources '("~/.authinfo"))
#+end_src
2023-12-23 20:45:08 +04:00
2023-11-01 20:53:52 +04:00
*** Direnv
#+begin_src emacs-lisp
2024-01-14 09:33:45 +04:00
(when (eq system-type 'gnu/linux)
2024-01-13 21:09:04 +04:00
(use-package direnv
:config
(direnv-mode))
)
2023-11-01 20:53:52 +04:00
#+end_src
*** Lsp-mode
**** Language Servers
#+begin_src emacs-lisp
2023-11-12 00:03:13 +04:00
(defun sakomacs/lsp-mode-setup ()
(setq lsp-headerline-breadcrumb-segments '(path-up-to-project file symbols))
(lsp-headerline-breadcrumb-mode))
(use-package lsp-mode
:commands (lsp lsp-deferred)
:hook (lsp-mode . sakomacs/lsp-mode-setup)
:init
(setq lsp-keymap-prefix "C-c l")
:config
(lsp-enable-which-key-integration t)
(setq lsp-keep-workspace-alive nil))
2023-11-01 20:53:52 +04:00
#+end_src
**** Lsp-ui
#+begin_src emacs-lisp
(use-package lsp-ui
:hook (lsp-mode . lsp-ui-mode)
:custom
(lsp-ui-doc-position 'bottom))
#+end_src
**** Treemacs Lsp
#+begin_src emacs-lisp
(use-package lsp-treemacs
:after lsp)
#+end_src
**** lsp-ivy
#+begin_src emacs-lisp
(use-package lsp-ivy
)
2023-11-01 20:53:52 +04:00
#+end_src
**** Languages
***** HTML/CSS
#+begin_src emacs-lisp
(use-package web-mode
:hook (web-mode . lsp)
:mode ("\\.html\\'"
"\\.css\\'"))
#+end_src
***** Javascript
#+begin_src emacs-lisp
2023-12-09 18:16:04 +04:00
(use-package js2-mode
:mode ("\\.js\\'"
"\\.jsx\\'")
:hook (js2-mode . lsp)
:config
(setq web-mode-markup-indent-offset 2) ; HTML
(setq web-mode-css-indent-offset 2) ; CSS
(setq web-mode-code-indent-offset 2) ; JS/JSX/TS/TSX
(setq web-mode-content-types-alist '(("jsx" . "\\.js[x]?\\'"))))
#+end_src
***** Typescript
#+begin_src emacs-lisp
(use-package typescript-mode
:mode ("\\.ts\\'"
"\\.tsx\\'")
:hook (typescript-mode . lsp))
#+end_src
***** Astro
2023-12-12 14:45:25 +04:00
#+begin_src emacs-lisp
2023-12-12 15:00:19 +04:00
(define-derived-mode astro-mode web-mode "astro")
(setq auto-mode-alist
(append '((".*\\.astro\\'" . astro-mode))
auto-mode-alist))
2023-12-12 14:45:25 +04:00
2023-12-12 15:00:19 +04:00
(add-to-list 'lsp-language-id-configuration
'(astro-mode . "astro"))
(defun astro-get-tsserver ()
""
(f-join (lsp-workspace-root) "node_modules/typescript/lib/tsserverlibrary.js"))
2023-12-12 14:45:25 +04:00
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection '("astro-ls" "--stdio"))
:activation-fn (lsp-activate-on "astro")
2023-12-12 15:00:19 +04:00
:initialization-options (lambda ()
`(:typescript (:serverPath ,(astro-get-tsserver))))
2023-12-12 14:45:25 +04:00
:server-id 'astro-ls))
2023-12-12 15:00:19 +04:00
2023-12-12 14:45:25 +04:00
#+end_src
2023-11-01 20:53:52 +04:00
***** C/C++
#+begin_src emacs-lisp
(add-hook 'c-mode-hook 'lsp)
(add-hook 'c++-mode-hook 'lsp)
#+end_src
***** CMake
#+begin_src emacs-lisp
(use-package cmake-mode
:mode "CMakeLists.txt"
:hook (cmake-mode . lsp))
#+end_src
2023-12-08 21:54:11 +04:00
***** Lua
#+begin_src emacs-lisp
(use-package lua-mode
:mode "\\.lua\\'"
:hook (lua-mode . lsp))
#+end_src
2023-11-01 20:53:52 +04:00
***** Python
#+begin_src emacs-lisp
(use-package python-mode
:mode "\\.py\\'"
:hook (python-mode . lsp))
(use-package elpy
:after python-mode
:custom
(elpy-rpc-python-command "python3")
:config
(elpy-enable))
2023-11-05 17:54:48 +04:00
(use-package lsp-pyright
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp)))) ; or lsp-deferred
2023-11-01 20:53:52 +04:00
#+end_src
***** Haskell
#+begin_src emacs-lisp
(use-package haskell-mode
:mode "\\.hs\\'"
:hook (python-mode . lsp))
#+end_src
***** Yaml editing
#+begin_src emacs-lisp
(use-package yaml-mode
:mode ("\\.yaml\\'"
"\\.yml\\'"))
#+end_src
***** Nix
#+begin_src emacs-lisp
(use-package nix-mode
:hook ((nix-mode . lsp)
(nix-mode . format-all-mode)
(nix-mode . (lambda () (setq-local format-all-formatters '(("Nix" alejandra))))))
:mode "\\.nix\\'")
#+end_src
***** Dart
#+begin_src emacs-lisp
2024-02-03 10:52:26 +04:00
(use-package lsp-dart)
2023-11-01 20:53:52 +04:00
(use-package dart-mode
:hook (dart-mode . lsp)
2023-11-01 21:06:03 +04:00
:mode "\\.dart\\'" )
2023-11-01 20:53:52 +04:00
#+end_src
2023-11-12 10:18:37 +04:00
***** Markdown
#+begin_src emacs-lisp
(use-package markdown-mode
:hook (markdown-mode . visual-line-mode))
2023-12-17 13:36:18 +04:00
(use-package markdown-preview-mode)
2023-11-12 10:18:37 +04:00
#+end_src
***** GDScript
#+begin_src emacs-lisp
(use-package gdscript-mode
:hook (gdscript-mode . lsp)
:mode "\\.gd\\'")
#+end_src
2024-04-02 02:20:08 +04:00
***** Rust
#+begin_src emacs-lisp
(use-package rust-mode
:hook (rust-mode . lsp)
:mode "\\.rs\\'")
#+end_src
2023-11-01 20:53:52 +04:00
*** Commenter
#+begin_src emacs-lisp
(use-package evil-nerd-commenter
:bind ("M-/" . evilnc-comment-or-uncomment-lines))
2023-09-23 16:21:42 +04:00
#+end_src
*** Company Mode (Better Autocompletion)
#+begin_src emacs-lisp
2023-11-12 10:18:37 +04:00
(use-package company
:after lsp-mode
:hook (lsp-mode . company-mode)
:bind (:map company-active-map
("<tab>" . company-complete-selection))
(:map lsp-mode-map
("<tab>" . company-indent-or-complete-common))
:custom
(company-minimum-prefix-length 1)
2023-11-16 18:50:54 +04:00
(company-idle-delay 0)
2023-11-12 10:18:37 +04:00
(company-selection-wrap-around t)
(company-tooltip-align-annotations t))
(use-package company-box
:hook (company-mode . company-box-mode))
#+end_src
*** Syntax Checking (Flycheck)
#+begin_src emacs-lisp
2023-12-25 14:31:45 +04:00
(use-package flycheck :config (global-flycheck-mode +1))
2023-09-23 16:21:42 +04:00
#+end_src
*** Formatting
#+begin_src emacs-lisp
(use-package format-all
)
2023-09-23 16:21:42 +04:00
#+end_src
2023-11-12 21:16:27 +04:00
*** Better Compile Messages
#+begin_src emacs-lisp
;; (use-package fancy-compilation
;; :commands (fancy-compilation-mode))
2023-11-12 21:16:27 +04:00
;; (with-eval-after-load 'compile
;; (fancy-compilation-mode))
2023-11-12 21:16:27 +04:00
#+end_src
2023-11-12 10:18:37 +04:00
*** Snippets
#+begin_src emacs-lisp
(use-package yasnippet
:diminish yas-minor-mode
:hook (after-init . yas-global-mode))
(use-package yasnippet-snippets)
2023-11-12 10:18:37 +04:00
(use-package yasnippet-capf
:init (add-to-list 'completion-at-point-functions #'yasnippet-capf))
#+end_src
2023-09-23 16:21:42 +04:00
** Dired (quick file management in emacs)
Dired is a built-in file manager for Emacs that does some pretty amazing things! Here are some key bindings you should try out:
*** Key Bindings
**** Navigation
*Emacs* / *Evil*
- =n= / =j= - next line
- =p= / =k= - previous line
- =j= / =J= - jump to file in buffer
- =RET= - select file or directory
- =^= - go to parent directory
- =S-RET= / =g O= - Open file in "other" window
- =M-RET= - Show file in other window without focusing (previewing files)
- =g o= (=dired-view-file=) - Open file but in a "preview" mode, close with =q=
- =g= / =g r= Refresh the buffer with =revert-buffer= after changing configuration (and after filesystem changes!)
**** Marking files
- =m= - Marks a file
- =u= - Unmarks a file
- =U= - Unmarks all files in buffer
- =* t= / =t= - Inverts marked files in buffer
- =% m= - Mark files in buffer using regular expression
- =*= - Lots of other auto-marking functions
- =k= / =K= - "Kill" marked items (refresh buffer with =g= / =g r= to get them back)
- Many operations can be done on a single file if there are no active marks!
**** Copying and Renaming files
- =C= - Copy marked files (or if no files are marked, the current file)
- Copying single and multiple files
- =U= - Unmark all files in buffer
- =R= - Rename marked files, renaming multiple is a move!
- =% R= - Rename based on regular expression: =^test= , =old-\&=
*Power command*: =C-x C-q= (=dired-toggle-read-only=) - Makes all file names in the buffer editable directly to rename them! Press =Z Z= to confirm renaming or =Z Q= to abort.
**** Deleting files
- =D= - Delete marked file
- =d= - Mark file for deletion
- =x= - Execute deletion for marks
- =delete-by-moving-to-trash= - Move to trash instead of deleting permanently
**** Creating and extracting archives
- =Z= - Compress or uncompress a file or folder to (=.tar.gz=)
- =c= - Compress selection to a specific file
- =dired-compress-files-alist= - Bind compression commands to file extension
**** Other common operations
- =T= - Touch (change timestamp)
- =M= - Change file mode
- =O= - Change file owner
- =G= - Change file group
- =S= - Create a symbolic link to this file
- =L= - Load an Emacs Lisp file into Emacs
*** Configuration
#+begin_src emacs-lisp
2023-12-29 00:04:35 +04:00
;; (use-package dired
;; :commands (dired dired-jump)
;; :bind (("C-x C-j" . dired-jump))
;; :custom ((dired-listing-switches "-agho --group-directories-first"))
;; :config
;; (evil-collection-define-key 'normal 'dired-mode-map
;; "h" 'dired-single-up-directory
;; "l" 'dired-single-buffer))
(global-set-key (kbd "C-x C-j") 'dired-jump)
(setq dired-listing-switches "-agho --group-directories-first")
2023-09-23 16:21:42 +04:00
(evil-collection-define-key 'normal 'dired-mode-map
2023-12-29 00:04:35 +04:00
"h" 'dired-single-up-directory
"l" 'dired-single-buffer)
2023-09-23 16:21:42 +04:00
2023-12-29 00:04:35 +04:00
;; (use-package dired-open
;; :config
;; (setq dired-open-extensions '(("png" . "feh")
;; ("mkv" . "mpv"))))
;; (use-package dired-hide-dotfiles
;; :hook (dired-mode . dired-hide-dotfiles-mode)
;; :config
;; (evil-collection-define-key 'normal 'dired-mode-map
;; "H" 'dired-hide-dotfiles-mode))
2023-09-23 16:21:42 +04:00
#+end_src
** Folder Cleaning
#+begin_src emacs-lisp
2023-11-12 00:03:13 +04:00
;; NOTE: If you want to move everything out of the ~/.emacs.d folder
;; reliably, set `user-emacs-directory` before loading no-littering!
;(setq user-emacs-directory "~/.cache/emacs")
2023-09-23 16:21:42 +04:00
2023-11-12 00:03:13 +04:00
(use-package no-littering
)
2023-09-23 16:21:42 +04:00
2023-11-12 00:03:13 +04:00
;; no-littering doesn't set this by default so we must place
;; auto save files in the same path as it uses for sessions
(setq auto-save-file-name-transforms
`((".*" ,(no-littering-expand-var-file-name "auto-save/") t)))
2023-09-23 16:21:42 +04:00
#+end_src
2023-12-15 17:03:41 +04:00
** RSS Reader
2023-11-04 16:01:16 +04:00
#+begin_src emacs-lisp
2024-02-28 21:08:34 +04:00
(when (eq system-type 'gnu/linux)
2023-12-15 21:34:18 +04:00
(use-package elfeed
2023-12-15 22:12:02 +04:00
:config
(setq elfeed-use-curl t)
2023-12-21 14:35:19 +04:00
(setq browse-url-browser-function 'eww-browse-url)
2023-12-21 19:02:41 +04:00
(setq elfeed-search-title-max-width 100)
2023-12-15 21:34:18 +04:00
)
2023-11-04 16:01:16 +04:00
2023-12-15 21:34:18 +04:00
(use-package elfeed-protocol
:after elfeed
:config
(elfeed-set-timeout 36000)
(setq elfeed-curl-extra-arguments '("--insecure")) ;necessary for https without a trust certificate
;; workaround for smth
(setq elfeed-protocol-fever-update-unread-only t)
;; setup feeds
(setq elfeed-protocol-feeds '(("fever+https://sako@rss.sako.box"
2024-01-27 12:15:43 +04:00
:api-url "https://rss.sako.box/fever/"
:use-authinfo t)))
2023-12-15 21:34:18 +04:00
;; enable elfeed-protocol
2023-12-15 21:58:38 +04:00
(setq elfeed-protocol-enabled-protocols '(fever))
2023-12-15 21:34:18 +04:00
(elfeed-protocol-enable)
)
2023-11-05 12:43:36 +04:00
2023-12-15 21:34:18 +04:00
(let* ((proto-id "fever+https://sako@rss.sako.box")
2024-01-27 12:15:43 +04:00
(last-id (elfeed-protocol-fever-get-update-mark proto-id 'update)))
2023-12-15 21:34:18 +04:00
(elfeed-protocol-fever-set-update-mark proto-id 'update (- last-id 1000)))
2023-12-15 21:25:31 +04:00
2024-01-14 14:14:53 +04:00
(run-at-time 300 300
2024-01-27 12:15:43 +04:00
(lambda () (when (= elfeed-curl-queue-active 0)
(elfeed-update))))
2023-12-15 21:25:31 +04:00
2024-01-14 09:30:10 +04:00
;; (add-hook 'emacs-startup-hook (elfeed-update))
2024-02-28 21:08:34 +04:00
)
2023-11-05 16:29:21 +04:00
2023-12-21 14:35:19 +04:00
#+end_src
2023-11-11 18:55:03 +04:00
** Telegram
only god knows why im doing this
#+begin_src emacs-lisp
;; codeberg thingy
2024-02-11 16:05:07 +04:00
;; breaks on nixos
;; (use-package visual-fill-column)
2024-02-11 16:05:58 +04:00
;; (use-package telega)
2023-11-11 18:55:03 +04:00
#+end_src
2023-12-13 13:20:29 +04:00
** pdf-tools
Emacs can be everything? Why not turn it into a pdf reader
#+begin_src emacs-lisp
2023-12-14 13:28:26 +04:00
(use-package pdf-tools
:mode ("\\.pdf\\'" . pdf-view-mode)
:config
(setq-default pdf-view-display-size 'fit-page)
:init
(pdf-tools-install))
#+end_src
** Matrix Client
okay this one is a bit more understandable
#+begin_src emacs-lisp
(use-package ement)
2023-12-13 13:20:29 +04:00
#+end_src
2023-12-22 23:34:01 +04:00
** Discord RPC
#+begin_src emacs-lisp
2024-02-03 14:27:20 +04:00
(use-package elcord
2024-02-07 14:33:34 +04:00
:init
(setq elcord-display-buffer-details nil)
(setq elcord-use-major-mode-as-main-icon t)
)
#+end_src
2023-12-22 23:34:01 +04:00
** Email
2023-12-29 15:58:37 +04:00
This ONLY works on Linux and Darwin
Not windows
2023-12-22 23:34:01 +04:00
#+begin_src emacs-lisp
2023-12-23 15:58:39 +04:00
2023-12-29 15:58:37 +04:00
(when (eq system-type 'gnu/linux)
2024-02-06 17:29:56 +04:00
(use-package mu4e)
2023-12-29 15:58:37 +04:00
)
2023-12-26 17:55:55 +04:00
2023-12-22 23:34:01 +04:00
#+end_src
2024-01-02 17:26:44 +04:00
** Docker
Aint no way bro
#+begin_src emacs-lisp
(use-package docker
:bind ("C-c d" . docker))
#+end_src
2024-02-04 12:57:26 +04:00
** EXWM
RELEASE ME
#+begin_src emacs-lisp
2024-02-08 09:48:05 +04:00
(when (eq system-type 'gnu/linux)
(display-battery-mode)
(use-package exwm
:config
2024-02-08 09:37:14 +04:00
2024-02-09 08:36:06 +04:00
(defun sakomacs/exwm-init-hook ()
;; background
(call-process-shell-command "feh --bg-fill ~/background.png" nil 0)
(set-frame-parameter (selected-frame)'alpha '(90 . 90))
(call-process-shell-command "~/.config/polybar/startpolybar" nil 0)
2024-02-09 08:53:58 +04:00
;; (call-process-shell-command "~/.config/picom/startpicom" nil 0)
2024-02-09 08:36:06 +04:00
;; startup
(call-process-shell-command "nm-applet" nil 0)
(call-process-shell-command "blueman-applet" nil 0)
(call-process-shell-command "nextcloud" nil 0)
(call-process-shell-command "bitwarden" nil 0)
(call-process-shell-command "flameshot" nil 0)
)
2024-02-08 09:48:05 +04:00
;; background
;; todo turn this info a function
2024-02-09 08:36:06 +04:00
(add-hook 'exwm-init-hook 'sakomacs/exwm-init-hook)
2024-02-08 09:48:05 +04:00
;; startup
;; workspaces
(setq exwm-workspace-number 5)
(require 'exwm-systemtray)
(exwm-systemtray-enable)
;; polybar
(defvar sakomacs/polybar-process nil
"Holds the process of the running Polybar instance, if any")
(server-start)
(defun sakomacs/kill-panel ()
(interactive)
(when sakomacs/polybar-process
(ignore-errors
(kill-process sakomacs/polybar-process)))
(setq sakomacs/polybar-process nil))
(defun sakomacs/start-panel ()
(interactive)
(sakomacs/kill-panel)
(setq sakomacs/polybar-process (start-process-shell-command "polybar" nil "polybar panel")))
(defun sakomacs/send-polybar-hook (module-name hook-index)
(start-process-shell-command "polybar-msg" nil (format "polybar-msg hook %s %s" module-name hook-index)))
(defun sakomacs/send-polybar-exwm-workspace ()
(sakomacs/send-polybar-hook "exwm-workspace" 1))
;; Update panel indicator when workspace changes
(add-hook 'exwm-workspace-switch-hook #'sakomacs/send-polybar-exwm-workspace)
;; always use these keys in emacs
(setq exwm-input-prefix-keys
'(?\C-x
?\C-u
?\C-h
?\M-x
?\M-`
?\M-&
?\M-:
?\C-\M-j ;; Buffer list
?\C-\ )) ;; Ctrl+Space
;; Ctrl+Q will enable the next key to be sent directly
(define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key)
;; app launcher and fullscreen
(exwm-input-set-key (kbd "s-SPC") 'counsel-linux-app)
(exwm-input-set-key (kbd "s-f") 'exwm-layout-toggle-fullscreen)
;; Set up global key bindings. These always work, no matter the input state!
;; Keep in mind that changing this list after EXWM initializes has no effect.
(setq exwm-input-global-keys
`(
;; Reset to line-mode (C-c C-k switches to char-mode via exwm-input-release-keyboard)
([?\s-r] . exwm-reset)
;; Move between windows
([s-left] . windmove-left)
([s-right] . windmove-right)
([s-up] . windmove-up)
([s-down] . windmove-down)
;; Launch applications via shell command
([?\s-&] . (lambda (command)
(interactive (list (read-shell-command "$ ")))
(start-process-shell-command command nil command)))
;; Switch workspace
([?\s-w] . exwm-workspace-switch)
;; 's-N': Switch to certain workspace with Super (Win) plus a number key (0 - 9)
,@(mapcar (lambda (i)
`(,(kbd (format "s-%d" i)) .
(lambda ()
(interactive)
(exwm-workspace-switch-create ,i))))
(number-sequence 0 9))))
2024-02-08 09:41:34 +04:00
)
2024-02-08 09:48:05 +04:00
(use-package desktop-environment
:after exwm
:config (desktop-environment-mode)
:custom
(desktop-environment-brightness-small-increment "2%+")
(desktop-environment-brightness-small-decrement "2%-")
(desktop-environment-brightness-normal-increment "5%+")
(desktop-environment-brightness-normal-decrement "5%-"))
)
2024-02-04 12:57:26 +04:00
#+end_src
2024-02-14 15:37:50 +04:00
** ERC
#+begin_src emacs-lisp
(setq erc-nick "sahko"
erc-user-full-name "sako"
;; erc-autojoin-channels-alist '(("irc-libera.chat" "#systemcrafters" "#emacs"))
erc-kill-buffer-on-part 8)
#+end_src
2024-03-17 01:05:42 +04:00
** fancy-compilation
#+begin_src emacs-lisp
;; to get past codeberg blocks in my country
(use-package (fancy-compilation :type git :host github :repo "emacsmirror/fancy-compilation")
:commands (fancy-compilation-mode))
(with-eval-after-load 'compile
(fancy-compilation-mode))
#+end_src
2023-09-23 16:21:42 +04:00
* Org Mode Configuration Setup
** Babel Languages
#+begin_src emacs-lisp
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(python . t)))
#+end_src
* Terminals
** EShell
god dammit why are they making my shells in emacs lisp
#+begin_src emacs-lisp
2023-12-28 23:57:47 +04:00
(defun sakomacs/configure-eshell ()
;; Save command history when commands are entered
(add-hook 'eshell-pre-command-hook 'eshell-save-some-history)
2023-09-23 16:21:42 +04:00
2023-12-28 23:57:47 +04:00
;; Truncate buffer for performance
(add-to-list 'eshell-output-filter-functions 'eshell-truncate-buffer)
2023-09-23 16:21:42 +04:00
2023-12-28 23:57:47 +04:00
;; Bind some useful keys for evil-mode
(evil-define-key '(normal insert visual) eshell-mode-map (kbd "C-r") 'counsel-esh-history)
(evil-define-key '(normal insert visual) eshell-mode-map (kbd "<home>") 'eshell-bol)
(evil-normalize-keymaps)
2023-09-23 16:21:42 +04:00
2023-12-28 23:57:47 +04:00
(setq eshell-history-size 10000
eshell-buffer-maximum-lines 10000
eshell-hist-ignoredups t
eshell-scroll-to-bottom-on-input t))
2023-09-23 16:21:42 +04:00
2023-12-28 23:57:47 +04:00
(use-package eshell-git-prompt)
2023-09-23 16:21:42 +04:00
2023-12-29 00:04:35 +04:00
(add-hook 'eshell-first-time-mode 'sakomacs/configure-eshell)
2023-09-23 16:21:42 +04:00
2023-12-28 23:57:47 +04:00
(with-eval-after-load 'esh-opt
(setq eshell-destroy-buffer-when-process-dies t)
2023-12-29 00:04:35 +04:00
(setq eshell-visual-commands '("htop" "zsh" "vim"))
2023-12-28 23:57:47 +04:00
(eshell-git-prompt-use-theme 'powerline))
2023-09-23 16:21:42 +04:00
#+end_src
2023-10-03 21:34:58 +04:00
** VTerm
#+begin_src emacs-lisp
(use-package vterm
2023-12-28 23:57:47 +04:00
:commands vterm
:config
(setq vterm-max-scrollback 10000))
2023-10-03 21:34:58 +04:00
#+end_src
2023-11-29 16:20:29 +04:00
* End
** notify that it has loaded
#+begin_src emacs-lisp
(require 'notifications)
(if (eq system-type 'windows-nt)
2023-12-28 23:57:47 +04:00
(w32-notification-notify
:title "Emacs Daemon"
:body "The Emacs Daemon has started"))
2023-11-29 16:20:29 +04:00
(if (eq system-type 'gnu/linux)
(notifications-notify
2023-12-28 23:57:47 +04:00
:title "Emacs Daemon"
:body "The Emacs Daemon has started"))
2023-11-29 16:20:29 +04:00
(message "Emacs is ready")
#+end_src