emacs/my-theme-theme.el

117 lines
5.3 KiB
EmacsLisp
Executable file

(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)))))
(if (plist-member args :italic) '(:slant italic))))))
`(,face
,`(
,(funcall build-face '((min-colors 0)) 0 args)
;;,(funcall build-face '((min-colors 256)) 0 args)
;;,(funcall build-face '((min-colors 8)) 1 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 8
(common-fg '("#b7c9ee" "white"))
(common-bg '("#0d1017" "black"))
(modeline '("#156570" "white"))
(highlight (funcall brighten-first common-bg 0.15))
(comment '("#42767d" "red"))
(doc '("#6a866f" "red"))
(keyword '("#349672" "cyan"))
(preprocessor '("#5ca9af" "cyan"))
(function '("#5fc995" "white"))
(variable '("#6ec5b1" "white"))
(string '("#15e04a" "green"))
(type '("#17b343" "white"))
(lsp-hover-highlight (funcall brighten-first common-bg 0.05))
(company-bg (funcall brighten-first common-bg 0.1))
(peek-code '("#0e151a" 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 'highlight :bg highlight)
(funcall face 'region :bg highlight)
(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-property-name-face :fg variable :italic)
(funcall face 'font-lock-string-face :fg string)
(funcall face 'font-lock-type-face :fg type)
;; Lsp
(funcall face 'lsp-face-highlight-textual :bg lsp-hover-highlight)
(funcall face 'lsp-face-highlight-read :bg lsp-hover-highlight)
(funcall face 'lsp-face-highlight-write :bg lsp-hover-highlight)
(funcall face 'lsp-ui-peek-filename :fg common-fg)
(funcall face 'lsp-ui-peek-header :bg modeline)
(funcall face 'lsp-ui-peek-peek :bg peek-code)
(funcall face 'lsp-ui-peek-list :bg peek-code)
(funcall face 'lsp-ui-peek-selection :bg highlight)
(funcall face 'lsp-ui-peek-highlight :bg highlight)
;; Company
(funcall face 'company-tooltip :bg company-bg)
(funcall face 'company-tooltip-selection :bg (funcall brighten-first company-bg 0.15))
(funcall face 'company-scrollbar-fg :bg (funcall brighten-first company-bg 0.3))
(funcall face 'company-scrollbar-bg :bg (funcall brighten-first company-bg 0.15))
))
(provide-theme 'my-theme)