This commit is contained in:
2023-05-18 21:32:08 +09:00
parent 97866e0636
commit ac07e1dd7f
14 changed files with 443 additions and 57 deletions

View File

@ -32,10 +32,13 @@
(cl-loop for font in '("Noto Sans CJK KR" "Nanum Gothic")
when (font-installed-p font)
return (progn
(setq face-font-rescale-alist `((,font . 1.26)))
(setq face-font-rescale-alist `((,font . 1.00)))
(set-fontset-font t '(#x1100 . #xffdc) (font-spec :family font))))))
(custom-setup-fonts)
(add-hook 'window-setup-hook #'custom-setup-fonts)
(add-hook 'server-after-make-frame-hook #'centaur-setup-fonts)
;; select theme
(setq custom-theme-sel 'doom-one)
;; default transparency (85 . 50) or (100 . 100)
(set-frame-parameter (selected-frame) 'alpha '(85 . 50))

View File

@ -56,11 +56,15 @@ Otherwise the startup will be very slow. "
(require 'init-base)
(require 'init-hydra)
(require 'init-general)
(require 'init-ui)
(require 'init-edit)
(require 'init-evil)
(require 'init-vertico)
(require 'init-yasnippet)
(require 'init-dashboard)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init.el ends here

View File

@ -1,7 +1,7 @@
;; init-base.el -*- lexical-binding: t -*-
(require 'init-const)
(require 'init-func)
(require 'init-funcs)
(with-no-warnings
(setq read-process-output-max (* 1024 1024)) ;; 1mb (lsp recommendation)
@ -110,6 +110,7 @@
(concat
" "
(nerd-icons-faicon "nf-fa-bolt" :face 'nerd-icons-lblue))
;;(all-the-icons-faicon "nf-fa-bolt" :face 'all-the-icons-lblue))
" x"))
(name (aref val 0))
(pid (aref val 1))

View File

@ -0,0 +1,237 @@
;;; init-dashboard.el -*- lexical-binding: t -*-
(use-package dashboard
:diminish dashboard-mode
:functions (nerd-icons-faicon
nerd-icons-mdicon
winner-undo
widget-forward)
:custom-face
(dashboard-heading ((t (:inherit (font-lock-string-face bold)))))
(dashboard-items-face ((t (:weight normal))))
(dashboard-no-items-face ((t (:weight normal))))
:pretty-hydra
((:title (pretty-hydra-title "Dashboard" 'mdicon "nf-md-view_dashboard")
:color pink :quit-key ("q" "C-g"))
("Navigator"
(("U" update-config-and-packages "update" :exit t)
("H" browse-homepage "homepage" :exit t)
("R" restore-previous-session "recover session" :exit t)
("L" restore-session "list sessions" :exit t)
("S" find-custom-file "settings" :exit t))
"Section"
(("}" dashboard-next-section "next")
("{" dashboard-previous-section "previous")
("r" dashboard-goto-recent-files "recent files")
("m" dashboard-goto-bookmarks "bookmarks")
("p" dashboard-goto-projects "projects"))
"Item"
(("RET" widget-button-press "open" :exit t)
("<tab>" widget-forward "next")
("C-i" widget-forward "next")
("<backtab>" widget-backward "previous")
("C-n" next-line "next line")
("C-p" previous-line "previous line"))
"Misc"
(("<f2>" open-dashboard "open" :exit t)
("g" dashboard-refresh-buffer "refresh" :exit t)
("Q" quit-dashboard "quit" :exit t))))
:bind (("<f2>" . open-dashboard)
:map dashboard-mode-map
("H" . browse-homepage)
("R" . restore-previous-session)
("L" . restore-session)
("S" . find-custom-file)
("U" . update-config-and-packages)
("q" . quit-dashboard)
("h" . dashboard-hydra/body)
("?" . dashboard-hydra/body))
:hook (dashboard-mode . (lambda ()
;; No title
(setq-local frame-title-format nil)
;; Enable `page-break-lines-mode'
(when (fboundp 'page-break-lines-mode)
(page-break-lines-mode 1))))
:init
(setq dashboard-banner-logo-title "CENTAUR EMACS - Enjoy Programming & Writing"
;;dashboard-startup-banner (or centaur-logo 'official)
dashboard-page-separator "\n\f\n"
dashboard-projects-backend 'project-el
dashboard-path-style 'truncate-middle
dashboard-path-max-length 60
dashboard-center-content t
dashboard-show-shortcuts nil
dashboard-items '((recents . 10)
(bookmarks . 5)
(projects . 5))
dashboard-set-init-info t
dashboard-display-icons-p #'icons-displayable-p
dashboard-icon-type 'nerd-icons
dashboard-set-file-icons t
dashboard-set-heading-icons t
dashboard-heading-icons '((recents . "nf-oct-history")
(bookmarks . "nf-oct-bookmark")
(agenda . "nf-oct-calendar")
(projects . "nf-oct-briefcase")
(registers . "nf-oct-database"))
dashboard-set-footer t
dashboard-footer-icon (cond
((icons-displayable-p)
(nerd-icons-octicon "nf-oct-heart" :height 1.2 :face 'nerd-icons-lred))
(t (propertize ">" 'face 'dashboard-footer)))
dashboard-set-navigator t
dashboard-navigator-buttons
`(((,(when (icons-displayable-p)
(nerd-icons-mdicon "nf-md-github" :height 1.5))
"Homepage" "Browse homepage"
(lambda (&rest _) (browse-url centaur-homepage)))
(,(when (icons-displayable-p)
(nerd-icons-mdicon "nf-md-backup_restore" :height 1.5))
"Restore" "Restore previous session"
(lambda (&rest _) (restore-previous-session)))
(,(when (icons-displayable-p)
(nerd-icons-mdicon "nf-md-tools" :height 1.5))
"Settings" "Open custom file"
(lambda (&rest _) (find-file custom-file)))
(,(when (icons-displayable-p)
(nerd-icons-mdicon "nf-md-update" :height 1.5))
"Update" "Update Centaur Emacs"
(lambda (&rest _) (centaur-update)))
(,(if (icons-displayable-p)
(nerd-icons-mdicon "nf-md-help" :height 1.5)
"?")
"" "Help (?/h)"
(lambda (&rest _) (dashboard-hydra/body))
font-lock-string-face))))
(dashboard-setup-startup-hook)
:config
;; Insert copyright
;; @see https://github.com/emacs-dashboard/emacs-dashboard/issues/219
(defun restore-previous-session ()
"Restore the previous session."
(interactive)
(when (bound-and-true-p persp-mode)
(restore-session persp-auto-save-fname)))
(defun restore-session (fname)
"Restore the specified session."
(interactive (list (read-file-name "Load perspectives from a file: "
persp-save-dir)))
(when (bound-and-true-p persp-mode)
(message "Restoring session...")
(quit-window t)
(condition-case-unless-debug err
(persp-load-state-from-file fname)
(error "Error: Unable to restore session -- %s" err))
(message "Restoring session...done")))
(defun dashboard-goto-recent-files ()
"Go to recent files."
(interactive)
(let ((func (local-key-binding "r")))
(and func (funcall func))))
(defun dashboard-goto-projects ()
"Go to projects."
(interactive)
(let ((func (local-key-binding "p")))
(and func (funcall func))))
(defun dashboard-goto-bookmarks ()
"Go to bookmarks."
(interactive)
(let ((func (local-key-binding "m")))
(and func (funcall func))))
(defvar dashboard-recover-layout-p nil
"Wether recovers the layout.")
(defun open-dashboard ()
"Open the *dashboard* buffer and jump to the first widget."
(interactive)
;; Check if need to recover layout
(if (length> (window-list-1)
;; exclude `treemacs' window
(if (and (fboundp 'treemacs-current-visibility)
(eq (treemacs-current-visibility) 'visible))
2
1))
(setq dashboard-recover-layout-p t))
;; Display dashboard in maximized window
(delete-other-windows)
;; Refresh dashboard buffer
(dashboard-refresh-buffer)
;; Jump to the first section
(dashboard-goto-recent-files))
(defun quit-dashboard ()
"Quit dashboard window."
(interactive)
(quit-window t)
(and dashboard-recover-layout-p
(and (bound-and-true-p winner-mode) (winner-undo))
(setq dashboard-recover-layout-p nil))))
;;(use-package dashboard
;; :diminish dashboard-mode
;; :hook (dashboard-mode . (lambda ()
;; ;; No title
;; (setq-local frame-title-format nil)
;; ;; Enable `page-break-lines-mode'
;; (when (fboundp 'page-break-lines-mode)
;; (page-break-lines-mode 1))))
;; :config
;; (setq dashboard-set-heading-icons t)
;; (setq dashboard-set-file-icons t)
;; (setq dashboard-icon-type 'nerd-icons)
;;
;; ;;(setq dashboard-banner-logo-title "Emacs is more than a text editor!")
;; ;; logo from github.com/egstatsml/emacs_fancy_logos
;; ;;(setq dashboard-startup-banner "~/.config/emacs/logos/xemacs_color.png")
;; ;;(setq dashboard-startup-banner 'logo)
;; (setq dashboard-center-content t)
;; (setq dashboard-week-agenda t)
;; (setq dashboard-set-footer t)
;; ;;(setq dashboard-page-separator "\n\n")
;; (setq dashboard-page-separator "\n\f\n")
;; (setq dashboard-agenda-time-string-format "%d/%m/%Y %A %H:%M")
;; (setq dashboard-projects-backend 'project-el)
;; (setq dashboard-items '((recents . 10)
;; (agenda . 5)
;; (bookmarks . 5)
;; ;;(if (version< emacs-version "29")
;; ;;(projects . 5)
;; (registers . 5)))
;; (setq dashboard-set-navigator t)
;;
;; ;;(setq dashboard-navigator-buttons
;; ;; `(;; line1
;; ;; ((,(all-the-icons-octicon "mark-github" :height 1.1 :v-adjust 0.0)
;; ;; "Github"
;; ;; "Browse my Github"
;; ;; (lambda (&rest _) (browse-url "https://github.com/JaeUs3792/")))
;; ;; (,(all-the-icons-octicon "home" :height 1.1 :v-adjust 0.0)
;; ;; "Homepage"
;; ;; "Browse my Homepage"
;; ;; (lambda (&rest _) (browse-url "https://jaeus.net")))
;; ;; (,(all-the-icons-octicon "zap" :height 1.1 :v-adjust 0.0)
;; ;; "Refresh"
;; ;; "Refresh Packages"
;; ;; (lambda (&rest _) (package-refresh-contents)) warning))))
;;
;; (dashboard-setup-startup-hook)
;; (dashboard-modify-heading-icons '((recents . "file-text")
;; (bookmarks . "book")))
;; (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))))
(provide 'init-dashboard)
;;; init-dashboard.el ends here

View File

@ -1,6 +1,6 @@
;;; init-edit.el -*- lexical-binding: t -*-
(require 'init-const)
(require 'init-func)
(require 'init-funcs)
(use-package autorevert
:ensure nil
@ -44,32 +44,32 @@
(use-package hideshow
:ensure nil
:diminish hs-minor-mode
;;:pretty-hydra
;;((:title (pretty-hydra-title "HideShow" 'octicon "nf-oct-fold")
;; :color amaranth :quit-key ("q" "C-g"))
;; ("Fold"
;; (("t" hs-toggle-all "toggle all")
;; ("a" hs-show-all "show all")
;; ("i" hs-hide-all "hide all")
;; ("g" hs-toggle-hiding "toggle hiding")
;; ("c" hs-cycle "cycle block")
;; ("s" hs-show-block "show block")
;; ("h" hs-hide-block "hide block")
;; ("l" hs-hide-level "hide level"))
;; "Move"
;; (("C-a" mwim-beginning-of-code-or-line "⭰")
;; ("C-e" mwim-end-of-code-or-line "⭲")
;; ("C-b" backward-char "←")
;; ("C-n" next-line "↓")
;; ("C-p" previous-line "↑")
;; ("C-f" forward-char "→")
;; ("C-v" pager-page-down "↘")
;; ("M-v" pager-page-up "↖")
;; ("M-<" beginning-of-buffer "⭶")
;; ("M->" end-of-buffer "⭸"))))
;;:bind (:map hs-minor-mode-map
;; ("C-~" . hideshow-hydra/body)
;; ("C-S-<escape>" . hideshow-hydra/body))
:pretty-hydra
((:title (pretty-hydra-title "HideShow" 'octicon "nf-oct-fold")
:color amaranth :quit-key ("q" "C-g"))
("Fold"
(("t" hs-toggle-all "toggle all")
("a" hs-show-all "show all")
("i" hs-hide-all "hide all")
("g" hs-toggle-hiding "toggle hiding")
("c" hs-cycle "cycle block")
("s" hs-show-block "show block")
("h" hs-hide-block "hide block")
("l" hs-hide-level "hide level"))
"Move"
(("C-a" mwim-beginning-of-code-or-line "")
("C-e" mwim-end-of-code-or-line "")
("C-b" backward-char "")
("C-n" next-line "")
("C-p" previous-line "")
("C-f" forward-char "")
("C-v" pager-page-down "")
("M-v" pager-page-up "")
("M-<" beginning-of-buffer "")
("M->" end-of-buffer ""))))
:bind (:map hs-minor-mode-map
("C-~" . hideshow-hydra/body)
("C-S-<escape>" . hideshow-hydra/body))
:hook (prog-mode . hs-minor-mode)
:config
;; More functions

View File

@ -1,6 +1,6 @@
;;; init-evil.el -*- lexical-binding: t -*-
(require 'init-const)
(require 'init-func)
(require 'init-funcs)
(use-package evil
:ensure nil

View File

@ -1,18 +0,0 @@
;;; init-func.el -*- lexical-binding: t -*-
(require 'cl-lib)
(require 'init-const)
(defun font-installed-p (font-name)
(find-font (font-spec :name font-name)))
(defun too-long-file-p ()
"Check whether the file is too long."
(if (fboundp 'buffer-line-statistics)
(> (car (buffer-line-statistics)) 10000)
(> (buffer-size) 100000)))
(defun icons-displayable-p ()
"Return non-nil if icons are displayable."
(or (featurep 'nerd-icons)
(require 'nerd-icons nil t)))
(provide 'init-func)
;;; init-func.el ends here

View File

@ -0,0 +1,35 @@
;;; init-funcs.el -*- lexical-binding: t -*-
(require 'cl-lib)
(require 'init-const)
(defun font-installed-p (font-name)
(find-font (font-spec :name font-name)))
(defun too-long-file-p ()
"Check whether the file is too long."
(if (fboundp 'buffer-line-statistics)
(> (car (buffer-line-statistics)) 10000)
(> (buffer-size) 100000)))
(defun icons-displayable-p ()
"Return non-nil if icons are displayable."
(or (featurep 'nerd-icons)
(require 'nerd-icons nil t)))
;;(or (featurep 'all-the-icons)
;; (require 'all-the-icons nil t)))
(defun toggle-transparency ()
(interactive)
(let ((alpha (frame-parameter nil 'alpha)))
(set-frame-parameter
nil 'alpha
(if (eql (cond ((numberp alpha) alpha)
((numberp (cdr alpha)) (cdr alpha))
;; Also handle undocumented (<active> <inactive>) form.
((numberp (cadr alpha)) (cadr alpha)))
100)
'(85 . 50) '(100 . 100)))))
(defun my/transparency-round (val)
"Round VAL to the nearest tenth of an integer."
(/ (round (* 10 val)) 10.0))
(provide 'init-funcs)
;;; init-funcs.el ends here

View File

@ -0,0 +1,112 @@
;;; init-general.el -*- lexical-binding: t -*-
(require 'init-const)
(require 'init-funcs)
;; Make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; this annoying binding.
(global-unset-key (kbd "C-j"))
(global-unset-key (kbd "C-k"))
(global-unset-key (kbd "S-SPC")) ;; input method / use only S-\
;; When you begin a keybind, whichkey will show you all keybinds you can follow the first one with in order to form a full keywords.
(use-package which-key
:defer t
:init (which-key-mode)
:diminish which-key-mode
:config
(setq which-key-idle-delay 0.5))
(use-package general
:init
(general-auto-unbind-keys)
:config
(general-evil-setup t)
(general-create-definer
ju/leader-key-def
:keymaps '(normal insert visual emacs)
:prefix "SPC"
:global-prefix "C-SPC"))
(ju/leader-key-def
"." 'find-file
;; Buffer
"b" '(:ignore t :which-key "buffer handling")
"b i" '(ibuffer :which-key "IBuffer")
"b r" '(revert-buffer :which-key "Revert Buffer")
"b k" '(kill-current-buffer :which-key "Kill current buffer")
"b n" '(next-buffer :which-key "Next buffer")
"b p" '(previous-buffer :which-key "Previous buffer")
"b B" '(ibuffer-list-buffers :which-key "IBuffer List Buffers")
"b K" '(kill-buffer :which-key "IBuffer Kill Buffers")
;; Eshell
"e" '(:ignore t :which-key "eshell")
"e h" '(counsel-esh-history :which-key "Kill history")
"e s" '(eshell :which-key "run eshell")
"e e" '(elfeed :which-key "elfeed")
;; Counsel
"f" '(:ignore t :which-key "file op.")
"f r" '(consult-recent-file :which-key "Recent files")
;; Magit
"g" '(:ignore t :which-key "magit")
"g g" '(magit :which-key "magit")
;; Hydra
"h" '(:ignore t :which-key "hydra")
"h t" '(hydra-text-scale/body :which-key "scale text")
"h w" '(hydra-writeroom-scale/body :which-key "scale whiteroom")
"h a" '(hydra-modify-alpha/body :which-key "modify alpha background")
;; Insert something
"i" '(:ignore t :which-key "insert something.")
"i s" '(yas-insert-snippet :which-key "snippet")
"i e" '(emojify-insert-emoji :which-key "emoji")
;; Org Journal / Org Roam
"j" '(:ignore t :which-key "Journal / Roam")
"n j" '(:ignore t :which-key "Org Journal")
"n j j" '(org-journal-new-entry :which-key "new Entry")
"n j J" '(org-journal-new-scheduled-entry :which-key "New Scheduled entry")
"n j s" '(org-journal-search :which-key "Journal Search")
"n r" '(:ignore t :which-key "Org Roam")
"n r c" '(org-roam-capture :which-key "capture")
"n r u" '(org-roam-ui-open :which-key "UI")
"n r l" '(org-roam-buffer-toggle :which-key "buffer toggle")
"n r f" '(org-roam-node-find :which-key "node find")
"n r i" '(org-roam-node-insert :which-key "node insert")
"n r I" '(org-id-get-create :which-key "create id")
"n r g" '(my/org-roam-rg-search :which-key "roam ripgrep")
"n r t" '(:ignore t :which-key "Org Roam Tags")
"n r t t" '(org-roam-tag-add :which-key "new tag")
"n r t d" '(org-roam-tag-remove :which-key "delete tag")
;; Org mode
"o" '(:ignore t :which-key "Org mode")
"o a" '(:ignore t :which-key "Org Agenda")
"o a a" '(org-agenda :which-key "open org agenda")
"o a r" '(my/org-roam-refresh-agenda-list :which-key "Org agenda refresh list")
"o a c" '((lambda () (interactive) (find-file (expand-file-name "agenda/agenda.org" org-directory))) :which-key "org agenda file")
"o c" '(cfw:open-org-calendar :which-key "org calendar")
;; Project-el
"p" '(:ignore t :which-key "project")
"p ." '(project-switch-project :which-key "switch project")
"p p" '(project-switch-project :which-key "switch project")
"p c" '(project-compile :which-key "compile")
"p f" '(project-find-file :which-key "find-file")
"p k" '(project-kill-buffers :which-key "kill buffers")
"p s" '(project-shell :which-key "shell")
"p e" '(project-eshell :which-key "eshell")
"p d" '(project-dired :which-key "dired")
;;"p g" '(project-find-regexp :which-key "find-regexp")
"p g" '(consult-ripgrep :which-key "ripgrep")
;; register
"r" '(:ignore t :which-key "register")
"r y" '(consult-register-save :which-key "yank to register")
"r p" '(consult-register-load :which-key "paste to buffer")
;; Extra
"t" '(:ignore t :which-key "extra")
"t a" '(toggle-transparency :which-key "Toggle Transparency")
"t t" '(toggle-truncate-lines :which-key "Toggle truncate lines")
;; Avy
"v" '(:ignore t :which-key "Avy")
"vc" '(avy-goto-char :which-key "Avy Goto Char")
"vw" '(avy-goto-word-0 :which-key "Avy Goto Word")
"vl" '(avy-goto-line :which-key "Avy Goto Line"))
(provide 'init-general)
;;; init-general.el ends here.

View File

@ -1,6 +1,6 @@
;; init-hydra.el -*- lexical-binding: t -*-
(require 'init-const)
(require 'init-func)
(require 'init-funcs)
(use-package hydra
:hook (emacs-lisp-mode . hydra-add-imenu))
@ -23,6 +23,7 @@
(concat
(when (and (icons-displayable-p) icon-type icon-name)
(let ((f (intern (format "nerd-icons-%s" icon-type))))
;;(let ((f (intern (format "all-the-icons-%s" icon-type))))
(when (fboundp f)
(concat
(apply f (list icon-name :face face :height height :v-adjust v-adjust))

View File

@ -1,6 +1,6 @@
;;; init-package.el -*- lexical-binding: t -*-
(require 'init-const)
(require 'init-func)
(require 'init-funcs)
(when (and (file-exists-p custom-default-file)
(not (file-exists-p custom-file)))

View File

@ -1,6 +1,6 @@
;;; init-ui.el -*- lexical-binding: t -*-
(require 'init-const)
(require 'init-func)
(require 'init-funcs)
;; Optimization
(setq idle-update-delay 1.0)
@ -21,8 +21,7 @@
(use-package doom-themes
:init
(if (display-graphic-p)
;;(load-theme 'doom-palenight t)
(load-theme 'doom-one t)
(load-theme custom-theme-sel t)
(load-theme 'doom-gruvbox t))
:config
(doom-themes-visual-bell-config))
@ -53,6 +52,7 @@
;; Icons
(use-package nerd-icons)
;;(use-package all-the-icons)
(use-package display-line-numbers
:ensure nil

View File

@ -1,6 +1,6 @@
;;; init-vertico.el -*- lexical-binding: t -*-
(require 'init-const)
(require 'init-func)
(require 'init-funcs)
(use-package vertico
:bind (:map vertico-map

View File

@ -0,0 +1,11 @@
;;; init-yasnippet.el -*- lexical-binding: t -*-
;; Yet another snippet extension
(use-package yasnippet
:diminish yas-minor-mode
:hook (after-init . yas-global-mode))
;; Collection of yasnippet snippets
(use-package yasnippet-snippets)
(provide 'init-yasnippet)
;;; init-yasnippet.el ends here