165 lines
4.9 KiB
EmacsLisp
165 lines
4.9 KiB
EmacsLisp
;;; init-ui.el --- ui and other style customization cofig -*- lexical-binding: t -*-
|
||
|
||
;;; Commentary:
|
||
|
||
;;; Code:
|
||
|
||
;; 设置系统编码
|
||
(when (fboundp 'set-charset-priority)
|
||
(set-charset-priority 'unicode))
|
||
|
||
(if *is-windows*
|
||
(progn
|
||
(set-language-environment 'chinese-gbk)
|
||
(prefer-coding-system 'utf-8-auto))
|
||
(progn
|
||
(set-language-environment "UTF-8")
|
||
(prefer-coding-system 'utf-8)))
|
||
|
||
;; 安装autothemer
|
||
(use-package autothemer)
|
||
|
||
;; 预览所有可用emacs颜色
|
||
(defun my-color-picker ()
|
||
"Pick a color with preview."
|
||
(interactive)
|
||
(let* ((colors (defined-colors))
|
||
(choice (completing-read
|
||
"Color: "
|
||
(mapcar (lambda (c)
|
||
(propertize
|
||
(format "%-20s %s" c "████")
|
||
'face `(:foreground ,c)))
|
||
colors))))
|
||
(string-trim (car (split-string choice)))))
|
||
|
||
;; rainbow mode
|
||
(use-package rainbow-mode)
|
||
|
||
;; 自定义主题路径
|
||
(add-to-list 'custom-theme-load-path "c:/Users/gaozh/AppData/Roaming/.emacs.d/lisp/")
|
||
|
||
;; 安装solarized dark
|
||
(use-package solarized-theme)
|
||
(load-theme 'solarized-dark t)
|
||
|
||
;; 很多主题
|
||
(use-package doom-themes)
|
||
(use-package color-theme-modern)
|
||
(use-package naysayer-theme)
|
||
|
||
;; 信任所有主题
|
||
(setq custom-safe-themes t)
|
||
|
||
;; 安装smart-mode-line
|
||
(use-package smart-mode-line
|
||
:defer 0.5
|
||
:config
|
||
(setq sml/no-confirm-load-theme t)
|
||
;; sml/theme 'respectful)
|
||
(sml/setup))
|
||
|
||
;; eshell高亮
|
||
(use-package eshell-syntax-highlighting
|
||
:hook (eshell-mode . eshell-syntax-highlighting-global-mode))
|
||
|
||
(add-hook 'eshell-mode-hook
|
||
(lambda ()
|
||
(setenv "TERM" "xterm-256color")
|
||
(setenv "COLORTERM" "truecolor")
|
||
(add-to-list 'eshell-output-filter-functions 'eshell-handle-ansi-color t)
|
||
(setq-local eshell-prefer-lisp-functions nil)
|
||
(setenv "LS_COLORS"
|
||
"di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46")
|
||
(setenv "GIT_CONFIG_GLOBAL" (expand-file-name "~/.emacs.d/.gitconfig-eshell"))))
|
||
|
||
;; 高亮当前行
|
||
(global-hl-line-mode t)
|
||
|
||
;; 显示文件大小
|
||
(size-indication-mode t)
|
||
|
||
;; 显示行号列号
|
||
(column-number-mode t)
|
||
|
||
;; 配置字体
|
||
(defvar cn-fonts-list '("Sarasa Fixed TC" "STHeiti" "微软雅黑" "文泉译微米黑")
|
||
"定义使用的中文字体候选列表")
|
||
|
||
(defvar en-fonts-list '("Sarasa Fixed TC" "Courier New" "Monaco" "Ubuntu Mono")
|
||
"定义使用的英文字体候选列表")
|
||
|
||
(defvar emoji-fonts-list '("Apple Color Emoji" "Segoe UI Emoji" "Noto Color Emoji" "Symbola" "Symbol")
|
||
"定义使用Emoji字体候选列表")
|
||
|
||
(defun tenon--available-font (font-list)
|
||
"从 FONT-LIST 中寻找第一个系统中可用的字"
|
||
(catch 'found
|
||
(dolist (font font-list)
|
||
(when (member font (font-family-list))
|
||
(throw 'found font)))))
|
||
|
||
;; 设置字体大小和字重变量
|
||
(when *is-windows*
|
||
(defvar tenon-font-size 125
|
||
"默认字体大小")
|
||
(defvar tenon-font-weight 'light
|
||
"默认字重,选项有ultra-light,light,normal,medium,semibold,bold"))
|
||
|
||
(when *is-mac*
|
||
(defvar tenon-font-size 160
|
||
"默认字体大小")
|
||
(defvar tenon-font-weight 'light
|
||
"默认字重,选项有ultra-light,light,normal,medium,semibold,bold"))
|
||
|
||
;; 定义函数
|
||
;;;###autoload
|
||
(defun tenon--font-setup ()
|
||
"Font setup."
|
||
(interactive)
|
||
(let* ((cf (tenon--available-font cn-fonts-list))
|
||
(ef (tenon--available-font en-fonts-list))
|
||
(em (tenon--available-font emoji-fonts-list)))
|
||
(when ef
|
||
(dolist (face '(default fixed-pitch fixed-pitch-serif variable-pitch))
|
||
(set-face-attribute face nil
|
||
:family ef
|
||
:height tenon-font-size
|
||
:weight tenon-font-weight)))
|
||
(when em
|
||
(dolist (charset `(unicode unicode-bmp ,(if (> emacs-major-version 27) 'emoji 'symbol)))
|
||
(set-fontset-font t charset em nil 'prepend)))
|
||
(when cf
|
||
(dolist (charset '(kana han cjk-misc bopomofo))
|
||
(set-fontset-font t charset cf))
|
||
(setq face-font-rescale-alist
|
||
(mapcar (lambda (item) (cons item 1)) `(,cf ,em))))))
|
||
|
||
;; 延迟执行字体设置
|
||
(add-hook 'after-init-hook #'tenon--font-setup)
|
||
|
||
;; 添加个人字体到 cnfonts
|
||
(setq cnfonts-personal-fontnames
|
||
'(("Sarasa Fixed TC") ; 英文字体
|
||
("Sarasa Fixed TC") ; 中文字体
|
||
nil ; Ext-B 字体(可选)
|
||
nil ; Symbol 字体(可选)
|
||
nil)) ; 装饰字体(可选)
|
||
|
||
;; 安装cnfonts脚本,用于修复中英文对齐
|
||
(use-package cnfonts
|
||
:defer 0
|
||
:config
|
||
(cnfonts-mode 1)
|
||
(cnfonts--select-profile "profile1"))
|
||
|
||
;; 主题修复脚本
|
||
(defun fix-theme-colors ()
|
||
"Fix invalid color name in theme files."
|
||
(interactive)
|
||
(load-file (expand-file-name "~/.emacs.d/lisp/fix-theme-colors.el")))
|
||
|
||
(provide 'init-ui)
|
||
|
||
;;; init-ui.el ends here
|