From ab1f91d99ceaed77478dead2ab861cbf5de3c589 Mon Sep 17 00:00:00 2001 From: JaeYoo-Im Date: Thu, 18 May 2023 01:29:57 +0900 Subject: [PATCH] 230518-1 --- .config/emacs/custom.el | 53 +++++++++++++ .config/emacs/early-init.el | 6 +- .config/emacs/init.el | 3 + .config/emacs/lisp/init-evil.el | 7 +- .config/emacs/lisp/init-func.el | 5 +- .config/emacs/lisp/init-hydra.el | 78 +++++++++++++++++++ .config/emacs/lisp/init-package.el | 10 +-- .config/emacs/lisp/init-ui.el | 16 ++-- .config/emacs/lisp/init-vertico.el | 117 +++++++++++++++++++++++++++++ .config/fish/config.fish | 1 + 10 files changed, 270 insertions(+), 26 deletions(-) create mode 100644 .config/emacs/custom.el create mode 100644 .config/emacs/lisp/init-hydra.el create mode 100644 .config/emacs/lisp/init-vertico.el diff --git a/.config/emacs/custom.el b/.config/emacs/custom.el new file mode 100644 index 0000000..d7a701e --- /dev/null +++ b/.config/emacs/custom.el @@ -0,0 +1,53 @@ +(setq user-full-name "JaeYoo-Im" + user-mail-address "cpu3792@gmail.com") +(setq default-input-method "korean-hangul") + +(defun custom-setup-fonts () + "setup fonts..." + (when (display-graphic-p) + ;; default font + (cl-loop for font in '("FiraCode Nerd Font Mono" "Jetbrains Mono" + "Source Code Pro" "DejaVu Sans Mono") + when (font-installed-p font) + return (set-face-attribute 'default nil + :family font + :height 130)) + ;; uni code caracter + (cl-loop for font in '("Segoe UI Symbol" "Symbola" "Symbol") + when (font-installed-p font) + return (set-fontset-font t 'symbol (font-spec :family font) nil 'prepend)) + + ;; Emoji + (cl-loop for font in '("Noto Color Emoji" "Apple Color Emoji" "Segoe UI Emoji") + when (font-installed-p font) + return (cond + ((< emacs-major-version 27) + (set-fontset-font "fontset-default" 'unicode font nil 'prepend)) + ((< emacs-major-version 28) + (set-fontset-font t 'symbol (font-spec :family font) nil 'prepend)) + (t + (set-fontset-font t 'emoji (font-spec :family font) nil 'prepend)))) + + ;; Noto font or Nanum + (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))) + (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) +(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. + '(paradox-github-token t)) +(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/.config/emacs/early-init.el b/.config/emacs/early-init.el index eabbdbd..d557651 100644 --- a/.config/emacs/early-init.el +++ b/.config/emacs/early-init.el @@ -1,8 +1,6 @@ ;;; early-init.el -*- lexical-binding: t -*- ;; do not garbage collection during startup (setq gc-cons-threshold most-positive-fixnum) -;; prefers newest version of a file -(customize-set-variable 'load-prefer-newer t) ;;; Native compilation settings (when (featurep 'native-compile) @@ -16,7 +14,7 @@ (setq use-package-enable-imenu-support t) ;; -(setq non-prefer-newer noninteractive) +(setq load-prefer-newer noninteractive) (setq frame-inhibit-implied-resize t) (push '(menu-bar-lines . 0) default-frame-alist) @@ -26,7 +24,7 @@ (push '(ns-transparent-titlebar . t) default-frame-alist)) (setq-default mode-line-format nil) -(setq inhibit-startup-message nil) +;;(setq inhibit-startup-message nil) ;; initial load with blue theme ;(load-theme 'deeper-blue) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index f0e93c1..30f2eaf 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -55,9 +55,12 @@ Otherwise the startup will be very slow. " (require 'init-package) (require 'init-base) +(require 'init-hydra) (require 'init-ui) (require 'init-edit) (require 'init-evil) + +(require 'init-vertico) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; init.el ends here diff --git a/.config/emacs/lisp/init-evil.el b/.config/emacs/lisp/init-evil.el index 5a6d569..268cad3 100644 --- a/.config/emacs/lisp/init-evil.el +++ b/.config/emacs/lisp/init-evil.el @@ -12,14 +12,13 @@ evil-want-C-u-scroll t evil-want-C-i-jump nil) ;;(setq evil-respect-visual-line-mode nil) ; t : on the screen, nil : by cr characters - (require 'evil-vars) - (evil-set-undo-system 'undo-tree) - ;;(evil-set-undo-system 'undo-redo) - ;; Make evil search more like vim (makes emacs slow) ;;(evil-select-search-module 'evil-search-module 'evil-search) :config + (require 'evil-vars) + (evil-set-undo-system 'undo-tree) + ;;(evil-set-undo-system 'undo-redo) (setq evil-want-fine-undo t) ; more granular undo with evil (evil-set-initial-state 'messages-buffer-mode 'normal) (evil-set-initial-state 'dashboard-mode 'normal) diff --git a/.config/emacs/lisp/init-func.el b/.config/emacs/lisp/init-func.el index 76291a0..2b59558 100644 --- a/.config/emacs/lisp/init-func.el +++ b/.config/emacs/lisp/init-func.el @@ -9,7 +9,10 @@ (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 diff --git a/.config/emacs/lisp/init-hydra.el b/.config/emacs/lisp/init-hydra.el new file mode 100644 index 0000000..b79f171 --- /dev/null +++ b/.config/emacs/lisp/init-hydra.el @@ -0,0 +1,78 @@ +;; init-hydra.el -*- lexical-binding: t -*- +(require 'init-const) +(require 'init-func) +(use-package hydra + :hook (emacs-lisp-mode . hydra-add-imenu)) + +;; TODO +(use-package pretty-hydra + :bind ("" . toggles-hydra/body) + :hook (emacs-lisp-mode . (lambda () + (add-to-list + 'imenu-generic-expression + '("Hydras" + "^.*(\\(pretty-hydra-define\\) \\([a-zA-Z-]+\\)" + 2)))) + :init + (cl-defun pretty-hydra-title (title &optional icon-type icon-name + &key face height v-adjust) + "Add an icon in the hydra title." + (let ((face (or face `(:foreground ,(face-background 'highlight)))) + (height (or height 1.2)) + (v-adjust (or v-adjust 0.0))) + (concat + (when (and (icons-displayable-p) icon-type icon-name) + (let ((f (intern (format "nerd-icons-%s" icon-type)))) + (when (fboundp f) + (concat + (apply f (list icon-name :face face :height height :v-adjust v-adjust)) + " ")))) + (propertize title 'face face)))) + + ;; Global toggles + (with-no-warnings + (pretty-hydra-define toggles-hydra (:title (pretty-hydra-title "Toggles" 'faicon "nf-fa-toggle_on") + :color amaranth :quit-key ("q" "C-g")) + ("Basic" + (("n" (cond ((fboundp 'display-line-numbers-mode) + (display-line-numbers-mode (if display-line-numbers-mode -1 1))) + ((fboundp 'gblobal-linum-mode) + (global-linum-mode (if global-linum-mode -1 1)))) + "line number" + :toggle (or (bound-and-true-p display-line-numbers-mode) + (bound-and-true-p global-linum-mode))) + ("a" global-aggressive-indent-mode "aggressive indent" :toggle t) + ("d" global-hungry-delete-mode "hungry delete" :toggle t) + ("e" electric-pair-mode "electric pair" :toggle t) + ("c" flyspell-mode "spell check" :toggle t) + ("s" prettify-symbols-mode "pretty symbol" :toggle t) + ("l" global-page-break-lines-mode "page break lines" :toggle t) + ("b" display-battery-mode "battery" :toggle t) + ("i" display-time-mode "time" :toggle t) + ("m" doom-modeline-mode "modern mode-line" :toggle t)) + "Highlight" + (("h l" global-hl-line-mode "line" :toggle t) + ("h p" show-paren-mode "paren" :toggle t) + ("h s" symbol-overlay-mode "symbol" :toggle t) + ("h r" rainbow-mode "rainbow" :toggle t) + ("h w" (setq-default show-trailing-whitespace (not show-trailing-whitespace)) + "whitespace" :toggle show-trailing-whitespace) + ("h d" rainbow-delimiters-mode "delimiter" :toggle t) + ("h i" highlight-indent-guides-mode "indent" :toggle t) + ("h t" global-hl-todo-mode "todo" :toggle t)) + "Program" + (("f" flycheck-mode "flycheck" :toggle t) + ("F" flymake-mode "flymake" :toggle t) + ("O" hs-minor-mode "hideshow" :toggle t) + ("u" subword-mode "subword" :toggle t) + ("W" which-function-mode "which function" :toggle t) + ("E" toggle-debug-on-error "debug on error" :toggle (default-value 'debug-on-error)) + ("Q" toggle-debug-on-quit "debug on quit" :toggle (default-value 'debug-on-quit)) + ("v" global-diff-hl-mode "gutter" :toggle t) + ("V" diff-hl-flydiff-mode "live gutter" :toggle t) + ("M" diff-hl-margin-mode "margin gutter" :toggle t) + ("D" diff-hl-dired-mode "dired gutter" :toggle t)))))) + + +(provide 'init-hydra) +;;; init-hydra.el ends here diff --git a/.config/emacs/lisp/init-package.el b/.config/emacs/lisp/init-package.el index bb786b1..385f56a 100644 --- a/.config/emacs/lisp/init-package.el +++ b/.config/emacs/lisp/init-package.el @@ -19,16 +19,8 @@ (advice-add 'package--save-selected-packages :override #'my-package--save-selected-packages) (require 'package) -(add-to-list 'package-archives '("stable" . "https://stable.melpa.org/packages/")) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) -(customize-set-variable 'package-archive-priorities - '(("gnu" . 99) ; prefer GNU packages - ("nongnu" . 80) ; use non-gnu packages if - ; not found in GNU elpa - ("stable" . 70) ; prefer "released" versions - ; from melpa - ("melpa" . 0))) ; if all else fails, get it - ; from melpa + (unless (bound-and-true-p package--initialized) (setq package-enable-at-startup nil) (package-initialize)) diff --git a/.config/emacs/lisp/init-ui.el b/.config/emacs/lisp/init-ui.el index b4fd5b6..597f2ca 100644 --- a/.config/emacs/lisp/init-ui.el +++ b/.config/emacs/lisp/init-ui.el @@ -38,14 +38,14 @@ doom-modeline-persp-icon t doom-modeline-display-default-persp-name t doom-modeline-indent-info t)) -(use-package hide-mode-line - :hook (((completion-list-mode - completion-in-region-mode - eshell-mode shell-mode - term-mode vterm-mode - treemacs-mode - lsp-ui-imenu-mode - pdf-annot-list-mode) . hide-mode-line-mode))) +;;(use-package hide-mode-line +;; :hook (((completion-list-mode +;; completion-in-region-mode +;; eshell-mode shell-mode +;; term-mode vterm-mode +;; treemacs-mode +;; lsp-ui-imenu-mode +;; pdf-annot-list-mode) . hide-mode-line-mode))) ;; A minor-mode menu for mode-line (use-package minions diff --git a/.config/emacs/lisp/init-vertico.el b/.config/emacs/lisp/init-vertico.el new file mode 100644 index 0000000..171a9f5 --- /dev/null +++ b/.config/emacs/lisp/init-vertico.el @@ -0,0 +1,117 @@ +;;; init-vertico.el -*- lexical-binding: t -*- +(require 'init-const) +(require 'init-func) + +(use-package vertico + :bind (:map vertico-map + ("C-j" . vertico-next) + ("C-k" . vertico-previous)) + :hook (after-init . vertico-mode) + :custom + (vertico-cycle t)) + +;; simple, but effective sorting and filtering for emacs. +(use-package vertico-prescient + :defer t + :config + (vertico-prescient-mode)) + +;; annotations placed at the margin of the minibuffer +(use-package marginalia + :after vertico + :defer t + :custom + (marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) + :init (marginalia-mode)) + + +(use-package consult + :demand t + :bind (:map minibuffer-local-map + ("C-r" . consult-history)) + :custom + (completion-in-region-function #'consult-completion-in-region) + :config + (global-set-key (kbd "C-s") 'consult-line) + (global-set-key (kbd "C-M-j") 'consult-buffer)) + +(use-package orderless + :defer t + :custom + (completion-styles '(orderless basic)) + (completion-category-overrides '((file (style basic partial-completion))))) + +;; Quick action in minibuffer +(use-package embark + :defer t + :bind (("C-." . embark-act)) + :config + (with-eval-after-load 'embark-consult + (add-hook 'embark-collect-mode-hook #'consult-preview-at-point-mode)) + (global-set-key [remap describe-bindings] #'embark-bindings) + ;; Use Embark to show bindings in a key prefix with `C-h` + (setq prefix-help-command #'embark-prefix-help-command)) + +(use-package embark-consult + :defer t + :after embark) + +;;; Corfu +(use-package corfu + :custom + (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' + (corfu-auto t) ;; Enable auto completion + (corfu-auto-prefix 2) + (corfu-auto-delay 0.0) + (corfu-echo-documentation 0.25) + ;; (corfu-separator ?\s) ;; Orderless field separator + ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary + ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match + ;; (corfu-preview-current nil) ;; Disable current candidate preview + ;; (corfu-preselect 'prompt) ;; Preselect the prompt + ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches + ;; (corfu-scroll-margin 5) ;; Use scroll margin + :init + (global-corfu-mode) + (require 'corfu-popupinfo) + (corfu-popupinfo-mode 1) + (eldoc-add-command #'corfu-insert) + (define-key corfu-map (kbd "M-p") #'corfu-popupinfo-scroll-down) + (define-key corfu-map (kbd "M-n") #'corfu-popupinfo-scroll-up) + (define-key corfu-map (kbd "M-d") #'corfu-popupinfo-toggle)) + +(use-package corfu-terminal + :config + (unless (display-graphic-p) + (corfu-terminal-mode))) + +(use-package kind-icon + :ensure t + :after corfu + :custom + (kind-icon-default-face 'corfu-default) ; to compute blended backgrounds correctly + :config + (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)) + +;;; Cape +;; Setup Cape for better completion-at-point support and more +(use-package cape + :config + ;; Add useful defaults completion sources from cape + (add-to-list 'completion-at-point-functions #'cape-file) + (add-to-list 'completion-at-point-functions #'cape-dabbrev) + ;;(add-to-list 'completion-at-point-functions #'cape-ispell) + ;; Silence the pcomplete capf, no errors or messages! + ;; Important for corfu + (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent) + ;; Ensure that pcomplete does not write to the buffer + ;; and behaves as a pure `completion-at-point-function'. + (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify) + (add-hook 'eshell-mode-hook + (lambda () (setq-local corfu-quit-at-boundary t + corfu-quit-no-match t + corfu-auto nil) + (corfu-mode)))) + +(provide 'init-vertico) +;;; init-vertico.el ends here diff --git a/.config/fish/config.fish b/.config/fish/config.fish index a0c78f8..a9b9601 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -17,6 +17,7 @@ alias emt="emacsclient -c -a 'emacs -nw'" alias emtangle="emacs --batch -eval \"(require 'org)\" --eval '(org-babel-tangle-file \"~/.config/emacs/emacs.org\")'" #neovim to vi alias vi=nvim +alias vimdiff="nvim -d" alias cat=bat #pacman unlock alias paruunlock="sudo rm /var/lib/pacman/db.lck"