move some configurations to local.el, not version controlled

This commit is contained in:
2026-07-23 18:32:25 +08:00
parent 33a7b314e6
commit 6a5f996b1a
2 changed files with 26 additions and 77 deletions
+3
View File
@@ -4,6 +4,9 @@
.#* .#*
.cache .cache
/local.el
/custom-file.el
/elpa /elpa
/eshell /eshell
/tree-sitter /tree-sitter
+23 -77
View File
@@ -1,16 +1,28 @@
;; package sources ;;=======================================
;; Local mirror of package archives
;;=======================================
(require 'package) (require 'package)
(setq package-archives '(("gnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/") (setq package-archives '(("gnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
("nongnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/nongnu/") ("nongnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/nongnu/")
("melpa" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/"))) ("melpa" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
(package-initialize) (package-initialize)
;; load local config script (not git controlled, like .env file)
;;=======================================
;; Load local config script
;; (not git controlled, like .env file)
;;=======================================
(setq local-file (expand-file-name "local.el" user-emacs-directory)) (setq local-file (expand-file-name "local.el" user-emacs-directory))
(when (file-exists-p local-file) (when (file-exists-p local-file)
(load-file local-file)) (load-file local-file))
;; handy settings
;;===================
;; Handy settings
;;===================
(tool-bar-mode -1) (tool-bar-mode -1)
(scroll-bar-mode -1) (scroll-bar-mode -1)
(global-display-line-numbers-mode 0) (global-display-line-numbers-mode 0)
@@ -35,30 +47,22 @@
(setq custom-file (expand-file-name "custom-file.el" user-emacs-directory)) (setq custom-file (expand-file-name "custom-file.el" user-emacs-directory))
(load custom-file) (load custom-file)
;; end handy settings
;; backup settings
;;====================
;; Backup settings
;;====================
(setq backup-directory-alist `(("." . "~/.emacs.d/backups/"))) (setq backup-directory-alist `(("." . "~/.emacs.d/backups/")))
(setq version-control t) ; 开启多版本备份 (setq version-control t) ; 开启多版本备份
(setq kept-old-versions 2) ; 保留最早的2个版本 (setq kept-old-versions 2) ; 保留最早的2个版本
(setq kept-new-versions 6) ; 保留最新的6个版本 (setq kept-new-versions 6) ; 保留最新的6个版本
(setq delete-old-versions t) ; 自动删除中间的多余版本 (setq delete-old-versions t) ; 自动删除中间的多余版本
;; treesit
(setq treesit-language-source-alist
'((c3 "https://github.com/c3lang/tree-sitter-c3")))
;; org ;;======================
(global-set-key (kbd "C-c c") 'org-capture) ;; Important packages
;;======================
(setq org-capture-templates
'(("d" "draft" entry
(file+headline "~/org/draft.org" "草稿本")
"* %? \n TIME: %U\n %i" :empty-lines 1)))
;; packages
(use-package use-package-treesit
:ensure t)
(use-package gruber-darker-theme (use-package gruber-darker-theme
:ensure t :ensure t
@@ -71,61 +75,3 @@
(setq dimmer-fraction 0.3) ; 调整变暗的程度(0.0 到y 1.0,越大越暗,0.3 刚刚好) (setq dimmer-fraction 0.3) ; 调整变暗的程度(0.0 到y 1.0,越大越暗,0.3 刚刚好)
:config :config
(dimmer-mode 1)) (dimmer-mode 1))
(use-package ace-window
:ensure t
:bind ("M-o" . ace-window))
(use-package treemacs
:ensure t
:defer t
:bind
("C-x t" . treemacs) ; 依然沿用你习惯的 C-x t 来开关
:config
(setq treemacs-position 'left ; 放在左边
treemacs-width 30 ; 宽度为 30
treemacs-is-never-other-window t ; 用 C-x o 切换分屏时,光标会自动跳过侧边栏,非常舒服
treemacs-file-follow-mode 'always)) ; 右边看什么代码,左边目录就自动高亮到哪里
(use-package projectile
:ensure t
:init
(projectile-mode +1)
:bind-keymap
("C-c p" . projectile-command-map) ; 统一把 C-c p 作为所有项目操作的前缀
:config
(setq projectile-sort-order 'recentf) ; 优先展示最近打开过的小伙伴
(setq projectile-project-search-path '("~/workspace/" "~/code/")))
(use-package go-mode
:ensure t
:hook (go-mode . eglot-ensure) ; 进入 go-mode 自动启动 eglot
:config
;; 配置 eglot 在保存时自动格式化和整理导包
(add-hook 'before-save-hook
(lambda ()
(when (derived-mode-p 'go-mode)
;; 相当于 goimports 的效果
(eglot-code-actions nil nil "source.organizeImports" t)
;; 相当于 gofmt 的效果
(eglot-format-buffer)))))
(use-package crystal-mode
:ensure t
:init
(autoload 'crystal-mode "crystal-mode" "Major mode for crystal files" t)
(add-to-list 'auto-mode-alist '("\\.cr$" . crystal-mode))
(add-to-list 'interpreter-mode-alist '("crystal" . crystal-mode))(autoload 'crystal-mode "crystal-mode" "Major mode for crystal files" t)
(add-to-list 'auto-mode-alist '("\\.cr$" . crystal-mode))
(add-to-list 'interpreter-mode-alist '("crystal" . crystal-mode)))
(use-package gleam-ts-mode
:ensure t
:mode (rx ".gleam" eos))
;; vendor
(add-to-list 'load-path (expand-file-name "vendor/c3-ts-mode" user-emacs-directory))
(require 'c3-ts-mode)
(add-to-list 'load-path (expand-file-name "vendor/odin-mode" user-emacs-directory))
(require 'odin-mode)