Ladicle's Emacs Configuration
Latest version is here.
Table of Contents
- 1 Configuration
- 1.1 Table of Contents:TOC_3_gh:
- 1.2 ScreenShot
- 1.3 Load Path
- 1.4 Generic
- 1.5 Key-bindings
- 1.5.1 Mouse
- 1.5.2 Custom Maps
- 1.5.3 Global
- 1.5.4 which-key
- 1.5.5 Hydra
- 1.6 Undo/Redo
- 1.7 Search/Replace
- 1.8 Cursor
- 1.8.1 multiple-cursor
- 1.8.2 avy/ace
- 1.8.3 Smart move
- 1.9 Check
- 1.10 Project
- 1.10.1 persp
- 1.11 Complition
- 1.12 Git
- 1.12.1 Timemachine
- 1.12.2 Diffview
- 1.12.3 Magit
- 1.12.4 GitModes
- 1.12.5 GitGutter
- 1.12.6 Git Remote
- 1.12.7 GitHub
- 1.12.8 Smerge
- 1.13 Tools
- 1.13.1 Google Translater
- 1.13.2 google this!
- 1.13.3 wakatime
- 1.14 Language
- 1.15 Custom Functions
- 1.15.1 Change letter case
- 1.15.2 Change smart Kill-word
- 1.15.3 Kill word or Region
- 1.15.4 Add execution flag to a file with shelbang
- 1.15.5 Copy file path
- 1.16 UI
- 1.16.1 Dashboard
- 1.16.2 General
- 1.16.3 persp
- 1.16.4 imenu-list
- 1.16.5 Transparency
- 1.16.6 Minimap
- 1.16.7 Neotree
- 1.16.8 Doom dracula Theme/Modeline
- 1.16.9 Nyan-mode
- 1.16.10 Hide Modeline
- 1.16.11 Line number
- 1.16.12 Dimmer
- 1.16.13 fill-column-indicator
- 1.16.14 Presentation
- 1.16.15 Eshell
- 1.17 High-Lights
- 1.17.1 Highlight Line
- 1.17.2 Paren
- 1.17.3 Highlight-symbol
- 1.17.4 Beacon
- 1.17.5 Rainbow delimiters
- 1.17.6 Rainbow Mode
- 1.17.7 Volatile
- 1.17.8 Indent
- 1.18 Mark
- 1.18.1 backward-forward
- 1.18.2 Point Undo
1 Configuration
1.1 Table of Contents
1.2 ScreenShot
![](/ox-hugo/screenshot.png)
1.3 Load Path
(setq user-emacs-directory "~/Developments/src/github.com/Ladicle/dotfiles/common/emacs.d/elisp")
(eval-and-compile
(setq load-prefer-newer t
package-user-dir "~/Developments/src/github.com/Ladicle/dotfiles/common/emacs.d/elpa"
package--init-file-ensured t
package-enable-at-startup nil)
(unless (file-directory-p package-user-dir)
(make-directory package-user-dir t)))
(eval-and-compile
(setq load-path (append load-path (directory-files package-user-dir t "^[^.]" t))))
(eval-when-compile
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package)
(package-install 'diminish)
(package-install 'quelpa)
(package-install 'bind-key))
(setq use-package-always-ensure t)
(setq use-package-expand-minimally t)
(require 'use-package))
(require 'diminish)
(require 'bind-key)
1.4 Generic
1.4.1 Server
(use-package server
:ensure nil
:hook (after-init . server-mode))
1.4.2 Editing
;; Ignore split window horizontally
(setq split-width-threshold nil)
(setq split-width-threshold 160)
;; Default Encoding
(prefer-coding-system 'utf-8-unix)
(set-locale-environment "en_US.UTF-8")
(set-default-coding-systems 'utf-8-unix)
(set-selection-coding-system 'utf-8-unix)
(set-buffer-file-coding-system 'utf-8-unix)
(set-clipboard-coding-system 'utf-8) ; included by set-selection-coding-system
(set-keyboard-coding-system 'utf-8) ; configured by prefer-coding-system
(set-terminal-coding-system 'utf-8) ; configured by prefer-coding-system
(setq buffer-file-coding-system 'utf-8) ; utf-8-unix
(setq save-buffer-coding-system 'utf-8-unix) ; nil
(setq process-coding-system-alist
(cons '("grep" utf-8 . utf-8) process-coding-system-alist))
;; Quiet Startup
(setq inhibit-startup-screen t)
(setq inhibit-startup-message t)
(setq inhibit-startup-echo-area-message t)
(setq initial-scratch-message nil)
(defun display-startup-echo-area-message ()
(message ""))
(setq frame-title-format nil)
(setq ring-bell-function 'ignore)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets) ; Show path if names are same
(setq adaptive-fill-regexp "[ t]+|[ t]*([0-9]+.|*+)[ t]*")
(setq adaptive-fill-first-line-regexp "^* *$")
(setq sentence-end "\\([。、!?]\\|……\\|[,.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
(setq sentence-end-double-space nil)
(setq delete-by-moving-to-trash t) ; Deleting files go to OS's trash folder
(setq make-backup-files nil) ; Forbide to make backup files
(setq auto-save-default nil) ; Disable auto save
(setq set-mark-command-repeat-pop t) ; Repeating C-SPC after popping mark pops it again
(setq track-eol t) ; Keep cursor at end of lines.
(setq line-move-visual nil) ; To be required by track-eol
(setq-default kill-whole-line t) ; Kill line including '\n'
(setq-default indent-tabs-mode nil) ; use space
(defalias 'yes-or-no-p #'y-or-n-p)
(when (functionp 'mac-auto-ascii-mode)
(mac-auto-ascii-mode 1))
;; Delete selection if insert someting
(use-package delsel
:ensure nil
:hook (after-init . delete-selection-mode))
;; Automatically reload files was modified by external program
(use-package autorevert
:ensure nil
:diminish
:hook (after-init . global-auto-revert-mode))
;; Hungry deletion
(use-package hungry-delete
:diminish
:hook (after-init . global-hungry-delete-mode)
:config (setq-default hungry-delete-chars-to-skip " \t\f\v"))
1.4.3 Smartparens
(use-package smartparens
:hook
(after-init . smartparens-global-mode)
:config
(require 'smartparens-config)
(sp-pair "=" "=" :actions '(wrap))
(sp-pair "+" "+" :actions '(wrap))
(sp-pair "<" ">" :actions '(wrap))
(sp-pair "$" "$" :actions '(wrap)))
1.4.4 History
;; History
(use-package saveplace
:ensure nil
:hook (after-init . save-place-mode))
;; Recent files
(use-package recentf
:ensure nil
:hook (after-init . recentf-mode)
:custom
(recentf-max-saved-items 20000000)
(recentf-auto-cleanup 'never)
(recentf-exclude '((expand-file-name package-user-dir)
".cache"
"cache"
"recentf"
"COMMIT_EDITMSG\\'"))
:preface
(defun ladicle/recentf-save-list-silence ()
(interactive)
(let ((message-log-max nil))
(if (fboundp 'shut-up)
(shut-up (recentf-save-list))
(recentf-save-list)))
(message ""))
(defun ladicle/recentf-cleanup-silence ()
(interactive)
(let ((message-log-max nil))
(if shutup-p
(shut-up (recentf-cleanup))
(recentf-cleanup)))
(message ""))
:hook
(focus-out-hook . (ladicle/recentf-save-list-silence ladicle/recentf-cleanup-silence)))
1.4.5 GUI/Font
font-size check
|abcdef ghijkl|
|ABCDEF GHIJKL|
|'";:-+ =/\~`?|
|∞≤≥∏∑∫ ×±⊆⊇|
|αβγδεζ ηθικλμ|
|ΑΒΓΔΕΖ ΗΘΙΚΛΜ|
|日本語 の美観|
|あいう えおか|
|アイウ エオカ|
|アイウエオカ キクケコサシ|
| hoge | hogeghoe | age |
|----------------------+----------+-------------------|
| 今日もいい天気ですね | お、 | 等幅になった :+1: |
(if window-system
(progn
;; UI parts
(toggle-scroll-bar 0)
(tool-bar-mode 0)
(menu-bar-mode 0)
;; Japanese font settings
(defun set-japanese-font (family)
(set-fontset-font (frame-parameter nil 'font) 'japanese-jisx0208 (font-spec :family family))
(set-fontset-font (frame-parameter nil 'font) 'japanese-jisx0212 (font-spec :family family))
(set-fontset-font (frame-parameter nil 'font) 'katakana-jisx0201 (font-spec :family family)))
;; Overwrite latin and greek char's font
(defun set-latin-and-greek-font (family)
(set-fontset-font (frame-parameter nil 'font) '(#x0250 . #x02AF) (font-spec :family family)) ; IPA extensions
(set-fontset-font (frame-parameter nil 'font) '(#x00A0 . #x00FF) (font-spec :family family)) ; latin-1
(set-fontset-font (frame-parameter nil 'font) '(#x0100 . #x017F) (font-spec :family family)) ; latin extended-A
(set-fontset-font (frame-parameter nil 'font) '(#x0180 . #x024F) (font-spec :family family)) ; latin extended-B
(set-fontset-font (frame-parameter nil 'font) '(#x2018 . #x2019) (font-spec :family family)) ; end quote
(set-fontset-font (frame-parameter nil 'font) '(#x2588 . #x2588) (font-spec :family family)) ; █
(set-fontset-font (frame-parameter nil 'font) '(#x2500 . #x2500) (font-spec :family family)) ; ─
(set-fontset-font (frame-parameter nil 'font) '(#x2504 . #x257F) (font-spec :family family)) ; box character
(set-fontset-font (frame-parameter nil 'font) '(#x0370 . #x03FF) (font-spec :family family)))
(setq use-default-font-for-symbols nil)
(setq inhibit-compacting-font-caches t)
(setq jp-font-family "SF Mono Square")
(setq default-font-family "FuraCode Nerd Font")
;; (set-face-attribute 'default nil :family default-font-family)
(when (eq system-type 'darwin)
(set-face-attribute 'default nil :family jp-font-family :height 140))
(when (eq system-type 'gnu/linux)
(set-face-attribute 'default nil :family jp-font-family :height 150))
(set-japanese-font jp-font-family)
(set-latin-and-greek-font default-font-family)
(add-to-list 'face-font-rescale-alist (cons default-font-family 0.86))
(add-to-list 'face-font-rescale-alist (cons jp-font-family 1.0))))
1.4.6 OS
- common
```emacs-lisp
(use-package exec-path-from-shell
:custom
(exec-path-from-shell-check-startup-files nil)
(exec-path-from-shell-variables '("PATH" "GOPATH"))
:config
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize)))
```
- Linux
1. xclip
```emacs-lisp
(use-package xclip
:if (eq system-type 'gnu/linux)
:config
(xclip-mode 1))
```
2. Mozc
```emacs-lisp
(use-package mozc
:if (eq system-type 'gnu/linux)
:commands (mozc-mode mozc-handle-event)
:custom (default-input-method "japanese-mozc")
:bind (("M-l" . mozc-start)
:map mozc-mode-map
("," . (lambda () (interactive) (mozc-insert-str "、")))
("." . (lambda () (interactive) (mozc-insert-str "。")))
("?" . (lambda () (interactive) (mozc-insert-str "?")))
("!" . (lambda () (interactive) (mozc-insert-str "!")))
("l" . mozc-end)
("C-m" . (lambda () (interactive) (mozc-insert-str "")))
("<enter>" . (lambda () (interactive) (mozc-insert-str "")))
("C-h" . delete-backward-char))
:init
(defun mozc-start()
(interactive)
(set-cursor-color "#ff79c6")
(message "Mozc start")
(mozc-mode 1))
(defun mozc-end()
(interactive)
(mozc-handle-event 'enter)
(set-cursor-color "cyan")
(message "Mozc end")
(mozc-mode -1))
(defun mozc-insert-str (str)
(mozc-handle-event 'enter)
(insert str))
:config
(mozc-mode 1)
;; Show candidates style
(use-package mozc-popup
:custom (mozc-candidates-style "popup")))
```
- macOS
```emacs-lisp
(when (equal system-type 'darwin)
(setq mac-option-modifier 'super)
(setq mac-command-modifier 'meta)
(setq ns-auto-hide-menu-bar t)
(setq ns-use-proxy-icon nil)
(setq initial-frame-alist
(append
'((ns-transparent-titlebar . t)
(ns-appearance . dark)
(vertical-scroll-bars . nil)
(internal-border-width . 0)))))
;; pbcopy
(use-package pbcopy
:if (eq system-type 'darwin)
:hook (dashboard-mode . (turn-on-pbcopy)))
```
1.4.7 Icons
(use-package all-the-icons
:defer t
:load-path "~/Developments/src/github.com/Ladicle/all-the-icons.el/")
1.4.8 posframe
(use-package posframe)
1.4.9 point
(use-package popwin)
(use-package point-history
:load-path "~/Developments/src/github.com/blue0513/point-history"
:config
(point-history-mode t))
1.5 Key-bindings
1.5.1 Mouse
(xterm-mouse-mode t)
(global-set-key [mouse-4] '(lambda () (interactive) (scroll-down 1)))
(global-set-key [mouse-5] '(lambda () (interactive) (scroll-up 1)))
1.5.2 Custom Maps
(define-prefix-command 'ladicle-window-map)
(define-key global-map (kbd "M-o") 'ladicle-window-map)
(define-prefix-command 'ladicle-toggle-map)
(define-key global-map (kbd "M-t") 'ladicle-toggle-map)
(define-prefix-command 'ladicle-link-map)
(define-key global-map (kbd "M-o l") 'ladicle-link-map)
1.5.3 Global
(global-unset-key "\C-z")
(global-set-key (kbd "M-o m") 'async-shell-command)
(global-set-key (kbd "M-o b") 'switch-to-buffer)
(global-set-key (kbd "C-x C-b") 'switch-to-buffer)
(global-set-key (kbd "C-M-g") 'goto-line)
(global-set-key (kbd "C-h") 'backward-delete-char)
(global-set-key (kbd "C-o") 'other-window)
(global-set-key (kbd "M-:") 'comment-dwim)
(global-set-key (kbd "C-m") 'electric-newline-and-maybe-indent)
(global-set-key (kbd "C-j") 'newline-and-indent)
(global-set-key (kbd "M-r") 'rename-file)
(global-set-key (kbd "M-t l") 'toggle-truncate-lines)
1.5.4 which-key
Guide Key-bindings https://github.com/justbur/emacs-which-key
(use-package which-key
:diminish which-key-mode
:hook (after-init . which-key-mode))
1.5.5 Hydra
(use-package hydra
:config
(use-package hydra-posframe
:load-path "~/Developments/src/github.com/Ladicle/hydra-posframe"
:custom
(hydra-posframe-parameters
'((left-fringe . 5)
(right-fringe . 5)))
:custom-face
(hydra-posframe-border-face ((t (:background "#6272a4"))))
:hook (after-init . hydra-posframe-enable)))
1.6 Undo/Redo
https://www.emacswiki.org/emacs/UndoTree
(use-package undo-tree
:bind
("M-/" . undo-tree-redo)
:config
(global-undo-tree-mode))
1.7 Search/Replace
1.7.1 Projectile
(use-package projectile
:diminish
:bind
("M-o p" . counsel-projectile-switch-project)
:config
(projectile-mode +1))
1.7.2 Wgrep
(use-package wgrep
:defer t
:custom
(wgrep-enable-key "e")
(wgrep-auto-save-buffer t)
(wgrep-change-readonly-file t))
1.7.3 Ag
(use-package ag
:custom
(ag-highligh-search t)
(ag-reuse-buffers t)
(ag-reuse-window t)
:bind
("M-s a" . ag-project)
:config
(use-package wgrep-ag))
1.7.4 Ivy
https://github.com/abo-abo/swiper
(use-package counsel
:diminish ivy-mode counsel-mode
:defines
(projectile-completion-system magit-completing-read-function)
:bind
(("C-s" . swiper)
("M-s r" . ivy-resume)
("C-c v p" . ivy-push-view)
("C-c v o" . ivy-pop-view)
("C-c v ." . ivy-switch-view)
("M-s c" . counsel-ag)
("M-o f" . counsel-fzf)
("M-o r" . counsel-recentf)
("M-y" . counsel-yank-pop)
:map ivy-minibuffer-map
("C-w" . ivy-backward-kill-word)
("C-k" . ivy-kill-line)
("C-j" . ivy-immediate-done)
("RET" . ivy-alt-done)
("C-h" . ivy-backward-delete-char))
:preface
(defun ivy-format-function-pretty (cands)
"Transform CANDS into a string for minibuffer."
(ivy--format-function-generic
(lambda (str)
(concat
(all-the-icons-faicon "hand-o-right" :height .85 :v-adjust .05 :face 'font-lock-constant-face)
(ivy--add-face str 'ivy-current-match)))
(lambda (str)
(concat " " str))
cands
"\n"))
:hook
(after-init . ivy-mode)
(ivy-mode . counsel-mode)
:custom
(counsel-yank-pop-height 15)
(enable-recursive-minibuffers t)
(ivy-use-selectable-prompt t)
(ivy-use-virtual-buffers t)
(ivy-on-del-error-function nil)
(swiper-action-recenter t)
(counsel-grep-base-command "ag -S --noheading --nocolor --nofilename --numbers '%s' %s")
:config
;; using ivy-format-fuction-arrow with counsel-yank-pop
(advice-add
'counsel--yank-pop-format-function
:override
(lambda (cand-pairs)
(ivy--format-function-generic
(lambda (str)
(mapconcat
(lambda (s)
(ivy--add-face (concat (propertize "┃ " 'face `(:foreground "#61bfff")) s) 'ivy-current-match))
(split-string
(counsel--yank-pop-truncate str) "\n" t)
"\n"))
(lambda (str)
(counsel--yank-pop-truncate str))
cand-pairs
counsel-yank-pop-separator)))
;; NOTE: this variable do not work if defined in :custom
(setq ivy-format-function 'ivy-format-function-pretty)
(setq counsel-yank-pop-separator
(propertize "\n────────────────────────────────────────────────────────\n"
'face `(:foreground "#6272a4")))
;; Integration with `projectile'
(with-eval-after-load 'projectile
(setq projectile-completion-system 'ivy))
;; Integration with `magit'
(with-eval-after-load 'magit
(setq magit-completing-read-function 'ivy-completing-read))
;; Enhance fuzzy matching
(use-package flx)
;; Enhance M-x
(use-package amx)
;; Ivy integration for Projectile
(use-package counsel-projectile
:config (counsel-projectile-mode 1))
;; Show ivy frame using posframe
(use-package ivy-posframe
:custom
(ivy-display-function #'ivy-posframe-display-at-frame-center)
;; (ivy-posframe-width 130)
;; (ivy-posframe-height 11)
(ivy-posframe-parameters
'((left-fringe . 5)
(right-fringe . 5)))
:custom-face
(ivy-posframe ((t (:background "#282a36"))))
(ivy-posframe-border ((t (:background "#6272a4"))))
(ivy-posframe-cursor ((t (:background "#61bfff"))))
:hook
(ivy-mode . ivy-posframe-enable))
;; ghq
(use-package ivy-ghq
:load-path "~/Developments/src/github.com/analyticd/ivy-ghq"
:commands (ivy-ghq-open)
:bind
("M-o p" . ivy-ghq-open-and-fzf)
:custom
(ivy-ghq-short-list t)
:preface
(defun ivy-ghq-open-and-fzf ()
(interactive)
(ivy-ghq-open)
(counsel-fzf)))
;; More friendly display transformer for Ivy
(use-package ivy-rich
:defines (all-the-icons-dir-icon-alist bookmark-alist)
:functions (all-the-icons-icon-family
all-the-icons-match-to-alist
all-the-icons-auto-mode-match?
all-the-icons-octicon
all-the-icons-dir-is-submodule)
:preface
(defun ivy-rich-bookmark-name (candidate)
(car (assoc candidate bookmark-alist)))
(defun ivy-rich-repo-icon (candidate)
"Display repo icons in `ivy-rich`."
(all-the-icons-octicon "repo" :height .9))
(defun ivy-rich-org-capture-icon (candidate)
"Display repo icons in `ivy-rich`."
(pcase (car (last (split-string (car (split-string candidate)) "-")))
("emacs" (all-the-icons-fileicon "emacs" :height .68 :v-adjust .001))
("schedule" (all-the-icons-faicon "calendar" :height .68 :v-adjust .005))
("tweet" (all-the-icons-faicon "commenting" :height .7 :v-adjust .01))
("link" (all-the-icons-faicon "link" :height .68 :v-adjust .01))
("memo" (all-the-icons-faicon "pencil" :height .7 :v-adjust .01))
(_ (all-the-icons-octicon "inbox" :height .68 :v-adjust .01))
))
(defun ivy-rich-org-capture-title (candidate)
(let* ((octl (split-string candidate))
(title (pop octl))
(desc (mapconcat 'identity octl " ")))
(format "%-25s %s"
title
(propertize desc 'face `(:inherit font-lock-doc-face)))))
(defun ivy-rich-buffer-icon (candidate)
"Display buffer icons in `ivy-rich'."
(when (display-graphic-p)
(when-let* ((buffer (get-buffer candidate))
(major-mode (buffer-local-value 'major-mode buffer))
(icon (if (and (buffer-file-name buffer)
(all-the-icons-auto-mode-match? candidate))
(all-the-icons-icon-for-file candidate)
(all-the-icons-icon-for-mode major-mode))))
(if (symbolp icon)
(setq icon (all-the-icons-icon-for-mode 'fundamental-mode)))
(unless (symbolp icon)
(propertize icon
'face `(
:height 1.1
:family ,(all-the-icons-icon-family icon)
))))))
(defun ivy-rich-file-icon (candidate)
"Display file icons in `ivy-rich'."
(when (display-graphic-p)
(let ((icon (if (file-directory-p candidate)
(cond
((and (fboundp 'tramp-tramp-file-p)
(tramp-tramp-file-p default-directory))
(all-the-icons-octicon "file-directory"))
((file-symlink-p candidate)
(all-the-icons-octicon "file-symlink-directory"))
((all-the-icons-dir-is-submodule candidate)
(all-the-icons-octicon "file-submodule"))
((file-exists-p (format "%s/.git" candidate))
(all-the-icons-octicon "repo"))
(t (let ((matcher (all-the-icons-match-to-alist candidate all-the-icons-dir-icon-alist)))
(apply (car matcher) (list (cadr matcher))))))
(all-the-icons-icon-for-file candidate))))
(unless (symbolp icon)
(propertize icon
'face `(
:height 1.1
:family ,(all-the-icons-icon-family icon)
))))))
:hook (ivy-rich-mode . (lambda ()
(setq ivy-virtual-abbreviate
(or (and ivy-rich-mode 'abbreviate) 'name))))
:init
(setq ivy-rich-display-transformers-list
'(ivy-switch-buffer
(:columns
((ivy-rich-buffer-icon)
(ivy-rich-candidate (:width 30))
(ivy-rich-switch-buffer-size (:width 7))
(ivy-rich-switch-buffer-indicators (:width 4 :face error :align right))
(ivy-rich-switch-buffer-major-mode (:width 12 :face warning))
(ivy-rich-switch-buffer-project (:width 15 :face success))
(ivy-rich-switch-buffer-path (:width (lambda (x) (ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.3))))))
:predicate
(lambda (cand) (get-buffer cand)))
ivy-switch-buffer-other-window
(:columns
((ivy-rich-buffer-icon)
(ivy-rich-candidate (:width 30))
(ivy-rich-switch-buffer-size (:width 7))
(ivy-rich-switch-buffer-indicators (:width 4 :face error :align right))
(ivy-rich-switch-buffer-major-mode (:width 12 :face warning))
(ivy-rich-switch-buffer-project (:width 15 :face success))
(ivy-rich-switch-buffer-path (:width (lambda (x) (ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.3))))))
:predicate
(lambda (cand) (get-buffer cand)))
counsel-M-x
(:columns
((counsel-M-x-transformer (:width 40))
(ivy-rich-counsel-function-docstring (:face font-lock-doc-face))))
counsel-describe-function
(:columns
((counsel-describe-function-transformer (:width 45))
(ivy-rich-counsel-function-docstring (:face font-lock-doc-face))))
counsel-describe-variable
(:columns
((counsel-describe-variable-transformer (:width 45))
(ivy-rich-counsel-variable-docstring (:face font-lock-doc-face))))
counsel-find-file
(:columns
((ivy-rich-file-icon)
(ivy-rich-candidate)))
counsel-file-jump
(:columns
((ivy-rich-file-icon)
(ivy-rich-candidate)))
counsel-dired-jump
(:columns
((ivy-rich-file-icon)
(ivy-rich-candidate)))
counsel-git
(:columns
((ivy-rich-file-icon)
(ivy-rich-candidate)))
counsel-recentf
(:columns
((ivy-rich-file-icon)
(ivy-rich-candidate (:width 110))))
counsel-bookmark
(:columns
((ivy-rich-bookmark-type)
(ivy-rich-bookmark-name (:width 30))
(ivy-rich-bookmark-info (:width 80))))
counsel-projectile-switch-project
(:columns
((ivy-rich-file-icon)
(ivy-rich-candidate)))
counsel-fzf
(:columns
((ivy-rich-file-icon)
(ivy-rich-candidate)))
ivy-ghq-open
(:columns
((ivy-rich-repo-icon)
(ivy-rich-candidate)))
ivy-ghq-open-and-fzf
(:columns
((ivy-rich-repo-icon)
(ivy-rich-candidate)))
counsel-projectile-find-file
(:columns
((ivy-rich-file-icon)
(ivy-rich-candidate)))
counsel-org-capture
(:columns
((ivy-rich-org-capture-icon)
(ivy-rich-org-capture-title)
))
counsel-projectile-find-dir
(:columns
((ivy-rich-file-icon)
(counsel-projectile-find-dir-transformer)))))
(setq ivy-rich-parse-remote-buffer nil)
:config
(ivy-rich-mode 1))
)
1.7.5 Anzu
(use-package anzu
:diminish
:bind
("C-r" . anzu-query-replace-regexp)
("C-M-r" . anzu-query-replace-at-cursor-thing)
:hook
(after-init . global-anzu-mode))
1.7.6 Migemo
(use-package migemo
:custom
(migemo-command "/usr/local/bin/cmigemo")
(migemo-options '("-q" "--emacs"))
(migemo-user-dictionary nil)
(migemo-regex-dictionary nil)
(migemo-coding-system 'utf-8-unix)
(migemo-dictionary "/usr/share/cmigemo/utf-8/migemo-dict")
:config
(when (eq system-type 'darwin)
(setq migemo-dictionary "/usr/local/share/migemo/utf-8/migemo-dict"))
(migemo-init)
(use-package avy-migemo
:after swiper
:config
;; (avy-migemo-mode 1)
(require 'avy-migemo-e.g.swiper))
)
1.8 Cursor
1.8.1 multiple-cursor
(use-package multiple-cursors
:functions hydra-multiple-cursors
:bind
("M-u" . hydra-multiple-cursors/body)
:preface
;; insert specific serial number
(defvar ladicle/mc/insert-numbers-hist nil)
(defvar ladicle/mc/insert-numbers-inc 1)
(defvar ladicle/mc/insert-numbers-pad "%01d")
(defun ladicle/mc/insert-numbers (start inc pad)
"Insert increasing numbers for each cursor specifically."
(interactive
(list (read-number "Start from: " 0)
(read-number "Increment by: " 1)
(read-string "Padding (%01d): " nil ladicle/mc/insert-numbers-hist "%01d")))
(setq mc--insert-numbers-number start)
(setq ladicle/mc/insert-numbers-inc inc)
(setq ladicle/mc/insert-numbers-pad pad)
(mc/for-each-cursor-ordered
(mc/execute-command-for-fake-cursor
'ladicle/mc--insert-number-and-increase
cursor)))
(defun ladicle/mc--insert-number-and-increase ()
(interactive)
(insert (format ladicle/mc/insert-numbers-pad mc--insert-numbers-number))
(setq mc--insert-numbers-number (+ mc--insert-numbers-number ladicle/mc/insert-numbers-inc)))
:config
(with-eval-after-load 'hydra
(defhydra hydra-multiple-cursors (:color pink :hint nil)
"
╔════════╗
Point^^^^^^ Misc^^ Insert ║ Cursor ║
──────────────────────────────────────────────────────────────────────╨────────╜
_k_ _K_ _M-k_ [_l_] edit lines [_i_] 0...
^↑^ ^↑^ ^↑^ [_m_] mark all [_a_] letters
mark^^ skip^^^ un-mk^ [_s_] sort [_n_] numbers
^↓^ ^↓^ ^↓^
_j_ _J_ _M-j_
╭──────────────────────────────────────────────────────────────────────────────╯
[_q_]: quit, [Click]: point
"
("l" mc/edit-lines :exit t)
("m" mc/mark-all-like-this :exit t)
("j" mc/mark-next-like-this)
("J" mc/skip-to-next-like-this)
("M-j" mc/unmark-next-like-this)
("k" mc/mark-previous-like-this)
("K" mc/skip-to-previous-like-this)
("M-k" mc/unmark-previous-like-this)
("s" mc/mark-all-in-region-regexp :exit t)
("i" mc/insert-numbers :exit t)
("a" mc/insert-letters :exit t)
("n" ladicle/mc/insert-numbers :exit t)
("<mouse-1>" mc/add-cursor-on-click)
;; Help with click recognition in this hydra
("<down-mouse-1>" ignore)
("<drag-mouse-1>" ignore)
("q" nil))))
1.8.2 avy/ace
(use-package avy
:functions (hydra-avy hydra-viewer)
:bind
("C-'" . avy-resume)
("C-:" . avy-goto-char-2-below)
("C-;" . avy-goto-char)
("M-j" . hydra-avy/body)
("C-M-v" . hydra-viewer/body)
:preface
;; fixed cursor scroll-up
(defun scroll-up-in-place (n)
(interactive "p")
(forward-line (- n))
(scroll-down n))
;; fixed cursor scroll-down
(defun scroll-down-in-place (n)
(interactive "p")
(forward-line n)
(scroll-up n))
;; yank inner sexp
(defun yank-inner-sexp ()
(interactive)
(backward-list)
(mark-sexp)
(copy-region-as-kill (region-beginning) (region-end)))
:config
(when (eq system-type 'darwin)
(progn
(global-set-key (kbd "C-:") 'avy-goto-char)
(global-set-key (kbd "C-;") 'avy-goto-char-2-below)))
(use-package avy-zap
:bind
("M-z" . avy-zap-to-char-dwim)
("M-z" . avy-zap-up-to-char-dwim))
(with-eval-after-load 'hydra
(defhydra hydra-viewer (:color pink :hint nil)
"
╔════════╗
Char/Line^^^^^^ Word/Page^^^^^^^^ Line/Buff^^^^ Paren ║ Window ║
──────────────────────────────────────────────────────────────────────╨────────╜
^^_k_^^ ^^_u_^^ ^^_g_^^ _(_ ← _y_ → _)_
^^^↑^^^ ^^^↑^^^ ^^^↑^^^ _,_ ← _/_ → _._
_h_ ← _d_ → _l_ _H_ ← _D_ → _L_ _a_ ← _K_ → _e_
^^^↓^^^ ^^^↓^^^ ^^^↓^
^^_j_^^ ^^_n_^^ ^^_G_
╭──────────────────────────────────────────────────────────────────────────────╯
[_q_]: quit, [_<SPC>_]: center
"
("j" scroll-down-in-place)
("k" scroll-up-in-place)
("l" forward-char)
("d" delete-char)
("h" backward-char)
("L" forward-word)
("H" backward-word)
("u" scroll-up-command)
("n" scroll-down-command)
("D" delete-word-at-point)
("a" mwim-beginning-of-code-or-line)
("e" mwim-end-of-code-or-line)
("g" beginning-of-buffer)
("G" end-of-buffer)
("K" kill-whole-line)
("(" backward-list)
(")" forward-list)
("y" yank-inner-sexp)
("." backward-forward-next-location)
("," backward-forward-previous-location)
("/" avy-goto-char :exit t)
("<SPC>" recenter-top-bottom)
("q" nil))
(defhydra hydra-avy (:color pink :hint nil)
"
╔════════╗
^^Goto^^ Kill^^ Yank^^ Move^^ Misc ║ Jump ║
──────────────────────────────────────────────────────────────────────╨────────╜
_c_ ← char^^ [_k_] region [_y_] region [_m_] region [_n_] line number
_a_ ← char2 → _b_ [_K_] line [_Y_] line [_M_] line [_v_] Goto viewer
_w_ ← word → _W_ [_z_] zap^^^^ [_o_] Goto clock
_l_ ← line → _e_ ^^^^^ _,_ ← f!y → _._
╭──────────────────────────────────────────────────────────────────────────────╯
[_q_]: quit, [_i_]: imenu, [_<SPC>_]: resume
"
("c" avy-goto-char :exit t)
("a" avy-goto-char-2 :exit t)
("b" avy-goto-char-below :exit t)
("w" avy-goto-word-1 :exit t)
("W" avy-goto-word-1-below :exit t)
("l" avy-goto-line :exit t)
("e" avy-goto-end-of-line :exit t)
("M" avy-move-line)
("m" avy-move-region)
("K" avy-kill-whole-line)
("k" avy-kill-region)
("Y" avy-copy-line :exit t)
("y" avy-copy-region :exit t)
("n" goto-line :exit t)
("o" org-clock-jump-to-current-clock :exit t)
("z" avy-zap-to-char-dwim :exit t)
("v" hydra-viewer/body :exit t)
("<SPC>" avy-resume :exit t)
("o" org-clock-jump-to-current-clock :exit t)
("i" counsel-imenu :exit t)
("," flymake-goto-previous-error)
("." flymake-goto-next-error)
("q" nil))))
(use-package ace-window
:functions hydra-frame-window/body
:bind
("C-M-o" . hydra-frame-window/body)
("M-t m" . ladicle/toggle-window-maximize)
:custom
(aw-keys '(?j ?k ?l ?i ?o ?h ?y ?u ?p))
:custom-face
(aw-leading-char-face ((t (:height 4.0 :foreground "#f1fa8c"))))
:preface
(defvar is-window-maximized nil)
(defun ladicle/toggle-window-maximize ()
(interactive)
(progn
(if is-window-maximized
(balance-windows)
(maximize-window))
(setq is-window-maximized
(not is-window-maximized))))
(defun hydra-title(title) (propertize title 'face `(:inherit font-lock-warning-face :weight bold)))
(defun command-name(title) (propertize title 'face `(:foreground "#f8f8f2")))
(defun spacer() (propertize "." 'face `(:foreground "#282a36")))
:config
(use-package rotate
:load-path "~/Developments/src/github.com/Ladicle/dotfiles/common/emacs.d/elisp/emacs-rotate"
:bind
("M-o SPC" . rotate-layout))
(with-eval-after-load 'hydra
(defhydra hydra-frame-window (:color blue :hint nil)
(format
(format "%s" (propertize " ╔════════╗
((%s))^^^^^^^^ ((%s))^^^^ ((%s))^^ ((%s))^^ ((%s))^^^^^^ ((%s))^ ║ Window ║
^^^^^^ ──────────────────────────────────────────────────────────────────────╨────────╜
^_k_^ %s_+_ _-_ %s _,_ ← %s → _._^ %s
^^↑^^ ^↑^ ^↑^ %s
_h_ ← → _l_ ^^%s%s^^^^^ ^%s ^^^%s^^^^ %s
^^↓^^ ^↓^ ^↓^ %s^^ %s
^_j_^ %s_=_ _/_ %s
^^^^^^ ┌──────────────────────────────────────────────────────────────────────────────┘
[_q_]: %s, [_<SPC>_]: %s" 'face `(:inherit font-lock-doc-face)))
(hydra-title "Size")
(hydra-title "Zoom")
(hydra-title "Split")
(hydra-title "Window")
(hydra-title "Buffer")
(hydra-title "Misc")
(all-the-icons-material "zoom_in" :height .85 :face 'font-lock-doc-face)
(command-name "_o_ther")
(command-name "page")
(command-name "_r_centf")
(command-name "_s_wap")
(all-the-icons-faicon "slideshare" :height .85 :face 'font-lock-doc-face)
(command-name "_p_mode")
(command-name "w_i_ndow")
(command-name "_m_aximize")
(command-name "_s_witch")
(command-name "_d_elete")
(command-name "_D_elete")
(all-the-icons-material "zoom_out" :height .85 :face 'font-lock-doc-face)
(command-name "del_O_thers")
(command-name "quit")
(command-name "rotate")
)
("K" kill-current-buffer :exit t)
("D" kill-buffer-and-window :exit t)
("O" delete-other-windows :exit t)
("F" toggle-frame-fullscreen)
("i" ace-window)
("s" ace-swap-window :exit t)
("d" ace-delete-window)
("m" ladicle/toggle-window-maximize :exit t)
("=" text-scale-decrease)
("+" text-scale-increase)
("-" split-window-vertically)
("/" split-window-horizontally)
("h" shrink-window-horizontally)
("k" shrink-window)
("j" enlarge-window)
("l" enlarge-window-horizontally)
("," previous-buffer)
("." next-buffer)
("o" other-window)
("p" presentation-mode)
("r" counsel-recentf :exit t)
("s" switch-to-buffer :exit t)
("D" kill-buffer-and-window)
("<SPC>" rotate-layout)
("q" nil)))
)
1.8.3 Smart move
(use-package mwim
:bind
("C-a" . mwim-beginning-of-code-or-line)
("C-e" . mwim-end-of-code-or-line))
1.9 Check
1.9.1 flymake
(use-package flymake-posframe
:load-path "~/Developments/src/github.com/Ladicle/flymake-posframe"
:custom
(flymake-posframe-error-prefix " ")
:custom-face
(flymake-posframe-foreground-face ((t (:foreground "white"))))
:hook (flymake-mode . flymake-posframe-mode))
(use-package flymake-diagnostic-at-point
:disabled
:after flymake
:custom
(flymake-diagnostic-at-point-timer-delay 0.1)
(flymake-diagnostic-at-point-error-prefix " ")
(flymake-diagnostic-at-point-display-diagnostic-function 'flymake-diagnostic-at-point-display-popup) ;; or flymake-diagnostic-at-point-display-minibuffer
:hook
(flymake-mode . flymake-diagnostic-at-point-mode))
1.9.2 flyspell
(use-package flyspell
:diminish
:if (executable-find "aspell")
:hook
((org-mode yaml-mode markdown-mode git-commit-mode) . flyspell-mode)
(prog-mode . flyspell-prog-mode)
(before-save-hook . flyspell-buffer)
(flyspell-mode . (lambda ()
(dolist (key '("C-;" "C-," "C-."))
(unbind-key key flyspell-mode-map))))
:custom
(flyspell-issue-message-flag nil)
(ispell-program-name "aspell")
(ispell-extra-args '("--sug-mode=ultra" "--lang=en_US" "--run-together"))
:custom-face
(flyspell-incorrect ((t (:underline (:color "#f1fa8c" :style wave)))))
(flyspell-duplicate ((t (:underline (:color "#50fa7b" :style wave)))))
:preface
(defun message-off-advice (oldfun &rest args)
"Quiet down messages in adviced OLDFUN."
(let ((message-off (make-symbol "message-off")))
(unwind-protect
(progn
(advice-add #'message :around #'ignore (list 'name message-off))
(apply oldfun args))
(advice-remove #'message message-off))))
:config
(advice-add #'ispell-init-process :around #'message-off-advice)
(use-package flyspell-correct-ivy
:bind ("C-M-:" . flyspell-correct-at-point)
:config
(when (eq system-type 'darwin)
(progn
(global-set-key (kbd "C-M-;") 'flyspell-correct-at-point)))
(setq flyspell-correct-interface #'flyspell-correct-ivy)))
1.10 Project
1.10.1 persp
(use-package persp-mode
:disabled
:diminish
:defines ivy-sort-functions-alist
:commands (get-current-persp persp-contain-buffer-p persp-add persp-by-name-and-exists)
:hook ((after-init . persp-mode)
(emacs-startup . toggle-frame-maximized))
:custom
(persp-keymap-prefix (kbd "C-x p"))
(persp-nil-name "default")
(persp-set-last-persp-for-new-frames nil)
(persp-auto-resume-time 0)
:config
;; NOTE: Redefine `persp-add-new' to address.
;; Issue: Unable to create/handle persp-mode
;; https://github.com/Bad-ptr/persp-mode.el/issues/96
;; https://github.com/Bad-ptr/persp-mode-projectile-bridge.el/issues/4
;; https://emacs-china.org/t/topic/6416/7
(defun* persp-add-new (name &optional (phash *persp-hash*))
"Create a new perspective with the given `NAME'. Add it to `PHASH'.
Return the created perspective."
(interactive "sA name for the new perspective: ")
(if (and name (not (equal "" name)))
(destructuring-bind (e . p)
(persp-by-name-and-exists name phash)
(if e p
(setq p (if (equal persp-nil-name name)
nil (make-persp :name name)))
(persp-add p phash)
(run-hook-with-args 'persp-created-functions p phash)
p))
(message "[persp-mode] Error: Can't create a perspective with empty name.")
nil))
;; Ignore temporary buffers
(add-hook 'persp-common-buffer-filter-functions
(lambda (b) (or (string-prefix-p "*" (buffer-name b))
(string-prefix-p "magit" (buffer-name b)))))
;; Integrate IVY
(with-eval-after-load "ivy"
(add-hook 'ivy-ignore-buffers
#'(lambda (b)
(when persp-mode
(let ((persp (get-current-persp)))
(if persp
(not (persp-contain-buffer-p b persp))
nil)))))
(setq ivy-sort-functions-alist
(append ivy-sort-functions-alist
'((persp-kill-buffer . nil)
(persp-remove-buffer . nil)
(persp-add-buffer . nil)
(persp-switch . nil)
(persp-window-switch . nil)
(persp-frame-switch . nil))))))
1.11 Complition
1.11.1 Yasnippet
(use-package yasnippet
:diminish yas-minor-mode
:custom (yas-snippet-dirs '("~/.emacs.d/snippets"))
:hook (after-init . yas-global-mode))
1.11.2 Company
(use-package company
:diminish company-mode
:defines
(company-dabbrev-ignore-case company-dabbrev-downcase)
:bind
(:map company-active-map
("C-n" . company-select-next)
("C-p" . company-select-previous)
("<tab>" . company-complete-common-or-cycle)
:map company-search-map
("C-p" . company-select-previous)
("C-n" . company-select-next))
:custom
(company-idle-delay 0)
(company-echo-delay 0)
(company-minimum-prefix-length 1)
:hook
(after-init . global-company-mode)
(plantuml-mode . (lambda () (set (make-local-variable 'company-backends)
'((company-yasnippet
;; company-dabbrev
)))))
((go-mode
c++-mode
c-mode
objc-mode) . (lambda () (set (make-local-variable 'company-backends)
'((company-yasnippet
company-lsp
company-files
;; company-dabbrev-code
)))))
:config
;; using child frame
(use-package company-posframe
:hook (company-mode . company-posframe-mode))
;; Show pretty icons
(use-package company-box
:diminish
:hook (company-mode . company-box-mode)
:init (setq company-box-icons-alist 'company-box-icons-all-the-icons)
:config
(setq company-box-backends-colors nil)
(setq company-box-show-single-candidate t)
(setq company-box-max-candidates 50)
(defun company-box-icons--elisp (candidate)
(when (derived-mode-p 'emacs-lisp-mode)
(let ((sym (intern candidate)))
(cond ((fboundp sym) 'Function)
((featurep sym) 'Module)
((facep sym) 'Color)
((boundp sym) 'Variable)
((symbolp sym) 'Text)
(t . nil)))))
(with-eval-after-load 'all-the-icons
(declare-function all-the-icons-faicon 'all-the-icons)
(declare-function all-the-icons-fileicon 'all-the-icons)
(declare-function all-the-icons-material 'all-the-icons)
(declare-function all-the-icons-octicon 'all-the-icons)
(setq company-box-icons-all-the-icons
`((Unknown . ,(all-the-icons-material "find_in_page" :height 0.7 :v-adjust -0.15))
(Text . ,(all-the-icons-faicon "book" :height 0.68 :v-adjust -0.15))
(Method . ,(all-the-icons-faicon "cube" :height 0.7 :v-adjust -0.05 :face 'font-lock-constant-face))
(Function . ,(all-the-icons-faicon "cube" :height 0.7 :v-adjust -0.05 :face 'font-lock-constant-face))
(Constructor . ,(all-the-icons-faicon "cube" :height 0.7 :v-adjust -0.05 :face 'font-lock-constant-face))
(Field . ,(all-the-icons-faicon "tags" :height 0.65 :v-adjust -0.15 :face 'font-lock-warning-face))
(Variable . ,(all-the-icons-faicon "tag" :height 0.7 :v-adjust -0.05 :face 'font-lock-warning-face))
(Class . ,(all-the-icons-faicon "clone" :height 0.65 :v-adjust 0.01 :face 'font-lock-constant-face))
(Interface . ,(all-the-icons-faicon "clone" :height 0.65 :v-adjust 0.01))
(Module . ,(all-the-icons-octicon "package" :height 0.7 :v-adjust -0.15))
(Property . ,(all-the-icons-octicon "package" :height 0.7 :v-adjust -0.05 :face 'font-lock-warning-face)) ;; Golang module
(Unit . ,(all-the-icons-material "settings_system_daydream" :height 0.7 :v-adjust -0.15))
(Value . ,(all-the-icons-material "format_align_right" :height 0.7 :v-adjust -0.15 :face 'font-lock-constant-face))
(Enum . ,(all-the-icons-material "storage" :height 0.7 :v-adjust -0.15 :face 'all-the-icons-orange))
(Keyword . ,(all-the-icons-material "filter_center_focus" :height 0.7 :v-adjust -0.15))
(Snippet . ,(all-the-icons-faicon "code" :height 0.7 :v-adjust 0.02 :face 'font-lock-variable-name-face))
(Color . ,(all-the-icons-material "palette" :height 0.7 :v-adjust -0.15))
(File . ,(all-the-icons-faicon "file-o" :height 0.7 :v-adjust -0.05))
(Reference . ,(all-the-icons-material "collections_bookmark" :height 0.7 :v-adjust -0.15))
(Folder . ,(all-the-icons-octicon "file-directory" :height 0.7 :v-adjust -0.05))
(EnumMember . ,(all-the-icons-material "format_align_right" :height 0.7 :v-adjust -0.15 :face 'all-the-icons-blueb))
(Constant . ,(all-the-icons-faicon "tag" :height 0.7 :v-adjust -0.05))
(Struct . ,(all-the-icons-faicon "clone" :height 0.65 :v-adjust 0.01 :face 'font-lock-constant-face))
(Event . ,(all-the-icons-faicon "bolt" :height 0.7 :v-adjust -0.05 :face 'all-the-icons-orange))
(Operator . ,(all-the-icons-fileicon "typedoc" :height 0.65 :v-adjust 0.05))
(TypeParameter . ,(all-the-icons-faicon "hashtag" :height 0.65 :v-adjust 0.07 :face 'font-lock-const-face))
(Template . ,(all-the-icons-faicon "code" :height 0.7 :v-adjust 0.02 :face 'font-lock-variable-name-face))))))
;; Show quick tooltip
(use-package company-quickhelp
:defines company-quickhelp-delay
:bind (:map company-active-map
("M-h" . company-quickhelp-manual-begin))
:hook (global-company-mode . company-quickhelp-mode)
:custom (company-quickhelp-delay 0.8)))
1.12 Git
1.12.1 Timemachine
(use-package git-timemachine
:bind ("M-g t" . git-timemachine-toggle))
1.12.2 Diffview
(use-package diffview
:commands (diffview-region diffview-current)
:preface
(defun ladicle/diffview-dwim ()
(interactive)
(if (region-active-p)
(diffview-region)
(diffview-current)))
:bind ("M-g v" . ladicle/diffview-dwim))
1.12.3 Magit
(use-package magit
:custom
(magit-auto-revert-mode nil)
:bind
("M-g s" . magit-status))
1.12.4 GitModes
(use-package gitattributes-mode :defer t)
(use-package gitconfig-mode :defer t)
(use-package gitignore-mode :defer t)
1.12.5 GitGutter
(use-package git-gutter
:custom
(git-gutter:modified-sign "~") ;
(git-gutter:added-sign "+") ;
(git-gutter:deleted-sign "-") ;
:custom-face
(git-gutter:modified ((t (:foreground "#f1fa8c" :background "#f1fa8c"))))
(git-gutter:added ((t (:foreground "#50fa7b" :background "#50fa7b"))))
(git-gutter:deleted ((t (:foreground "#ff79c6" :background "#ff79c6"))))
:config
(global-git-gutter-mode +1))
1.12.6 Git Remote
(use-package browse-at-remote
:bind ("M-g r" . browse-at-remote))
1.12.7 GitHub
(use-package github-pullrequest)
1.12.8 Smerge
(use-package smerge-mode
:diminish
:preface
(with-eval-after-load 'hydra
(defhydra smerge-hydra
(:color pink :hint nil :post (smerge-auto-leave))
"
^Move^ ^Keep^ ^Diff^ ^Other^
^^-----------^^-------------------^^---------------------^^-------
_n_ext _b_ase _<_: upper/base _C_ombine
_p_rev _u_pper _=_: upper/lower _r_esolve
^^ _l_ower _>_: base/lower _k_ill current
^^ _a_ll _R_efine
^^ _RET_: current _E_diff
"
("n" smerge-next)
("p" smerge-prev)
("b" smerge-keep-base)
("u" smerge-keep-upper)
("l" smerge-keep-lower)
("a" smerge-keep-all)
("RET" smerge-keep-current)
("\C-m" smerge-keep-current)
("<" smerge-diff-base-upper)
("=" smerge-diff-upper-lower)
(">" smerge-diff-base-lower)
("R" smerge-refine)
("E" smerge-ediff)
("C" smerge-combine-with-next)
("r" smerge-resolve)
("k" smerge-kill-current)
("ZZ" (lambda ()
(interactive)
(save-buffer)
(bury-buffer))
"Save and bury buffer" :color blue)
("q" nil "cancel" :color blue)))
:hook ((find-file . (lambda ()
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil t)
(smerge-mode 1)))))
(magit-diff-visit-file . (lambda ()
(when smerge-mode
(smerge-hydra/body))))))
1.13 Tools
1.13.1 Google Translater
(use-package google-translate
:bind
("M-o t" . google-translate-at-point)
("M-o T" . google-translate-at-point-reverse)
:custom
(google-translate-default-source-language "en")
(google-translate-default-target-language "ja"))
1.13.2 google this!
(use-package google-this)
1.13.3 wakatime
(use-package wakatime-mode
:custom (wakatime-cli-path "/usr/local/bin/wakatime")
:config (global-wakatime-mode))
1.14 Language
1.14.1 LSP
- bingo(LSP server)
- delve(Go debugger)
- VSCode.Go(Dap delve server)
- VSCode.NativeDebug(Dap GDB-LLDB server)
(use-package lsp-mode
:custom
;; debug
(lsp-print-io nil)
(lsp-trace nil)
(lsp-print-performance nil)
;; general
(lsp-auto-guess-root t)
(lsp-document-sync-method 'incremental) ;; none, full, incremental, or nil
(lsp-response-timeout 10)
(lsp-prefer-flymake t) ;; t(flymake), nil(lsp-ui), or :none
;; go-client
(lsp-clients-go-server-args '("--cache-style=always" "--diagnostics-style=onsave" "--format-style=goimports"))
:hook
((go-mode c-mode c++-mode) . lsp)
:bind
(:map lsp-mode-map
("C-c r" . lsp-rename))
:config
(require 'lsp-clients)
;; LSP UI tools
(use-package lsp-ui
:custom
;; lsp-ui-doc
(lsp-ui-doc-enable nil)
(lsp-ui-doc-header t)
(lsp-ui-doc-include-signature nil)
(lsp-ui-doc-position 'at-point) ;; top, bottom, or at-point
(lsp-ui-doc-max-width 120)
(lsp-ui-doc-max-height 30)
(lsp-ui-doc-use-childframe t)
(lsp-ui-doc-use-webkit t)
;; lsp-ui-flycheck
(lsp-ui-flycheck-enable nil)
;; lsp-ui-sideline
(lsp-ui-sideline-enable nil)
(lsp-ui-sideline-ignore-duplicate t)
(lsp-ui-sideline-show-symbol t)
(lsp-ui-sideline-show-hover t)
(lsp-ui-sideline-show-diagnostics nil)
(lsp-ui-sideline-show-code-actions t)
(lsp-ui-sideline-code-actions-prefix "")
;; lsp-ui-imenu
(lsp-ui-imenu-enable t)
(lsp-ui-imenu-kind-position 'top)
;; lsp-ui-peek
(lsp-ui-peek-enable t)
(lsp-ui-peek-peek-height 20)
(lsp-ui-peek-list-width 50)
(lsp-ui-peek-fontify 'on-demand) ;; never, on-demand, or always
:preface
(defun ladicle/toggle-lsp-ui-doc ()
(interactive)
(if lsp-ui-doc-mode
(progn
(lsp-ui-doc-mode -1)
(lsp-ui-doc--hide-frame))
(lsp-ui-doc-mode 1)))
:bind
(:map lsp-mode-map
("C-c C-r" . lsp-ui-peek-find-references)
("C-c C-j" . lsp-ui-peek-find-definitions)
("C-c i" . lsp-ui-peek-find-implementation)
("C-c m" . lsp-ui-imenu)
("C-c s" . lsp-ui-sideline-mode)
("C-c d" . ladicle/toggle-lsp-ui-doc))
:hook
(lsp-mode . lsp-ui-mode))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection
(lambda () (cons "bingo"
lsp-clients-go-server-args)))
:major-modes '(go-mode)
:priority 2
:initialization-options 'lsp-clients-go--make-init-options
:server-id 'go-bingo
:library-folders-fn (lambda (_workspace)
lsp-clients-go-library-directories)))
;; DAP
(use-package dap-mode
:custom
(dap-go-debug-program `("node" "~/.extensions/go/out/src/debugAdapter/goDebug.js"))
:config
(dap-mode 1)
(require 'dap-hydra)
(require 'dap-gdb-lldb) ; download and expand lldb-vscode to the =~/.extensions/webfreak.debug=
(require 'dap-go) ; download and expand vscode-go-extenstion to the =~/.extensions/go=
(use-package dap-ui
:ensure nil
:config
(dap-ui-mode 1)))
;; Lsp completion
(use-package company-lsp
:custom
(company-lsp-cache-candidates t) ;; auto, t(always using a cache), or nil
(company-lsp-async t)
(company-lsp-enable-snippet t)
(company-lsp-enable-recompletion t)))
1.14.2 Golang
(use-package go-mode
:mode "\\.go\\'"
:custom (gofmt-command "goimports")
:bind (:map go-mode-map
("C-c C-n" . go-run)
("C-c ." . go-test-current-test)
("C-c f" . go-test-current-file)
("C-c a" . go-test-current-project))
:config
(add-hook 'before-save-hook #'gofmt-before-save)
(use-package gotest)
(use-package go-tag
:config (setq go-tag-args (list "-transform" "camelcase"))))
1.14.3 C/C++
(use-package cc-mode
:bind (:map c-mode-base-map
("C-c c" . compile))
:hook (c-mode-common . (lambda ()
(c-set-style "bsd")
(setq tab-width 4)
(setq c-base-offset 4))))
(use-package ccls
:custom
(ccls-executable "/usr/local/bin/ccls")
(ccls-sem-highlight-method 'font-lock)
:config
:hook ((c-mode c++-mode objc-mode) .
(lambda () (require 'ccls) (lsp))))
1.14.4 PlantUML
(use-package plantuml-mode
:custom
(plantuml-jar-path "~/.emacs.d/plantuml.jar")
:mode "\\.uml\\'")
1.14.5 Org
- ob-async
```emacs-lisp
(use-package ob-async
:load-path "~/Developments/src/github.com/astahlman/ob-async"
:config
(add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)
(add-hook 'ob-async-pre-execute-src-block-hook
'(lambda ()
(setq org-plantuml-jar-path "~/.emacs.d/plantuml.jar"))))
```
- screenshot
```emacs-lisp
(defun my-org-screenshot ()
"Take a screenshot into a time stamped unique-named file in the
same directory as the org-buffer and insert a link to this file."
(interactive)
(org-display-inline-images)
(setq filename
(concat
(make-temp-name
(concat (file-name-nondirectory (buffer-file-name))
"_imgs/"
(format-time-string "%Y%m%d_%H%M%S_")) ) ".png"))
(unless (file-exists-p (file-name-directory filename))
(make-directory (file-name-directory filename)))
; take screenshot
(if (eq system-type 'darwin)
(call-process "screencapture" nil nil nil "-i" filename))
(if (eq system-type 'gnu/linux)
(call-process "import" nil nil nil filename))
; insert into file if correctly taken
(if (file-exists-p filename)
(insert (concat "[[file:" filename "]]"))))
```
- org
```emacs-lisp
(use-package org
:custom
(org-src-fontify-natively t)
(private-directory "~/Private/")
(task-file (concat private-directory "task.org"))
(schedule-file (concat private-directory "schedule.org"))
(org-directory private-directory)
(org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
(org-plantuml-jar-path "~/.emacs.d/plantuml.jar")
(org-confirm-babel-evaluate nil)
(org-clock-out-remove-zero-time-clocks t)
(org-startup-folded 'content)
(org-columns-default-format "%50ITEM(Task) %5TODO(Todo) %10Effort(Effort){:} %10CLOCKSUM(Clock) %2PRIORITY %TAGS")
(org-agenda-columns-add-appointments-to-effort-sum t)
(org-agenda-span 'day)
(org-agenda-log-mode-items (quote (closed clock)))
(org-agenda-clockreport-parameter-plist
'(:maxlevel 5 :block t :tstart t :tend t :emphasize t :link t :narrow 80 :indent t :formula nil :timestamp t :level 5 :tcolumns nil :formatter nil))
(org-global-properties (quote ((
"Effort_ALL" . "00:05 00:10 00:15 00:30 01:00 01:30 02:00 02:30 03:00"))))
(org-agenda-files (quote (
"~/Private/task.org"
"~/Private/routine.org"
"~/Private/task.org_archive"
"~/Private/schedule.org")))
:custom-face
(org-link ((t (:foreground "#ebe087" :underline t))))
(org-list-dt ((t (:foreground "#bd93f9"))))
(org-special-keyword ((t (:foreground "#6272a4"))))
(org-todo ((t (:background "#272934" :foreground "#51fa7b" :weight bold))))
(org-document-title ((t (:foreground "#f1fa8c" :weight bold))))
(org-done ((t (:background "#373844" :foreground "#216933" :strike-through nil :weight bold))))
(org-footnote ((t (:foreground "#76e0f3"))))
;; do not scale outline header
;; (org-level-1 ((t (:inherit outline-1 :height 1.0))))
;; (org-level-2 ((t (:inherit outline-2 :height 1.0))))
;; (org-level-3 ((t (:inherit outline-3 :height 1.0))))
;; (org-level-4 ((t (:inherit outline-4 :height 1.0))))
;; (org-level-5 ((t (:inherit outline-5 :height 1.0))))
:bind (("M-o c" . counsel-org-capture)
("M-o a" . org-agenda)
("C-x C-l" . org-store-link)
:map org-mode-map
("C-c i" . org-clock-in)
("C-c o" . org-clock-out)
("C-c n" . org-narrow-to-subtree)
("C-c b" . org-narrow-to-block)
("C-c w" . widen)
("C-c e" . org-set-effort)
;; custom functions
("C-c 1" . (lambda () (interactive) (org-cycle-list-bullet 2)))
("M-o l i" . (lambda () (interactive) (ladicle/open-org-file task-file)))
("M-o l s" . (lambda () (interactive) (ladicle/open-org-file schedule-file)))
("M-o l y" . (lambda () (interactive) (ladicle/open-org-file (ladicle/get-yesterday-diary))))
("M-o l p" . (lambda () (interactive) (ladicle/open-org-file (ladicle/get-diary-from-cal))))
("M-o l t" . (lambda () (interactive) (ladicle/open-org-file (ladicle/get-today-diary)))))
:hook
(kill-emacs . ladicle/org-clock-out-and-save-when-exit)
(org-clock-in .
(lambda ()
(setq org-mode-line-string (ladicle/task-clocked-time))
(run-at-time 0 60 '(lambda ()
(setq org-mode-line-string (ladicle/task-clocked-time))
(force-mode-line-update)))
(force-mode-line-update)))
(org-mode . (lambda ()
(dolist (key '("C-'" "C-," "C-."))
(unbind-key key org-mode-map))))
:preface
(defun ladicle/get-today-diary ()
(concat private-directory
(format-time-string "diary/%Y/%m/%Y-%m-%d.org" (current-time))))
(defun ladicle/get-yesterday-diary ()
(concat private-directory
(format-time-string "diary/%Y/%m/%Y-%m-%d.org" (time-add (current-time) (* -24 3600)))))
(defun ladicle/get-diary-from-cal ()
(concat private-directory
(format-time-string "diary/%Y/%m/%Y-%m-%d.org"
(apply 'encode-time (parse-time-string (concat (org-read-date) " 00:00"))))))
(defun ladicle/open-org-file (fname)
(switch-to-buffer (find-file-noselect fname)))
(defun ladicle/org-get-time ()
(format-time-string "<%H:%M>" (current-time)))
(defun ladicle/code-metadata ()
(concat ":" (projectile-project-name) ":"))
(defun ladicle/org-clock-out-and-save-when-exit ()
"Save buffers and stop clocking when kill emacs."
(ignore-errors (org-clock-out) t)
(save-some-buffers t))
(defun ladicle/task-clocked-time ()
"Return a string with the clocked time and effort, if any"
(interactive)
(let* ((clocked-time (org-clock-get-clocked-time))
(h (truncate clocked-time 60))
(m (mod clocked-time 60))
(work-done-str (format "%d:%02d" h m)))
(if org-clock-effort
(let* ((effort-in-minutes
(org-duration-to-minutes org-clock-effort))
(effort-h (truncate effort-in-minutes 60))
(effort-m (truncate (mod effort-in-minutes 60)))
(effort-str (format "%d:%02d" effort-h effort-m)))
(format "%s/%s" work-done-str effort-str))
(format "%s" work-done-str))))
:config
;; Pomodoro
(use-package org-pomodoro
:after org-agenda
:custom
(org-pomodoro-ask-upon-killing t)
(org-pomodoro-format "%s") ;;
(org-pomodoro-short-break-format "%s")
(org-pomodoro-long-break-format "%s")
:custom-face
(org-pomodoro-mode-line ((t (:foreground "#ff5555"))))
(org-pomodoro-mode-line-break ((t (:foreground "#50fa7b"))))
:hook
(org-pomodoro-started . (lambda () (notifications-notify
:title "org-pomodoro"
:body "Let's focus for 25 minutes!"
:app-icon "~/.emacs.d/img/001-food-and-restaurant.png")))
(org-pomodoro-finished . (lambda () (notifications-notify
:title "org-pomodoro"
:body "Well done! Take a break."
:app-icon "~/.emacs.d/img/004-beer.png")))
:config
(when (eq system-type 'darwin)
(setq alert-default-style 'osx-notifier))
(require 'alert)
:bind (:map org-agenda-mode-map
("p" . org-pomodoro)))
(setq org-agenda-current-time-string "← now")
(setq org-agenda-time-grid ;; Format is changed from 9.1
'((daily today require-timed)
(0900 01000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400)
"-"
"────────────────"))
(setq org-todo-keyword-faces
'(("WAIT" . (:foreground "#6272a4":weight bold))
("NEXT" . (:foreground "#f1fa8c" :weight bold))
("CARRY/O" . (:foreground "#6272a4" :background "#373844" :weight bold))))
(setq org-capture-templates
'(("tweet" "Write down the thoughts of this moment with a timestamp." item
(file+headline ladicle/get-today-diary "Log")
"%(ladicle/org-get-time) %? \n")
;; memo
("memo" "Memorize something in the memo section of today's diary." entry
(file+headline ladicle/get-today-diary "Memo")
"** %? \n"
:unnarrowed 1)
;; tasks
("inbox" "Create a general task to the inbox and jump to the task file." entry
(file+headline "~/Private/task.org" "Inbox")
"** TODO %?"
:jump-to-captured 1)
("interrupt-task" "Create an interrupt task to the inbox and start clocking." entry
(file+headline "~/Private/task.org" "Inbox")
"** TODO %?"
:jump-to-captured 1 :clock-in 1 :clock-resume 1)
("hack-emacs" "Collect hacking Emacs ideas!" item
(file+headline "~/Private/task.org" "Hacking Emacs")
"- [ ] %?"
:prepend t)
("private-schedule" "Add an event to the private calendar." entry
(file+olp schedule-file "Calendar" "2019" "Private")
"** %?\n SCHEDULED: <%(org-read-date)>\n"
:prepend t)
("work-schedule" "Add an event to the work calendar." entry
(file+olp schedule-file "Calendar" "2019" "Work")
"** %?\n SCHEDULED: <%(org-read-date)>\n")
("store-link" "Store the link of the current position in the clocking task." item
(clock)
"- %A\n"
:immediate t :prepend t)
;; code-reading
("code-link" "Store the code reading memo to today's diary with metadata." entry
(file+headline ladicle/get-today-diary "Code")
;;(file+headline ladicle/get-today-diary "Code")
"** %? %(ladicle/code-metadata)\n%A\n")))
;; delete unused modules
(setq org-modules (delete '(org-gnus org-w3m org-bbdb org-bibtex org-docview org-info org-irc org-mhe org-rmail org-eww) org-modules))
;; load org-protocol for capturing websites
(use-package org-protocol
:ensure nil)
;; load babel languages
(org-babel-do-load-languages
'org-babel-load-languages
'((dot . t)
(plantuml . t)
(latex . t)
(R . t)))
;; Pretty bullets
(use-package org-bullets
:custom (org-bullets-bullet-list '("" "" "" "" "" "" "" "" "" ""))
:hook (org-mode . org-bullets-mode))
(use-package ox-hugo
:after ox
:custom
(org-blackfriday--org-element-string '((src-block . "Code")
(table . "Table")
(figure . "Figure"))))
;; Download Drag&Drop images
(use-package org-download)
(with-eval-after-load 'hydra
(eval-and-compile
(defun hot-expand (str &optional mod)
"Expand org template."
(let (text)
(when (region-active-p)
(setq text (buffer-substring (region-beginning) (region-end)))
(delete-region (region-beginning) (region-end)))
(insert str)
(org-try-structure-completion)
(when mod (insert mod) (forward-line))
(when text (insert text)))))
(defhydra hydra-org-template (:color blue :hint nil)
(format " %s^^ %s^^^^ %s^^^^^ %s
%s
%s _e_lisp %s _h_ugo %s plant_u_ml %s _s_ource
%s _r_uby %s _c_aption %s La_t_ex %s _n_ote
%s _f_ish %s _l_ink %s i_P_ython %s _i_nfo
%s _b_ash %s %s^^^^^ %s %s^^^^ %s qu_o_te
%s _g_o
%s _y_aml
%s
%s quit%s insert
"
(concat (propertize "((" 'face `(:foreground "#6272a4"))
(propertize "CODE" 'face `(:foreground "#ff79c6" :weight bold))
(propertize "))" 'face `(:foreground "#6272a4")))
(concat (propertize "((" 'face `(:foreground "#6272a4"))
(propertize "META" 'face `(:foreground "#ff79c6" :weight bold))
(propertize "))" 'face `(:foreground "#6272a4")))
(concat (propertize "((" 'face `(:foreground "#6272a4"))
(propertize "DRAW" 'face `(:foreground "#ff79c6" :weight bold))
(propertize "))" 'face `(:foreground "#6272a4")))
(concat (propertize "((" 'face `(:foreground "#6272a4"))
(propertize "BLOCK" 'face `(:foreground "#ff79c6" :weight bold))
(propertize "))" 'face `(:foreground "#6272a4")))
(propertize " ──────────────────────────────────────────────────────────── " 'face `(:foreground "#6272a4"))
;; L1
(all-the-icons-fileicon "emacs" :v-adjust .00001 :height .68 :face '(:foreground "#6272a4"))
(all-the-icons-material "web" :v-adjust -.1 :height .7 :face '(:foreground "#6272a4"))
(all-the-icons-material "format_shapes" :v-adjust -.15 :height .7 :face '(:foreground "#6272a4"))
(all-the-icons-octicon "code" :v-adjust -.05 :height .75 :face '(:foreground "#6272a4"))
;; L2
(all-the-icons-alltheicon "ruby-alt" :v-adjust .0505 :height .7 :face '(:foreground "#6272a4"))
(all-the-icons-faicon "flag" :v-adjust -.05 :height .69 :face '(:foreground "#6272a4"))
(all-the-icons-faicon "text-height" :v-adjust -.05 :height .69 :face '(:foreground "#6272a4"))
(all-the-icons-octicon "light-bulb" :v-adjust -.1 :height .78 :face '(:foreground "#6272a4"))
;; L3
(all-the-icons-alltheicon "script" :v-adjust .05 :height .7 :face '(:foreground "#6272a4"))
(all-the-icons-faicon "link" :v-adjust -.05 :height .69 :face '(:foreground "#6272a4"))
(all-the-icons-fileicon "test-python" :v-adjust -.1 :height .75 :face '(:foreground "#6272a4"))
(all-the-icons-faicon "info-circle" :v-adjust -.1 :height .72 :face '(:foreground "#6272a4"))
;; L4
(all-the-icons-alltheicon "script" :v-adjust .05 :height .7 :face '(:foreground "#6272a4"))
(all-the-icons-fileicon "test-python" :v-adjust -.1 :height .7 :face '(:foreground "#282a36")) ;; dummy
(propertize "link" 'face `(:foreground "#282a36"))
(all-the-icons-fileicon "test-python" :v-adjust -.1 :height .7 :face '(:foreground "#282a36")) ;; dummy
(propertize "latex" 'face `(:foreground "#282a36"))
(all-the-icons-faicon "quote-right" :v-adjust -.05 :height .65 :face '(:foreground "#6272a4"))
;; L5
(all-the-icons-fileicon "go" :v-adjust -.1 :height .75 :face '(:foreground "#6272a4"))
;; L6
(all-the-icons-octicon "settings" :v-adjust -.1 :height .75 :face '(:foreground "#6272a4"))
;; Draw
(propertize " ┌──────────────────────────────────────────────────────────┘ " 'face `(:foreground "#6272a4"))
(propertize "[_q_]:" 'face `(:foreground "#6272a4"))
(propertize ", [_<_]:" 'face `(:foreground "#6272a4"))
)
("s" (hot-expand "<s"))
("o" (hot-expand "<q"))
("c" (hot-expand "<c"))
("t" (hot-expand "<L"))
("c" (insert "#+CAPTION: "))
("l" (insert "#+NAME: "))
("n" (insert "#+BEGIN_NOTE\n\n#+END_NOTE"))
("i" (insert "#+BEGIN_INFO\n\n#+END_INFO"))
("h" (insert ":PROPERTIES:\n:EXPORT_FILE_NAME:\n:EXPORT_HUGO_SECTION: pages\n:EXPORT_HUGO_TAGS:\n:EXPORT_HUGO_CATEGORIES:\n:END:"))
("e" (hot-expand "<s" "emacs-lisp"))
("f" (hot-expand "<s" "fish"))
("b" (hot-expand "<s" "bash"))
("y" (hot-expand "<s" "yaml"))
("P" (hot-expand "<s" "ipython :session :exports both :async :cache yes :results raw drawer\n$0"))
("g" (hot-expand "<s" "go"))
("r" (hot-expand "<s" "ruby"))
("S" (hot-expand "<s" "sh"))
("u" (hot-expand "<s" "plantuml :file overview.svg :cache yes :cmdline -config \"$HOME/Private/style.uml\" :async"))
("<" self-insert-command)
("q" nil))
(bind-key "<"
(lambda () (interactive)
(if (or (region-active-p) (looking-back "^\s*" 1))
(hydra-org-template/body)
(self-insert-command 1)))
org-mode-map))
)
```
1.14.6 R
(use-package ess
:disabled
:custom (ess-ask-for-ess-directory nil)
:config
(require 'ess-site))
1.14.7 HTML/CSS/JS
(use-package js2-mode
:mode ("\\.js\\'" . js2-mode))
1.14.8 Protobuf
(use-package protobuf-mode
:mode "\\.proto$")
1.14.9 Fish
(use-package fish-mode
:mode "\\.fish\\'")
1.14.10 Markdown
(use-package markdown-mode
:custom
(markdown-hide-markup nil)
(markdown-bold-underscore t)
(markdown-italic-underscore t)
(markdown-header-scaling t)
(markdown-indent-function t)
(markdown-enable-math t)
(markdown-hide-urls nil)
:custom-face
(markdown-header-delimiter-face ((t (:foreground "mediumpurple"))))
(markdown-header-face-1 ((t (:foreground "violet" :weight bold :height 1.0))))
(markdown-header-face-2 ((t (:foreground "lightslateblue" :weight bold :height 1.0))))
(markdown-header-face-3 ((t (:foreground "mediumpurple1" :weight bold :height 1.0))))
(markdown-link-face ((t (:background "#0e1014" :foreground "#bd93f9"))))
(markdown-list-face ((t (:foreground "mediumpurple"))))
(markdown-pre-face ((t (:foreground "#bd98fe"))))
:mode "\\.md\\'")
(use-package markdown-toc)
1.14.11 Log
(use-package logview :defer t)
1.14.12 Systemd
(use-package systemd
:mode
("\\.service\\'" "\\.timer\\'" "\\.target\\'" "\\.mount\\'"
"\\.automount\\'" "\\.slice\\'" "\\.socket\\'" "\\.path\\'"
"\\.netdev\\'" "\\.network\\'" "\\.link\\'"))
1.14.13 YAML
(use-package yaml-mode
:mode ("\\.yaml\\'" "\\.yml\\'")
:custom-face
(font-lock-variable-name-face ((t (:foreground "violet")))))
1.14.14 Bazel
(use-package bazel-mode :defer t)
1.14.15 Dockerfile
(use-package dockerfile-mode
:mode "\\Dockerfile\\'")
1.15 Custom Functions
1.15.1 Change letter case
(defun upcase-backward-word (arg)
(interactive "p")
(upcase-word (- arg)))
(defun downcase-backward-word (arg)
(interactive "p")
(downcase-word (- arg)))
(defun capitalize-backward-word (arg)
(interactive "p")
(capitalize-word (- arg)))
(global-set-key (kbd "C-M-u") 'upcase-backward-word)
(global-set-key (kbd "C-M-l") 'downcase-backward-word)
(global-set-key (kbd "M-c") 'capitalize-backward-word)
1.15.2 Change smart Kill-word
(defun kill-word-at-point ()
(interactive)
(let ((char (char-to-string (char-after (point)))))
(cond
((string= " " char) (delete-horizontal-space))
((string-match "[\t\n -@\[-`{-~],.、。" char) (kill-word 1))
(t (forward-char) (backward-word) (kill-word 1)))))
(global-set-key (kbd "M-d") 'kill-word-at-point)
1.15.3 Kill word or Region
(defun backward-kill-word-or-region (&optional arg)
(interactive "p")
(if (region-active-p)
(call-interactively #'kill-region)
(backward-kill-word arg)))
(global-set-key (kbd "C-w") 'backward-kill-word-or-region)
1.15.4 Add execution flag to a file with shelbang
(defun add-chmod()
(interactive)
(save-restriction
(widen)
(let ((name (buffer-file-name)))
(if (and (not (string-match ":" name))
(not (string-match "/\\.[^/]+$" name))
(equal "#!" (buffer-substring 1 (min 3 (point-max)))))
(progn (set-file-modes name (logior (file-modes name) 73))
(message "Wrote %s (chmod +x)" name))))))
(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p)
1.15.5 Copy file path
(defun put-current-path-to-clipboard ()
(interactive)
(let ((file-path buffer-file-name)
(dir-path default-directory))
(cond (file-path
(kill-new (expand-file-name file-path))
(message "This file path is on the clipboard!"))
(dir-path
(kill-new (expand-file-name dir-path))
(message "This directory path is on the clipboard!"))
(t
(error-message-string "Fail to get path name.")))))
(defun put-current-filename-to-clipboard ()
(interactive)
(let ((file-path buffer-file-name)
(dir-path default-directory))
(cond (file-path
(kill-new (file-name-nondirectory file-path))
(message "This file path is on the clipboard!"))
(dir-path
(kill-new (file-name-nondirectory dir-path))
(message "This directory path is on the clipboard!"))
(t
(error-message-string "Fail to get path name.")))))
(defun put-current-filename-with-line-to-clipboard ()
(interactive)
(let ((file-path buffer-file-name)
(dir-path default-directory))
(cond (file-path
(kill-new (format "%s:%s"
(file-name-nondirectory file-path)
(count-lines (point-min) (point))))
(message "This file path is on the clipboard!"))
(dir-path
(kill-new (file-name-nondirectory dir-path))
(message "This directory path is on the clipboard!"))
(t
(error-message-string "Fail to get path name.")))))
1.16 UI
1.16.1 Dashboard
(use-package dashboard
:diminish
(dashboard-mode page-break-lines-mode)
:custom
(dashboard-center-content t)
(dashboard-startup-banner 4)
(dashboard-items '((recents . 15)
(projects . 5)
(bookmarks . 5)))
:custom-face
(dashboard-heading ((t (:foreground "#f1fa8c" :weight bold))))
:hook
(after-init . dashboard-setup-startup-hook))
1.16.2 General
;; Change cursor style
(add-to-list 'default-frame-alist '(cursor-type . bar))
;; vertical border
(let ((display-table (or standard-display-table (make-display-table))))
(set-display-table-slot display-table 'vertical-border (make-glyph-code ?│)) ; or ┃ │
(setq standard-display-table display-table))
(set-face-background 'vertical-border "#0e0f1b")
(set-face-foreground 'vertical-border (face-background 'vertical-border))
1.16.3 persp
(use-package persp-mode
:disabled
:diminish
:commands (get-current-persp persp-contain-buffer-p)
:hook (after-init . persp-mode))
1.16.4 imenu-list
(use-package imenu-list
:load-path "~/Developments/src/github.com/Ladicle/imenu-list"
:bind
("<f10>" . imenu-list-smart-toggle)
:custom-face
(imenu-list-entry-face-1 ((t (:foreground "white"))))
:custom
(imenu-list-focus-after-activation t)
(imenu-list-auto-resize t))
1.16.5 Transparency
(defun ladicle/toggle-window-transparency ()
"Cycle the frame transparency from default to transparent."
(interactive)
(let ((transparency 85)
(opacity 100))
(if (and (not (eq (frame-parameter nil 'alpha) nil))
(< (frame-parameter nil 'alpha) opacity))
(set-frame-parameter nil 'alpha opacity)
(set-frame-parameter nil 'alpha transparency))))
(global-set-key (kbd "M-t t") 'ladicle/toggle-window-transparency)
1.16.6 Minimap
(use-package minimap
:commands
(minimap-bufname minimap-create minimap-kill)
:custom
(minimap-major-modes '(prog-mode))
(minimap-window-location 'right)
(minimap-update-delay 0.2)
(minimap-minimum-width 20)
:bind
("M-t p" . ladicle/toggle-minimap)
:preface
(defun ladicle/toggle-minimap ()
"Toggle minimap for current buffer."
(interactive)
(if (null minimap-bufname)
(minimap-create)
(minimap-kill)))
:config
(custom-set-faces
'(minimap-active-region-background
((((background dark)) (:background "#555555555555"))
(t (:background "#C847D8FEFFFF"))) :group 'minimap)))
1.16.7 Neotree
(use-package neotree
:after
projectile
:commands
(neotree-show neotree-hide neotree-dir neotree-find)
:custom
(neo-theme 'nerd2)
:bind
("<f8>" . neotree-current-dir-toggle)
("<f9>" . neotree-projectile-toggle)
:preface
(defun neotree-projectile-toggle ()
(interactive)
(let ((project-dir
(ignore-errors
;;; Pick one: projectile or find-file-in-project
(projectile-project-root)
))
(file-name (buffer-file-name))
(neo-smart-open t))
(if (and (fboundp 'neo-global--window-exists-p)
(neo-global--window-exists-p))
(neotree-hide)
(progn
(neotree-show)
(if project-dir
(neotree-dir project-dir))
(if file-name
(neotree-find file-name))))))
(defun neotree-current-dir-toggle ()
(interactive)
(let ((project-dir
(ignore-errors
(ffip-project-root)
))
(file-name (buffer-file-name))
(neo-smart-open t))
(if (and (fboundp 'neo-global--window-exists-p)
(neo-global--window-exists-p))
(neotree-hide)
(progn
(neotree-show)
(if project-dir
(neotree-dir project-dir))
(if file-name
(neotree-find file-name)))))))
1.16.8 Doom dracula Theme/Modeline
(use-package doom-themes
:custom
(doom-themes-enable-italic t)
(doom-themes-enable-bold t)
:custom-face
;; (vertical-bar (doom-darken base5 0.4))
;; (doom-darken bg 0.4)
:config
(load-theme 'doom-dracula t)
(doom-themes-neotree-config)
(doom-themes-org-config)
;; Modeline
(use-package doom-modeline
:custom
(doom-modeline-buffer-file-name-style 'truncate-with-project)
(doom-modeline-icon t)
(doom-modeline-major-mode-icon nil)
(doom-modeline-minor-modes nil)
:hook
(after-init . doom-modeline-mode)
:config
(set-cursor-color "cyan")
(line-number-mode 0)
(column-number-mode 0)
(doom-modeline-def-modeline 'main
'(bar workspace-number window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info remote-host buffer-position parrot selection-info)
'(misc-info persp-name lsp github debug minor-modes input-method major-mode process vcs checker))))
1.16.9 Nyan-mode
(use-package nyan-mode
:custom
(nyan-cat-face-number 4)
(nyan-animate-nyancat t)
:hook
(doom-modeline-mode . nyan-mode))
1.16.10 Hide Modeline
(use-package hide-mode-line
:hook
((neotree-mode imenu-list-minor-mode minimap-mode) . hide-mode-line-mode))
1.16.11 Line number
(use-package display-line-numbers
:ensure nil
:hook
((prog-mode yaml-mode systemd-mode) . display-line-numbers-mode))
1.16.12 Dimmer
(use-package dimmer
:disabled
:custom
(dimmer-fraction 0.5)
(dimmer-exclusion-regexp-list
'(".*Minibuf.*"
".*which-key.*"
".*NeoTree.*"
".*Messages.*"
".*Async.*"
".*Warnings.*"
".*LV.*"
".*Ilist.*"))
:config
(dimmer-mode t))
1.16.13 fill-column-indicator
(use-package fill-column-indicator
:hook
((markdown-mode
git-commit-mode) . fci-mode))
1.16.14 Presentation
(use-package presentation)
1.16.15 Eshell
(setq eshell-prompt-function
(lambda ()
(format "%s %s\n%s%s%s "
(all-the-icons-octicon "repo")
(propertize (cdr (shrink-path-prompt default-directory)) 'face `(:foreground "white"))
(propertize "❯" 'face `(:foreground "#ff79c6"))
(propertize "❯" 'face `(:foreground "#f1fa8c"))
(propertize "❯" 'face `(:foreground "#50fa7b")))))
(setq eshell-hist-ignoredups t)
(setq eshell-cmpl-cycle-completions nil)
(setq eshell-cmpl-ignore-case t)
(setq eshell-ask-to-save-history (quote always))
(setq eshell-prompt-regexp "❯❯❯ ")
(add-hook 'eshell-mode-hook
'(lambda ()
(progn
(define-key eshell-mode-map "\C-a" 'eshell-bol)
(define-key eshell-mode-map "\C-r" 'counsel-esh-history)
(define-key eshell-mode-map [up] 'previous-line)
(define-key eshell-mode-map [down] 'next-line)
)))
1.17 High-Lights
1.17.1 Highlight Line
(use-package hl-line
:ensure nil
:hook
(after-init . global-hl-line-mode))
1.17.2 Paren
(use-package paren
:ensure nil
:hook
(after-init . show-paren-mode)
:custom-face
(show-paren-match ((nil (:background "#44475a" :foreground "#f1fa8c")))) ;; :box t
:custom
(show-paren-style 'mixed)
(show-paren-when-point-inside-paren t)
(show-paren-when-point-in-periphery t))
1.17.3 Highlight-symbol
(use-package highlight-symbol
:bind
(:map prog-mode-map
("M-o h" . highlight-symbol)
("M-p" . highlight-symbol-prev)
("M-n" . highlight-symbol-next)))
1.17.4 Beacon
(use-package beacon
:custom
(beacon-color "#f1fa8c")
:hook (after-init . beacon-mode))
1.17.5 Rainbow delimiters
(use-package rainbow-delimiters
:hook
(prog-mode . rainbow-delimiters-mode))
1.17.6 Rainbow Mode
(use-package rainbow-mode
:diminish
:hook (emacs-lisp-mode . rainbow-mode))
1.17.7 Volatile
(use-package volatile-highlights
:diminish
:hook
(after-init . volatile-highlights-mode)
:custom-face
(vhl/default-face ((nil (:foreground "#FF3333" :background "#FFCDCD")))))
1.17.8 Indent
(use-package highlight-indent-guides
:diminish
:hook
((prog-mode yaml-mode) . highlight-indent-guides-mode)
:custom
(highlight-indent-guides-auto-enabled t)
(highlight-indent-guides-responsive t)
(highlight-indent-guides-method 'character)) ; column
1.18 Mark
1.18.1 backward-forward
(use-package backward-forward
:disabled
:bind
("C-," . backward-forward-previous-location)
("C-." . backward-forward-next-location)
:custom
(mark-ring-max 60)
(set-mark-command-repeat-pop t)
:config
(backward-forward-mode t))
1.18.2 Point Undo
(use-package point-undo
:load-path "~/Developments/src/github.com/emacsmirror/point-undo"
:bind
("C-," . point-undo)
("C-." . point-redo))
.