From 45bb0d11161b1c5077a1415eed6dbd0fd25ccb6a Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Fri, 20 Sep 2024 14:16:56 +0200 Subject: Change dotfiles structure, and add guix-channels declaration. --- files/.emacs.d/.gitignore | 5 + files/.emacs.d/init.el | 146 +++++++++++++++++++++++++++ files/.emacs.d/jd/jd-apps.el | 49 +++++++++ files/.emacs.d/jd/jd-custom.el | 33 ++++++ files/.emacs.d/jd/jd-dev.el | 177 ++++++++++++++++++++++++++++++++ files/.emacs.d/jd/jd-exwm.el | 177 ++++++++++++++++++++++++++++++++ files/.emacs.d/jd/jd-gym.el | 120 ++++++++++++++++++++++ files/.emacs.d/jd/jd-keys.el | 49 +++++++++ files/.emacs.d/jd/jd-misc.el | 34 +++++++ files/.emacs.d/jd/jd-mu4e.el | 84 ++++++++++++++++ files/.emacs.d/jd/jd-org.el | 224 +++++++++++++++++++++++++++++++++++++++++ files/.emacs.d/jd/jd-sway.el | 18 ++++ files/.emacs.d/jd/jd-ui.el | 104 +++++++++++++++++++ 13 files changed, 1220 insertions(+) create mode 100644 files/.emacs.d/.gitignore create mode 100755 files/.emacs.d/init.el create mode 100755 files/.emacs.d/jd/jd-apps.el create mode 100755 files/.emacs.d/jd/jd-custom.el create mode 100755 files/.emacs.d/jd/jd-dev.el create mode 100755 files/.emacs.d/jd/jd-exwm.el create mode 100755 files/.emacs.d/jd/jd-gym.el create mode 100755 files/.emacs.d/jd/jd-keys.el create mode 100644 files/.emacs.d/jd/jd-misc.el create mode 100755 files/.emacs.d/jd/jd-mu4e.el create mode 100755 files/.emacs.d/jd/jd-org.el create mode 100644 files/.emacs.d/jd/jd-sway.el create mode 100755 files/.emacs.d/jd/jd-ui.el (limited to 'files/.emacs.d') diff --git a/files/.emacs.d/.gitignore b/files/.emacs.d/.gitignore new file mode 100644 index 0000000..10f87ad --- /dev/null +++ b/files/.emacs.d/.gitignore @@ -0,0 +1,5 @@ +* +!init.el +!jd +!jd/* +!.gitignore \ No newline at end of file diff --git a/files/.emacs.d/init.el b/files/.emacs.d/init.el new file mode 100755 index 0000000..090592f --- /dev/null +++ b/files/.emacs.d/init.el @@ -0,0 +1,146 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + +;; Minimize garbage collection during startup +(setq gc-cons-threshold most-positive-fixnum) + +;; Lower threshold back to 8 MiB (default is 800kB) +(add-hook 'emacs-startup-hook + (lambda () + (setq gc-cons-threshold (expt 2 23)))) + +(defvar jd/manifest-list + nil + "List that contain Emacs packages for GNU/Guix." ) + +(defvar jd/exwm-p + (or (not (null (getenv "JD_EXWM"))) + (and (seq-contains command-line-args "exwm" #'string-match) + t)) + "Is non-nil when Emacs is run as a window manager.") + +(defvar jd/guix-p + (and (eq system-type 'gnu/linux) + (file-exists-p "/etc/os-release") + (with-temp-buffer + (insert-file-contents "/etc/os-release") + (search-forward "ID=guix" nil t)) + t) + "Is non-nil when Emacs packages are installed by GNU/Guix package manager.") + +(defun jd/add-package-to-manifest (guix-package-name) + "Add GUIX-PACKAGE-NAME to jd/manifest-list." + (unless (member guix-package-name jd/manifest-list) + (setq jd/manifest-list + (cons guix-package-name jd/manifest-list)))) + +(add-to-list 'load-path (concat user-emacs-directory "/jd")) + +(defun jd/display-startup-time () + (message "Emacs loaded in %s with %d garbage collections." + (format "%.2f seconds" + (float-time + (time-subtract after-init-time before-init-time))) + gcs-done)) + +(defun jd-emacs/startup () + "This procedure will run after Emacs startup." + (electric-pair-mode 1) + (global-company-mode 1) + (jd/display-startup-time)) + +(add-hook 'emacs-startup-hook #'jd-emacs/startup) + +(setq user-full-name "Jakub Dlugosz" + user-mail-address "jdlugosz963@gmail.com") + +(setq backup-directory-alist '(("." . "~/.cache/emacs/backup")) + backup-by-copying t + version-control t + delete-old-versions t + kept-new-versions 20 + kept-old-versions 5 + custom-file (concat user-emacs-directory + "custom.el")) + +;; (setq user-emacs-directory "~/.cache/emacs") + +(require 'package) +(setq package-archives '(("melpa" . "https://melpa.org/packages/") + ("org" . "https://orgmode.org/elpa/") + ("gnu-devel" . "https://elpa.gnu.org/devel/") + ("elpa" . "https://elpa.gnu.org/packages/"))) +(package-initialize) + +(unless package-archive-contents + (package-refresh-contents)) + +(jd/add-package-to-manifest "emacs-use-package") +(unless jd/guix-p + (unless (package-installed-p 'use-package) + (package-install 'use-package))) + +(require 'use-package) + +(setq use-package-always-ensure (not jd/guix-p)) + +(defun jd/generate-manifest () + "Generate GNU/Guix Emacs manifest to temp-buffer." + (interactive) + (with-output-to-temp-buffer "*guix-emacs-packages-manifest.scm*" + (princ (concat ";; This file is auto-generated by Emacs " + "function: jd/manifest-generate-to-file \n")) + (princ `(specifications->manifest + '(,@(mapcar #'(lambda (guix-package-name) + (concat "\"" + guix-package-name + "\"\n")) + jd/manifest-list)))))) + +(defun use-package-normalize/:guix-package (name keyword args) + (use-package-as-one (symbol-name keyword) args + #'(lambda (_label arg) + (cond + ((consp arg) arg) + ((stringp arg) (list arg)) + ((use-package-non-nil-symbolp arg) (symbol-name arg)) + (t + (use-package-error + ":pin wants an archive name (a string)")))))) + +(defun use-package-handler/:guix-package + (name _keyword args rest state) + (let ((body (use-package-process-keywords name rest state))) + (use-package-concat + (when (consp args) + (mapcar #'(lambda (arg) + `(jd/add-package-to-manifest ,arg)) + args)) + body))) + +(add-to-list 'use-package-keywords ':guix-package) + +(jd/add-package-to-manifest "emacs") +(jd/add-package-to-manifest "emacs-guix") + +(require 'jd-keys) +(require 'jd-ui) +(require 'jd-org) +(require 'jd-dev) +(require 'jd-apps) +(require 'jd-custom) +(require 'jd-mu4e) +(require 'jd-misc) +(require 'jd-sway) + +(when jd/exwm-p + (require 'jd-exwm)) + +;; (setq gc-cons-threshold (* 2 1000 1000)) + +;;; init.el ends here +(put 'upcase-region 'disabled nil) +(put 'downcase-region 'disabled nil) +(put 'set-goal-column 'disabled nil) diff --git a/files/.emacs.d/jd/jd-apps.el b/files/.emacs.d/jd/jd-apps.el new file mode 100755 index 0000000..f06430b --- /dev/null +++ b/files/.emacs.d/jd/jd-apps.el @@ -0,0 +1,49 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + +(use-package vterm + :guix-package "emacs-vterm" + :init + (add-to-list 'project-switch-commands '(project-vterm "Vterm") t) + (add-to-list 'project-kill-buffer-conditions + '(major-mode . vterm-mode)) + (setq vterm-copy-exclude-prompt t) + :config + (setq vterm-buffer-name "vterm") + ;; (evil-set-initial-state 'vterm-mode 'emacs) + (setq vterm-tramp-shells + (append '(("ssh" "/bin/bash")) vterm-tramp-shells)) + + ) + +(use-package all-the-icons-dired + :guix-package "emacs-all-the-icons-dired" + :hook (dired-mode . all-the-icons-dired-mode)) + +(use-package dired + :ensure nil + :commands (dired dired-jump) + :custom ((dired-listing-switches "-agho --group-directories-first")) + :config + (setq dired-kill-when-opening-new-dired-buffer t)) + +(use-package pdf-tools + :guix-package + "emacs-pdf-tools") + +(use-package password-store + :guix-package "emacs-password-store" + :bind + ("C-c P p" . password-store-copy) + ("C-c P i" . password-store-insert) + ("C-c P g" . password-store-generate)) + +(use-package shell + :bind + ("C-c C-" . shell)) + +(provide 'jd-apps) + +;;; jd-apps.el ends here diff --git a/files/.emacs.d/jd/jd-custom.el b/files/.emacs.d/jd/jd-custom.el new file mode 100755 index 0000000..a634baa --- /dev/null +++ b/files/.emacs.d/jd/jd-custom.el @@ -0,0 +1,33 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + +(setq erc-nick "bobbma" + erc-user-full-name "Jakub Dlugosz" + erc-notify-list '("akuleszaa")) + +(defun hipis-znc () + (interactive) + (erc :server "195.74.91.18" + :port "6697")) + + +;; Repair load paths when tramp try to connect to guix instances +(require 'tramp) + +(connection-local-set-profile-variables + 'guix-system + '((tramp-remote-path . (tramp-own-remote-path)))) + +(connection-local-set-profiles + '(:application tramp :protocol "sudo" :machine "localhost") + 'guix-system) + +(connection-local-set-profiles + '(:application tramp :protocol "ssh" :machine "jdlugosz.com") + 'guix-system) + +(provide 'jd-custom) + +;;; jd-custom.el ends here diff --git a/files/.emacs.d/jd/jd-dev.el b/files/.emacs.d/jd/jd-dev.el new file mode 100755 index 0000000..12cd21b --- /dev/null +++ b/files/.emacs.d/jd/jd-dev.el @@ -0,0 +1,177 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + +;; (setq c-default-style "linux" +;; c-basic-offset 8 +;; gdb-many-windows t) + +(use-package lsp-mode + :guix-package "emacs-lsp-mode" + :diminish t + :commands (lsp lsp-deferred) + :init + (setq lsp-headerline-breadcrumb-enable nil) + (setq lsp-diagnostics-provider :none) + (setq lsp-modeline-diagnostics-enable nil) + (setq lsp-keymap-prefix "C-c l") + :config + (lsp-enable-which-key-integration t) + + (global-set-key (kbd "C-x ]") + #'(lambda () + (interactive) + (forward-page) + (recenter-top-bottom 0))) + + (global-set-key (kbd "C-x [") + #'(lambda () + (interactive) + (backward-page) + (recenter-top-bottom 0))) + + (define-key c-mode-map + (kbd "C-c C-c") + #'(lambda () + (interactive) + (compile compile-command))) + + (define-key c-mode-map + (kbd "C-c M-c") + 'compile)) + +(use-package lsp-ivy + :guix-package "emacs-lsp-ivy" + :after lsp) + + +(use-package paredit + :guix-package "emacs-paredit") + +(defun jd/lisp-mode-setup () + (rainbow-delimiters-mode) + (paredit-mode)) + +(add-hook 'emacs-startup-hook + (lambda () + (add-hook 'scheme-mode-hook 'jd/lisp-mode-setup) + (add-hook 'emacs-lisp-mode-hook 'jd/lisp-mode-setup) + (add-hook 'clojure-mode-hook 'jd/lisp-mode-setup) + (add-hook 'lisp-mode-hook 'jd/lisp-mode-setup))) + +(use-package rainbow-delimiters + :guix-package "emacs-rainbow-delimiters") + +(use-package sly + :guix-package "emacs-sly") + +(use-package geiser + :guix-package "emacs-geiser") + +(use-package geiser-racket + :guix-package "emacs-geiser-racket") + +(use-package racket-mode + :guix-package "emacs-racket-mode") + +(use-package geiser-guile + :guix-package "emacs-geiser-guile" + :config + (when jd/guix-p + (defun jd/guix-repl () + (interactive) + (let ((geiser-guile-binary '("guix" "repl")) + (geiser-guile-load-path (cons "~/dotfiles/guix" geiser-guile-load-path))) + (geiser 'guile))))) + +(use-package pyvenv + :guix-package "emacs-pyvenv" + :after python-mode) + +(use-package typescript-mode + :guix-package "emacs-typescript-mode" + :mode ("\\.ts\\'") + :config + (setq typescript-indent-level 2)) + +(use-package cider + :guix-package "emacs-cider") + +(use-package tide + :guix-package "emacs-tide" + :after (typescript-mode company web-mode)) + +(use-package flycheck + :guix-package "emacs-flycheck" + :hook ((after-init . global-flycheck-mode))) + +(use-package web-mode + :guix-package "emacs-web-mode" + :mode + ("\\.ejs\\'" "\\.hbs\\'" "\\.html\\'" "\\.php\\'" "\\.[jt]sx?\\'") + :config + (setq web-mode-content-types-alist '(("jsx" . "\\.[jt]sx?\\'"))) + (setq web-mode-markup-indent-offset 2) + (setq web-mode-css-indent-offset 2) + (setq web-mode-code-indent-offset 2) + (setq web-mode-script-padding 2) + (setq web-mode-block-padding 2) + (setq web-mode-style-padding 2) + (setq web-mode-enable-auto-pairing t) + (setq web-mode-enable-auto-closing t) + (setq web-mode-enable-current-element-highlight t)) + +(use-package yaml-mode + :guix-package "emacs-yaml-mode") + +(use-package docker + :guix-package "emacs-docker" + :bind + ("C-c D d" . docker-containers) + ("C-c D D" . docker)) + +(use-package company + :guix-package "emacs-company" + :diminish t + :after lsp-mode + :hook (lsp-mode . company-mode) + :bind (:map company-active-map + ("" . company-complete-selection)) + (:map lsp-mode-map + ("" . company-indent-or-complete-common)) + :custom + (company-minimum-prefix-length 1) + (company-idle-delay 0.0) + :config + (global-company-mode)) + +(use-package projectile + :guix-package "emacs-projectile" + :diminish projectile-mode + :init + (when (file-directory-p "~/Documents/code") + (setq projectile-project-search-path '("~/Documents/code/"))) + :custom ((projectile-Completion-system 'ivy)) + :config + (setq projectile-switch-project-action #'projectile-dired) + (projectile-mode)) + +(use-package magit + :guix-package "emacs-magit" + :custom + (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) + +(use-package restclient + :guix-package "emacs-restclient") + +(setq sql-connection-alist + '(("net47-abaks" + (sql-product 'postgres) + (sql-user "kuba") + (sql-database "net47") + (sql-server "net47.abaks.pl")))) + +(provide 'jd-dev) + +;;; jd-dev.el ends here diff --git a/files/.emacs.d/jd/jd-exwm.el b/files/.emacs.d/jd/jd-exwm.el new file mode 100755 index 0000000..7731b01 --- /dev/null +++ b/files/.emacs.d/jd/jd-exwm.el @@ -0,0 +1,177 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + + +(use-package perspective + :guix-package "emacs-perspective") + +(use-package exwm + :guix-package "emacs-exwm" + :config + (defun jd/exwm-update-class () + (exwm-workspace-rename-buffer exwm-class-name)) + + (defun jd-exwm/run-in-background (command) + (let ((command-parts (split-string command "[ ]+"))) + (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) + + (defun jd-exwm/restart-process (program-name) + (call-process "killall" nil nil nil program-name) + (jd-exwm/run-in-background program-name)) + + (defun jd-exwm/exwm-init-hook () + (jd-exwm/run-in-background "nitrogen --restore") + (start-process-shell-command "xinput" nil "xinput set-prop 'ETPS/2 Elantech Touchpad' 'Synaptics Tap Action' 1 1 1 2 1") + (start-process-shell-command "syndaemon" nil "syndaemon -i 0.8 -K -R -d") + + (jd-exwm/restart-process "polybar") + (jd-exwm/restart-process "nm-applet") + (jd-exwm/restart-process "redshift-gtk -l 54.37:18.6") + (jd-exwm/restart-process "blueman-applet")) + + (defun jd-exwm/exwm-update-title () + (exwm-workspace-rename-buffer exwm-title)) + + (defun jd-exwm/configure-window-by-class () + (interactive) + (pcase exwm-class-name + ("firefox" (exwm-workspace-move-window 2)) + ("Brave" (exwm-workspace-move-window 2)) + ("qutebrowser" (exwm-workspace-move-window 2)) + ("discord" (exwm-workspace-move-window 5)) + ("obs" (exwm-workspace-move-window 5)) + ("Virt-manager" (exwm-workspace-move-window 4)))) + + (setq exwm-workspace-number 10) + + ;; (add-hook 'exwm-init-hook #'jd-exwm/exwm-init-hook) + (add-hook 'exwm-update-class-hook #'jd/exwm-update-class) + (add-hook 'exwm-update-title-hook #'jd-exwm/exwm-update-title) + (add-hook 'exwm-manage-finish-hook #'jd-exwm/configure-window-by-class) + + (require 'exwm-randr) + (setq exwm-randr-workspace-monitor-plist '(9 "eDP-1" 0 "eDP-1")) + (exwm-randr-enable) + + (setq exwm-input-simulation-keys + '(([?\C-b] . [left]) + ([?\C-f] . [right]) + ([?\C-p] . [up]) + ([?\C-n] . [down]) + ([?\C-a] . [home]) + ([?\C-e] . [end]) + ([?\C-k] . [S-end delete]) + ([?\M-w] . [C-c]) + ([?\C-y] . [C-v]) + ([?\C-v] . [next]) + ([?\M-v] . [prior]) + )) + + (setq exwm-input-prefix-keys + '(?\C-x + ?\C-u + ?\C-h + ?\M-x + ?\M-` + ?\M-& + ?\M-! + ?\C-g + ?\M-: + ?\C-\M-j + ?\C-\ )) + + (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key) + (exwm-input-set-key (kbd "s-p") 'counsel-linux-app) + + (setq exwm-input-global-keys + `(([?\s-R] . exwm-reset) + + + ([?\s-r] . (lambda (command) + (interactive (list (read-shell-command "$ "))) + (start-process-shell-command command nil command))) + + ([?\s-W] . exwm-workspace-move-window) + ([?\s-w] . exwm-workspace-switch) + + ,@(mapcar (lambda (i) + `(,(kbd (format "s-%d" i)) . + (lambda () + (interactive) + (exwm-workspace-switch-create ,i)))) + (number-sequence 0 9)))) + + (exwm-enable) + (require 'exwm-systemtray) + (exwm-systemtray-enable)) + +(use-package desktop-environment + :guix-package "emacs-desktop-environment" + :after exwm + :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%-") + + :config + (defun jd/dunst-show-history () + (interactive) + (start-process-shell-command "dunstctl" nil "dunstctl history-pop")) + (global-set-key (kbd "C-c N h") #'jd/dunst-show-history) + + (defun jd/dunst-close () + (interactive) + (start-process-shell-command "dunstctl" nil "dunstctl close")) + (global-set-key (kbd "C-c N c") #'jd/dunst-close) + + (defun jd/dunst-close-all () + (interactive) + (start-process-shell-command "dunstctl" nil "dunstctl close-all")) + (global-set-key (kbd "C-c N a") #'jd/dunst-close-all) + + (desktop-environment-mode)) + +;; (set-frame-parameter (selected-frame) 'alpha '(90 . 90)) +;; (add-to-list 'default-frame-alist `(alpha . (90 . 90))) +;; (set-frame-parameter (selected-frame) 'fullscreen 'maximized) +;; (add-to-list 'default-frame-alist '(fullscreen . maximized)) + +(defun jd-exwm/get-color (ATTRIBUTE) + (face-attribute 'default ATTRIBUTE)) + +(defun theme-to-xresources () + (interactive) + (require 'term) + (with-temp-buffer + (insert "! Generated by theme-to-xresources\n") + (dolist (spec + '(("emacs.background" :background "E6") + ("emacs.foreground" :foreground ""))) + (let ((color (jd-exwm/get-color (cadr spec)))) + (insert (format "%s: #%s%s\n" + (car spec) + (caddr spec) + (string-remove-prefix "#" color)))) + jd + (write-region (point-min) (point-max) "~/.Xresources"))) + (call-process "xrdb" nil nil nil "-merge" (expand-file-name "~/.Xresources"))) + +(defun jd/theme-sync () + (interactive) + (theme-to-xresources) + (setq org-confirm-babel-evaluate nil) + (org-babel-tangle-file "~/dotfiles/Desktop.org") + (setq org-confirm-babel-evaluate 't) + (call-process "killall" nil nil nil "dunst") ;; TODO: prevent clear notification history + (jd-exwm/restart-process "polybar")) + +;; (add-hook 'jd/load-theme-hook #'jd/theme-sync) +;; (add-hook 'exwm-init-hook #'jd/theme-sync) + +(provide 'jd-exwm) + +;;; jd-exwm.el ends here + diff --git a/files/.emacs.d/jd/jd-gym.el b/files/.emacs.d/jd/jd-gym.el new file mode 100755 index 0000000..581bf65 --- /dev/null +++ b/files/.emacs.d/jd/jd-gym.el @@ -0,0 +1,120 @@ +;;; jd-gym.el --- Gym workout manager. +;;; Commentary: +;; It will be a gym workout manager in the future. +;;; code: + +(require 'emacsql-sqlite) + +(defconst jd-gym/db--tables-schema + '((workout-plans + [(id integer :primary-key :autoincrement) + (name text)]) + + (workouts + [(id integer :primary-key :autoincrement) + (workout-plan-id integer :not-null) + (day integer :not-null) + (month integer :not-null) + (year integer :not-null)] + (:foreign-key [workout-plan-id] :references workout-plans [id] :on-delete :cascade)) + + (muscle-part + [(id integer :primary-key :autoincrement) + (name text :not-null)]) + + (exercises + [(id integer :primary-key :autoincrement) + (name text :not-null) + (muscle-part-id integer :not-null)] + (:foreign-key [muscle-part-id] :references muscle-part [id] :on-delete :cascade)) + + (workout-plan-exercise-map + [(id integer :primary-key :autoincrement) + (week-day integer :not-null) + (workout-plan-id integer :not-null) + (exercise-id integer :not-null)] + (:foreign-key [workout-plan-id] :references workout-plans [id] :on-delete :cascade) + (:foreign-key [exercise-id] :references exercises [id] :on-delete :cascade)) + + (workout-sets + [(id integer :primary-key :autoincrement) + (reps integer :not-null) + (weight integer :not-null) + (workout-plan-exercise-map-id integer :not-null) + (comment text)] + (:foreign-key [workout-plan-exercise-map-id] :references workout-plan-exercise-map [id] :on-delete :cascade)))) + +(defconst jd-gym/db--test-data + '((workout-plans + ([nil "Push pull"])) + (workouts + ([nil 1 3 1 2023])) + (muscle-part + ([nil "glutes"] + [nil "chest"])) + (exercises + ([nil "Bench press" 2] + [nil "RDL" 1])) + (workout-plan-exercise-map + ([nil 0 1 1] ; Monday, Push pull, Bench press + [nil 1 1 2] ; Tuesday, Push pull, RDL + [nil 3 1 1] ; Thursday, Push pull, Bench press + [nil 4 1 2] ; Friday, Push pull, RDL + )) + (workout-sets + ([nil 7 70 1 "New PR!"] + [nil 8 110 2 "It was hard!"])))) + +(defun jd-gym/db--test-data-insert () + "Insert test data to jd-gym database." + (mapc (lambda (table) + (let ((table-name (car table)) + (table-data (cdr table))) + (emacsql jd-gym/db--conn [:insert :into $i1 + :values $v2] + table-name table-data))) + jd-gym/db--test-data)) + +(defvar jd-gym/db-path "~/Documents/Gym/gym.sqlite" + "Path can be relative or absolute.") + +(defvar jd-gym/db--conn nil + "Store connection to jd-gym database.") + +(defun jd-gym/db--conn-p () + "Check if jd-gym is connected to db." + (and (emacsql-sqlite-connection-p jd-gym/db--conn) + (emacsql-live-p jd-gym/db--conn))) + +(defun jd-gym/db--connect () + "Connect to db if there is no connection yet." + (unless (jd-gym/db--conn-p) + (setq jd-gym/db--conn (emacsql-sqlite jd-gym/db-path)))) + +(defun jd-gym/db--close () + "Close db connection." + (when (jd-gym/db--conn-p) + (emacsql-close jd-gym/db--conn))) + +(defun jd-gym/db--init () + "Initialize database structure." + (when (jd-gym/db--conn-p) + (emacsql jd-gym/db--conn [:pragma (= foreign_keys ON)]) + (emacsql jd-gym/db--conn "PRAGMA foreign_keys=ON") + (mapc (lambda (table) + (let ((table-name (car table)) + (table-schema (cdr table))) + (emacsql jd-gym/db--conn [:create-table $i1 $S2] table-name table-schema))) + jd-gym/db--tables-schema))) + +(defun jd-gym/db () + "Entrypoint to jd-gym db." + (unless (file-exists-p jd-gym/db-path) + (jd-gym/db--close) + (jd-gym/db--connect) ; Restart connection + (jd-gym/db--init))) + + +(provide 'jd-gym) + +;;; jd-gym.el ends here diff --git a/files/.emacs.d/jd/jd-keys.el b/files/.emacs.d/jd/jd-keys.el new file mode 100755 index 0000000..8c1c4cb --- /dev/null +++ b/files/.emacs.d/jd/jd-keys.el @@ -0,0 +1,49 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: +;; Custom keysets used in my emacs +;;; Code: + +(use-package multiple-cursors + :guix-package "emacs-multiple-cursors" + :config + (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines) + (global-set-key (kbd "C->") 'mc/mark-next-like-this) + (global-set-key (kbd "C-<") 'mc/mark-previous-like-this) + (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)) + +(use-package hydra + :guix-package "emacs-hydra" + ;; :defer t + :config + (defun jd/text-scale-increase () + (interactive) + (let ((old-face-attribute (face-attribute 'default :height))) + (set-face-attribute 'default nil :height (+ old-face-attribute 10)))) + + (defun jd/text-scale-decrease () + (interactive) + (let ((old-face-attribute (face-attribute 'default :height))) + (set-face-attribute 'default nil :height (- old-face-attribute 10)))) + + (defhydra hydra-text-scale-global (:timeout 4) + "scale text" + ("j" jd/text-scale-increase "in") + ("k" jd/text-scale-decrease "out") + ("q" nil "finished" :exit t)) ;; TODO not working + + (defhydra hydra-text-scale (:timeout 4) + "scale text" + ("j" text-scale-increase "in") + ("k" text-scale-decrease "out") + ("q" nil "finished" :exit t))) + +(use-package undo-tree + :guix-package "emacs-undo-tree" + :diminish + :config + (setq undo-tree-auto-save-history nil) + (global-undo-tree-mode 1)) + +(provide 'jd-keys) + +;;; jd-keys.el ends here diff --git a/files/.emacs.d/jd/jd-misc.el b/files/.emacs.d/jd/jd-misc.el new file mode 100644 index 0000000..2b7d1bd --- /dev/null +++ b/files/.emacs.d/jd/jd-misc.el @@ -0,0 +1,34 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + +(defun jd/generete-qr-from-clipboard () + (interactive) + (let ((clipboard-value (x-get-clipboard)) + (clipboard-file-path "/tmp/clipboard_value.txt") + (clipboard-out-image "/tmp/qr.png")) + (with-temp-file clipboard-file-path + (insert clipboard-value)) + (shell-command (concat + "qrencode -o " + clipboard-out-image + " < " + clipboard-file-path)) + (find-file clipboard-out-image))) + +(defun jd/dired-open-file-in-kill-ring () + (interactive) + (let* ((last-killed (car kill-ring)) + (exists-p (file-exists-p last-killed)) + (dir-p (file-directory-p last-killed))) + (cond + ((not exists-p) (message "File doesn't exists!")) + (dir-p (dired last-killed)) + ((not dir-p) (find-file last-killed))))) + +(global-set-key (kbd "C-c O") #'jd/dired-open-file-in-kill-ring) + +(provide 'jd-misc) + +;;; jd-misc.el ends here diff --git a/files/.emacs.d/jd/jd-mu4e.el b/files/.emacs.d/jd/jd-mu4e.el new file mode 100755 index 0000000..b388201 --- /dev/null +++ b/files/.emacs.d/jd/jd-mu4e.el @@ -0,0 +1,84 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + +(use-package htmlize + :guix-package "emacs-htmlize") + +(use-package mu4e + :guix-package ("mu" "isync") + :defer 10 + :ensure nil + :bind + ("C-c M" . mu4e) + :config + ;a (require 'org-mu4e) + + (unless jd/guix-p + (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e") + (setq mu4e-mu-binary "/usr/local/bin/mu")) + + (setq mu4e-update-interval (* 10 60)) + (setq mu4e-get-mail-command "mbsync -a") + (setq mu4e-maildir "~/Mail") + + (setq mu4e-completing-read-function #'ivy-completing-read) + + (setq mu4e-change-filenames-when-moving t) + + (setq mu4e-contexts + `(,(make-mu4e-context + :name "Abaks" + :match-func (lambda (msg) (when msg + (string-prefix-p "/abaks" (mu4e-message-field msg :maildir)))) + :vars '( + (user-full-name . "Jakub Dlugosz") + (user-mail-address . "jakub@abaks.pl") + (mu4e-sent-folder . "/abaks/Sent Items") + (mu4e-trash-folder . "/abaks/Trash") + (mu4e-drafts-folder . "/abaks/Drafts") + (mu4e-refile-folder . "/abaks/Archive") + (mu4e-sent-messages-behavior . sent) + (smtpmail-local-domain . "pl") + (smtpmail-smtp-server . "smtp.abaks.pl") + (smtpmail-smtp-user . "jakub@abaks.pl"))) + ,(make-mu4e-context + :name "Gmail" + :match-func (lambda (msg) (when msg + (string-prefix-p "/gmail" (mu4e-message-field msg :maildir)))) + :vars '( + (user-full-name . "Jakub Dlugosz") + (user-mail-address . "jdlugosz963@gmail.com") + (mu4e-sent-folder . "/gmail/\[Gmail\]/Wys\&AUI-ane") + (mu4e-trash-folder . "/gmail/\[Gmail\]/Kosz") + (mu4e-drafts-folder . "/gmail/\[Gmail\]/Wersje\ robocze") + (mu4e-refile-folder . "/gmail/Archive") + (smtpmail-local-domain . "com") + (smtpmail-smtp-server . "smtp.gmail.com") + (smtpmail-smtp-user . "jdlugosz963@gmail.com") + (mu4e-sent-messages-behavior . sent))))) + + (setq mail-user-agent 'mu4e-user-agent + mail-host-address nil + message-send-mail-function 'smtpmail-send-it + smtpmail-smtp-service 465 + smtpmail-stream-type 'ssl + smtpmail-servers-requiring-authorization ".*") + + (setq mu4e-compose-signature (concat + "Pozdrawiam,\n" + "Jakub Długosz")) + + (mu4e t) + (mu4e-modeline-mode nil)) + +(use-package mu4e-alert + :guix-package "emacs-mu4e-alert" + :defer 20 + :config + (mu4e-alert-set-default-style 'libnotify) + (mu4e-alert-enable-mode-line-display) + (mu4e-alert-enable-notifications)) + +(provide 'jd-mu4e) diff --git a/files/.emacs.d/jd/jd-org.el b/files/.emacs.d/jd/jd-org.el new file mode 100755 index 0000000..400d00c --- /dev/null +++ b/files/.emacs.d/jd/jd-org.el @@ -0,0 +1,224 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + +(defvar jd/org-home "~/Notes") +(defvar jd/org-roam-home (concat jd/org-home "/roam")) +(defvar jd/org-sync (concat jd/org-home "/sync")) +(defvar jd/org-roam-daily-home (concat jd/org-roam-home "/daily")) + +(defun jd/org-mode-init () + (org-indent-mode) + (variable-pitch-mode 1) + (visual-line-mode 1)) + +(defun jd-emacs/org-insert-date (&optional date) + (org-insert-time-stamp (org-read-date nil t (or date "+0d")))) + +(use-package org-pomodoro + :guix-package "emacs-org-pomodoro") + +(use-package org-caldav + :guix-package "emacs-org-caldav" + :config + (setq org-caldav-url "http://caldav.jdlugosz.com/radicale/admin/" + org-caldav-files nil + org-icalendar-timezone "Europe/Warsaw") + + (defun jd/caldav-calendar-sync () + (interactive) + (let ((org-caldav-calendar-id "0c54a523-c7aa-2f26-2c18-a12b69c2bc86") + (org-caldav-inbox (concat jd/org-sync + "/calendar.org"))) + (org-caldav-sync))) + + (defun jd/caldav-journal-sync () + (interactive) + (let ((org-caldav-calendar-id "3cc70419-a787-5f84-28c6-96f15fc606d9") + (org-caldav-inbox (concat jd/org-sync + "/journal.org"))) + (org-caldav-sync))) + + (defun jd/caldav-tasks-sync () + (interactive) + (let ((org-caldav-calendar-id "372cbbb3-14f7-fc15-9f7b-cae04114920c") + (org-caldav-inbox (concat jd/org-sync + "/tasks.org"))) + (org-caldav-sync)))) + +(use-package org + :guix-package "emacs-org" + :pin org + :commands (org-capture org-agenda) + :hook (org-mode . jd/org-mode-init) + :bind + ("C-c o c" . #'org-capture) + ("C-c o p" . #'org-mobile-pull) + ("C-c o P" . #'org-mobile-push) + ("C-c o a" . #'org-agenda) + :config + (defun jd/org-mode-file (file-name) (concat org-directory "/" file-name ".org")) + (setq org-directory (file-truename "~/Notes") + org-mobile-directory (concat org-directory "/Mobile") + org-mobile-inbox-for-pull (concat org-directory "/flagged.org") ;; TODO: ?? + + org-refile-targets '((org-agenda-files :maxlevel . 1)) + org-outline-path-complete-in-steps nil + org-refile-use-outline-path t + org-agenda-files '("Personal.org" "Work.org" "Inbox.org") + org-ellipsis " ▾" + org-agenda-start-with-log-mode t + org-log-done 'time + org-log-into-drawer t + org-return-follows-link t + org-latex-listings 'minted + org-latex-packages-alist '(("" "minted")) + + org-agenda-custom-commands + `(("p" "Planning" + ((tags-todo "+planning" + ((org-agenda-overriding-header "Planning Tasks"))) + (tags-todo "-{.*}" + ((org-agenda-overriding-header "Untagged Tasks"))) + (todo "*" ((org-agenda-files '(,(jd/org-mode-file "Inbox"))) + (org-agenda-overriding-header "Unprocessed Inbox Items"))))) + + ("d" "Daily Agenda" + ((agenda "" ((org-agenda-span 'day) + (org-deadline-warning-days 7))) + (tags-todo "+PRIORITY=\"A\"" + ((org-agenda-overriding-header "High Priority Tasks"))))) + + ("w" "Weekly Review" + ((agenda "" + ((org-agenda-overriding-header "Completed Tasks") + (org-agenda-skip-function '(org-agenda-skip-entry-if 'nottodo 'done)) + (org-agenda-span 'week))) + + (agenda "" + ((org-agenda-overriding-header "Unfinished Scheduled Tasks") + (org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) + (org-agenda-span 'week)))))) + + org-capture-templates + `(("i" "Capture to Inbox" entry (file+olp ,(jd/org-mode-file "Inbox") "Inbox") + "* TODO %?\n %t\n" :empty-lines 1)) + + org-latex-pdf-process + '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" + "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")) + + (require 'org-tempo) + + (defun jd/org-font-setup () + ;; Replace list hyphen with dot + ;; (font-lock-add-keywords 'org-mode + ;; '(("^ *\\([.]\\) " + ;; (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•-")))))) + + ;; Set faces for heading levels + (dolist (face '((org-level-1 . 1.3) + (org-level-2 . 1.2) + (org-level-3 . 1.1) + (org-level-4 . 1.0) + (org-level-5 . 1.0) + (org-level-6 . 1.0) + (org-level-7 . 1.0) + (org-level-8 . 1.0))) + (set-face-attribute (car face) nil :font "Terminus" :weight 'Bold :height (cdr face))) + + ;; Ensure that anything that should be fixed-pitch in Org files appears that way + (set-face-attribute 'org-block nil :font "Terminus" :inherit 'fixed-pitch :height 100) + (set-face-attribute 'org-table nil :inherit 'fixed-pitch) + (set-face-attribute 'org-formula nil :inherit 'fixed-pitch) + (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch)) + (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch)) + (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch)) + (set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch)) + (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch) + (set-face-attribute 'line-number nil :inherit 'fixed-pitch) + (set-face-attribute 'line-number-current-line nil :inherit 'fixed-pitch)) + + (with-eval-after-load 'org (jd/org-font-setup)) + + (defun jd-emacs/org-timer-stop () + (start-process-shell-command "notify-send" nil "notify-send Zakonczono odliczanie")) + + (add-hook 'org-timer-stop-hook #'jd-emacs/org-timer-stop) + + (defun jd/org-tempo-setup () + (dolist (template '(("s" . "src") + ("sql" . "src sql") + ("sh" . "src sh") + ("el" . "src emacs-lisp") + ("li" . "src lisp") + ("sc" . "src scheme") + ("ts" . "src typescript") + ("py" . "src python") + ("go" . "src go") + ("yaml" . "src yaml"))) + (add-to-list 'org-structure-template-alist template))) + + (with-eval-after-load 'org-tempo (jd/org-tempo-setup)) + + (org-babel-do-load-languages + 'org-babel-load-languages + '((emacs-lisp . t) + (python . t) + (shell . t)))) + +(use-package org-superstar + :guix-package "emacs-org-superstar" + :hook (org-mode . org-superstar-mode) + :init + (setq org-superstar-special-todo-items t) + (setq org-superstar-remove-leading-stars t) + (setq org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●"))) + +(use-package org-roam + :guix-package "emacs-org-roam" + :custom + (org-roam-directory (file-truename jd/org-roam-home)) + :bind (("C-c n l" . org-roam-buffer-toggle) + ("C-c n f" . org-roam-node-find) + ("C-c n g" . org-roam-graph) + ("C-c n i" . org-roam-node-insert) + ("C-c n c" . org-roam-capture) + ;; Dailies + ("C-c n j" . org-roam-dailies-capture-today)) + :bind-keymap + ("C-c n d" . org-roam-dailies-map) + :config + (require 'org-roam-dailies) + + (defun jd/org-roam-filter-by-tag (tag-name) + (lambda (node) + (member tag-name (org-roam-node-tags node)))) + + (defun jd/org-roam-list-notes-by-tag (tag-name) + (mapcar #'org-roam-node-file + (seq-filter + (jd/org-roam-filter-by-tag tag-name) + (org-roam-node-list)))) + + (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) + (setq org-roam-capture-templates + '(("d" "default" plain "%?" + :target (file+head + "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n\n* ${title}\n %?") ;; TODO: point cursor to the end of the file, it should be: `%?` + :unnarrowed t) + ;; ("n" "insert node" plain (file "~/Documents/roam/study/templates/research.org") + ;; :target (file+head "study/%<%Y%m%d%H%M%S>-${slug}.org" + ;; "#+title: ${title}\n") + ;; :unnarrowed t) + )) + + (org-roam-db-autosync-mode)) + +(use-package ox-pandoc + :guix-package "emacs-ox-pandoc") + +(provide 'jd-org) + +;;; jd-org.el ends here diff --git a/files/.emacs.d/jd/jd-sway.el b/files/.emacs.d/jd/jd-sway.el new file mode 100644 index 0000000..cdfb667 --- /dev/null +++ b/files/.emacs.d/jd/jd-sway.el @@ -0,0 +1,18 @@ +;;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + +(defun use-package-normalize/:diminish (name keyword args) + (use-package-as-one (symbol-name keyword) args + (apply-partially #'use-package-normalize-diminish name) t)) + +(use-package shackle + :guix-package "emacs-shackle") + +(use-package sway + :guix-package "emacs-sway") + +(provide 'jd-sway) + +;;; jd-sway.el ends here diff --git a/files/.emacs.d/jd/jd-ui.el b/files/.emacs.d/jd/jd-ui.el new file mode 100755 index 0000000..4e388c9 --- /dev/null +++ b/files/.emacs.d/jd/jd-ui.el @@ -0,0 +1,104 @@ +;; Dotfiles --- Jakub Dlugosz emacs config +;;; Commentary: + +;;; Code: + +(setq inhibit-startup-message t) +(setq visible-bell t) +(scroll-bar-mode -1) +(tool-bar-mode -1) +(tooltip-mode -1) +(menu-bar-mode -1) +(set-fringe-mode 10) + +;; (set-frame-parameter (selected-frame) 'alpha '(92 . 92)) +;; (add-to-list 'default-frame-alist '(alpha . (92 . 92))) + +(let ((height (if (string-equal (system-name) + "berserker") + 175 + 125))) + (custom-set-faces + `(default ((t (:inherit nil :height ,height :family "Terminus")))) + `(line-number ((t (:inherit nil :height ,height :family "Terminus")))) + `(line-number-current-line ((t (:inherit nil :height ,height :family "Terminus")))))) + +(add-hook 'prog-mode-hook 'menu-bar--display-line-numbers-mode-relative) + +(global-set-key (kbd "") 'keyboard-escape-quit) + +(global-prettify-symbols-mode 1) + +(defalias 'yes-or-no-p 'y-or-n-p) + +(require 'diminish) + +(use-package doom-modeline + :guix-package "emacs-doom-modeline" + :config + (doom-modeline-mode)) + +(use-package solarized-theme + :guix-package "emacs-solarized-theme" + :config + (load-theme 'solarized-dark-high-contrast t)) + + +(use-package diminish + :guix-package "emacs-diminish") + +(use-package hl-todo + :guix-package "emacs-hl-todo" + :init + (setq hl-todo-keyword-faces + '(("TODO" . "#FF0000") + ("FIXME" . "#FF0000") + ("DEBUG" . "#A020F0"))) + :config + (global-hl-todo-mode 1)) + +(defvar jd/load-theme-hook nil) +(defun jd/load-theme () + (interactive) + (counsel-load-theme) + (run-hooks 'jd/load-theme-hook)) + +(use-package ivy + :guix-package "emacs-ivy" + :diminish + :bind + (("C-s" . swiper)) + :config + (ivy-mode 1)) + +(use-package counsel + :guix-package "emacs-counsel" + :diminish t + :config + (counsel-mode 1)) + +(use-package which-key + :guix-package "emacs-which-key" + :diminish + :config + (which-key-mode) + (setq which-key-idle-delay 0.3)) + +(use-package all-the-icons + :guix-package "emacs-all-the-icons") + +(use-package beacon + :guix-package "emacs-beacon" + :config + (beacon-mode 1)) + +(setq display-time-string-forms + '(" " 24-hours ":" minutes " ")) + +(when jd/exwm-p + (display-battery-mode) + (display-time-mode)) + +(provide 'jd-ui) + +;;; jd-ui.el ends here -- cgit v1.2.3