rewrite emacs configuration

This commit is contained in:
Sakooooo 2024-12-04 21:33:15 +04:00
parent eba58fc407
commit faeea539ce
Signed by: sako
GPG key ID: FE52FD65B76E4751
8 changed files with 400 additions and 45 deletions

View file

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

359
config/emacs/init.el Normal file
View file

@ -0,0 +1,359 @@
;; -*- lexical-binding: t; -*-
;; Sako's terrible eMacs config!
;; Lots of things missing but its whats needed
;; TODO(sako):: Setup mu4e
;; TODO(sako):: Setup irc (erc/rcirc)
;; TODO(sako):: Setup elfeed
;; TODO(sako):: Setup elcord
;; --- Display Options ---
(scroll-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(menu-bar-mode -1)
(set-fringe-mode 0)
(setq visible-bell nil)
(setq inhibit-startup-message t)
(repeat-mode 1)
(column-number-mode)
(setq display-line-numbers 'relative)
(dolist (mode '(text-mode-hook
prog-mode-hook
conf-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 1))))
(set-face-attribute 'default nil
:font "JetBrainsMono NF"
:weight 'light
:height 120)
(setq frame-resize-pixelwise t)
(setq global-auto-revert-non-file-buffers t)
(global-auto-revert-mode 1)
(add-to-list 'default-frame-alist '(font . "JetBrainsMono NF"))
(set-frame-font "JetBrainsMono NF" nil t)
(fset 'yes-or-no-p 'y-or-n-p)
;; --- Extra options ---
(setq backup-directory-alist '(("." . "~/.emacs.d/backup"))
backup-by-copying t
version-control t
delete-old-versions t
delete-old-versions t
kept-new-versions 20
kept-old-version 5)
(setq native-comp-async-report-warnings-errors nil)
(add-to-list 'native-comp-eln-load-path (expand-file-name "eln-cache/" user-emacs-directory))
;; --- Package Setup ---
(require `package)
(setq package-archives `(("mepla" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")
("elpa" . "https://elpa.gnu.org/packages/")))
(setq use-package-always-ensure t)
(package-initialize)
(unless (package-installed-p 'use-package)
(progn
(package-refresh-contents)
(package-install 'use-package)))
;; --- Theme ---
(use-package cherry-blossom-theme
:ensure t
:config
(load-theme 'cherry-blossom t))
;; --- no-littering ---
(use-package no-littering
:config
(setq custom-file (if (boundp 'server-socket-dir)
(expand-file-name "custom.el" server-socket-dir)
(no-littering-expand-etc-file-name "custom.el")))
(when (file-exists-p custom-file)
(load custom-file t))
;; Don't litter project folders with backup files
(let ((backup-dir (no-littering-expand-var-file-name "backup/")))
(make-directory backup-dir t)
(setq backup-directory-alist
`(("\\`/tmp/" . nil)
("\\`/dev/shm/" . nil)
("." . ,backup-dir))))
(setq auto-save-default nil)
;; Tidy up auto-save files
(setq auto-save-default nil)
(let ((auto-save-dir (no-littering-expand-var-file-name "auto-save/")))
(make-directory auto-save-dir t)
(setq auto-save-file-name-transforms
`(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'"
,(concat temporary-file-directory "\\2") t)
("\\`\\(/tmp\\|/dev/shm\\)\\([^/]*/\\)*\\(.*\\)\\'" "\\3")
("." ,auto-save-dir t)))))
;; 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)))
;; --- Keybinds ---
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; --- helpful ---
(use-package helpful
:ensure t
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable)
:bind (([remap describe-function] . helpful-function)
([remap describe-symbol] . helpful-symbol)
([remap describe-variable] . helpful-variable)
([remap describe-command] . helpful-command)
([remap describe-key] . helpful-key)))
;; --- Startup Dashboard ---
(use-package enlight
:ensure t
:custom
(enlight-content
(concat
(propertize "MENU" 'face 'highlight)
"\n"
(enlight-menu
'(("Org Mode"
("Org-Agenda (current day)" (org-agenda nil "a") "a"))
("Other"
("Projects" project-switch-project "p"))))))
:config
(setopt initial-buffer-choice #'enlight))
;; --- Completition ---
(use-package vertico
:ensure t
:custom
(vertico-cycle t)
:init
(require 'vertico-directory)
(vertico-mode))
(use-package marginalia
:after vertico
:ensure t
:init
(marginalia-mode))
(use-package consult
:after vertico
:ensure t
:bind (("C-s" . consult-line)
("C-M-j" . consult-buffer)
("C-x C-b" . consult-buffer)))
(use-package orderless
:ensure t
:config
(orderless-define-completion-style orderless+initialism
(orderless-matching-styles '(orderless-initialism
orderless-literal
orderless-regexp)))
(setq completion-styles '(orderless)
completion-category-defaults nil
orderless-matching-styles '(orderless-literal orderless-regexp)
completion-category-overrides
'((file (styles partial-completion)))))
(use-package corfu
:ensure t
:bind (:map corfu-map
("TAB" . corfu-insert)
([tab] . corfu-insert)
("RET" . nil))
:config
(setq corfu-cycle t
corfu-quit-at-boundary t
corfu-auto t
corfu-quit-no-match t
corfu-popupinfo-delay '(1.0 . 0.5))
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)
:init
(global-corfu-mode)
(corfu-popupinfo-mode))
(use-package nerd-icons-corfu
:ensure t
:after corfu)
;; --- Pinentry ---
(unless (eq system-type 'windows-nt)
(use-package pinentry
:config
(setq epa-pinentry-mode 'loopback)
(pinentry-start)))
;; --- Passwords ---
(use-package password-store
:ensure t
:bind (("C-c p p" . password-store-copy)
("C-c p i" . password-store-insert)
("C-c p g" . password-store-generate)))
(auth-source-pass-enable)
;; --- Terminal ---
(use-package vterm
:ensure t
:bind ("<f1>" . vterm)
:config
(setq vterm-max-scrollback 10000))
;; --- Parens ---
(use-package smartparens
:ensure t
:hook (prog-mode . smartparens-mode)
:config
(sp-use-smartparens-bindings))
(use-package rainbow-delimiters
:ensure t
:hook (prog-mode . rainbow-delimiters-mode))
;; --- M-x compile ---
(setq compilation-scroll-output t)
(setq compilation-environment '("TERM=xterm-256color"))
(defun sk/advice-compilation-filter (f proc string)
(funcall f proc (xterm-color-filter string)))
(advice-add 'compilation-filter :around #'sk/advice-compilation-filter)
(defun sk/auto-recompile-buffer ()
(interactive)
(if (member #'recompile after-save-hook)
(remove-hook 'after-save-hook #'recompile t)
(add-hook 'after-save-hook #'recompile nil t)))
;; --- project.el ---
(setq project-switch-commands '((project-find-file "Find file" "f")
(project-find-dir "Find dir" "d")
(project-dired "Dired" "D")
(consult-ripgrep "ripgrep" "g")
(magit-project-status "Magit" "m")))
;; --- magit ---
(use-package magit
:ensure t
:custom
(magit-show-long-lines-warning nil)
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
;; --- flycheck ---
(use-package flycheck
:ensure t
:config
(global-flycheck-mode +1))
;; --- direnv ---
(when (eq system-type 'gnu/linux)
(use-package envrc
:ensure t
:hook (after-init . envrc-global-mode)))
;; --- editorconfig ---
(use-package editorconfig
:ensure t
:config
(editorconfig-mode 1))
;; --- wakatime ---
(use-package wakatime-mode
:ensure t
:config
(global-wakatime-mode))
;; --- formatting ---
(use-package aphelelia
:ensure t
:hook (prog-mode . aphelia-mode))
;; --- LSP ---
(use-package eglot
:ensure t
:bind (:map eglot-mode-map
("C-c C-a" . eglot-code-actions)
("C-c C-r" . eglot-rename))
:config
(setq eglot-autoshutdown t
eglot-confirm-server-initiated-edits nil))
;; --- LSP Booster ---
(when (eq system-type 'gnu/linux)
(use-package eglot-booster
:ensure nil
:config (eglot-booster-mode)))
;; --- Org-Mode ---
(use-package org
:ensure t
:bind (("C-c o a" . org-agenda))
:hook (org-mode . org-indent-mode)
:config
;; replace ... with >
(setq org-ellipsis " >")
(setq org-startup-with-inline-images t)
(setq org-todo-keywords
'((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@)")))
;; --- Org Agenda ---
(setq org-agenda-files
'("~/org/tasks.org"
"~/org/school.org"
"~/org/daily.org"
"~/org/irl.org"
"~/org/work.org"))
(setq org-agenda-custom-commands
`(("s" "School" tags-todo "+school")))
;; --- org2pdf ---
(setq org-latex-compiler "lualatex")
(setq org-preview-latex-default-process 'dvisvgm))
;; --- Org-Roam ---
(use-package org-roam
:ensure t
:custom
(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))
;; --- Org Extras ---
(use-package org-wild-notifier
:ensure t
:config
(setq alert-default-style 'libnotifiy)
(setq org-wild-notifier-alert-time 30)
(org-wild-notifier-mode))
(use-package org-pomodoro
:ensure t)

View file

@ -12,18 +12,18 @@ let
});
myEmacs = pkgs.emacsWithPackagesFromUsePackage {
config = ../../../../config/emacs/emacs.org;
config = ../../../../config/emacs/init.el;
package = cfg.package;
alwaysEnsure = true;
alwaysTangle = true;
# alwaysEnsure = true;
# alwaysTangle = true;
extraEmacsPackages = epkgs: [
epkgs.use-package
epkgs.mu4e
# epkgs.mu4e
# TODO make this check if EXWM is enabled or not
epkgs.exwm
# epkgs.exwm
# epkgs.sakomodules
epkgs.eglot-booster
epkgs.app-launcher
# epkgs.app-launcher
];
# add eglot-lsp-booster package
override = epkgs:
@ -41,23 +41,23 @@ let
hash = "sha256-vF34ZoUUj8RENyH9OeKGSPk34G6KXZhEZozQKEcRNhs=";
};
};
app-launcher = epkgs.melpaBuild {
pname = "app-launcher";
version = "1.0";
# app-launcher = epkgs.melpaBuild {
# pname = "app-launcher";
# version = "1.0";
commit = "d5015e394b0a666a8c7c4d4bdf786266e773b145";
# commit = "d5015e394b0a666a8c7c4d4bdf786266e773b145";
recipe = pkgs.writeText "recipe" ''
(app-launcher :repo "SebastienWae/app-launcher" :fetcher github)
'';
# recipe = pkgs.writeText "recipe" ''
# (app-launcher :repo "SebastienWae/app-launcher" :fetcher github)
# '';
src = pkgs.fetchFromGitHub {
owner = "SebastienWae";
repo = "app-launcher";
rev = "d5015e394b0a666a8c7c4d4bdf786266e773b145";
hash = "sha256-d0d5rkuxK/zKpSCa1UTdpV7o+RDDsEeab56rI7xUJ1E=";
};
};
# src = pkgs.fetchFromGitHub {
# owner = "SebastienWae";
# repo = "app-launcher";
# rev = "d5015e394b0a666a8c7c4d4bdf786266e773b145";
# hash = "sha256-d0d5rkuxK/zKpSCa1UTdpV7o+RDDsEeab56rI7xUJ1E=";
# };
# };
};
# override for modules
# override = epkgs: epkgs // {
@ -104,16 +104,16 @@ in {
# direnv
direnv
# mu for email
mu
# mu
# email sync
offlineimap
(isync.override { withCyrusSaslXoauth2 = true; })
# offlineimap
# (isync.override { withCyrusSaslXoauth2 = true; })
# oauth
oama
# oama
# protonmail
hydroxide
# hydroxide
# send mail
msmtp
# msmtp
# org to pdf
tex
# lsp
@ -126,16 +126,16 @@ in {
wakatime-cli
];
systemd.services.hydroxide = {
enable = true;
description = "Unofficial Protonmail Bridge";
serviceConfig = {
User = "sako";
Type = "simple";
};
script = "${pkgs.hydroxide}/bin/hydroxide serve";
wantedBy = [ "multi-user.target" ];
};
# systemd.services.hydroxide = {
# enable = true;
# description = "Unofficial Protonmail Bridge";
# serviceConfig = {
# User = "sako";
# Type = "simple";
# };
# script = "${pkgs.hydroxide}/bin/hydroxide serve";
# wantedBy = [ "multi-user.target" ];
# };
# services.pantalaimon-headless.instances = {
# "wires.cafe" = {
@ -147,16 +147,12 @@ in {
home-manager.users.sako = { lib, ... }: {
home.file = {
".emacs.d/init.el".source = pkgs.runCommand "init.el" { } ''
cp ${../../../../config/emacs/emacs.org} emacs.org
${myEmacs}/bin/emacs -Q --batch ./emacs.org -f org-babel-tangle
mv init.el $out
'';
".emacs.d/icon.png".source = ../../../../config/emacs/icon.png;
".emacs.d/init.el".source = ../../../../config/emacs/init.el;
# ".emacs.d/icon.png".source = ../../../../config/emacs/icon.png;
# ".mbsyncrc".source = ../../../../config/emacs/.mbsyncrc;
".offlineimaprc".source = ../../../../config/emacs/.offlineimaprc;
".offlineimap.py".source = ../../../../config/emacs/.offlineimap.py;
".msmtprc".source = ../../../../config/emacs/.msmtprc;
# ".offlineimaprc".source = ../../../../config/emacs/.offlineimaprc;
# ".offlineimap.py".source = ../../../../config/emacs/.offlineimap.py;
# ".msmtprc".source = ../../../../config/emacs/.msmtprc;
};
};