From c8f45404a06da908e8780ff11378f4ecb4f1e1fc Mon Sep 17 00:00:00 2001 From: Zelong Kuang Date: Sun, 14 Dec 2025 04:51:24 +1100 Subject: [PATCH] Initial commit --- .gitignore | 56 ++++++++++++++ custom.el | 16 ++++ early-init.el | 3 + lisp/init-better-default.el | 21 +++++ lisp/init-bindings.el | 12 +++ lisp/init-coding.el | 5 ++ lisp/init-completion.el | 150 ++++++++++++++++++++++++++++++++++++ lisp/init-edit.el | 9 +++ lisp/init-meow.el | 94 ++++++++++++++++++++++ lisp/init-org.el | 54 +++++++++++++ lisp/init-snippet.el | 10 +++ lisp/init-ui.el | 109 ++++++++++++++++++++++++++ 12 files changed, 539 insertions(+) create mode 100644 .gitignore create mode 100644 custom.el create mode 100644 early-init.el create mode 100644 lisp/init-better-default.el create mode 100644 lisp/init-bindings.el create mode 100644 lisp/init-coding.el create mode 100644 lisp/init-completion.el create mode 100644 lisp/init-edit.el create mode 100644 lisp/init-meow.el create mode 100644 lisp/init-org.el create mode 100644 lisp/init-snippet.el create mode 100644 lisp/init-ui.el diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..907145a --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# generated by macOS +.DS_Store + +# machine generated doom profiles or metadata +/profiles/*.el +/.local*/ + +# possible user config files +/profiles.el +/init.el +/config.el +/packages.el + +# generated by elisp packages in sub-directories +*~ +*.*~ +\#* +.\#* +*.cache* +*.log +*.elc +*.eln +*.lib +*.fas +*.dat +*.eld +*.rel +*_archive +*_flymake.* +.dap-breakpoints +.emacs.desktop +.emacs.desktop.lock +.org-id-locations +.projectile +.tern-port +.yas-compiled-snippets.el +flycheck_*.el + +# generated by elisp packages at root +/.local/ +/.cask/ +/auto/ +/auto-save-list/ +/cask/ +/ede-projects.el +/eln-cache/ +/elpa/ +/eshell/ +/network-security.data +/places +/semanticdb +/server/ +/smex-items +/tramp +/transient/ +/var/ diff --git a/custom.el b/custom.el new file mode 100644 index 0000000..be5d5a3 --- /dev/null +++ b/custom.el @@ -0,0 +1,16 @@ +;;; -*- lexical-binding: t -*- +(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 + '("b3db0d7354ef14156b4d16d406b85ef4441e45a54841e11a49d6bc4933eebf58" + default)) + '(org-agenda-files '("~/org/workout.org"))) +(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. + ) diff --git a/early-init.el b/early-init.el new file mode 100644 index 0000000..9bd3573 --- /dev/null +++ b/early-init.el @@ -0,0 +1,3 @@ +;; -*- lexical-binding: t -*- + +(setq package-enable-at-startup nil) diff --git a/lisp/init-better-default.el b/lisp/init-better-default.el new file mode 100644 index 0000000..6966753 --- /dev/null +++ b/lisp/init-better-default.el @@ -0,0 +1,21 @@ +;; -*- lexical-binding: t -*- +(tool-bar-mode -1) +(scroll-bar-mode -1) +(display-line-numbers-mode 1) +(setq-default cursor-type 'bar) +(setq display-line-numbers 'relative) +(show-paren-mode t) +(recentf-mode 1) +(setq recentf-max-menu-item 10) +(setq make-backup-files nil) +(setq custom-file (expand-file-name "~/.emacs.d/custom.el")) +(load custom-file 'no-error 'no-message) + +(global-set-key (kbd "s-a") 'mark-whole-buffer) ;;对应Windows上面的Ctrl-a 全选 +(global-set-key (kbd "s-c") 'kill-ring-save) ;;对应Windows上面的Ctrl-c 复制 +(global-set-key (kbd "s-s") 'save-buffer) ;; 对应Windows上面的Ctrl-s 保存 +(global-set-key (kbd "s-v") 'yank) ;对应Windows上面的Ctrl-v 粘贴 +(global-set-key (kbd "s-z") 'undo) ;对应Windows上面的Ctrol-z 撤销 +(global-set-key (kbd "s-x") 'sexp) ;对应Windows上面的Ctrol-x 剪切 + +(provide 'init-better-default) diff --git a/lisp/init-bindings.el b/lisp/init-bindings.el new file mode 100644 index 0000000..8303621 --- /dev/null +++ b/lisp/init-bindings.el @@ -0,0 +1,12 @@ +;; -*- lexical-binding: t -*- + +(define-prefix-command 'orgmode-map) +(global-set-key (kbd "C-c n") 'orgmode-map) + +(define-key orgmode-map (kbd "a") #'org-agenda) +(define-key orgmode-map (kbd "n") #'org-capture) + +(global-set-key (kbd "C-c g") #'magit-status) + + +(provide 'init-bindings) diff --git a/lisp/init-coding.el b/lisp/init-coding.el new file mode 100644 index 0000000..26a3c5d --- /dev/null +++ b/lisp/init-coding.el @@ -0,0 +1,5 @@ +;; -*- lexical-binding: t -*- + +(use-package magit) + +(provide 'init-coding) diff --git a/lisp/init-completion.el b/lisp/init-completion.el new file mode 100644 index 0000000..413e9b2 --- /dev/null +++ b/lisp/init-completion.el @@ -0,0 +1,150 @@ +;;; init-completion.el --- Initialize completion configurations. -*- lexical-binding: t -*- + +;; Copyright (C) 2016-2025 Vincent Zhang + +;; Author: Vincent Zhang +;; URL: https://github.com/seagle0128/.emacs.d + +;; This file is not part of GNU Emacs. +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 3, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth +;; Floor, Boston, MA 02110-1301, USA. +;; + +;;; Commentary: +;; +;; Modern completion configuration. +;; + + +;; Optionally use the `orderless' completion style. +(use-package orderless + :custom + (completion-styles '(orderless basic)) + (completion-category-defaults nil) + (completion-category-overrides '((file (styles basic partial-completion)))) + (orderless-component-separator #'orderless-escapable-split-on-space)) + +;; Support Pinyin +(use-package pinyinlib + :after orderless + :functions orderless-regexp + :autoload pinyinlib-build-regexp-string + :init + (defun orderless-regexp-pinyin (str) + "Match COMPONENT as a pinyin regex." + (orderless-regexp (pinyinlib-build-regexp-string str))) + (add-to-list 'orderless-matching-styles 'orderless-regexp-pinyin)) + +;; VERTical Interactive COmpletion +(use-package vertico + :custom (vertico-count 15) + :bind (:map vertico-map + ("RET" . vertico-directory-enter) + ("DEL" . vertico-directory-delete-char) + ("M-DEL" . vertico-directory-delete-word)) + :init + (vertico-mode t)) + +;; Enrich existing commands with completion annotations +(use-package marginalia + :hook (after-init . marginalia-mode)) + +;; Consulting completing-read +(use-package consult + :defines (xref-show-xrefs-function xref-show-definitions-function) + :defines shr-color-html-colors-alist + :autoload (consult-register-format consult-register-window consult-xref) + :autoload (consult--read consult--customize-put) + :commands (consult-narrow-help) + :functions (list-colors-duplicates consult-colors--web-list) + :bind (("C-s" . consult-line))) + + +(use-package consult-dir + :ensure t + :bind (("C-x C-d" . consult-dir) + :map minibuffer-local-completion-map + ("C-x C-d" . consult-dir) + ("C-x C-j" . consult-dir-jump-file))) + +(use-package embark + :commands embark-prefix-help-command + :bind (("C-;" . embark-act) + ("M-." . embark-dwim) ; overrides `xref-find-definitions' + ([remap describe-bindings] . embark-bindings) + :map minibuffer-local-map + ("M-." . my-embark-preview)) + :init + ;; Optionally replace the key help with a completing-read interface + (setq prefix-help-command #'embark-prefix-help-command)) +(use-package embark-consult + :bind (:map minibuffer-mode-map + ("C-c C-o" . embark-export)) + :hook (embark-collect-mode . consult-preview-at-point-mode)) + +;; Auto completion +(use-package corfu + :custom + (corfu-auto t) + (corfu-auto-prefix 2) + (corfu-count 12) + (corfu-preview-current nil) + (corfu-on-exact-match nil) + (corfu-auto-delay 0.2) + (corfu-popupinfo-delay '(0.4 . 0.2)) + (global-corfu-modes '((not erc-mode + circe-mode + help-mode + gud-mode + vterm-mode) + t)) + :custom-face + (corfu-border ((t (:inherit region :background unspecified)))) + :bind ("M-/" . completion-at-point) + :init + (global-corfu-mode) + (corfu-history-mode) + (corfu-popupinfo-mode) + :config + ;;Quit completion before saving + (add-hook 'before-save-hook #'corfu-quit) + (advice-add #'persistent-scratch-save :before #'corfu-quit)) + + +;; A few more useful configurations... +(use-package emacs + :ensure nil + :custom + ;; TAB cycle if there are only few candidates + ;; (completion-cycle-threshold 3) + + ;; Enable indentation+completion using the TAB key. + ;; `completion-at-point' is often bound to M-TAB. + (tab-always-indent 'complete) + + ;; Emacs 30 and newer: Disable Ispell completion function. As an alternative, + ;; try `cape-dict'. + (text-mode-ispell-word-completion nil) + + ;; Emacs 28 and newer: Hide commands in M-x which do not apply to the current + ;; mode. Corfu commands are hidden, since they are not used via M-x. This + ;; setting is useful beyond Corfu. + (read-extended-command-predicate #'command-completion-default-include-p)) + +(provide 'init-completion) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; init-completion.el ends here diff --git a/lisp/init-edit.el b/lisp/init-edit.el new file mode 100644 index 0000000..3588cd4 --- /dev/null +++ b/lisp/init-edit.el @@ -0,0 +1,9 @@ +;; -*- lexical-binding: t -*- + +(use-package smartparens + :config + (require 'smartparens-config) + (smartparens-global-mode)) + + +(provide 'init-edit) diff --git a/lisp/init-meow.el b/lisp/init-meow.el new file mode 100644 index 0000000..7b202e4 --- /dev/null +++ b/lisp/init-meow.el @@ -0,0 +1,94 @@ +;; -*- lexical-binding: t -*- + +(defun meow-setup () + (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty) + (meow-motion-define-key + '("j" . meow-next) + '("k" . meow-prev) + '("" . ignore)) + (meow-leader-define-key + ;; Use SPC (0-9) for digit arguments. + '("1" . meow-digit-argument) + '("2" . meow-digit-argument) + '("3" . meow-digit-argument) + '("4" . meow-digit-argument) + '("5" . meow-digit-argument) + '("6" . meow-digit-argument) + '("7" . meow-digit-argument) + '("8" . meow-digit-argument) + '("9" . meow-digit-argument) + '("0" . meow-digit-argument) + '("/" . meow-keypad-describe-key) + '("?" . meow-cheatsheet)) + (meow-normal-define-key + '("0" . meow-expand-0) + '("9" . meow-expand-9) + '("8" . meow-expand-8) + '("7" . meow-expand-7) + '("6" . meow-expand-6) + '("5" . meow-expand-5) + '("4" . meow-expand-4) + '("3" . meow-expand-3) + '("2" . meow-expand-2) + '("1" . meow-expand-1) + '("-" . negative-argument) + '(";" . meow-reverse) + '("," . meow-inner-of-thing) + '("." . meow-bounds-of-thing) + '("[" . meow-beginning-of-thing) + '("]" . meow-end-of-thing) + '("a" . meow-append) + '("A" . meow-open-below) + '("b" . meow-back-word) + '("B" . meow-back-symbol) + '("c" . meow-change) + '("d" . meow-delete) + '("D" . meow-backward-delete) + '("e" . meow-next-word) + '("E" . meow-next-symbol) + '("f" . meow-find) + '("g" . meow-cancel-selection) + '("G" . meow-grab) + '("h" . meow-left) + '("H" . meow-left-expand) + '("i" . meow-insert) + '("I" . meow-open-above) + '("j" . meow-next) + '("J" . meow-next-expand) + '("k" . meow-prev) + '("K" . meow-prev-expand) + '("l" . meow-right) + '("L" . meow-right-expand) + '("m" . meow-join) + '("n" . meow-search) + '("o" . meow-block) + '("O" . meow-to-block) + '("p" . meow-yank) + '("q" . meow-quit) + '("Q" . meow-goto-line) + '("r" . meow-replace) + '("R" . meow-swap-grab) + '("s" . meow-kill) + '("t" . meow-till) + '("u" . meow-undo) + '("U" . meow-undo-in-selection) + '("v" . meow-visit) + '("w" . meow-mark-word) + '("W" . meow-mark-symbol) + '("x" . meow-line) + '("X" . meow-goto-line) + '("y" . meow-save) + '("Y" . meow-sync-grab) + '("z" . meow-pop-selection) + '("'" . repeat) + '("" . ignore))) + +(use-package meow + :init + (meow-global-mode 1) + :config + (meow-setup) + (setq meow-cursor-type-normal 'bar) + ) + +(provide 'init-meow) diff --git a/lisp/init-org.el b/lisp/init-org.el new file mode 100644 index 0000000..6f13a8a --- /dev/null +++ b/lisp/init-org.el @@ -0,0 +1,54 @@ +;; -*- lexical-binding: t -*- + +;; (defun org-capture-init() +;; (setq org-capture-templates +;; '(("t" "Personal todo" entry ("Inbox") +;; "* TODO %?\n%i\n%a" :prepend t)))) + +(use-package org + :defer + :ensure `(org :repo "https://code.tecosaur.net/tec/org-mode.git/" + :branch "dev") + :hook (org-mode . org-modern-mode) + :config + ;; (org-capture-init) + (add-to-list 'org-modules 'org-habit) + (setq org-directory "~/org/") + ) +(use-package org-modern + :config + (setq org-modern-table nil)) + +(use-package org-latex-preview + :defer + :ensure nil + :config + ;; Increase preview width + (plist-put org-latex-preview-appearance-options + :page-width 0.8) + + ;; ;; Use dvisvgm to generate previews + ;; ;; You don't need this, it's the default: + ;; (setq org-latex-preview-process-default 'dvisvgm) + + ;; Turn on `org-latex-preview-mode', it's built into Org and much faster/more + ;; featured than org-fragtog. (Remember to turn off/uninstall org-fragtog.) + (add-hook 'org-mode-hook 'org-latex-preview-mode) + + ;; ;; Block C-n, C-p etc from opening up previews when using `org-latex-preview-mode' + ;; (setq org-latex-preview-mode-ignored-commands + ;; '(next-line previous-line mwheel-scroll + ;; scroll-up-command scroll-down-command)) + + ;; ;; Enable consistent equation numbering + ;; (setq org-latex-preview-numbered t) + + ;; Bonus: Turn on live previews. This shows you a live preview of a LaTeX + ;; fragment and updates the preview in real-time as you edit it. + ;; To preview only environments, set it to '(block edit-special) instead + (setq org-latex-preview-mode-display-live t) + + ;; More immediate live-previews -- the default delay is 1 second + (setq org-latex-preview-mode-update-delay 0.25)) + +(provide 'init-org) diff --git a/lisp/init-snippet.el b/lisp/init-snippet.el new file mode 100644 index 0000000..4cd6c8c --- /dev/null +++ b/lisp/init-snippet.el @@ -0,0 +1,10 @@ +(use-package! yasnippet + :config + (defun my-yas-try-expanding-auto-snippets () + (when yas-minor-mode + (let ((yas-buffer-local-condition ''(require-snippet-condition . auto))) + (yas-expand)))) + (add-hook 'post-command-hook #'my-yas-try-expanding-auto-snippets) + ) + +(provide 'init-snippet) diff --git a/lisp/init-ui.el b/lisp/init-ui.el new file mode 100644 index 0000000..092e617 --- /dev/null +++ b/lisp/init-ui.el @@ -0,0 +1,109 @@ +;; -*- lexical-binding: t -*- + +(setq idle-update-delay 1.0) + +(setq-default cursor-in-non-selected-windows nil) +(setq highlight-nonselected-windows nil) + +(setq fast-but-imprecise-scrolling t) +(setq redisplay-skip-fontification-on-input t) + +(setq frame-inhibit-implied-resize t + frame-resize-pixelwise t) + +(use-package solaire-mode + :hook (after-init . solaire-global-mode)) +(use-package ef-themes + :ensure t + :init + ;; This makes the Modus commands listed below consider only the Ef + ;; themes. For an alternative that includes Modus and all + ;; derivative themes (like Ef), enable the + ;; `modus-themes-include-derivatives-mode' instead. The manual of + ;; the Ef themes has a section that explains all the possibilities: + ;; + ;; - Evaluate `(info "(ef-themes) Working with other Modus themes or taking over Modus")' + ;; - Visit + (ef-themes-take-over-modus-themes-mode 1) + :bind + (("" . modus-themes-rotate) + ("C-" . modus-themes-select) + ("M-" . modus-themes-load-random)) + :config + ;; All customisations here. + (setq modus-themes-mixed-fonts t) + (setq modus-themes-italic-constructs t) + + ;; Finally, load your theme of choice (or a random one with + ;; `modus-themes-load-random', `modus-themes-load-random-dark', + ;; `modus-themes-load-random-light'). + (modus-themes-load-theme 'ef-day)) + +(use-package rainbow-delimiters + :hook ((prog-mode . rainbow-delimiters-mode) + (typst-ts-mode . rainbow-delimiters-mode) + (foo-mode . rainbow-delimiters-mode))) + +(use-package doom-modeline + :init (doom-modeline-mode 1)) + +(use-package hide-mode-line + :autoload turn-off-hide-mode-line-mode + :hook (((eat-mode + eshell-mode shell-mode + term-mode vterm-mode + embark-collect-mode lsp-ui-imenu-mode + pdf-annot-list-mode) . turn-on-hide-mode-line-mode))) + +;; Suppress GUI features +(setq use-file-dialog nil + use-dialog-box nil + inhibit-startup-screen t + inhibit-startup-echo-area-message user-login-name + inhibit-default-init t + initial-scratch-message nil) +(unless (daemonp) + (advice-add #'display-startup-echo-area-message :override #'ignore)) + +;; Display dividers between windows +(setq window-divider-default-places t + window-divider-default-bottom-width 1 + window-divider-default-right-width 1) +(add-hook 'window-setup-hook #'window-divider-mode) + +(pcase system-type + ('darwin ; macOS + (set-face-attribute 'default nil :font "Maple Mono-16") + (add-to-list 'default-frame-alist '(height . 53)) + (add-to-list 'default-frame-alist '(width . 120))) + + ('gnu/linux ; Linux (including Debian) + (set-face-attribute 'default nil :font "Maple Mono-16") ; 20 * 1.5 + (add-to-list 'default-frame-alist '(height . 40)) + (add-to-list 'default-frame-alist '(width . 100)))) + + + +;; Easily adjust the font size in all frames +(use-package default-text-scale + :hook (after-init . default-text-scale-mode) + :bind (:map default-text-scale-mode-map + ("s-=" . default-text-scale-increase) + ("s--" . default-text-scale-decrease) + ("s-0" . default-text-scale-reset) + ("C-s-=" . default-text-scale-increase) + ("C-s--" . default-text-scale-decrease) + ("C-s-0" . default-text-scale-reset))) + +(setq hscroll-step 1 + hscroll-margin 2 + scroll-step 1 + scroll-margin 0 + scroll-conservatively 100000 + scroll-preserve-screen-position t + auto-window-vscroll nil + ;; mouse + mouse-wheel-scroll-amount-horizontal 1 + mouse-wheel-progressive-speed nil) + +(provide 'init-ui)