From 9d92b4f058d8f955c432195c3a7f28b140a43ad3 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 28 Nov 2022 14:12:01 -0800 Subject: [PATCH] Create base of custom theme --- init.el | 39 +++++++++++++++++++--- my-theme-theme.el | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 my-theme-theme.el diff --git a/init.el b/init.el index a2bafdb..6a5e89c 100644 --- a/init.el +++ b/init.el @@ -1,8 +1,5 @@ ;;;; Appearance -;; Set theme -(load-theme 'tango-dark) - ;; Hide ribbon, menu bar, and scroll bars (menu-bar-mode -1) (tool-bar-mode -1) @@ -15,7 +12,7 @@ (global-display-line-numbers-mode +1) ;; Highlight current line -;;(global-hl-line-mode 1) -- disabled until less nasty theme +(global-hl-line-mode 1) ;; Replace yes/no prompts with y/n prompts (fset #'yes-or-no-p #'y-or-n-p) @@ -26,6 +23,20 @@ mouse-wheel-follow-mouse +1 scroll-step 1) ;; C-n C-p scroll step +;;;; Tabs +(setq custom-tab-width 2) + +(defun disable-tabs () + (indent-tabs-mode -1)) +(defun enable-tabs () + (local-set-key (kbd "TAB") 'tab-to-tab-stop) + (indent-tabs-mode +1) + (setq tab-width custom-tab-width)) + +(add-hook 'prog-mode-hook 'enable-tabs) +(add-hook 'lisp-mode-hook 'disable-tabs) +(add-hook 'emacs-lisp-mode-hook 'disable-tabs) + ;;;; Packages (straight.el) (defvar bootstrap-version) @@ -53,3 +64,23 @@ ;; Magit (git frontend) (use-package magit) + +;; Rainbow-Mode (show hex strings in color) +(use-package rainbow-mode) + +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(custom-safe-themes + '("5abd9e0076c5e1a0c81d963040b81fb58b986006c2b0c472b0afb985fe704b87" default))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + ) + +;; Set theme +(load-theme 'my-theme) diff --git a/my-theme-theme.el b/my-theme-theme.el new file mode 100644 index 0000000..ead82c2 --- /dev/null +++ b/my-theme-theme.el @@ -0,0 +1,85 @@ +(deftheme my-theme) + +(let* (;; Helper functions + (face (lambda (face &rest args) + (let ((build-face #'(lambda (termspec type args) + (append `(,termspec) + (if (plist-get args :fg) (if (nth type (plist-get args :fg)) + `(:foreground ,(nth type (plist-get args :fg))))) + (if (plist-get args :bg) (if (nth type (plist-get args :bg)) + `(:background ,(nth type (plist-get args :bg))))))))) + `(,face + ,`(,(funcall build-face '((class color) (min-colors 257)) 0 args) + ,(funcall build-face '((class color) (min-colors 256)) 1 args) + ,(funcall build-face '((class color) (min-colors 16)) 2 args)))))) + (color-join (lambda (list) + (format "#%02x%02x%02x" + (ash (nth 0 list) -8) + (ash (nth 1 list) -8) + (ash (nth 2 list) -8)))) + (color-blend (lambda (c1 c2 alpha) + (let ((blend (lambda (a b alpha) + (round (+ + (* a alpha) + (* b (- 1 alpha))))))) + `(,(funcall blend (nth 0 c1) (nth 0 c2) alpha) + ,(funcall blend (nth 1 c1) (nth 1 c2) alpha) + ,(funcall blend (nth 2 c1) (nth 2 c2) alpha))))) + (blend (lambda (c1 c2 alpha) + (funcall color-join + (funcall color-blend + (color-values c1) + (color-values c2) + alpha)))) + (darken (lambda (color amount) + (funcall blend + "#000000" + color + amount))) + (brighten (lambda (color amount) + (funcall blend + "#ffffff" + color + amount))) + (darken-first (lambda (color amount) + (append + `(,(funcall darken (car color) amount)) + (cdr color)))) + (brighten-first (lambda (color amount) + (append + `(,(funcall brighten (car color) amount)) + (cdr color)))) + ;; name full 256 16 + (common-fg '("#b7c9ee" "white" "white")) + (common-bg '("#0d1017" "black" "black")) + (modeline '("#156570" nil nil)) + (comment '("#384345" nil nil)) + (doc '("#6a866f" nil nil)) + (keyword '("#349672" nil nil)) + (preprocessor '("#5ca9af" nil nil)) + (function '("#5fc995" nil nil)) + (variable '("#6ec5b1" nil nil)) + (string '("#15e04a" nil nil)) + (type '("#17b343" nil nil)) + ;; Extra colors #1fa345 + ) + (custom-theme-set-faces + 'my-theme + (funcall face 'default :fg common-fg :bg common-bg) + (funcall face 'cursor :bg common-fg) + (funcall face 'line-number-current-line :fg common-fg) + (funcall face 'line-number :fg (funcall darken-first common-fg 0.25)) + (funcall face 'mode-line-inactive :bg (funcall darken-first common-bg 0.35) :fg common-fg) + (funcall face 'mode-line :bg modeline :fg common-fg) + (funcall face 'hl-line :bg (funcall darken-first common-bg 0.15)) + (funcall face 'font-lock-comment-face :fg comment) + (funcall face 'font-lock-doc-face :fg doc) + (funcall face 'font-lock-keyword-face :fg keyword) + (funcall face 'font-lock-preprocessor-face :fg preprocessor) + (funcall face 'font-lock-function-name-face :fg function) + (funcall face 'font-lock-variable-name-face :fg variable) + (funcall face 'font-lock-string-face :fg string) + (funcall face 'font-lock-type-face :fg type) + )) + +(provide-theme 'my-theme)