This commit is contained in:
Zelong Kuang
2025-12-14 09:04:11 +11:00
parent 2321eb603b
commit 753ea5ea48
185 changed files with 1608 additions and 18 deletions

View File

@@ -1,7 +1,8 @@
;; -*- lexical-binding: t -*-
(tool-bar-mode -1)
(scroll-bar-mode -1)
(global-display-line-numbers-mode)
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
(add-hook 'org-mode-hook #'display-line-numbers-mode)
(setq-default cursor-type 'bar)
(setq display-line-numbers 'relative)
(show-paren-mode t)
@@ -24,4 +25,11 @@
(global-set-key (kbd "C-x C-b") 'ibuffer)
(use-package ultra-scroll
:init
(setq scroll-conservatively 3
scroll-margin 0)
:config
(ultra-scroll-mode 1))
(provide 'init-better-default)

View File

@@ -7,7 +7,11 @@
(define-key orgmode-map (kbd "n") #'org-capture)
(define-key orgmode-map (kbd "t") #'org-todo-list)
(global-set-key (kbd "C-\\") #'vterm)
(setq duplicate-line-final-position 1)
(global-set-key (kbd "M-p") #'duplicate-dwim)
(global-set-key (kbd "C-c y") #'copy-from-above-command)
(global-set-key (kbd "s-k") #'kill-current-buffer)
(provide 'init-bindings)

View File

@@ -1,6 +1,7 @@
;; -*- lexical-binding: t -*-
(use-package magit
:defer
:bind ("C-c g" . magit-status)
:config
(setq magit-show-long-lines-warning nil))
@@ -15,6 +16,26 @@
;; :config
;; )
(use-package vterm)
(use-package vterm
:defer
:bind ("C-\\" . vterm))
(use-package editorconfig
:diminish
:hook after-init)
(use-package yaml-mode)
;; Fish shell mode and auto-formatting
(use-package fish-mode
:defer t
:commands fish_indent-before-save
:defines eglot-server-programs
:hook (fish-mode . (lambda ()
"Integrate `fish_indent` formatting with Fish shell mode."
(add-hook 'before-save-hook #'fish_indent-before-save)))
:config
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(fish-mode . ("fish-lsp" "start")))))
(provide 'init-coding)

View File

@@ -70,7 +70,11 @@
:autoload (consult--read consult--customize-put)
:commands (consult-narrow-help)
:functions (list-colors-duplicates consult-colors--web-list)
:bind (("C-s" . consult-line)))
:bind (("s-f" . consult-line)
("C-c s s" . consult-line)
("C-c p f" . consult-project-buffer)
("C-c f r" . consult-recent-file)
("C-c s p" . consult-ripgrep)))
(use-package consult-dir

10
lisp/init-dashboard.el Normal file
View File

@@ -0,0 +1,10 @@
;; -*- lexical-binding: t; -*-
(use-package dashboard
:demand t
:bind ("<f2>" . dashboard-open)
:config
(dashboard-setup-startup-hook))
(provide 'init-dashboard)

16
lisp/init-dired.el Normal file
View File

@@ -0,0 +1,16 @@
;; -*- lexical-binding: t -*-
(use-package dired
:ensure nil
:bind (:map dired-mode-map
("C-c C-p" . wdired-change-to-wdired-mode))
:config
;; Always delete and copy recursively
(setq dired-recursive-deletes 'always
dired-recursive-copies 'always)
;; Show directory first
;; (setq dired-listing-switches "-alh --group-directories-first")
)
(provide 'init-dired)

View File

@@ -9,7 +9,28 @@
:init
(winum-mode)
:config
(winum-set-keymap-prefix (kbd "C-c w")) )
(winum-set-keymap-prefix (kbd "C-c w")))
;; Yasnippet settings
(use-package yasnippet
:ensure t
:hook ((LaTeX-mode . yas-minor-mode)
(post-self-insert . my/yas-try-expanding-auto-snippets))
:config
(use-package warnings
:config
(cl-pushnew '(yasnippet backquote-change)
warning-suppress-types
:test 'equal))
(setq yas-triggers-in-field t)
;; Function that tries to autoexpand YaSnippets
;; The double quoting is NOT a typo!
(defun my/yas-try-expanding-auto-snippets ()
(when (and (boundp 'yas-minor-mode) yas-minor-mode)
(let ((yas-buffer-local-condition ''(require-snippet-condition . auto)))
(yas-expand)))))
(provide 'init-edit)

View File

@@ -1,6 +1,6 @@
;; -*- lexical-binding: t -*-
(defun meow-setup ()
(defun meow-setup()
(setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
(meow-motion-define-key
'("j" . meow-next)
@@ -84,6 +84,7 @@
'("<escape>" . ignore)))
(use-package meow
:demand t
:init
(meow-global-mode 1)
:config

View File

@@ -9,17 +9,57 @@
:defer
:ensure `(org :repo "https://code.tecosaur.net/tec/org-mode.git/"
:branch "dev")
:hook (org-mode . org-modern-mode)
;; :hook (org-mode . org-indent-mode)
:config
;; (org-capture-init)
(add-to-list 'org-modules 'org-habit)
(setq org-modules '(org-habit))
(setq org-directory "~/org/")
(add-to-list 'org-agenda-files "~/org")
)
(use-package org-contrib)
(with-eval-after-load 'org
(setq org-highlight-latex-and-related '(native script entities)))
(use-package org-modern
:hook (org-mode . org-modern-mode)
:hook (org-agenda-finalize . org-modern-agenda)
:init
(with-eval-after-load 'org
(setq org-hide-emphasis-markers t
org-pretty-entities t))
:config
(setq org-modern-table nil))
(use-package org-appear
:defer)
(use-package hl-todo
:hook (prog-mode . hl-todo-mode)
:hook (yaml-mode . hl-todo-mode)
:config
(setq hl-todo-highlight-punctuation ":"
hl-todo-keyword-faces
'(;; For reminders to change or add something at a later date.
("TODO" warning bold)
;; For code (or code paths) that are broken, unimplemented, or slow,
;; and may become bigger problems later.
("FIXME" error bold)
;; For code that needs to be revisited later, either to upstream it,
;; improve it, or address non-critical issues.
("REVIEW" font-lock-keyword-face bold)
;; For code smells where questionable practices are used
;; intentionally, and/or is likely to break in a future update.
("HACK" font-lock-constant-face bold)
;; For sections of code that just gotta go, and will be gone soon.
;; Specifically, this means the code is deprecated, not necessarily
;; the feature it enables.
("DEPRECATED" font-lock-doc-face bold)
;; Extra keywords commonly found in the wild, whose meaning may vary
;; from project to project.
("NOTE" success bold)
("BUG" error bold)
("XXX" font-lock-constant-face bold))))
(use-package org-latex-preview
:defer
@@ -55,6 +95,7 @@
(use-package org-roam
:ensure t
:defer
:custom
(org-roam-directory (file-truename "~/org/roam"))
:bind (("C-c n l" . org-roam-buffer-toggle)
@@ -71,6 +112,7 @@
;; If using org-roam-protocol
(require 'org-roam-protocol))
(use-package org-roam-ui)
(use-package org-roam-ui
:defer t)
(provide 'init-org)

67
lisp/init-tex.el Normal file
View File

@@ -0,0 +1,67 @@
(use-package latex
:ensure auctex
:hook ((LaTeX-mode . prettify-symbols-mode))
:bind (:map LaTeX-mode-map
("C-S-e" . latex-math-from-calc))
:config
;; Format math as a Latex string with Calc
(defun latex-math-from-calc ()
"Evaluate `calc' on the contents of line at point."
(interactive)
(cond ((region-active-p)
(let* ((beg (region-beginning))
(end (region-end))
(string (buffer-substring-no-properties beg end)))
(kill-region beg end)
(insert (calc-eval `(,string calc-language latex
calc-prefer-frac t
calc-angle-mode rad)))))
(t (let ((l (thing-at-point 'line)))
(end-of-line 1) (kill-line 0)
(insert (calc-eval `(,l
calc-language latex
calc-prefer-frac t
calc-angle-mode rad))))))))
(use-package cdlatex
:ensure t
:hook (LaTeX-mode . turn-on-cdlatex)
:bind (:map cdlatex-mode-map
("<tab>" . cdlatex-tab)))
(use-package cdlatex
:hook ((cdlatex-tab . yas-expand)
(cdlatex-tab . cdlatex-in-yas-field))
:config
(use-package yasnippet
:bind (:map yas-keymap
("<tab>" . yas-next-field-or-cdlatex)
("TAB" . yas-next-field-or-cdlatex))
:config
(defun cdlatex-in-yas-field ()
;; Check if we're at the end of the Yas field
(when-let* ((_ (overlayp yas--active-field-overlay))
(end (overlay-end yas--active-field-overlay)))
(if (>= (point) end)
;; Call yas-next-field if cdlatex can't expand here
(let ((s (thing-at-point 'sexp)))
(unless (and s (assoc (substring-no-properties s)
cdlatex-command-alist-comb))
(yas-next-field-or-maybe-expand)
t))
;; otherwise expand and jump to the correct location
(let (cdlatex-tab-hook minp)
(setq minp
(min (save-excursion (cdlatex-tab)
(point))
(overlay-end yas--active-field-overlay)))
(goto-char minp) t))))
(defun yas-next-field-or-cdlatex nil
(interactive)
"Jump to the next Yas field correctly with cdlatex active."
(if
(or (bound-and-true-p cdlatex-mode)
(bound-and-true-p org-cdlatex-mode))
(cdlatex-tab)
(yas-next-field-or-maybe-expand)))))

View File

@@ -73,12 +73,12 @@
(pcase system-type
('darwin ; macOS
(set-face-attribute 'default nil :font "Maple Mono-16")
(set-face-attribute 'default nil :font "Maple Mono NF CN-18")
(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
(set-face-attribute 'default nil :font "Maple Mono NF CN-18") ; 20 * 1.5
(add-to-list 'default-frame-alist '(height . 40))
(add-to-list 'default-frame-alist '(width . 100))))