mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 00:33:00 +00:00
feat(emacs): org mode basic qol improvements
* CJK zero-width space * Fonts for CJK characters * Paste images from clipboard (org-download) * Line-feed by default * Visual relative line mode number (instead of physical relative) * Treemacs: Sidebar file tree in Emacs
This commit is contained in:
parent
56a684d5ba
commit
87c237684b
7 changed files with 122 additions and 8 deletions
1
tools/emacs.d/.gitignore
vendored
1
tools/emacs.d/.gitignore
vendored
|
|
@ -21,3 +21,4 @@ custom.el
|
|||
|
||||
.org-id-locations
|
||||
bookmarks
|
||||
.cache
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
;;; init-appearance.el
|
||||
|
||||
;; Set Font - JetBrains Mono Nerd Font
|
||||
(when (display-graphic-p)
|
||||
(add-to-list 'default-frame-alist '(font . "JetBrainsMono NF")))
|
||||
|
||||
;; Set CJK Display Font - LXGW Wenkai Mono
|
||||
(dolist (charset '(kana han cjk-misc bopomofo))
|
||||
(set-fontset-font t charset (font-spec :family "霞鹜文楷等宽")))
|
||||
|
||||
;; Icon Support
|
||||
;; Once installed, Manually install the fonts required:
|
||||
;; M-x all-the-icons-install-fonts
|
||||
|
|
|
|||
|
|
@ -6,7 +6,14 @@
|
|||
;; Use line number by default
|
||||
(global-display-line-numbers-mode 1)
|
||||
;; Vim-like relativenumber
|
||||
(setq display-line-numbers-type 'relative)
|
||||
;; fix: work for folded region (visual relative line instead of physical)
|
||||
(use-package display-line-numbers
|
||||
:config
|
||||
(setq display-line-numbers-type 'visual)
|
||||
(setq display-line-numbers-current-absolute t)
|
||||
:hook
|
||||
(prog-mode . display-line-numbers-mode))
|
||||
|
||||
|
||||
;; Auto input pairred brackets
|
||||
(electric-pair-mode 1)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
;;; init-edit.el
|
||||
|
||||
;; Use UTF-8 & LF
|
||||
(setq-default buffer-file-coding-system 'utf-8-unix)
|
||||
|
||||
;; Company - Complete Anything
|
||||
(use-package company
|
||||
:ensure t
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
;;; init-file.el -- File Management configuration
|
||||
;;; init-file.el -- File Management configuration
|
||||
;;; First edit at 2025/01/29
|
||||
|
||||
;; Dired
|
||||
|
|
@ -20,5 +20,38 @@
|
|||
;; https://stackoverflow.com/q/1839313
|
||||
(setq dired-kill-when-opening-new-dired-buffer t)
|
||||
|
||||
;; Treemacs - Sidebar File Tree
|
||||
(use-package treemacs
|
||||
:ensure t
|
||||
:defer t
|
||||
:init
|
||||
(with-eval-after-load 'winum
|
||||
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
|
||||
: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-evil
|
||||
:after (treemacs evil)
|
||||
:ensure t
|
||||
:config
|
||||
;; Evil treemacs state bindings
|
||||
(define-key evil-treemacs-state-map (kbd "n") #'treemacs-next-line)
|
||||
(define-key evil-treemacs-state-map (kbd "e") #'treemacs-previous-line)
|
||||
(define-key evil-treemacs-state-map (kbd "N") #'treemacs-next-neighbour)
|
||||
(define-key evil-treemacs-state-map (kbd "E") #'treemacs-previous-neighbour)
|
||||
(define-key evil-treemacs-state-map (kbd "H") #'treemacs-toggle-show-dotfiles)
|
||||
(define-key evil-treemacs-state-map (kbd "I") #'treemacs-hide-gitignored-files-mode)
|
||||
;; Treemacs mode specific binding
|
||||
(evil-define-key 'treemacs treemacs-mode-map (kbd "i") #'treemacs-RET-action))
|
||||
|
||||
|
||||
(provide 'init-file)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
;;; init-org.el
|
||||
|
||||
;; Use =M-x org-mode-restart= to take effects
|
||||
;; After =M-x eval-buffer=
|
||||
|
||||
(use-package org
|
||||
:ensure nil ;; Use Emacs built-in Org Mode
|
||||
:config
|
||||
(setq org-log-done 'time)
|
||||
(setq org-startup-indented nil)
|
||||
(setq org-startup-indented t)
|
||||
;; Use inline image
|
||||
(setq org-startup-with-inline-images t)
|
||||
(setq org-display-remote-inline-images 'cache) ; 预览网络图片
|
||||
|
||||
;; Use LaTeX rendering
|
||||
(setq org-startup-with-latex-preview t)
|
||||
(setq org-image-actual-width 600)
|
||||
|
|
@ -24,6 +29,16 @@
|
|||
(evil-define-key 'normal org-mode-map (kbd "SPC a") 'org-agenda-list) ; TODO: Here Simulates the leader
|
||||
)
|
||||
|
||||
|
||||
;; Set Org Styles
|
||||
(setq org-emphasis-alist
|
||||
'(("*" (bold :foreground "cyan" ))
|
||||
("/" (italic :foreground "green"))
|
||||
("_" underline)
|
||||
("=" (org-verbatim verbatim :background "maroon" :foreground "white"))
|
||||
("~" (org-code verbatim :background "deep sky blue" :foreground "MidnightBlue"))
|
||||
("+" (:strike-through t))))
|
||||
|
||||
(use-package org-bullets
|
||||
:after org
|
||||
:hook (org-mode . org-bullets-mode))
|
||||
|
|
@ -44,8 +59,9 @@
|
|||
|
||||
(org-babel-do-load-languages
|
||||
'org-babel-load-languages
|
||||
'(
|
||||
'(
|
||||
(python . t) ; No need to declare C/C++/emacs-lisp since is integrated
|
||||
(shell . t)
|
||||
))
|
||||
;; Use clang as default C/C++ Compiler (Easier to install and configure in Windows)
|
||||
(setq org-babel-C-compiler "clang")
|
||||
|
|
@ -53,5 +69,40 @@
|
|||
;; Don't ask me again when running source block
|
||||
(setq org-confirm-babel-evaluate nil)
|
||||
|
||||
;; Pasting Images
|
||||
;; Use =M-x org-download-clipboard= to paste image
|
||||
;; Additional program required: magick
|
||||
;; Windows: scoop install imagemagick
|
||||
;; org-download config
|
||||
(use-package org-download
|
||||
:ensure t
|
||||
:after org
|
||||
:config
|
||||
;; Hardcoding the image dir
|
||||
(setq-default org-download-image-dir "~/OrgFiles/Attachments")
|
||||
|
||||
(setq org-download-heading-lvl nil ; don't use heading when creating files
|
||||
org-download-timestamp "%Y%m%d-%H%M%S"
|
||||
org-download-screenshot-method "screencapture -i %s" ; for macOS only
|
||||
org-download-backend 'curl) ; use curl to `download` image
|
||||
|
||||
(org-download-enable)
|
||||
|
||||
:bind (:map org-mode-map
|
||||
("C-c d c" . org-download-clipboard) ; 粘贴剪贴板内容
|
||||
("C-c d s" . org-download-screenshot))) ; 截图
|
||||
|
||||
|
||||
;; For CJK users
|
||||
;; Insert zero width space around the emphasis symbols, this might be useful for
|
||||
;; languages that does not rely on space
|
||||
(defun my/insert-emphasis-with-zws (char)
|
||||
(interactive "c")
|
||||
(insert ?\u200B char)
|
||||
(save-excursion (insert char ?\u200B)))
|
||||
|
||||
(global-set-key (kbd "C-c b") (lambda () (interactive) (my/insert-emphasis-with-zws ?*)))
|
||||
(global-set-key (kbd "C-c i") (lambda () (interactive) (my/insert-emphasis-with-zws ?/)))
|
||||
|
||||
|
||||
(provide 'init-org)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,13 @@
|
|||
(require 'use-package))
|
||||
(setq use-package-always-ensure t)
|
||||
|
||||
;; use-package offers many syntax sugar.
|
||||
;; :bind -> bindkeys
|
||||
;; :config -> `(progn do sth)
|
||||
;; :init -> (progn do sth)
|
||||
;; :after -> (when (featurep 'package)do sth)
|
||||
;; :hook -> (add-hook 'some-hook #'some-mode)
|
||||
|
||||
;; This part initialse the GPG Keyring
|
||||
; Disable signature first
|
||||
(setq package-check-signature nil)
|
||||
|
|
@ -44,13 +51,21 @@
|
|||
|
||||
;; Dashboard
|
||||
(use-package dashboard
|
||||
; Open with :dashboard-open<CR>
|
||||
;; Open with :dashboard-open<CR>
|
||||
:after evil
|
||||
:bind (:map dashboard-mode-map
|
||||
;; Navigation
|
||||
("n" . dashboard-next-line)
|
||||
("e" . dashboard-previous-line)
|
||||
;; Buffer switching
|
||||
("H" . previous-buffer)
|
||||
("I" . next-buffer))
|
||||
:config
|
||||
(dashboard-setup-startup-hook)
|
||||
; Use Emacs mode to use number to navigate dashboard
|
||||
(evil-set-initial-state 'dashboard-mode 'emacs)
|
||||
(setq dashboard-center-content t)
|
||||
;; Use Emacs mode to use number to navigate dashboard
|
||||
)
|
||||
|
||||
;(use-package dashboard
|
||||
; :ensure t
|
||||
; :init
|
||||
|
|
@ -58,7 +73,6 @@
|
|||
; :config
|
||||
; (setq dashboard-banner-logo-title "EMACS")
|
||||
; (setq dashboard-startup-banner 'official)
|
||||
; (setq dashboard-center-content t)
|
||||
; (setq dashboard-items '((recents . 5)
|
||||
; (bookmark . 5))))
|
||||
;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue