Initial commit

This commit is contained in:
lemyx 2024-12-28 10:59:10 +08:00
commit d8c8f49495
29 changed files with 1439 additions and 0 deletions

56
.gitignore vendored Normal file
View File

@ -0,0 +1,56 @@
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
# network security
/network-security.data
custom.el
transient/
site-lisp/
projects
eln-cache/
.cache/
history

12
.gitmodules vendored Normal file
View File

@ -0,0 +1,12 @@
[submodule "site-lisp/one-key"]
path = site-lisp/one-key
url = https://github.com/manateelazycat/one-key.git
[submodule "site-lisp/lsp-bridge"]
path = site-lisp/lsp-bridge
url = https://github.com/manateelazycat/lsp-bridge.git
[submodule "site-lisp/auto-save"]
path = site-lisp/auto-save
url = https://github.com/manateelazycat/auto-save.git
[submodule "site-lisp/beancount"]
path = site-lisp/beancount
url = https://github.com/beancount/beancount-mode.git

5
README.org Normal file
View File

@ -0,0 +1,5 @@
* Installation
#+begin_src bash
git clone git@github.com:lemyx/.emacs.d.git && cd .emacs.d
bash install.sh
#+end_src

41
early-init.el Normal file
View File

@ -0,0 +1,41 @@
;;; early-init.el --- Emacs pre-initialization config -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; 设置垃圾回收参数
(setq gc-cons-threshold most-positive-fixnum)
;; 清空避免加载远程文件的时候分析文件
(setq file-name-handler-alist nil)
;; 启动早期不加载`package.el'包管理器
(setq package-enable-at-startup nil)
;; 不从包缓存中加载
(setq package-quickstart nil)
;; 禁止展示菜单栏、工具栏和纵向滚动条
(push '(menu-bar-lines . 0) default-frame-alist)
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)
;; 禁止自动缩放窗口先
(setq frame-inhibit-implied-resize t)
;; 禁止菜单栏、工具栏、滚动条模式,禁止启动屏幕和文件对话框
(menu-bar-mode -1) ; 关闭菜单栏
(tool-bar-mode -1) ; 关闭工具栏
(scroll-bar-mode -1) ; 关闭滚动条
(setq inhibit-splash-screen t)
(setq use-file-dialog nil)
;; 在这个阶段不编译
(setq comp-deferred-compilation nil)
;; 启动时窗口全屏
(add-to-list 'default-frame-alist '(fullscreen . maximized))
(setq type-compile-warnings nil)
(provide 'early-init)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; early-init.el ends here

44
init.el Normal file
View File

@ -0,0 +1,44 @@
;;; init.el --- The main init entry for Emacs -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; load paths
(dolist (folder '("lisp" "site-lisp"))
(add-to-list 'load-path (expand-file-name folder user-emacs-directory)))
;; stop emacs automatically editing .emacs
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
;; Generic
(require 'init-package)
(require 'init-onekey)
(require 'init-ui)
(require 'init-treemacs)
(require 'init-save)
(require 'init-window)
;; Edit
(require 'init-completion)
(require 'init-meow)
(require 'init-dired)
;; Coding
(require 'init-prog)
(require 'init-magit)
(require 'init-lsp)
(require 'init-env)
(require 'init-vterm)
;; Writing
(require 'init-org)
(require 'init-beancount)
(require 'init-blog)
(require 'init-gtd)
(require 'init-diary)
(require 'init-tex)
(require 'init-pdf)
(provide 'init)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init.el ends here

View File

@ -0,0 +1,117 @@
#!/usr/bin/env bash
## Author: Abidán Brito
## This script builds GNU Emacs 29.1 with support for native elisp compilation,
## tree-sitter, libjansson (C JSON library), pure GTK and mailutils.
# Exit on error and print out commands before executing them.
set -euxo pipefail
# Let's set the number of jobs to something reasonable; keep 2 cores
# free to avoid choking the computer during compilation.
JOBS=`nproc --ignore=2`
# Clone repo locally and get into it.
git clone --depth 1 git://git.savannah.gnu.org/emacs.git
pushd emacs
# Get essential dependencies.
sudo apt install -y build-essential \
texinfo \
libgnutls28-dev \
libjpeg-dev \
libpng-dev \
libtiff5-dev \
libgif-dev \
libxpm-dev \
libncurses-dev \
libgtk-3-dev \
libtree-sitter-dev \
libmagick++-dev \
#libwebkit2gtk-4.1-dev \
# Get dependencies for gcc-10 and the build process.
sudo apt update -y
sudo apt install -y gcc-11 \
g++-11 \
libgccjit0 \
libgccjit-11-dev \
autoconf \
# Get dependencies for fast JSON.
sudo apt install -y libjansson4 libjansson-dev
# Get GNU Mailutils (protocol-independent mail framework).
sudo apt install -y mailutils
# Enable source packages and get dependencies for whatever
# Emacs version Ubuntu supports by default.
#
# Taken from here:
# https://www.masteringemacs.org/article/speed-up-emacs-libjansson-native-elisp-compilation
#sudo sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list \
# && apt update \
# && apt build-dep -y emacs
# Stop debconf from complaining about postfix nonsense.
DEBIAN_FRONTEND=noninteractive
# Needed for compiling libgccjit or we'll get cryptic error messages.
export CC=/usr/bin/gcc-11 CXX=/usr/bin/g++-11
# Configure and run.
# NOTE(abi): binaries should go to /usr/local/bin by default.
#
# Options:
# --with-native-compilation -> use the libgccjit native compiler
# --with-pgtk -> better font rendering
# --with-x-toolkit=gtk3 -> widgets toolkit
# --with-tree-sitter -> syntax parsing
# --with-wide-int -> larger file size limit
# --with-json -> fast JSON
# --with-gnutls -> TLS/SSL
# --with-mailutils -> e-mail
# --without-pop -> no pop3 (insecure channels)
# --with-cairo -> vector graphics backend
# --with-imagemagick -> raster images backend
./autogen.sh \
&& ./configure \
--with-native-compilation \
--with-pgtk \
--with-x-toolkit=gtk3 \
--with-tree-sitter \
--with-wide-int \
--with-json \
--with-modules \
--without-dbus \
--with-gnutls \
--with-mailutils \
--without-pop \
--with-cairo \
--with-imagemagick \
# Other interesting compilation options:
#
#--prefix="" # output binaries location
#--with-x-toolkit=lucid # supposedly more stable
#--with-xwidgets
# Compiler flags:
# -O2 -> Turn on a bunch of optimization flags. There's also -O3, but it increases
# the instruction cache footprint, which may end up reducing performance.
# -pipe -> Reduce temporary files to the minimum.
# -mtune=native -> Optimize code for the local machine (under ISA constraints).
# -march=native -> Enable all instruction subsets supported by the local machine.
# -fomit-frame-pointer -> Small functions don't need a frame pointer (optimization).
#
# https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/
CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"
# Build.
# NOTE(abi): NATIVE_FULL_AOT=1 ensures native compilation ahead-of-time for all
# elisp files included in the distribution.
make -j${JOBS} NATIVE_FULL_AOT=1 \
&& make install
# Return to the original path.
popd

37
install/install-macos.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
if command -v xelatex > /dev/null 2> /dev/null; then
echo "TeX Live is already installed."
else
echo "ERROR! TeX Live has not been installed. Make sure it's installed and environment variables are configured correctly."
echo "Depends on the TeX Live edition, append corresponding environments variables into ~/.zshrc"
echo 'export PATH="/usr/local/texlive/2023/bin/x86_64-linux:$PATH"'
echo 'export MANPATH="/usr/local/texlive/2023/texmf-dist/doc/man:$MANPATH"'
echo 'export INFOPATH="/usr/local/texlive/2023/texmf-dist/doc/info:$INFOPATH"'
exit 1
fi
# emacs
brew tap d12frosted/emacs-plus
brew uninstall emacs-plus
brew install emacs-plus --with-xwidgets --with-imagemagick
brew services restart d12frosted/emacs-plus/emacs-plus@29
osascript -e 'tell application "Finder" to make alias file to posix file "/opt/homebrew/opt/emacs-plus@29/Emacs.app" at POSIX file "/Applications" with properties {name:"Emacs.app"}'
# fonts
brew tap laishulu/cask-fonts
brew install --cask font-sarasa-nerd
brew install --cask font-symbols-only-nerd-font
# lsp-bridge
pip3 install epc orjson sexpdata six setuptools paramiko rapidfuzz pynput pyobjc --break-system-packages
brew install node
npm install -g yaml-language-server
npm install -g bash-language-server
npm install -g vscode-langservers-extracted
npm install -g pyright
pip3 install ruff-lsp --break-system-packages
brew install texlab
# fetch submodules
git submodule update --init

40
install/install-ubuntu.sh Normal file
View File

@ -0,0 +1,40 @@
#!/bin/bash
if command -v xelatex > /dev/null 2> /dev/null; then
echo "TeX Live is already installed."
else
echo "ERROR! TeX Live has not been installed. Make sure it's installed and environment variables are configured correctly."
echo "Depends on the TeX Live edition, append corresponding environments variables into ~/.zshrc"
echo 'export PATH="/usr/local/texlive/2023/bin/x86_64-linux:$PATH"'
echo 'export MANPATH="/usr/local/texlive/2023/texmf-dist/doc/man:$MANPATH"'
echo 'export INFOPATH="/usr/local/texlive/2023/texmf-dist/doc/info:$INFOPATH"'
exit 1
fi
# emacs
cd
sudo bash ~/.emacs.d/install/build-emacs-ubuntu.sh
# fonts
wget https://github.com/laishulu/Sarasa-Term-SC-Nerd/releases/download/v2.3.0/SarasaTermSCNerd.ttf.tar.gz && && tar -zxvf SarasaTermSCNerd.ttf.tar.gz && mv SarasaTermSCNerd*.ttf ~/.local/share/fonts
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/NerdFontsSymbolsOnly.zip && unzip NerdFontsSymbolsOnly && mv SymbolsNerdFont*.ttf ~/.local/share/fonts
fc-cache -fv
# lsp-bridge
pip3 install epc orjson sexpdata six setuptools paramiko rapidfuzz pynput pyobjc --break-system-packages
sudo apt install npm
sudo npm install -g yaml-language-server
sudo npm install -g bash-language-server
sudo npm install -g vscode-langservers-extracted
sudo npm install -g pyright
pip3 install ruff-lsp --break-system-package
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"
git clone https://github.com/latex-lsp/texlab.git && cd texlab
cargo build --release
# vterm
sudo apt install cmake libtool-bin libvterm-dev
# fetch submodules
git submodule update --init

17
lisp/init-beancount.el Normal file
View File

@ -0,0 +1,17 @@
;;; init-beancount.el --- Beancount settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(add-to-list 'load-path "~/.emacs.d/site-lisp/beancount/")
(require 'beancount)
(add-to-list 'auto-mode-alist '("\\.bean\\'" . beancount-mode))
(add-hook 'beancount-mode-hook
(lambda () (setq-local electric-indent-chars nil)))
(add-hook 'beancount-mode-hook #'outline-minor-mode)
(define-key beancount-mode-map (kbd "C-c C-n") #'outline-next-visible-heading)
(define-key beancount-mode-map (kbd "C-c C-p") #'outline-previous-visible-heading)
(provide 'init-beancount)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-beancount.el ends here

152
lisp/init-blog.el Normal file
View File

@ -0,0 +1,152 @@
;;; init-blog.el --- Blog settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; org-static-blog for blog
(use-package org-static-blog
:ensure t
:config
(setq org-static-blog-publish-url "https://lemyx.github.io/"
org-static-blog-publish-title "LEMYX")
(setq org-static-blog-publish-directory "~/blog" ; Store published HTML files
org-static-blog-posts-directory "~/org/blog/posts/" ; Store published org files
org-static-blog-drafts-directory "~/org/blog/drafts/") ; Store unpublished org files
(setq org-static-blog-index-file "index.html"
org-static-blog-archive-file "archive.html" ; Archive page lists all posts as headlines.
org-static-blog-tags-file "tags.html" ; Tags page lists all posts as headlines.
org-static-blog-rss-file "rss.xml")
(setq org-static-blog-index-length 100 ; Number of articles to include on index page.
org-static-blog-enable-tags t ; Show tags below posts, and generate tag pages.
org-static-blog-use-preview t ; Use preview versions of posts on multipost pages.
org-static-blog-preview-ellipsis "(...)" ; appended HTML to the preview as hidden part
org-static-blog-preview-link-p t ; Make preview-ellipsis a link to article's page
org-static-blog-preview-date-first-p nil) ; Print post dates before title in preview
(setq org-export-with-toc nil
org-export-with-section-numbers t)
(setq org-static-blog-page-header ; HTML to put in the <head> of each page.
"<meta name=\"author\" content=\"lemyx\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<link href= \"static/style.css\" rel=\"stylesheet\" type=\"text/css\" />
<script src=\"static/toc.js\" type=\"text/javascript\" defer></script>
<script src=\"static/others.js\" type=\"text/javascript\" defer></script>
<link rel=\"icon\" href=\"static/favicon.ico\">")
(setq org-static-blog-page-preamble ; HTML to put before the content of each page.
"<div id=\"blog-nav\">
<a href=\"https://lemyx.github.io/index.html\">Home</a>
<a href=\"https://lemyx.github.io/tags.html\">Tags</a>
<a href=\"https://lemyx.github.io/rss.xml\">Feeds</a>
<a href=\"https://lemyx.github.io/about.html\">About</a></div>")
(defun org-static-blog-get-preview (post-filename)
"Get title, date, tags from POST-FILENAME and get the first paragraph from the rendered HTML.
If the HTML body contains multiple paragraphs, include only the first paragraph,
and display an ellipsis.
Preamble and Postamble are excluded, too."
(with-temp-buffer
(insert-file-contents (org-static-blog-matching-publish-filename post-filename))
(let ((post-title (org-static-blog-get-title post-filename))
(post-date (org-static-blog-get-date post-filename))
(preview-region (org-static-blog--preview-region)))
;; Put the substrings together.
(let ((title-link
(format "<h2 class=\"post-title\"><a href=\"%s\">%s</a></h2>"
(org-static-blog-get-post-url post-filename) post-title))
(date-link
(format-time-string (concat "<div class=\"post-date\">"
(org-static-blog-gettext 'date-format)
"</div>")
post-date)))
(concat
title-link
preview-region
date-link
"<hr class=\"post-divider\">"
)))))
(defun org-static-blog-assemble-multipost-page (pub-filename post-filenames &optional front-matter)
"Assemble a page that contains multiple posts one after another.
Posts are sorted in descending time."
(setq post-filenames (sort post-filenames (lambda (x y) (time-less-p (org-static-blog-get-date y)
(org-static-blog-get-date x)))))
(org-static-blog-with-find-file
pub-filename
(org-static-blog-template
org-static-blog-publish-title
(concat
(when front-matter front-matter)
(apply 'concat (mapcar
(if org-static-blog-use-preview
'org-static-blog-get-preview
'org-static-blog-get-post-content) post-filenames))))))
(defun org-static-blog-assemble-multipost-page (pub-filename post-filenames &optional front-matter)
"Assemble a page that contains multiple posts one after another.
Posts are sorted in descending time."
(setq post-filenames (sort post-filenames (lambda (x y) (time-less-p (org-static-blog-get-date y)
(org-static-blog-get-date x)))))
(org-static-blog-with-find-file
pub-filename
(org-static-blog-template
org-static-blog-publish-title
(concat
(when front-matter front-matter)
(apply 'concat (mapcar
(if org-static-blog-use-preview
'org-static-blog-get-preview
'org-static-blog-get-post-content) post-filenames))))))
(defun org-static-blog-assemble-tags ()
"Render the tag archive and tag pages."
(org-static-blog-assemble-tags-archive)
(dolist (tag (org-static-blog-get-tag-tree))
(org-static-blog-assemble-multipost-page
(concat-to-dir org-static-blog-publish-directory
(concat "tag-" (downcase (car tag)) ".html"))
(cdr tag)
(concat "<h1 class=\"title\">" "" (car tag) "」</h1>"))))
(defun org-static-blog-assemble-tags-archive ()
"Assemble the blog tag archive page.
The archive page contains single-line links and dates for every
blog post, sorted by tags, but no post body."
(let ((tags-archive-filename (concat-to-dir org-static-blog-publish-directory org-static-blog-tags-file))
(tag-tree (org-static-blog-get-tag-tree)))
(setq tag-tree (sort tag-tree (lambda (x y) (string-greaterp (car y) (car x)))))
(org-static-blog-with-find-file
tags-archive-filename
(org-static-blog-template
org-static-blog-publish-title
(concat
(apply 'concat (mapcar 'org-static-blog-assemble-tags-archive-tag tag-tree)))))))
(defun org-static-blog-get-post-summary (post-filename)
"Assemble post summary for an archive page.
This function is called for every post on the archive and
tags-archive page. Modify this function if you want to change an
archive headline."
(concat
"<h2 class=\"post-title\">"
"<a href=\"" (org-static-blog-get-post-url post-filename) "\">" (org-static-blog-get-title post-filename) "</a>"
"</h2>\n"))
(defun org-static-blog-assemble-tags-archive-tag (tag)
"Assemble single TAG for all filenames."
(let ((post-filenames (cdr tag)))
(setq post-filenames
(sort post-filenames (lambda (x y) (time-less-p (org-static-blog-get-date x)
(org-static-blog-get-date y)))))
(concat "<h1 class=\"tags-title\">" "" (downcase (car tag)) "」</h1>\n"
(apply 'concat (mapcar 'org-static-blog-get-post-summary post-filenames)))))
)
(provide 'init-blog)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-blog.el ends here

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

@ -0,0 +1,67 @@
;;; init-completion.el --- Completion settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; which-key
(use-package which-key
:config
(which-key-mode 1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; vertico
;; performant and minimalistic vertical completion UI based on the default completion system
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))
(use-package vertico
:init
(vertico-mode)
;; Different scroll margin
(setq vertico-scroll-margin 0)
;; Show more candidates
(setq vertico-count 20)
;; Grow and shrink the Vertico minibuffer
(setq vertico-resize t)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t)
)
(use-package orderless
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
(use-package marginalia
;; Bind `marginalia-cycle' locally in the minibuffer. To make the binding
;; available in the *Completions* buffer, add it to the
;; `completion-list-mode-map'.
:bind (:map minibuffer-local-map
("M-A" . marginalia-cycle))
;; The :init section is always executed.
:init
;; Marginalia must be activated in the :init section of use-package such that
;; the mode gets enabled right away. Note that this forces loading the
;; package.
(marginalia-mode))
(use-package nerd-icons-completion
:after marginalia
:config
(nerd-icons-completion-mode)
(add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup))
;; Enhance M-x
(use-package amx
:init
(setq amx-history-length 20))
(provide 'init-completion)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-completion.el ends here

21
lisp/init-diary.el Normal file
View File

@ -0,0 +1,21 @@
;;; init-diary.el --- Diary settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; org-journal for diary
(use-package org-journal
:ensure t
:init
;; Change default prefix key; needs to be set before loading org-journal
(setq org-journal-prefix-key "C-c j ")
:config
(setq org-journal-dir "~/org/journal/"
org-journal-date-format "%A, %d %B %Y"
org-journal-file-format "%Y-%m-W%W.org"
org-journal-file-type 'weekly))
(provide 'init-diary)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-diary.el ends here

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

@ -0,0 +1,29 @@
;;; init-dired.el --- dired settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; allow dired to delete or copy dir
;; 'top means ask every time
;; 'always means no asking
(setq dired-recursive-copies 'top)
(setq dired-recursive-deletes 'top)
;; smart suggest target directory
(setq dired-dwim-target t)
;; make dired use the same buffer for viewing directory
(setq dired-kill-when-opening-new-dired-buffer t)
;; show human readable file size
;; https://github.com/d12frosted/homebrew-emacs-plus/issues/383#issuecomment-899157143
(setq insert-directory-program "gls" dired-use-ls-dired t)
(setq dired-listing-switches "-al --group-directories-first")
(use-package nerd-icons-dired
:hook
(dired-mode . nerd-icons-dired-mode))
(provide 'init-dired)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-dired.el ends here

13
lisp/init-env.el Normal file
View File

@ -0,0 +1,13 @@
;;; init-env.el --- Environment settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package exec-path-from-shell
:demand t
:config
(exec-path-from-shell-initialize))
(provide 'init-env)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-env.el ends here

28
lisp/init-gtd.el Normal file
View File

@ -0,0 +1,28 @@
;;; init-gtd.el --- GTD settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; org-static-blog for blog
(use-package org-gtd
:init
(setq org-gtd-update-ack "3.0.0")
:after org
:demand t
:custom
(org-gtd-directory "~/org/gtd")
(org-edna-use-inheritance t)
(org-gtd-organize-hooks '(org-gtd-set-area-of-focus org-set-tags-command))
:config
(org-edna-mode)
:bind
(("C-c d c" . org-gtd-capture)
("C-c d e" . org-gtd-engage)
("C-c d p" . org-gtd-process-inbox)
:map org-gtd-clarify-map
("C-c c" . org-gtd-organize)))
(provide 'init-gtd)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-gtd.el ends here

40
lisp/init-lsp.el Normal file
View File

@ -0,0 +1,40 @@
;;; init-lsp.el --- LSP settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package markdown-mode
:mode ("README\\.md\\'" . gfm-mode)
:init (setq markdown-command "multimarkdown")
:bind (:map markdown-mode-map
("C-c C-e" . markdown-do)))
(use-package yasnippet
:init
(yas-global-mode 1))
(add-to-list 'load-path "~/.emacs.d/site-lisp/lsp-bridge")
(require 'lsp-bridge)
(global-lsp-bridge-mode)
(setq acm-enable-doc t)
(setq acm-enable-copilot nil)
(setq lsp-bridge-enable-hover-diagnostic t)
(setq lsp-bridge-enable-completion-in-string t)
(setq lsp-bridge-enable-completion-in-minibuffer t)
(setq lsp-bridge-enable-with-tramp t)
(setq lsp-bridge-python-lsp-server "pyright")
(setq lsp-bridge-tex-lsp-server "texlab")
(setq lsp-bridge-python-command "/usr/bin/python3")
(one-key-create-menu
"LSP"
'((("a" . "lsp-bridge-code-action") . lsp-bridge-code-action)
(("f" . "lsp-bridge-find-def") . lsp-bridge-find-def)
(("b" . "lsp-bridge-find-def-return") . lsp-bridge-find-def-return)
(("h" . "lsp-bridge-popup-documentation") . lsp-bridge-popup-documentation)
(("s" . "lsp-bridge-toggle-sdcv-helper") . lsp-bridge-toggle-sdcv-helper))
t)
(provide 'init-lsp)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-lsp.el ends here

18
lisp/init-magit.el Normal file
View File

@ -0,0 +1,18 @@
;;; init-magit.el --- Magit settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package magit)
(use-package diff-hl
:hook
((magit-pre-refresh . diff-hl-magit-pre-refresh)
(magit-post-refresh . diff-hl-magit-post-refresh))
:init
(global-diff-hl-mode t))
(provide 'init-magit)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-magit.el ends here

109
lisp/init-meow.el Normal file
View File

@ -0,0 +1,109 @@
;;; init-meow.el --- Meow settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(defun meow-setup ()
(setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
(meow-motion-overwrite-define-key
'("j" . meow-next)
'("k" . meow-prev)
'("<escape>" . ignore))
(meow-leader-define-key
;; SPC j/k will run the original command in MOTION state.
'("j" . "H-j")
'("k" . "H-k")
;; 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)
;; one-key group
'("l" . one-key-menu-lsp)
)
(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)
'("<escape>" . ignore)))
(use-package meow
:demand nil
:init
(meow-global-mode 1)
:config
; custom function
(meow-setup)
; hack cursor position @ https://github.com/meow-edit/meow/discussions/87
(setq meow-use-cursor-position-hack t)
(setq meow-use-clipboard t)
(setq meow-use-enhanced-selection-effect t))
(provide 'init-meow)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-meow.el ends here

12
lisp/init-onekey.el Normal file
View File

@ -0,0 +1,12 @@
;;; init-onekey.el --- One-key settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; one-key
(add-to-list 'load-path "~/.emacs.d/site-lisp/one-key/")
(require 'one-key)
(provide 'init-onekey)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-onekey.el ends here

79
lisp/init-org.el Normal file
View File

@ -0,0 +1,79 @@
;;; init-org.el --- Org settings -*- lexical-binding: t -*-;;; Commentary:
;;; Code:
(use-package org
:config
; Line Truncation @ https://www.gnu.org/software/emacs/manual/html_node/emacs/Line-Truncation.html
(add-hook 'org-mode-hook (lambda () (setq truncate-lines nil)))
; Dynamic Headline Numbering @ https://orgmode.org/manual/Dynamic-Headline-Numbering.html
(setq org-startup-numerated t)
; Hide emphasis markup characters in buffers @ https://orgmode.org/manual/Emphasis-and-Monospace.html
(setq org-hide-emphasis-markers t)
; https://orgmode.org/manual/Fast-access-to-TODO-states.html
; https://orgmode.org/guide/Progress-Logging.html
(setq org-todo-keywords
'((sequence "TODO(t)" "HOLD(h!)" "WIP(i!)" "WAIT(w!)" "|" "DONE(d!)" "CANCELLED(c@/!)")
(sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f!)")))
; https://orgmode.org/manual/Faces-for-TODO-keywords.html
(setq org-todo-keyword-faces
'(("TODO" . (:foreground "#7c7c75" :weight bold))
("HOLD" . (:foreground "#feb24c" :weight bold))
("WIP" . (:foreground "#0098dd" :weight bold))
("WAIT" . (:foreground "#9f7efe" :weight bold))
("DONE" . (:foreground "#50a14f" :weight bold))
("CANCELLED" . (:foreground "#ff6480" :weight bold))
("REPORT" . (:foreground "magenta" :weight bold))
("BUG" . (:foreground "red" :weight bold))
("KNOWNCAUSE" . (:foreground "yellow" :weight bold))
("FIXED" . (:foreground "green" :weight bold))))
)
(use-package org-modern
:hook (after-init . (lambda ()
(setq org-modern-hide-stars 'leading)
(global-org-modern-mode t)))
:config
(setq org-modern-table nil))
(use-package org-appear
:hook
(org-mode . org-appear-mode)
:config
(setq org-appear-autolinks t)
(setq org-appear-autosubmarkers t)
(setq org-appear-autoentities t)
(setq org-appear-autokeywords t)
(setq org-appear-inside-latex t)
)
(use-package org-bars
:vc (org-bars :url "https://github.com/tonyaldon/org-bars.git"
:rev :newest)
:hook (org-mode . org-bars-mode))
;; org-mode 导出为 markdown @ https://emacs-china.org/t/org-mode-markdown/17393/3
;; 如果将 #+begin_src #+end_src 紧跟标题, 则导出效果正常 (workaround)
(use-package ox-gfm
:after org
:config
(setq org-export-with-sub-superscripts nil)
(setq org-export-headline-levels 5)
(setq org-export-coding-system 'utf-8)
(setq org-export-with-broken-links 'mark)
(setq org-link-file-path-type 'relative)
;; 定义自动导出为 Markdown 的函数
(defun export-org-to-markdown-if-org-mode ()
"Export current org-mode buffer to a markdown file if in org-mode."
(when (eq major-mode 'org-mode) ; 确保当前缓冲区是 org-mode
(org-gfm-export-to-markdown)))
;; 添加到 org-mode 的保存钩子中
(add-hook 'org-mode-hook
(lambda ()
(add-hook 'after-save-hook 'export-org-to-markdown-if-org-mode nil 'make-it-local))))
(provide 'init-org)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-org.el ends here

33
lisp/init-package.el Normal file
View File

@ -0,0 +1,33 @@
;;; init-package.el --- The main init entry for Emacs -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; configure package archives
(require 'package)
(setq package-check-signature nil)
(setq package-archives
'(("melpa" . "https://melpa.org/packages/")
("melpa-stable" . "https://stable.melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(unless (bound-and-true-p package--initialized)
(package-initialize))
;; configure use-package
(require 'use-package)
(eval-and-compile
(setq use-package-always-ensure t)
(setq use-package-always-defer t))
;; configure vc-use-package
; As of 2023-05-16, vc-use-package has been merged into Emacs master! Thus, if you are using a recent enough version of Emacs 30+, you don't need to install this package and can instead use use-packages own :vc keyword.
; Note that the keyword syntax differs in the core differs from that used in this package! Instead of a MELPA-style :vc (:fetcher github :repo oantolin/math-delimiters), the built-in keyword uses ELPA-style :vc (:url "https://github.com/oantolin/math-delimiters") package specifications.
(when (< emacs-major-version 30)
(unless (package-installed-p 'vc-use-package)
(package-vc-install "https://github.com/slotThe/vc-use-package"))
(require 'vc-use-package))
(provide 'init-package)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-package.el ends here

37
lisp/init-pdf.el Normal file
View File

@ -0,0 +1,37 @@
;;; init-pdf.el --- pdf settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package pdf-tools
:mode ("\\.pdf\\'" . pdf-view-mode) ; pdf 文件默认打开方式
:bind
(:map pdf-view-mode-map
("d" . pdf-view-next-page-command)
("a" . pdf-view-previous-page-command)
("s" . pdf-view-scroll-up-or-next-page)
("w" . pdf-view-scroll-down-or-previous-page)
:map pdf-history-minor-mode-map
("b" . pdf-history-backward)
:map pdf-annot-minor-mode-map
("C-a a" . pdf-annot-add-highlight-markup-annotation)
("C-a s" . pdf-annot-add-squiggly-markup-annotation)
("C-a u" . pdf-annot-add-underline-markup-annotation)
("C-a d" . pdf-annot-delete))
:custom
(pdf-view-midnight-colors '("#000000" . "#9bCD9b")) ; 夜间模式设置绿色底色
:config
(pdf-tools-install)
(setq native-comp-deferred-compilation-deny-list '(".*pdf.*"))
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))) ; 设置 pdf-tools 打开 pdf
(require 'pdf-annot) ; 设置 pdf-annot-mimor-mode-map
(require 'pdf-history) ; 设置 pdf-history-minor-mode-map
(add-hook 'pdf-view-mode-hook 'pdf-view-fit-width-to-window) ; 默认适应页宽
; (add-hook 'pdf-view-mode-hook 'pdf-view-midnight-minor-mode) ; 默认夜间模式
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer) ; 完成编译后刷新 pdf 文件
)
(provide 'init-pdf)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-pdf.el ends here

51
lisp/init-prog.el Normal file
View File

@ -0,0 +1,51 @@
;;; init-prog.el --- Programming settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Fluently Edit Large Files
;; https://emacs-china.org/t/topic/25811/6
(setq-default bidi-display-reordering nil)
(setq-default bidi-paragraph-direction 'left-to-right)
(setq bidi-inhibit-bpa t
long-line-threshold 1000
large-hscroll-threshold 1000
syntax-wholeline-max 1000)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Line Numbers
(use-package display-line-numbers
:ensure nil
:init
(setq display-line-numbers-width-start t)
(setq-default display-line-numbers t)
:config
(dolist (mode '(org-mode-hook
term-mode-hook
eshell-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 0)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; indent-bars
(use-package indent-bars
; reference: https://elpa.gnu.org/devel/doc/use-package.html
:vc (indent-bars :url "https://github.com/jdtsmith/indent-bars.git"
:rev :newest)
:hook (prog-mode . indent-bars-mode)
:config
(setq indent-bars-display-on-blank-lines t)
(setq indent-bars-width-frac 0.2)
(setq indent-bars-color '(highlight :face-bg t :blend 0.2))
(setq indent-bars-zigzag nil)
(setq indent-bars-highlight-current-depth nil)
(setq indent-bars-prefer-character t))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; rainbow-delimiters
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
(provide 'init-prog)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-prog.el ends here

13
lisp/init-save.el Normal file
View File

@ -0,0 +1,13 @@
;;; init-save.el --- Save settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(add-to-list 'load-path "~/.emacs.d/site-lisp/auto-save/")
(require 'auto-save)
(auto-save-enable)
(setq auto-save-silent t)
(provide 'init-save)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-save.el ends here

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

@ -0,0 +1,41 @@
;;; init-tex.el --- TeX settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; cdlatex
(use-package cdlatex
:after tex)
;; TeX Core
(use-package tex
:ensure auctex
:demand t
:custom
; 自动解析新文件 (usepackage, bibliograph, newtheorem) 等信息
(TeX-parse-selt t)
(TeX-PDF-mode t)
; 正反向搜索
(TeX-source-correlate-mode t)
(TeX-source-correlate-method 'synctex)
; 使用 pdf-tools 预览
(TeX-view-program-selection '((output-pdf "PDF Tools")))
:config
(add-to-list 'auto-mode-alist '("\\.tex$" . LaTeX-mode))
(setq TeX-auto-save t)
(setq TeX-save-query nil)
(setq TeX-show-compilation t)
; 编译时问询主文件名称
(setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook (lambda ()
(cdlatex-mode)
(reftex-mode)
(prettify-symbols-mode t)
(outline-minor-mode)
(outline-hide-body)
(add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex --synctex=1%(mode)%' %t" TeX-run-TeX nil t))
)))
(provide 'init-tex)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-tex.el ends here

122
lisp/init-treemacs.el Normal file
View File

@ -0,0 +1,122 @@
;; init-treemacs.el --- Treemacs settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Treemacs
;;; https://github.com/Alexander-Miller/treemacs?tab=readme-ov-file#installation
(use-package treemacs
:ensure t
:defer t
:init
(with-eval-after-load 'winum
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
:config
(progn
(setq treemacs-collapse-dirs (if treemacs-python-executable 3 0)
treemacs-deferred-git-apply-delay 0.5
treemacs-directory-name-transformer #'identity
treemacs-display-in-side-window t
treemacs-eldoc-display 'simple
treemacs-file-event-delay 2000
treemacs-file-extension-regex treemacs-last-period-regex-value
treemacs-file-follow-delay 0.2
treemacs-file-name-transformer #'identity
treemacs-follow-after-init t
treemacs-expand-after-init t
treemacs-find-workspace-method 'find-for-file-or-pick-first
treemacs-git-command-pipe ""
treemacs-goto-tag-strategy 'refetch-index
treemacs-header-scroll-indicators '(nil . "^^^^^^")
treemacs-hide-dot-git-directory t
treemacs-indentation 2
treemacs-indentation-string " "
treemacs-is-never-other-window nil
treemacs-max-git-entries 5000
treemacs-missing-project-action 'ask
treemacs-move-files-by-mouse-dragging t
treemacs-move-forward-on-expand nil
treemacs-no-png-images nil
treemacs-no-delete-other-windows t
treemacs-project-follow-cleanup nil
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory)
treemacs-position 'left
treemacs-read-string-input 'from-child-frame
treemacs-recenter-distance 0.1
treemacs-recenter-after-file-follow nil
treemacs-recenter-after-tag-follow nil
treemacs-recenter-after-project-jump 'always
treemacs-recenter-after-project-expand 'on-distance
treemacs-litter-directories '("/node_modules" "/.venv" "/.cask")
treemacs-project-follow-into-home nil
treemacs-show-cursor nil
treemacs-show-hidden-files t
treemacs-silent-filewatch nil
treemacs-silent-refresh nil
treemacs-sorting 'alphabetic-asc
treemacs-select-when-already-in-treemacs 'move-back
treemacs-space-between-root-nodes t
treemacs-tag-follow-cleanup t
treemacs-tag-follow-delay 1.5
treemacs-text-scale nil
treemacs-user-mode-line-format nil
treemacs-user-header-line-format nil
treemacs-wide-toggle-width 70
treemacs-width 35
treemacs-width-increment 1
treemacs-width-is-initially-locked t
treemacs-workspace-switch-cleanup nil)
;; The default width and height of the icons is 22 pixels. If you are
;; using a Hi-DPI display, uncomment this to double the icon size.
;;(treemacs-resize-icons 44)
(treemacs-follow-mode t)
(treemacs-filewatch-mode t)
(treemacs-fringe-indicator-mode 'always)
(when treemacs-python-executable
(treemacs-git-commit-diff-mode t))
(pcase (cons (not (null (executable-find "git")))
(not (null treemacs-python-executable)))
(`(t . t)
(treemacs-git-mode 'deferred))
(`(t . _)
(treemacs-git-mode 'simple)))
(treemacs-hide-gitignored-files-mode nil))
:bind
(:map global-map
("M-0" . treemacs-select-window)
("C-x t 1" . treemacs-delete-other-windows)
("C-x t t" . treemacs)
("C-x t d" . treemacs-select-directory)
("C-x t B" . treemacs-bookmark)
("C-x t C-t" . treemacs-find-file)
("C-x t M-t" . treemacs-find-tag)))
(use-package treemacs-nerd-icons
:ensure t
:config
(treemacs-load-theme "nerd-icons"))
(use-package treemacs-icons-dired
:hook (dired-mode . treemacs-icons-dired-enable-once)
:ensure t)
(use-package treemacs-magit
:after (treemacs magit)
:ensure t)
(use-package treemacs-tab-bar ;;treemacs-tab-bar if you use tab-bar-mode
:after (treemacs)
:ensure t
:config (treemacs-set-scope-type 'Tabs))
(treemacs-start-on-boot)
(provide 'init-treemacs)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-treemacs.el ends here

85
lisp/init-ui.el Normal file
View File

@ -0,0 +1,85 @@
;; init-ui.el --- UI settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Theme
(use-package circadian
:hook
(emacs-startup . circadian-setup)
:config
(setq calendar-latitude 40.0)
(setq calendar-longitude 116.4)
(setq circadian-themes '((:sunrise . (
;; modus-operandi
adwaita
))
(:sunset . (
modus-vivendi
))
)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Font
(set-face-attribute 'default nil :font (font-spec :family "Sarasa Term SC Nerd" :size 14))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Tab Bar
(use-package tab-bar
:hook
(window-setup . tab-bar-mode)
:custom
(tab-bar-new-tab-to 'rightmost)
(tab-bar-close-button-show nil)
(tab-bar-tab-hints t)
(tab-bar-separator "")
(tab-bar-new-tab-choice "*scratch*")
(tab-bar-tab-name-truncated-max 20)
(tab-bar-auto-width nil)
:config
(customize-set-variable 'tab-bar-select-tab-modifiers '(super))
(setq tab-bar-tab-name-format-function
(lambda (tab i)
(let ((face (funcall tab-bar-tab-face-function tab)))
(concat
(propertize " " 'face face)
(propertize (number-to-string i) 'face `(:inherit ,face :weight ultra-bold :underline t))
(propertize (concat " " (alist-get 'name tab) " ") 'face face)))))
(setq tab-bar-tab-name-function
(lambda () (let* ((raw-tab-name (buffer-name (window-buffer (minibuffer-selected-window))))
(count (length (window-list-1 nil 'nomini)))
(truncated-tab-name (if (< (length raw-tab-name)
tab-bar-tab-name-truncated-max)
raw-tab-name
(truncate-string-to-width raw-tab-name
tab-bar-tab-name-truncated-max
nil nil tab-bar-tab-name-ellipsis))))
(if (> count 1)
(concat truncated-tab-name "(" (number-to-string count) ")")
truncated-tab-name))))
(when (daemonp)
(add-hook 'after-make-frame-functions
#'(lambda (&rest _) (force-mode-line-update))))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Icons
(use-package nerd-icons
:custom
;; The Nerd Font you want to use in GUI
;; "Symbols Nerd Font Mono" is the default and is recommended
;; but you can use any other Nerd Font if you want
(nerd-icons-font-family "Symbols Nerd Font Mono")
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Modeline
(use-package doom-modeline
:ensure t
:hook (after-init . doom-modeline-mode))
(provide 'init-ui)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-ui.el ends here

50
lisp/init-vterm.el Normal file
View File

@ -0,0 +1,50 @@
;;; init-vterm.el --- vterm settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package vterm
:when (memq window-system '(mac ns x pgtk))
:bind (:map vterm-mode-map
("C-y" . vterm-yank)
("M-y" . vterm-yank-pop)
("C-k" . vterm-send-C-k-and-kill))
:init
(setq vterm-shell "zsh")
:config
(setq vterm-always-compile-module t)
(defun vterm-send-C-k-and-kill ()
"Send `C-k' to libvterm, and put content in kill-ring."
(interactive)
(kill-ring-save (point) (vterm-end-of-line))
(vterm-send-key "k" nil nil t)))
(use-package vterm-toggle
:when (memq window-system '(mac ns x pgtk))
:bind (([f8] . vterm-toggle)
([f9] . vterm-compile)
:map vterm-mode-map
([f8] . vterm-toggle)
([(control return)] . vterm-toggle-insert-cd))
:config
(setq vterm-toggle-cd-auto-create-buffer nil)
(defvar vterm-compile-buffer nil)
(defun vterm-compile ()
"Compile the program including the current buffer in `vterm'."
(interactive)
(setq compile-command (compilation-read-command compile-command))
(let ((vterm-toggle-use-dedicated-buffer t)
(vterm-toggle--vterm-dedicated-buffer (if (vterm-toggle--get-window)
(vterm-toggle-hide)
vterm-compile-buffer)))
(with-current-buffer (vterm-toggle-cd)
(setq vterm-compile-buffer (current-buffer))
(rename-buffer "*vterm compilation*")
(compilation-shell-minor-mode 1)
(vterm-send-M-w)
(vterm-send-string compile-command t)
(vterm-send-return)))))
(provide 'init-vterm)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-vterm.el ends here

70
lisp/init-window.el Normal file
View File

@ -0,0 +1,70 @@
;;; init-window.el --- Window settings -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package shackle
:ensure t
:hook (after-init . shackle-mode)
:init
(setq shackle-lighter "")
(setq shackle-select-reused-windows nil) ; default nil
(setq shackle-default-alignment 'below) ; default below
(setq shackle-rules
;; CONDITION(:regexp) :select :inhibit-window-quit :size+:align|:other :same|:popup
'((compilation-mode :ignore t)
("\\*Async Shell.*\\*" :regexp t :ignore t)
("\\*corfu.*\\*" :regexp t :ignore t)
("*eshell*" :select t :size 0.4 :align t :popup t)
("*vterm*" :select t :size 0.4 :align t :popup t)
(helpful-mode :select t :size 0.6 :align right :popup t)
("*Messages*" :select t :size 0.4 :align t :popup t)
("*Calendar*" :select t :size 0.3 :align t :popup t)
("*info*" :select t :same t)
(magit-status-mode :select t :inhibit-window-quit t :same t)
(magit-log-mode :select t :inhibit-window-quit t :same t)
))
)
(use-package popper
:ensure t
:bind (("C-`" . popper-toggle-latest)
("M-<tab>" . popper-cycle)
("M-\\" . popper-toggle-type)
)
:init
(setq popper-reference-buffers
'("\\*Messages\\*"
"\\*Async Shell Command\\*"
help-mode
helpful-mode
occur-mode
pass-view-mode
"^\\*eshell.*\\*$" eshell-mode ;; eshell as a popup
"^\\*shell.*\\*$" shell-mode ;; shell as a popup
"^\\*vterm*\\*$" vterm-mode ;; vterm as a popup
("\\*corfu\\*" . hide)
(compilation-mode . hide)
;; derived from `fundamental-mode' and fewer than 10 lines will be considered a popup
(lambda (buf) (with-current-buffer buf
(and (derived-mode-p 'fundamental-mode)
(< (count-lines (point-min) (point-max))
10))))
)
)
(popper-mode +1)
(popper-echo-mode +1)
:config
;; group by project.el, projectile, directory or perspective
(setq popper-group-function nil)
;; pop in child frame or not
(setq popper-display-function #'display-buffer-in-child-frame)
;; use `shackle.el' to control popup
(setq popper-display-control nil)
)
(provide 'init-window)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-window.el ends here