My Emacs Configuration

Emacs Configuration

いろんな言語を書いてるせいか設定が多くなってきたので init-loader で分割しています。 (一部はもう動かなくなってるかも)

init.el

(require 'package)

(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives
             '("gnu" . "http://elpa.gnu.org/packages/") t)

(package-initialize)

(unless (file-exists-p package-user-dir)
  (package-refresh-contents))

(unless (package-installed-p 'init-loader)
  (package-refresh-contents)
  (package-install 'init-loader))

(require 'init-loader)
(setq init-loader-show-log-after-init 'error-only)
(init-loader-load)

Configuration

00_package.el

(package-install 'use-package)
(require 'use-package)
(setq explicit-shell-file-name "/bin/bash")

01_basic.el

(require 'cl-lib)
(require 'color)

;;
;; basic settings
;;

(use-package s
  :ensure t)

(use-package server
  :ensure t
  :config
  (unless (server-running-p)
    (setq server-port 50545)
    (setq server-use-tcp t)
    (server-start))
  (when (display-graphic-p)
    (add-to-list 'default-frame-alist '(font . "Ricty Diminished 14"))
    (set-face-attribute 'default nil :font "Ricty Diminished 14")))

(global-display-line-numbers-mode)

(use-package whitespace
  :ensure t
  :config
  (setq whitespace-style '(space-mark tab-mark face spaces trailing))
  (setq whitespace-display-mappings
        '(
          ;; (space-mark   ?\     [?\u00B7]     [?.]) ; space - centered dot
          (space-mark   ?\xA0  [?\u00A4]     [?_]) ; hard space - currency
          (space-mark   ?\x8A0 [?\x8A4]      [?_]) ; hard space - currency
          (space-mark   ?\x920 [?\x924]      [?_]) ; hard space - currency
          (space-mark   ?\xE20 [?\xE24]      [?_]) ; hard space - currency
          (space-mark   ?\xF20 [?\xF24]      [?_]) ; hard space - currency
          (space-mark ?\u3000 [?\u25a1] [?_ ?_]) ; full-width-space - square
          (tab-mark     ?\t    [?\u00BB ?\t] [?\\ ?\t]) ; tab - left quote mark))
  (setq whitespace-space-regexp "\\(\u3000+\\)")
  (set-face-foreground 'whitespace-space "cyan")
  (set-face-background 'whitespace-space 'nil)
  (set-face-underline  'whitespace-trailing t)
  (set-face-foreground 'whitespace-trailing "cyan")
  (set-face-background 'whitespace-trailing 'nil))

(setq debug-on-error nil)

(use-package mozc
  :ensure t
  :config
  (set-language-environment "Japanese")
  (setq default-input-method "japanese-mozc")
  (global-set-key [zenkaku-hankaku] 'toggle-input-method)
  (global-set-key [henkan]
                  (lambda ()
                    (interactive)
                    (when (null current-input-method)
                      (toggle-input-method))))
  (global-set-key [muhenkan]
                  (lambda ()
                    (interactive)
                    (deactivate-input-method)))

  (defadvice mozc-handle-event (around intercept-keys (event))
    "Intercept keys muhenkan and zenkaku-hankaku, before passing keys
to mozc-server (which the function mozc-handle-event does), to
properly disable mozc-mode."
    (if (member event (list 'zenkaku-hankaku 'muhenkan))
        (progn
          (mozc-clean-up-session)
          (toggle-input-method))
      (progn
        ad-do-it)))
  (ad-activate 'mozc-handle-event))

(global-unset-key (kbd "C-\\"))
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(global-set-key (kbd "C-h") 'delete-backward-char)
(column-number-mode 1)
(cua-mode t)
(setq cua-enable-cua-keys nil)
(show-paren-mode t)

(setq-default fill-column 100)
(setq-default c-basic-offset 2
              tab-width 2
              indent-tabs-mode nil)

(setq vc-follow-symlinks t)
(global-auto-revert-mode 1)
(setq auto-revert-check-vc-info t)
(setq auto-revert-interval 1)
(setq inhibit-splash-screen t)

(setq make-backup-files nil)
(setq auto-save-default nil)
(setq auto-save-list-file-prefix nil)
(setq create-lockfiles nil)

(setq recentf-save-file "~/.emacs.d/.recentf")
(setq recentf-max-saved-items 10000)

(savehist-mode t)
(setq history-length 1000)
(setq messagep-log-max 10000)

(defun beginning-of-indented-line (current-point)
  (interactive "d")
  (if (string-match
       "^[ \t]+$"
       (save-excursion
         (buffer-substring-no-properties
          (progn (beginning-of-line) (point))
          current-point)))
      (beginning-of-line)
    (back-to-indentation)))

(defun beginning-of-visual-indented-line (current-point)
  (interactive "d")
  (let ((vhead-pos (save-excursion (progn (beginning-of-visual-line) (point))))
        (head-pos (save-excursion (progn (beginning-of-line) (point)))))
    (cond
     ((eq vhead-pos head-pos)
      (if (string-match
           "^[ \t]+$"
           (buffer-substring-no-properties vhead-pos current-point))
          (beginning-of-visual-line)
        (back-to-indentation)))
     ((eq vhead-pos current-point)
      (backward-char)
      (beginning-of-visual-indented-line (point)))
     (t (beginning-of-visual-line)))))

(defun new-next-line (current-point)
  (interactive "d")
  (next-line)
  (beginning-of-visual-indented-line current-point))

(defun new-previous-line (current-point)
  (interactive "d")
  (previous-line)
  (beginning-of-visual-indented-line current-point))

(defun toggle-snakecase ()
  "Toggle between camelcase and underscore notation for the symbol at point."
  (interactive)
  (save-excursion
    (let* ((bounds (bounds-of-thing-at-point 'symbol))
           (str (thing-at-point 'symbol))
           (start (car bounds))
           (end (cdr bounds)))
      (if (or (s-contains? "_" str) (s-contains? "-" str))
          (replace-string str (s-lower-camel-case str) nil start end)
        (replace-string str (s-snake-case str) nil start end)))))

(defun word-initials ()
    "Toggle between camelcase and underscore notation for the symbol at point."
  (interactive)
  (save-excursion
    (let* ((bounds (bounds-of-thing-at-point 'symbol))
           (str (thing-at-point 'symbol))
           (start (car bounds))
           (end (cdr bounds)))
      (replace-string str (s-word-initials str) nil start end))))


(global-set-key (kbd "C-a") 'beginning-of-visual-indented-line)
(global-set-key (kbd "C-e") 'end-of-visual-line)

(defun current-line ()
  (string-to-number (format-mode-line "%l")))

(defun forward-to-word (arg)
  (interactive "^p")
  (let ((c1 (point))
        (l1 (current-line))
        (end (line-end-position))
        (p (viper-forward-word arg))
        (c2 (point))
        (l2 (current-line)))
    (when (and (> l2 l1) (/= c1 end))
      (re-search-backward "\\(\\W\\b\\|.$\\)" nil t arg)
      (forward-char 1))))

(defun backward-to-word (arg)
  (interactive "^p")
  (let ((c1 (point))
        (l1 (current-line))
        (begin (line-beginning-position))
        (p (viper-backward-word arg))
        (c2 (point))
        (l2 (current-line)))
    (when (and (> l1 l2) (/= c1 begin))
      (end-of-line))))

(require 'viper-cmd)
(global-set-key (kbd "C-<right>") 'forward-to-word)
(global-set-key (kbd "C-<left>") 'backward-to-word)

(transient-mark-mode t)
(delete-selection-mode t)

(setq redisplay-dont-pause t)
(global-whitespace-mode t)

(setq frame-title-format "%b")
(menu-bar-mode -1)
(tool-bar-mode 0)

(setq truncate-lines t)
(setq truncate-partial-width-windows nil)
(setq kill-whole-line t)

(defun set-alpha (alpha-num)
  "set frame parameter 'alpha"
  (interactive "nAlpha: ")
  (set-frame-parameter nil 'alpha (cons alpha-num '(100))))

(defalias 'exit 'save-buffers-kill-emacs)

(defun prev-window ()
  (interactive)
  (other-window -1))

(global-set-key (kbd "s-<left>") 'prev-window)
(global-set-key (kbd "s-<right>") 'other-window)
(global-set-key (kbd "C-|") 'split-window-horizontally)

(defun delete-word (arg)
  (interactive "p")
  (delete-region (point) (progn (viper-forward-word arg) (point))))

(defun backward-delete-word (arg)
  (interactive "p")
  (delete-word (- arg)))

(global-set-key (kbd "M-d") 'delete-word)
(global-set-key [C-backspace] 'backward-delete-word)

(use-package auto-sudoedit
  :ensure t
  :config
  (auto-sudoedit-mode 1))

(use-package smart-hungry-delete
  :ensure t
  :bind (("<backspace>" . smart-hungry-delete-backward-char)
         ("C-d" . smart-hungry-delete-forward-char))
  :config (smart-hungry-delete-add-default-hooks))

02_display.el


(use-package all-the-icons
  :ensure t)

(use-package all-the-icons-dired
  :ensure t)

(use-package focus
  :ensure t
  :config
  (add-to-list 'focus-mode-to-thing
               '(c-mode . lsp-folding-range)))

(if (daemonp)
    (add-hook 'after-make-frame-functions
              (lambda (frame)
                (select-frame frame)
                (setenv "SSH_AUTH_SOCK" "/run/user/1000/gnupg/S.gpg-agent.ssh")
                (when (display-graphic-p)
                  (add-to-list 'default-frame-alist '(font . "Ricty Diminished 14"))
                  (set-face-attribute 'default nil :font "Ricty Diminished 14"))
                (use-package doom-themes
                  :ensure t
                  :custom
                  (doom-themes-enable-italic t)
                  (doom-themes-enable-bold t)
                  (doom-challenger-deep-brighter-comments t)
                  (doom-molokai-brighter-comments t)
                  (doom-dracula-brighter-comments t)
                  :custom-face
                  (doom-modeline-bar ((t (:background "#6272a4"))))
                  (font-lock-comment-face ((t (:foreground "#e0e0e0"))))
                  :config
                  (load-theme 'doom-laserwave t)
                  (doom-themes-neotree-config)
                  (doom-themes-org-config))))

  (use-package doom-themes
    :ensure t
    :custom
    (doom-themes-enable-italic t)
    (doom-themes-enable-bold t)
    (doom-challenger-deep-brighter-comments t)
    (doom-molokai-brighter-comments t)
    (doom-dracula-brighter-comments t)
    :custom-face
    (doom-modeline-bar ((t (:background "#6272a4"))))
    (font-lock-comment-face ((t (:foreground "#e0e0e0"))))
    :config
    (load-theme 'doom-laserwave t)
    (doom-themes-neotree-config)
    (doom-themes-org-config)))

;;;
;;; color-identifiers-mode
;;;

(use-package color-identifiers-mode
  :ensure t
  :defer t
  :hook
  (after-init . global-color-identifiers-mode))

;;;
;;; highlight-indent-guides
;;;

(use-package highlight-indent-guides
  :ensure t
  :defer t
  :diminish
  :commands
  (highlight-indent-guides-mode)
  :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))

;;;
;;; git-gutter
;;;

(use-package git-gutter
  :ensure t
  :defer t
  :custom
  (git-gutter:modified-sign "~")
  (git-gutter:added-sign    "+")
  (git-gutter:deleted-sign  "-")
  :custom-face
  (git-gutter:modified ((t (:background "#f1fa8c"))))
  (git-gutter:added    ((t (:background "#50fa7b"))))
  (git-gutter:deleted  ((t (:background "#ff79c6"))))
  :config
  (global-git-gutter-mode +1))

;;;
;;; doom-modeline
;;;

(use-package doom-modeline
  :ensure t
  :hook (after-init . doom-modeline-mode)
  :custom
  (doom-modeline-buffer-file-name-style 'truncate-with-project)
  (doom-modeline-icon t)
  (doom-modeline-major-mode-icon t)
  (doom-modeline-major-mode-color-icon t)
  (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)))

(use-package volatile-highlights
  :ensure t
  :defer t
  :diminish
  :commands
  (volatile-highlights-mode)
  :hook
  (after-init . volatile-highlights-mode)
  :custom-face
  (vhl/default-face ((nil (:foreground "#FF3333" :background "#FFCDCD")))))

(use-package beacon
  :ensure t
  :defer t
  :hook
  (prog-mode . beacon-mode)
  :commands
  (beacon-mode)
  :custom
  (beacon-color "#77fffa")
  (beacon-blink-duration 0.5)
  (beacon-size 80))

(use-package presentation
  :ensure t
  :defer t
  ;; :bind
  ;; (:map presentation-mode-map
  ;;       ("C-z" .  hydra-presentation/body))
  :commands
  (presentation-mode))

(defhydra hydra-presentation (:hint nil)
"
^Presentation^
^^^^^^~~-----------------------------------
_i_: zoom-in          _o_: zoom-out
_p_: presentation-mode

"
  ("i" text-scale-increase)
  ("o" text-scale-decrease)
  ("p" presentation-mode)
  ("z" nil "leave"))

(use-package fill-column-indicator
  :ensure t
  :defer t
  :commands
  (fci-mode))

(use-package rainbow-delimiters
  :ensure t
  :defer t
  :hook
  (prog-mode . rainbow-delimiters-mode)
  :commands
  (rainbow-delimiters-mode)
  :config
  (custom-set-faces
   '(rainbow-delimiters-depth-1-face ((t (:foreground "#2aa198"))))
   '(rainbow-delimiters-depth-2-face ((t (:foreground "#b58900"))))
   '(rainbow-delimiters-depth-3-face ((t (:foreground "#268bd2"))))
   '(rainbow-delimiters-depth-4-face ((t (:foreground "#dc322f"))))
   '(rainbow-delimiters-depth-5-face ((t (:foreground "#859900"))))
   '(rainbow-delimiters-depth-6-face ((t (:foreground "#268bd2"))))
   '(rainbow-delimiters-depth-7-face ((t (:foreground "#cb4b16"))))
   '(rainbow-delimiters-depth-8-face ((t (:foreground "#d33682"))))
   '(rainbow-delimiters-depth-9-face ((t (:foreground "#839496"))))))

(use-package dired
  :ensure nil
  :config
  ;; Always delete and copy recursively
  (setq dired-recursive-deletes 'always)
  (setq dired-recursive-copies 'always)

  ;; Colourful dired
  (use-package diredfl
    :ensure t
    :init (diredfl-global-mode 1))

  ;; Shows icons
  (use-package all-the-icons-dired
    :diminish
    :custom-face (all-the-icons-dired-dir-face ((t (:foreground nil))))
    :hook (dired-mode . all-the-icons-dired-mode)
    :config
    (defun my-all-the-icons-dired--display ()
      "Display the icons of files without colors in a dired buffer."
      (when (and (not all-the-icons-dired-displayed) dired-subdir-alist)
        (setq-local all-the-icons-dired-displayed t)
        (let ((inhibit-read-only t)
              (remote-p (and (fboundp 'tramp-tramp-file-p)
                             (tramp-tramp-file-p default-directory))))
          (save-excursion
            (goto-char (point-min))
            (while (not (eobp))
              (when (dired-move-to-filename nil)
                (let ((file (dired-get-filename 'verbatim t)))
                  (unless (member file '("." ".."))
                    (let ((filename (dired-get-filename nil t)))
                      (if (file-directory-p filename)
                          (let* ((matcher (all-the-icons-match-to-alist file all-the-icons-dir-icon-alist))
                                 (icon (cond
                                        (remote-p
                                         (all-the-icons-octicon "file-directory"
                                                                :height 0.80
                                                                :v-adjust all-the-icons-dired-v-adjust
                                                                :face 'all-the-icons-dired-dir-face))
                                        ((file-symlink-p filename)
                                         (all-the-icons-octicon "file-symlink-directory"
                                                                :height 0.80
                                                                :v-adjust all-the-icons-dired-v-adjust
                                                                :face 'all-the-icons-dired-dir-face))
                                        ((all-the-icons-dir-is-submodule filename)
                                         (all-the-icons-octicon "file-submodule"
                                                                :height 0.80
                                                                :v-adjust all-the-icons-dired-v-adjust
                                                                :face 'all-the-icons-dired-dir-face))
                                        ((file-exists-p (format "%s/.git" filename))
                                         (all-the-icons-octicon "repo"
                                                                :height 0.8
                                                                :v-adjust all-the-icons-dired-v-adjust
                                                                :face 'all-the-icons-dired-dir-face))
                                        (t (apply (car matcher)
                                                  (list (cadr matcher)
                                                        :height 0.80
                                                        :face 'all-the-icons-dired-dir-face
                                                        :v-adjust all-the-icons-dired-v-adjust))))))
                            (insert (concat icon " ")))
                        (insert (concat
                                 (all-the-icons-icon-for-file
                                  file
                                  :height 0.8
                                  :v-adjust -0.05) " ")))))))
              (forward-line 1))))))
    (advice-add #'all-the-icons-dired--display :override #'my-all-the-icons-dired--display))

  ;; Extra Dired functionality
  (use-package dired-aux
    :ensure nil)

  (use-package dired-x
    :demand
    :config
    (let ((cmd "xdg-open"))
      (setq dired-guess-shell-alist-user
            `(("\\.pdf\\'" ,cmd)
              ("\\.docx\\'" ,cmd)
              ("\\.\\(?:djvu\\|eps\\)\\'" ,cmd)
              ("\\.\\(?:jpg\\|jpeg\\|png\\|gif\\|xpm\\)\\'" ,cmd)
              ("\\.\\(?:xcf\\)\\'" ,cmd)
              ("\\.csv\\'" ,cmd)
              ("\\.tex\\'" ,cmd)
              ("\\.\\(?:mp4\\|mkv\\|avi\\|flv\\|rm\\|rmvb\\|ogv\\)\\(?:\\.part\\)?\\'" ,cmd)
              ("\\.\\(?:mp3\\|flac\\)\\'" ,cmd)
              ("\\.html?\\'" ,cmd)
              ("\\.md\\'" ,cmd))))

    (setq dired-omit-files
          (concat dired-omit-files
                  "\\|^.DS_Store$\\|^.projectile$\\|^.git*\\|^.svn$\\|^.vscode$\\|\\.js\\.meta$\\|\\.meta$\\|\\.elc$\\|^.emacs.*"))))

03_yas.el

;;;
;;; yasnippet
;;;

(use-package yasnippet
  :ensure t
  :diminish yas-minor-mode
  :custom (yas-snippet-dirs '("~/.emacs.d/inits/snippets"))
  :hook (after-init . yas-global-mode))

04_ivy.el

(use-package wgrep
  :ensure t
  :defer t
  :custom
  (wgrep-enable-key "e")
  (wgrep-auto-save-buffer t)
  (wgrep-change-readonly-file t))

(defun counsel-fzf-root ()
  (interactive)
  (counsel-fzf nil (locate-dominating-file default-directory ".git")))

(use-package ivy
  :ensure t
  :bind
  (("C-c C-r" . ivy-resume)
   :map ivy-minibuffer-map
   ("<backspace>" . backward-delete-char-untabify)
   ("<right>" . ivy-alt-done)
   ("<left>" . ivy-alt-done)
   ("<enter>" . ivy-immediate-done)
   ("C-z" . ivy-dispatching-done))
  :custom
  (enable-recursive-minibuffers t)
  (ivy-use-virtual-buffers t)
  (ivy-count-format "(%d/%d) ")
  (ivy-format-function 'ivy-format-function-line)
  :hook
  (after-init . ivy-mode))

(use-package swiper
  :ensure t
  :defer t
  :commands
  (swiper)
  :bind
  ;; ("C-s" . swiper-isearch)
  ("C-S-s" . swiper-all)
  :custom
  (swiper-action-recenter t))

(use-package counsel
  :ensure t
  :defer t
  :commands
  (counsel-M-x
   counsel-find-file
   counsel-switch-buffer
   counsel-rg
   counsel-imenu)
  :bind
  (("M-x" . counsel-M-x)
   ("C-x C-f" . counsel-find-file)
   ("C-x f" . counsel-fzf)
   ("C-x C-b" . counsel-switch-buffer)
   ("C-c g" . counsel-git)
   ("C-c i" . counsel-imenu)
   ("C-c a" . counsel-ag)
   ("C-c r" . counsel-rg)
   :map minibuffer-local-map
   ("C-r" . counsel-minibuffer-history))
  :custom
  (counsel-find-file-at-point t)
  :config
  (let ((cmd (cond ((executable-find "rg")
                    "rg -S --no-heading --line-number --color never '%s' %s")
                   ((executable-find "ag")
                    "ag -S --noheading --nocolor --nofilename --numbers '%s' %s")
                   (t counsel-grep-base-command))))
    (setq counsel-grep-base-command cmd)))

(use-package amx
  :ensure t
  :after ivy)

(use-package ivy-rich
  :ensure t
  :defines (all-the-icons-icon-alist
            all-the-icons-dir-icon-alist
            bookmark-alist)
  :functions (all-the-icons-icon-for-file
              all-the-icons-icon-for-mode
              all-the-icons-icon-family
              all-the-icons-match-to-alist
              all-the-icons-faicon
              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-buffer-icon (candidate)
    "Display buffer icons in `ivy-rich'."
    (when (display-graphic-p)
      (let* ((buffer (get-buffer candidate))
             (buffer-file-name (buffer-file-name buffer))
             (major-mode (buffer-local-value 'major-mode buffer))
             (icon (if (and buffer-file-name
                            (all-the-icons-match-to-alist buffer-file-name
                                                          all-the-icons-icon-alist))
                       (all-the-icons-icon-for-file (file-name-nondirectory buffer-file-name)
                                                    :height 0.9 :v-adjust -0.05)
                     (all-the-icons-icon-for-mode major-mode :height 0.9 :v-adjust -0.05))))
        (if (symbolp icon)
            (setq icon (all-the-icons-faicon "file-o" :face 'all-the-icons-dsilver :height 0.9 :v-adjust -0.05))
          icon))))

  (defun ivy-rich-file-icon (candidate)
    "Display file icons in `ivy-rich'."
    (when (display-graphic-p)
      (let* ((path (concat ivy--directory candidate))
             (file (file-name-nondirectory path))
             (icon (cond ((file-directory-p path)
                          (cond
                           ((and (fboundp 'tramp-tramp-file-p)
                                 (tramp-tramp-file-p default-directory))
                            (all-the-icons-octicon "file-directory" :height 0.93 :v-adjust 0.01))
                           ((file-symlink-p path)
                            (all-the-icons-octicon "file-symlink-directory" :height 0.93 :v-adjust 0.01))
                           ((all-the-icons-dir-is-submodule path)
                            (all-the-icons-octicon "file-submodule" :height 0.93 :v-adjust 0.01))
                           ((file-exists-p (format "%s/.git" path))
                            (all-the-icons-octicon "repo" :height 1.0 :v-adjust -0.01))
                           (t (let ((matcher (all-the-icons-match-to-alist candidate all-the-icons-dir-icon-alist)))
                                (apply (car matcher) (list (cadr matcher) :height 0.93 :v-adjust 0.01))))))
                         ((string-match "^/.*:$" path)
                          (all-the-icons-material "settings_remote" :height 0.9 :v-adjust -0.2))
                         ((not (string-empty-p file))
                          (all-the-icons-icon-for-file file :height 0.9 :v-adjust -0.05)))))
        (if (symbolp icon)
            (setq icon (all-the-icons-faicon "file-o" :face 'all-the-icons-dsilver :height 0.9 :v-adjust -0.05))
          icon))))
  :hook ((ivy-mode . ivy-rich-mode)
         (ivy-rich-mode . (lambda ()
                            (setq ivy-virtual-abbreviate
                                  (or (and ivy-rich-mode 'abbreviate) 'name)))))
  :init
  ;; For better performance
  (setq ivy-rich-parse-remote-buffer nil)
  (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-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)))
          persp-switch-to-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)))
          counsel-M-x
          (:columns
           ((counsel-M-x-transformer (:width 50))
            (ivy-rich-counsel-function-docstring (:face font-lock-doc-face))))
          counsel-describe-function
          (:columns
           ((counsel-describe-function-transformer (:width 50))
            (ivy-rich-counsel-function-docstring (:face font-lock-doc-face))))
          counsel-describe-variable
          (:columns
           ((counsel-describe-variable-transformer (:width 50))
            (ivy-rich-counsel-variable-docstring (:face font-lock-doc-face))))
          counsel-find-file
          (:columns
           ((ivy-rich-file-icon)
            (ivy-read-file-transformer)))
          counsel-file-jump
          (:columns
           ((ivy-rich-file-icon)
            (ivy-rich-candidate)))
          counsel-dired
          (:columns
           ((ivy-rich-file-icon)
            (ivy-read-file-transformer)))
          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 0.8))
            (ivy-rich-file-last-modified-time (:face font-lock-comment-face))))
          counsel-bookmark
          (:columns
           ((ivy-rich-bookmark-type)
            (ivy-rich-bookmark-name (:width 40))
            (ivy-rich-bookmark-info)))
          counsel-projectile-switch-project
          (:columns
           ((ivy-rich-file-icon)
            (ivy-rich-candidate)))
          counsel-projectile-find-file
          (:columns
           ((ivy-rich-file-icon)
            (counsel-projectile-find-file-transformer)))
          counsel-projectile-find-dir
          (:columns
           ((ivy-rich-file-icon)
            (counsel-projectile-find-dir-transformer)))
          treemacs-projectile
          (:columns
           ((ivy-rich-file-icon)
            (ivy-rich-candidate))))))

(use-package ivy-xref
  :ensure t
  :init (setq xref-show-xrefs-function #'ivy-xref-show-xrefs))

;; Correcting words with flyspell via Ivy
(use-package flyspell-correct-ivy
  :ensure t
  :after flyspell
  :bind (:map flyspell-mode-map
              ([remap flyspell-correct-word-before-point] . flyspell-correct-previous-word-generic)))

(use-package posframe
  :ensure t)

;; #373844
;; #282a36
;; #1E2029

(use-package ivy-posframe
  :ensure t
  :after ivy
  :custom-face
  ;; (ivy-posframe ((t (:background "#282a36"))))
  (ivy-posframe-border ((t (:background "white"))))
  :custom
  (ivy-posframe-border-width 2)
  (ivy-posframe-display-functions-alist '((t . ivy-posframe-display-at-frame-center)))
  (ivy-posframe-parameters '((left-fringe . 8)
                             (right-fringe . 8)))
  (ivy-posframe-height-alist '((swiper . 30)
                               (counsel . 20)
                               (t      . 20)))
  :config
  (ivy-posframe-mode 1) )

05_search.el

;;;
;;; ace-isearch
;;;
(use-package ace-jump-mode
  :ensure t)

(use-package avy
  :ensure t)

(use-package ace-isearch
  :ensure t
  :custom
  (ace-isearch-input-length 6)
  (ace-isearch-jump-delay 1.2)
  (ace-isearch-function 'avy-goto-char)
  (ace-isearch-use-jump 'printing-char)
  (ace-isearch-function-from-isearch 'ace-isearch-swiper-from-isearch)
  :config
  (use-package swiper
    :ensure t)
  (global-ace-isearch-mode +1))

;;;
;;; anzu
;;;

(use-package anzu
  :ensure t
  :bind
  (("M-%" . anzu-query-replace)
   ("C-M-%" . anzu-query-replace-regexp))
  :custom
  (anzu-mode-lighter "")
  (anzu-search-threshold 1000)
  (anzu-replace-to-string-separator " => ")
  :commands
  (anzu-mode
   anzu-query-replace
   anzu-query-replace-regexp)
  :config
  (global-anzu-mode t))

(use-package symbol-overlay
  :ensure t
  :diminish
  :functions
  (symbol-overlay-switch-first symbol-overlay-switch-last)
  :commands
  (symbol-overlay-get-symbol
   symbol-overlay-assoc
   symbol-overlay-get-list
   symbol-overlay-jump-call)
  :bind (("M-i" . symbol-overlay-put)
         ("C-M-n" . symbol-overlay-jump-next)
         ("C-M-m" . symbol-overlay-jump-prev)
         ("M-N" . symbol-overlay-switch-forward)
         ("M-P" . symbol-overlay-switch-backward)
         ("M-C" . symbol-overlay-remove-all))
  :hook ((prog-mode . symbol-overlay-mode))
  :config
  (defun symbol-overlay-switch-first ()
    (interactive)
    (let* ((symbol (symbol-overlay-get-symbol))
           (keyword (symbol-overlay-assoc symbol))
           (a-symbol (car keyword))
           (before (symbol-overlay-get-list a-symbol 'car))
           (count (length before)))
      (symbol-overlay-jump-call 'symbol-overlay-basic-jump (- count))))

  (defun symbol-overlay-switch-last ()
    (interactive)
    (let* ((symbol (symbol-overlay-get-symbol))
           (keyword (symbol-overlay-assoc symbol))
           (a-symbol (car keyword))
           (after (symbol-overlay-get-list a-symbol 'cdr))
           (count (length after)))
      (symbol-overlay-jump-call 'symbol-overlay-basic-jump (- count 1))))

  (bind-keys :map symbol-overlay-map
             ("<" . symbol-overlay-switch-first)
             (">" . symbol-overlay-switch-last)))

(use-package dumb-jump
  :ensure t
  :defer t
  :commands
  (dumb-jump-mode)
  :custom
  (dumb-jump-selector 'ivy))

(defvar initial-mark nil)

(defun set-initial-mark ()
  (unless initial-mark
    (setq initial-mark t)
    (jumplist--set)))

(use-package jumplist
  :ensure t
  :defer t
  :commands
  (jumplist-previous jumplist-next jumplist--set)
  :bind
  (("C-<" . jumplist-previous)
   ("C->" . jumplist-next))
  :hook
  ((prog-mode markdown-mode) . (lambda () (set-initial-mark)))
  :custom
  (jumplist-ex-mode t)
  (jumplist-hook-commands '(find-file
                            dired-jump
                            counsel-find-file
                            counsel-git
                            counsel-git-grep
                            counsel-ag
                            counsel-rg
                            counsel-rg-root
                            counsel-fzf
                            counsel-fzf-root
                            smart-jump-go
                            dumb-jump-go
                            buffer-expose
                            swiper
                            ivy-switch-buffer
                            isearch-forward
                            end-of-buffer
                            beginning-of-buffer
                            godef-jump
                            meghanada-jump-declaration)))

(use-package smart-jump
  :ensure t
  :config
  (smart-jump-setup-default-registers))

06_company.el

;;;
;;; company-mode
;;;

;;;
;;; eacl
;;;

(use-package eacl
  :ensure t
  :defer t
  :commands
  (eacl-complete-line)
  :bind (("C-c C-c" . eacl-complete-line)))

(use-package company
  :ensure t
  :diminish company-mode
  :defines (company-dabbrev-ignore-case company-dabbrev-downcase)
  ;; :commands company-abort
  :bind (("M-/" . company-complete)
         :map company-active-map
         ("C-p" . company-select-previous)
         ("C-n" . company-select-next)
         ("<tab>" . company-complete-common-or-cycle)
         :map company-search-map
         ("C-p" . company-select-previous)
         ("C-n" . company-select-next))
  :hook
  (after-init . global-company-mode)
  ((go-mode
    c++-mode
    c-mode
    vue-mode
    js2-mode
    rust-mode
    objc-mode) . (lambda () (set (make-local-variable 'company-backends)
                                 '((company-lsp
                                    :with
                                    company-yasnippet
                                    company-files
                                    company-dabbrev-code)))))
  :init
  (defun my-company-yasnippet ()
    (interactive)
    (company-abort)
    (call-interactively 'company-yasnippet))
  :config
  (setq company-transformers '(company-sort-by-backend-importance)
        company-tooltip-align-annotations t ; aligns annotation to the right
        company-idle-delay 0               ; decrease delay before autocompletion popup shows
        company-echo-delay 0                ; remove annoying blinking
        company-minimum-prefix-length 2
        company-require-match nil
        company-dabbrev-ignore-case nil
        company-dabbrev-downcase nil))

(use-package company-box
  :ensure t
  :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-material 'all-the-icons)
      (setq company-box-icons-all-the-icons
            `((Unknown . ,(all-the-icons-material "find_in_page" :height 0.85 :v-adjust -0.2))
              (Text . ,(all-the-icons-faicon "text-width" :height 0.80 :v-adjust -0.05))
              (Method . ,(all-the-icons-faicon "cube" :height 0.80 :v-adjust -0.05 :face 'all-the-icons-purple))
              (Function . ,(all-the-icons-faicon "cube" :height 0.80 :v-adjust -0.05 :face 'all-the-icons-purple))
              (Constructor . ,(all-the-icons-faicon "cube" :height 0.80 :v-adjust -0.05 :face 'all-the-icons-purple))
              (Field . ,(all-the-icons-faicon "tag" :height 0.80 :v-adjust -0.05 :face 'all-the-icons-lblue))
              (Variable . ,(all-the-icons-faicon "tag" :height 0.80 :v-adjust -0.05 :face 'all-the-icons-lblue))
              (Class . ,(all-the-icons-material "settings_input_component" :height 0.85 :v-adjust -0.2 :face 'all-the-icons-orange))
              (Interface . ,(all-the-icons-material "share" :height 0.85 :v-adjust -0.2 :face 'all-the-icons-lblue))
              (Module . ,(all-the-icons-material "view_module" :height 0.85 :v-adjust -0.2 :face 'all-the-icons-lblue))
              (Property . ,(all-the-icons-faicon "wrench" :height 0.80 :v-adjust -0.05))
              (Unit . ,(all-the-icons-material "settings_system_daydream" :height 0.85 :v-adjust -0.2))
              (Value . ,(all-the-icons-material "format_align_right" :height 0.85 :v-adjust -0.2 :face 'all-the-icons-lblue))
              (Enum . ,(all-the-icons-material "storage" :height 0.85 :v-adjust -0.2 :face 'all-the-icons-orange))
              (Keyword . ,(all-the-icons-material "filter_center_focus" :height 0.85 :v-adjust -0.2))
              (Snippet . ,(all-the-icons-material "format_align_center" :height 0.85 :v-adjust -0.2))
              (Color . ,(all-the-icons-material "palette" :height 0.85 :v-adjust -0.2))
              (File . ,(all-the-icons-faicon "file-o" :height 0.85 :v-adjust -0.05))
              (Reference . ,(all-the-icons-material "collections_bookmark" :height 0.85 :v-adjust -0.2))
              (Folder . ,(all-the-icons-faicon "folder-open" :height 0.85 :v-adjust -0.05))
              (EnumMember . ,(all-the-icons-material "format_align_right" :height 0.85 :v-adjust -0.2 :face 'all-the-icons-lblue))
              (Constant . ,(all-the-icons-faicon "square-o" :height 0.85 :v-adjust -0.05))
              (Struct . ,(all-the-icons-material "settings_input_component" :height 0.85 :v-adjust -0.2 :face 'all-the-icons-orange))
              (Event . ,(all-the-icons-faicon "bolt" :height 0.80 :v-adjust -0.05 :face 'all-the-icons-orange))
              (Operator . ,(all-the-icons-material "control_point" :height 0.85 :v-adjust -0.2))
              (TypeParameter . ,(all-the-icons-faicon "arrows" :height 0.80 :v-adjust -0.05))
              (Template . ,(all-the-icons-material "format_align_center" :height 0.85 :v-adjust -0.2))))))

07_flycheck.el

;;;
;;; flycheck-mode
;;;

;;; Code:

(use-package flycheck
  :ensure t
  :defer t
  :bind
  (("M-p" . flycheck-previous-error)
   ("M-n" . flycheck-next-error))
  :commands
  (flycheck-mode flycheck-previous-error flycheck-next-error))

(use-package flycheck-posframe
  :ensure t
  :after flycheck
  :hook (flycheck-mode . flycheck-posframe-mode)
  :custom
  (flycheck-posframe-error-prefix "☠ ")
  (flycheck-posframe-warning-prefix "⚠ "))

;;;
;;; flymake
;;;

(use-package flymake-diagnostic-at-point
  :ensure t
  :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)
  :hook
  (flymake-mode . flymake-diagnostic-at-point-mode))

08_popwin.el


;;;
;;; popwin
;;;

(use-package popwin
  :ensure t
  :defer t
  :commands
  (popwin-mode)
  :config
  (setq popwin:special-display-config
        '(("*Completions*" :noselect t :height 0.4)
          ("*tag" :noselect t :regexp t :height 0.4)
          ("helm" :regexp t :height 0.4)
          ("typeinfo" :regexp t :height 0.4)
          ("reference" :regexp t :height 0.4)
          ("*cider-repl" :regexp t :height 0.4)
          ("*cider-error" :regexp t :height 0.4)
          ("*cider-doc" :regexp t :height 0.4)
          ("*cider-apropos" :regexp t :height 0.4))))

;;;
;;; shell-pop
;;;

(use-package shell-pop
  :ensure t
  :defer t
  :bind
  ("C-t" . shell-pop)
  :custom
  (shell-pop-shell-type (quote ("eshell" "*eshell*" (lambda () (eshell)))))
  (shell-pop-universal-key "C-t")
  (shell-pop-window-size 50)
  (shell-pop-full-span t)
  (shell-pop-window-position "bottom")
  :commands
  (shell-pop)
  :config
  (setq eshell-command-aliases-list
        (append
         (list
          (list "o" "xdg-open")))))

;;;
;;; eshell
;;;

(use-package eshell
  :ensure t
  :defines (compilation-last-buffer eshell-prompt-function)
  :commands (eshell/alias
             eshell-send-input eshell-flatten-list
             eshell-interactive-output-p eshell-parse-command)
  :hook (eshell-mode . (lambda ()
                         (bind-key "C-l" 'eshell/clear eshell-mode-map)
                         (eshell/alias "f" "find-file $1")
                         (eshell/alias "fo" "find-file-other-window $1")
                         (eshell/alias "d" "dired $1")
                         (eshell/alias "ll" "ls -l")
                         (eshell/alias "la" "ls -al")))
  :preface
  (defun eshell/clear ()
    "Clear the eshell buffer."
    (interactive)
    (let ((inhibit-read-only t))
      (erase-buffer)
      (eshell-send-input)))

  (defun eshell/emacs (&rest args)
    "Open a file (ARGS) in Emacs.  Some habits die hard."
    (if (null args)
        ;; If I just ran "emacs", I probably expect to be launching
        ;; Emacs, which is rather silly since I'm already in Emacs.
        ;; So just pretend to do what I ask.
        (bury-buffer)
      ;; We have to expand the file names or else naming a directory in an
      ;; argument causes later arguments to be looked for in that directory,
      ;; not the starting directory
      (mapc #'find-file (mapcar #'expand-file-name (eshell-flatten-list (reverse args))))))

  (defalias 'eshell/e 'eshell/emacs)

  (defun eshell/ec (&rest args)
    "Compile a file (ARGS) in Emacs.  Use `compile' to do background make."
    (if (eshell-interactive-output-p)
        (let ((compilation-process-setup-function
               (list 'lambda nil
                     (list 'setq 'process-environment
                           (list 'quote (eshell-copy-environment))))))
          (compile (eshell-flatten-and-stringify args))
          (pop-to-buffer compilation-last-buffer))
      (throw 'eshell-replace-command
             (let ((l (eshell-stringify-list (eshell-flatten-list args))))
               (eshell-parse-command (car l) (cdr l))))))
  (put 'eshell/ec 'eshell-no-numeric-conversions t)

  (defun eshell-view-file (file)
    "View FILE.  A version of `view-file' which properly rets the eshell prompt."
    (interactive "fView file: ")
    (unless (file-exists-p file) (error "%s does not exist" file))
    (let ((buffer (find-file-noselect file)))
      (if (eq (get (buffer-local-value 'major-mode buffer) 'mode-class)
              'special)
          (progn
            (switch-to-buffer buffer)
            (message "Not using View mode because the major mode is special"))
        (let ((undo-window (list (window-buffer) (window-start)
                                 (+ (window-point)
                                    (length (funcall eshell-prompt-function))))))
          (switch-to-buffer buffer)
          (view-mode-enter (cons (selected-window) (cons nil undo-window))
                           'kill-buffer)))))

  (defun eshell/less (&rest args)
    "Invoke `view-file' on a file (ARGS).  \"less +42 foo\" will go to line 42 in the buffer for foo."
    (while args
      (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args))
          (let* ((line (string-to-number (match-string 1 (pop args))))
                 (file (pop args)))
            (eshell-view-file file)
            (forward-line line))
        (eshell-view-file (pop args)))))

  (defalias 'eshell/more 'eshell/less)
  :config
  ;; Fish-like history autosuggestions
  (use-package esh-autosuggest
    :ensure t
    :defines ivy-display-functions-alist
    :preface
    (defun setup-eshell-ivy-completion ()
      (setq-local ivy-display-functions-alist
                  (remq (assoc 'ivy-completion-in-region ivy-display-functions-alist)
                        ivy-display-functions-alist)))
    :bind (:map eshell-mode-map
                ([remap eshell-pcomplete] . completion-at-point))
    :hook ((eshell-mode . esh-autosuggest-mode)
           (eshell-mode . setup-eshell-ivy-completion)))

  ;; Eldoc support
  (use-package esh-help
    :ensure t
    :init (setup-esh-help-eldoc))

  ;; `cd' to frequent directory in eshell
  (use-package eshell-z
    :ensure t
    :hook (eshell-mode
           .
           (lambda () (require 'eshell-z)))))

09_lsp.el

;;;
;;; eglot, lsp-mode
;;;

(use-package lsp-mode
  :ensure t
  :defer t
  :commands
  (lsp)
  :custom
  (lsp-inhibit-message t)
  (lsp-enable-completion-at-point nil)
  :config
  (lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection '("yaml-language-server" "--stdio"))
                    :major-modes '(yaml-mode)
                    :priority -1
                    :server-id 'yaml-ls)))

(use-package company-lsp
  :ensure t
  :custom
  (company-lsp-cache-candidates 'auto)
  :after
  (lsp-mode))

(use-package dap-mode
  :ensure t
  :after
  (lsp-mode))

(use-package eglot
  :commands (eglot eglot-ensure)
  :ensure t
  :config
  (add-to-list 'eglot-server-programs '(go-mode . ("bingo")))
  (add-to-list 'eglot-server-programs '(vue-mode . ("vls"))))

09_misc.el

;;;
;;; magit
;;;

(use-package magit
  :ensure t
  :defer t
  :commands
  (magit-status magit-dispatch-popup magit-list-repositories)
  :custom
  (magit-repository-directories '(("~/repos/" . 3))))

;;;
;;; reformatter
;;;

(use-package reformatter
  :ensure t)

;;;
;;; smartparens-mode
;;;

(use-package smartparens
  :ensure t
  :defer t
  :commands
  (smartparens-mode smartparens-global-mode)
  :hook
  ((prog-mode markdown-mode) . smartparens-mode)
  :config
  (use-package smartparens-config))


;;;
;;; paradox
;;;

(use-package paradox
  :ensure t
  :defer t
  :commands
  (paradox-list-packages paradox-enable)
  :custom
  (paradox-github-token t))


;;;
;;; expand-region
;;;

(use-package expand-region
  :ensure t
  :defer t
  :bind
  (("C-@" . er/expand-region)
   ("C-M-@" . er/contract-region))
  :commands
  (er/expand-region er/contract-region))

;;;
;;; aspell
;;;
(use-package flyspell
  :ensure t
  :diminish
  :if (executable-find "aspell")
  :hook (((text-mode outline-mode) . flyspell-mode)
         (prog-mode . flyspell-prog-mode)
         (flyspell-mode . (lambda ()
                            (dolist (key '("C-;" "C-," "C-."))
                              (unbind-key key flyspell-mode-map)))))
  :init
  (setq flyspell-issue-message-flag nil)
  (setq ispell-program-name "aspell")
  (setq ispell-extra-args '("--sug-mode=ultra" "--lang=en_US" "--run-together")))

(use-package origami
  :ensure t
  :config
  (global-origami-mode))

;;;
;;; buffer-expose
;;;

(use-package buffer-expose
  :ensure t
  :init (buffer-expose-mode 1))

;;;
;;; imenu-list
;;;

(use-package imenu-list
  :ensure t
  :custom-face
  (imenu-list-entry-face-1 ((t (:foreground "white"))))
  :custom
  (imenu-list-focus-after-activation t)
  (imenu-list-auto-resize nil))

;;;
;;; which-key
;;;

(use-package which-key
  :ensure t
  :diminish which-key-mode
  :hook (after-init . which-key-mode)
  :custom-face
  (which-key-posframe ((t (:background "#282a36"))))
  (which-key-posframe-border ((t (:background "white"))))
  :custom
  (which-key-posframe-border-width 2))

(use-package which-key-posframe
  :load-path "~/repos/github.com/yanghaoxie/which-key-posframe"
  :config
  ( which-key-posframe-enable))

;;;
;;; frog-jump-buffer
;;;

(use-package frog-menu
  :load-path "~/repos/github.com/clemera/frog-menu")

(use-package frog-jump-buffer
  :load-path "~/repos/github.com/waymondo/frog-jump-buffer"
  :bind
  (("C-b" . frog-jump-buffer)))

(use-package docker
  :ensure t
  :bind ("C-c d" . docker))

(use-package restclient
  :ensure t)

(use-package devdocs-lookup
  :load-path "~/repos/github.com/skeeto/devdocs-lookup")
(devdocs-setup)

(use-package easy-hugo
  :ensure t
  :bind ("C-c C-e" . easy-hugo)
  :config
  (setq easy-hugo-basedir "~/repos/github.com/mopemope/blog/")
  (setq easy-hugo-url "https://yourblogdomain")
  (setq easy-hugo-sshdomain "blogdomain")
  (setq easy-hugo-postdir "content/blog")
  (setq easy-hugo-root "~/repos/github.com/mopemope/blog/")
  (setq easy-hugo-previewtime "300"))

10_java.el

(use-package autodisass-java-bytecode
  :ensure t
  :defer t)

(use-package google-c-style
  :defer t
  :ensure t
  :commands
  (google-set-c-style))

(use-package meghanada
  :load-path "~/repos/github.com/mopemope/meghanada-emacs"
  :defer t
  :init
  (add-hook 'java-mode-hook
            (lambda ()
              (google-set-c-style)
              (google-make-newline-indent)
              (flycheck-mode t)
              (meghanada-mode t)
              (add-hook 'before-save-hook (lambda ()
                                            (meghanada-code-beautify-before-save)))))
  :config
  (setq indent-tabs-mode nil)
  (setq tab-width 2)
  (setq c-basic-offset 2)
  (setq meghanada-server-remote-debug t)
  (setq meghanada-telemetry-enable t)
  (setq meghanada-javac-xlint "-Xlint:all,-processing")
  (setq meghanada-server-jvm-option "-Xms128m -Xmx1024m -Dmeghanada.zpage.port=8080")
  (setq meghanada-import-static-enable "java.util.Objects,org.junit.Assert")
  (setq meghanada-cache-in-project nil)
  :bind
  (:map meghanada-mode-map
        ("C-S-t" . meghanada-switch-testcase)
        ("C-M-." . counsel-imenu)
        ("M-r" . meghanada-reference)
        ("M-t" . meghanada-typeinfo)
        ("C-z" . hydra-meghanada/body))
  :commands (meghanada-mode))

(defun _exit ()
  (interactive)
  (if (display-graphic-p)
      (delete-frame)
  (exit)))

(defhydra hydra-meghanada (:hint nil :exit t)
"
^Java menu^
^^^^^^-------------------------------------------------------
_C_: compile-file         _m_: restart-server
_c_: compile-project      _t_: run-task
_o_: optimize-import      _j_: run-junit-test-case
_S_: switch-test-case     _J_: run-junit-class
_v_: local-variable       _R_: run-junit-recent
_i_: import-at-point      _r_: reference
_I_: import-all           _T_: typeinfo
_p_: show-project         _e_: exec-main

_q_: exit
"
  ("C" meghanada-compile-file)
  ("c" meghanada-compile-project)
  ("m" meghanada-restart)
  ("o" meghanada-optimize-import)
  ("S" meghanada-switch-test-case)
  ("v" meghanada-local-variable)
  ("i" meghanada-import-at-point)
  ("I" meghanada-import-all)
  ("p" meghanada-show-project)

  ("g" magit-status)
  ("a" counsel-ag)
  ("l" counsel-git)
  ("I" counsel-imenu)
  ("P" presentation-mode)
  ("+" text-scale-increase)
  ("-" text-scale-decrease)

  ("t" meghanada-run-task)
  ("T" meghanada-typeinfo)
  ("j" meghanada-run-junit-test-case)
  ("J" meghanada-run-junit-class)
  ("r" meghanada-reference)
  ("R" meghanada-run-junit-recent)
  ("e" meghanada-exec-main)
  ("s" split-window-horizontally)

  ("q" _exit)
  ("z" nil "leave"))

(defun my-java-ascii-to-native ()
  (interactive)
  (let ((p (point)))
    (when (and buffer-file-name
               (string-ends-with buffer-file-name ".properties" ))
      (erase-buffer)
      (insert (shell-command-to-string (format "native2ascii -encoding UTF-8 -reverse '%s'" buffer-file-name)))
      (goto-char p))))

(defun my-java-native-to-ascii ()
  (interactive)
  (let ((p (point)))
    (when (and buffer-file-name
               (string-ends-with buffer-file-name ".properties" ))
      (erase-buffer)
      (insert (shell-command-to-string (format "native2ascii -encoding UTF-8 '%s'" buffer-file-name)))
      (goto-char p))))

(defalias 'n2a 'my-java-native-to-ascii)
(defalias 'a2n 'my-java-ascii-to-native)

(use-package groovy-mode
  :defer t
  :ensure t
  :commands (groovy-mode)
  :config
  (setq groovy-indent-offset 2)
  :mode (("\\.gradle\\'" . groovy-mode)))

12_js.el

(use-package add-node-modules-path
  :ensure t
  :commands (add-node-modules-path))

;;;
;;; js2-mode
;;;

(use-package js2-mode
  :ensure t
  :defer t
  :hook
  (js2-mode . (lambda ()
                (add-node-modules-path)
                (lsp)
                (yas-minor-mode)
                (add-hook 'before-save-hook 'delete-trailing-whitespace)))
  :mode
  ("\\.js$" . js2-mode)
  :commands
  (js2-mode)
  :config
  (setq js2-basic-offset 2)
  (font-lock-add-keywords
   'js2-mode `(("\\(function\\) *("
                (0 (progn
                     (compose-region
                      (match-beginning 1)
                      (match-end 1)
                      "\u03bb")
                     nil))))))

;;;
;;; json-mode
;;;

(use-package json-mode
  :ensure t
  :defer t
  :custom
  (js-indent-level 2)
  (json-reformat:indent-width 2)
  (tab-width 2)
  :hook
  (json-mode . (lambda ()))
  :mode
  ("\\.json$" . json-mode)
  :commands
  (json-mode))

(use-package tide
  :ensure t
  :defer t
  :commands
  (tide-setup))

(use-package typescript-mode
  :ensure t
  :defer t
  :mode
  ("\\.ts$" . typescript-mode)
  ("\\.tsx$" . typescript-mode)
  :commands
  (typescript-mode)
  :custom
  (js-indent-level 2)
  (typescript-indent-level 2)
  (indent-tabs-mode nil)
  (c-basic-offset 2)
  :hook
  (typescript-mode . (lambda ()
                       (add-node-modules-path)
                       (tide-setup)
                       (flycheck-mode t)
                       (eldoc-mode t)
                       (tide-hl-identifier-mode t)
                       (add-hook 'before-save-hook 'delete-trailing-whitespace)
                       (flycheck-mode t)
                       (yas-minor-mode))))

(use-package vue-mode
  :ensure t
  :defer t
  :mode
  ("\\.vue$" . vue-mode)
  :commands
  (vue-mode)
  :custom
  (js-indent-level 2)
  (indent-tabs-mode nil)
  (typescript-indent-level 2)
  (c-basic-offset 2)
  :hook
  (vue-mode . (lambda ()
                (add-node-modules-path)
                (lsp)
                (yas-minor-mode))))

;;;###autoload (autoload 'vue-format-buffer "vue-format" nil t)
;;;###autoload (autoload 'vue-format-on-save-mode "vue-format" nil t)
(reformatter-define vue-format
  :program "prettier"
  :args (list "--parser" "vue")
  :group 'vue
  :lighter 'VueFmt)

;;;###autoload (autoload 'typescript-format-buffer "typescript-format" nil t)
;;;###autoload (autoload 'typescript-format-on-save-mode "typescript-format" nil t)
(reformatter-define typescript-format
  :program "prettier"
  :args (list "--parser" "typescript")
  :group 'typescript
  :lighter 'TSFmt)

13_haskell.el

;;;
;;; haskell-mode
;;;

(use-package haskell-mode
  :ensure t
  :defer t
  :mode ("\\.hs$" . haskell-mode)
  :hook (haskell-mode-hook . (lambda()
                               (intero-mode t)
                               (flycheck-mode t)
                               (hindent-mode t)
                               (smartparens-mode t)
                               (rainbow-delimiters-mode t)))
  :commands (haskell-mode)
  :config
  (use-package cmm-mode
    :ensure t)
  (use-package company
    :ensure t)
  (use-package haskell-snippets
    :ensure t)
  (use-package hindent
    :ensure t)
  (use-package hlint-refactor
    :ensure t)
  (use-package intero
    :ensure t
    :config
    (flycheck-add-next-checker 'intero '(warning . haskell-hlint)))
  (use-package flycheck-haskell
    :ensure t
    :commands flycheck-haskell-configure
    :hook
    ((flycheck-mode-hook . flycheck-haskell-configure)))
  (setq hindent-reformat-buffer-on-save t))

14_go.el

;;;
;;; go-mode
;;;

(use-package go-mode
  :defer t
  :ensure t
  :mode
  ("\\.go$" . go-mode)
  :commands
  (go-mode)
  :hook
  (go-mode . (lambda ()
               (lsp)))
  :config
  (add-hook 'before-save-hook 'lsp-format-buffer))


;;;###autoload (autoload 'go-format-buffer "go-format" nil t)
;;;###autoload (autoload 'go-format-on-save-mode "go-format" nil t)
(reformatter-define go-format
  :program "go"
  :args (list "fmt")
  :group 'go
  :lighter 'GoFmt)

15_emacs_lisp.el

;;;
;;; emacs-lisp-mode
;;;

(use-package emacs-lisp-mode
  :defer t
  :hook
  (emacs-lisp-mode . (lambda ()
                       (add-hook 'before-save-hook
                                 'delete-trailing-whitespace)))
  :bind
  (:map emacs-lisp-mode-map
        ("C-M-." . counsel-imenu))
  :commands
  (emacs-lisp-mode)
  :config
  (use-package flycheck-package
    :ensure t)
  (flycheck-package-setup))

16_clojure.el

;;;
;;; clojure-mode
;;;

;; cider-repl-mode
;; key             binding
;; ---             -------

;; C-c             Prefix Command
;; TAB             cider-repl-tab
;; C-j             cider-repl-newline-and-indent
;; RET             cider-repl-return
;; C-x             Prefix Command
;; ESC             Prefix Command
;; ,               cider-repl-handle-shortcut
;; C-S-a           cider-repl-bol-mark
;; <C-down>        cider-repl-forward-input
;; <C-return>      cider-repl-closing-return
;;   (that binding is currently shadowed by another mode)
;; <C-up>          cider-repl-backward-input
;; <S-home>        cider-repl-bol-mark

;; C-x C-e         cider-eval-last-sexp

;; M-n             cider-repl-next-input
;; M-p             cider-repl-previous-input
;; M-r             cider-repl-previous-matching-input
;; M-s             cider-repl-next-matching-input

;; C-c C-b .. C-c C-c              cider-interrupt
;; C-c C-d         cider-doc-map
;; C-c RET         cider-macroexpand-1
;; C-c C-n         cider-repl-next-prompt
;; C-c C-o         cider-repl-clear-output
;; C-c C-p         cider-repl-previous-prompt
;; C-c C-q         cider-quit
;; C-c C-r         cider-eval-region
;; C-c C-u         cider-repl-kill-input
;; C-c C-x         cider-refresh
;; C-c C-z         cider-switch-to-last-clojure-buffer
;; C-c ESC         Prefix Command
;; C-c C-.         cider-find-ns

;; C-c M-.         cider-find-resource
;; C-c M-i         cider-inspect
;; C-c M-m         cider-macroexpand-all
;; C-c M-n         cider-repl-set-ns
;; C-c M-o         cider-repl-switch-to-other
;; C-c M-s         cider-selector
;; C-c M-t         Prefix Command

;; C-c M-t n       cider-toggle-trace-ns
;; C-c M-t v       cider-toggle-trace-var

;; C-c C-d C-a     cider-apropos
;; C-c C-d C-d     cider-doc
;; C-c C-d C-j     cider-javadoc
;; C-c C-d C-r     cider-grimoire
;; C-c C-d A       cider-apropos-documentation
;; C-c C-d a       cider-apropos
;; C-c C-d d       cider-doc
;; C-c C-d h       cider-grimoire-web
;; C-c C-d j       cider-javadoc
;; C-c C-d r       cider-grimoire


;; (defhydra hydra-clj-refactor-a (:exit t
;;                                       :columns 2
;;                                       :idle 1.0)
;;   "Clojure Refactor (a)"
;;   ("i" cljr-add-import-to-ns "Add import")
;;   ("r" cljr-add-require-to-ns "Add require")
;;   ("u" cljr-add-use-to-ns "Add use")
;;   ("m" cljr-add-missing-libspec "Add missing libspec")
;;   ("p" cljr-add-project-dependency "Add project dependency")
;;   ("d" cljr-add-declaration "Add declaration for current top-level form")
;;   ("s" cljr-add-stubs "Add stubs for interface at point"))

;; (defhydra hydra-clj-refactor-c (:exit t
;;                                       :columns 2
;;                                       :idle 1.0)
;;   "Clojure Refactor (c)"
;;   ("c" cljr-cycle-coll "Cycle surrounding collection type" :color red)
;;   ("i" cljr-cycle-if "Cycle between if and if-not")
;;   ("p" cljr-cycle-privacy "Cycle privacy of defn or def")
;;   ("n" cljr-clean-ns "Clean namespace form")
;;   ("t" cljr-cycle-thread "Cycle threading between -> and ->>. Also applies to versions like cond->"))

;; (defhydra hydra-clj-refactor-d (:exit t
;;                                       :columns 1
;;                                       :idle 1.0)
;;   "Clojure Refactor (d)"
;;   ("k" cljr-destructure-keys "Destructure keys"))

;; (defhydra hydra-clj-refactor-e (:exit t
;;                                       :columns 2
;;                                       :idle 1.0)
;;   "Clojure Refactor (e)"
;;   ("c" cljr-extract-constant "Extract constant")
;;   ("d" cljr-extract-def "Extract def")
;;   ("f" cljr-extract-function "Extract function")
;;   ("l" cljr-expand-let "Expand let"))

;; (defhydra hydra-clj-refactor-f (:exit t
;;                                       :columns 1
;;                                       :idle 1.0)
;;   "Clojure Refactor (f)"
;;   ("e" cljr-create-fn-from-example "Create fn from example stub")
;;   ("u" cljr-find-usages "Find usages"))

;; (defhydra hydra-clj-refactor-h (:exit t
;;                                       :columns 1
;;                                       :idle 1.0)
;;   "Clojure Refactor (h)"
;;   ("d" cljr-hotload-dependency "Hotload dependency"))

;; (defhydra hydra-clj-refactor-i (:exit t
;;                                       :columns 1
;;                                       :idle 1.0)
;;   "Clojure Refactor (i)"
;;   ("l" cljr-introduce-let "Introduce let")
;;   ("s" cljr-inline-symbol "Inline symbol"))

;; (defhydra hydra-clj-refactor-m (:exit t
;;                                       :columns 1
;;                                       :idle 1.0)
;;   "Clojure Refactor (m)"
;;   ("f" cljr-move-form "Move form(s) to other ns, :refer functions")
;;   ("l" cljr-move-to-let "Move to let"))

;; (defhydra hydra-clj-refactor-p (:exit t
;;                                       :columns 1
;;                                       :idle 1.0)
;;   "Clojure Refactor (p)"
;;   ("c" cljr-project-clean-functions "Run project clean functions on project")
;;   ("f" cljr-promote-function "Promote function literal to fn, or fn to defn"))

;; (defhydra hydra-clj-refactor-r (:exit t
;;                                       :columns 2
;;                                       :idle 1.0)
;;   "Clojure Refactor (r)"
;;   ("d" cljr-remove-debug-fns "Remove debug function invocations")
;;   ("D" cljr-reify-to-defrecord "Reify to defrecord")
;;   ("f" cljr-rename-file-or-dir "Rename file or dir updating any affected files")
;;   ("l" cljr-remove-let "Remove let, inline all variables and remove the let form")
;;   ("r" cljr-remove-unused-requires "Remove unused requires")
;;   ("s" cljr-rename-symbol "Rename symbol")
;;   ("u" cljr-replace-use "Replace use statements with equivalent require statements"))

;; (defhydra hydra-clj-refactor-s (:exit t
;;                                       :columns 2
;;                                       :idle 1.0)
;;   "Clojure Refactor (s)"
;;   ("c" cljr-show-changelog "Show the changelog, to learn about recent changes")
;;   ("n" cljr-sort-ns "Sort the ns form. :use, :require and :import clauses are sorted")
;;   ("p" cljr-sort-project-dependencies "Sort project dependencies found in project.clj")
;;   ("r" cljr-stop-referring "Stop referring (removes :refer [...] from current require, fix references)"))

;; (defhydra hydra-clj-refactor-t (:exit t
;;                                       :columns 2
;;                                       :idle 1.0)
;;   "Clojure Refactor (t)"
;;   ("d" cljr-toggle-debug-mode "Toggle debug mode")
;;   ("f" cljr-thread-first-all "Wrap in thread-first (->) and fully thread")
;;   ("h" cljr-thread "Thread another expression")
;;   ("l" cljr-thread-last-all "Wrap in thread-last (->>) and fully thread"))

;; (defhydra hydra-clj-refactor-u (:exit t
;;                                       :columns 2
;;                                       :idle 1.0)
;;   "Clojure Refactor (u)"
;;   ("a" cljr-unwind-all "Fully unwind a threaded expression")
;;   ("d" cljr-update-project-dependency "Update project dependency (lein only)")
;;   ("p" cljr-update-project-dependencies "Update project dependencies (lein only)")
;;   ("w" cljr-unwind "Unwind a threaded expression"))

(defun _exit ()
  (interactive)
  (if (display-graphic-p)
      (delete-frame)
  (exit)))

(defhydra hydra-cider-mode (:hint nil :exit t)
"
^Main^                        ^Eval^                           ^Other^
^^^^^^--------------------------------------------------------------------------------------
_c_: cider-connect            _b_: cider-eval-buffer           _a_: helm-do-ag
_j_: cider-jack-in            _n_: cider-eval-ns-form          _A_: helm-do-ag-project-root
_i_: cider-inspect            _r_: cider-eval-region           _l_: helm-ls-git-ls
_t_: cider-toggle-trace       _f_: cider-eval-file             _g_: magit-status
_d_: cider-doc                _N_: repl-set-ns
_E_: compilation-error

_q_: exit
"

  ("c" cider-connect)
  ("j" cider-jack-in)
  ("i" cider-inspect)
  ("t" cider-toggle-trace)
  ("d" cider-doc)
  ("E" cider-jump-to-compilation-error)

  ("b" cider-eval-buffer)
  ("n" cider-eval-ns-form)
  ("r" cider-eval-region)
  ("f" cider-eval-file)
  ("N" cider-repl-set-ns)
  ("e" cider-eval-last-sexp)

  ("g" magit-status)
  ("a" helm-do-ag)
  ("A" helm-do-ag-project-root)
  ("l" helm-ls-git-ls)

  ("q" _exit)
  ("z" nil "leave"))

(defhydra hydra-cider-repl-mode (:hint nil :exit t)
  "
^Main^
^^^^^^-------------------------------------------------------
_c_: clear-buffer
_o_: clear-output

  "

  ("c" cider-repl-clear-buffer "Clear buffer")
  ("o" cider-repl-clear-output "Clear output")
  ("z" nil "leave"))

(use-package clojure-mode
  :ensure t
  :defer t
  :mode (("\\.clj$" . clojure-mode)
         ("\\.cljs$" . clojure-mode))
  :bind
  (:map clojure-mode-map
        ("C-z" . hydra-cider-mode/body)
        :map cider-repl-mode-map
        ("C-z" . hydra-cider-repl-mode/body))
  :init
  (add-hook 'clojure-mode-hook
            '(lambda ()
               (flycheck-mode t)
               (subword-mode t)
               (smartparens-mode t)
               (rainbow-delimiters-mode t)
               (clj-refactor-mode t)
               (yas-minor-mode t)
               (add-hook 'before-save-hook 'delete-trailing-whitespace)))
  :commands
  (clojure-mode)
  :config
  (use-package clj-refactor
    :ensure t))

(use-package cider
  :ensure t
  :defer t
  :init
  (add-hook 'cider-mode-hook #'clj-refactor-mode)
  (add-hook 'cider-mode-hook #'company-mode)
  (add-hook 'cider-mode-hook #'eldoc-mode)
  (add-hook 'cider-repl-mode-hook #'company-mode)
  (add-hook 'cider-repl-mode-hook #'eldoc-mode)
  :diminish subword-mode
  :config
  (setq nrepl-log-messages t
        cider-repl-display-in-current-window t
        cider-repl-use-clojure-font-lock t
        cider-prompt-save-file-on-load 'always-save
        cider-font-lock-dynamically '(macro core function var)
        cider-overlays-use-font-lock t)
  (cider-repl-toggle-pretty-printing))

17_sql.el

;;;
;;; sql-mode
;;;

(use-package sql
  :defer t
  :hook
  (sql-mode . (lambda ()
                (add-hook 'before-save-hook 'delete-trailing-whitespace)))
  :commands
  (sql-mode)
  :mode
  ("\\.sql$" . sql-mode)
  :custom
  (sql-indent-offset 2)
  (indent-tabs-mode nil)
  (tab-width 2)
  (c-basic-offset 2)
  (sql-mysql-options '("--prompt=mysql> "))
  :config
  (use-package sql-indent
    :ensure t))

18_scala.el

(use-package ensime
  :ensure t
  :defer t)

(use-package scala-mode
  :ensure t
  :defer t
  :interpreter
  ("scala" . scala-mode))

(use-package sbt-mode
  :ensure t
  :defer t
  :commands sbt-start sbt-command
  :config
  ;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31
  ;; allows using SPACE when in the minibuffer
  (substitute-key-definition
   'minibuffer-complete-word
   'self-insert-command
   minibuffer-local-completion-map))

19_lfe.el

;;;
;;; lfe-mode
;;;

(use-package lfe-mode
  :ensure t
  :defer t
  :init
  (add-hook 'lfe-mode-hook
            '(lambda ()
               (flycheck-mode t)
               (smartparens-mode t)
               (rainbow-delimiters-mode t)))

  :mode ("\\.lfe$" . lfe-mode)
  :commands (lfe-mode))

20_c.el

(use-package google-c-style
  :ensure t
  :defer t
  :commands
  (google-set-c-style))

(use-package clang-format
  :ensure t
  :defer t
  :commands
  (clang-format clang-format-buffer))

;;
;; cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
;;

(use-package ccls
  :ensure t
  :custom
  (indent-tabs-mode nil)
  (tab-width 2)
  (c-basic-offset 2)
  :hook
  ((c-mode c++-mode) . (lambda ()
                         (lsp))))

21_rust.el

(use-package rustic
  :ensure t
  :config
  (setq rustic-format-on-save t)
  (use-package quickrun
    :defer t
    :ensure t))

;;;###autoload (autoload 'rust-format-buffer "rust-format" nil t)
;;;###autoload (autoload 'rust-format-on-save-mode "rust-format" nil t)
(reformatter-define rust-format
  :program "cargo"
  :args (list "fmt" "-q")
  :group 'rust
  :lighter 'RustFmt)

22_sml.el

(use-package sml-mode
  :defer t
  :ensure t
  :mode ("\\.sml$" . sml-mode))

23_shell.el

(use-package fish-mode
  :defer t
  :ensure t)

24_yaml.el

(use-package yaml-mode
  :defer t
  :ensure t
  :config
  (use-package flycheck-yamllint
    :ensure t)
  :hook
  (yaml-mode . (lambda () (lsp))))


;;;###autoload (autoload 'yaml-format-buffer "yaml-format" nil t)
;;;###autoload (autoload 'yaml-format-on-save-mode "yaml-format" nil t)
(reformatter-define yaml-format
  :program "prettier"
  :group 'yaml
  :lighter 'YAMLFmt)

25_platformio.el

(use-package platformio-mode
  :ensure t
  :defer t
  :init
  (add-hook 'c-mode-hook 'platformio-conditionally-enable)
  (add-hook 'c++-mode-hook 'platformio-conditionally-enable)
  :commands (platformio-mode platformio-conditionally-enable)
  :config
  (use-package projectile
    :ensure t)
  (use-package irony
    :ensure t)
  (use-package company-irony
    :ensure t)
  (use-package irony-eldoc
    :ensure t)
  (use-package flycheck-irony
    :ensure t)

  (setq indent-tabs-mode nil)
  (setq tab-width 2)
  (setq c-basic-offset 2)
  (rainbow-delimiters-mode t)
  (smartparens-mode t)
  (dumb-jump-mode t))

26_csharp.el

(use-package csharp-mode
  :load-path "~/repos/github.com/mopemope/csharp-mode"
  :defer t
  :mode
  ("\\.cs$" . csharp-mode)
  :init
  (add-hook 'csharp-mode-hook
            (lambda ()
              (setq indent-tabs-mode nil)
              (setq tab-width 4)
              (setq c-basic-offset 4)
              (omnisharp-mode t)
              (dumb-jump-mode t)
              (flycheck-mode t)
              (smartparens-mode t)
              (rainbow-delimiters-mode t)
              (add-hook 'before-save-hook
                        'delete-trailing-whitespace)))
  :config
  (use-package omnisharp
    :ensure t)
  (setq indent-tabs-mode nil)
  (setq c-syntactic-indentation t)
  (electric-pair-local-mode 1)
  (add-to-list 'company-backends 'company-omnisharp))

27_markdown.el

(use-package markdown-mode
  :defer t
  :ensure t
  :mode
  ("\\.md$" . markdown-mode)
  :commands
  (markdown-mode)
  :hook
  (markdown-mode . (lambda()
                     ))
  :config
  (use-package vmd-mode
    :ensure t
    :after markdown-mode)
  (use-package gh-md
    :ensure t
    :after markdown-mode)
  (use-package markdown-toc
    :ensure t
    :after markdown-mode))

28_python.el

(use-package python-mode
  :hook
  (python-mode . (lambda ()
                   (lsp))))
(use-package conda
   :init
   (custom-set-variables '(conda-anaconda-home "~/miniconda3")))

90_hydra.el

(defun generate-tmp-buffer ()
  (interactive)
  (switch-to-buffer (make-temp-name "temp-")))

(defun counsel-rg-root ()
  (interactive)
  (counsel-rg nil (locate-dominating-file default-directory ".git")))

(defun _exit ()
  (interactive)
  (if (display-graphic-p)
      (delete-frame)
  (exit)))

(defun eshell-new()
  "Open a new instance of eshell."
  (interactive)
  (eshell 'N))

(use-package hydra-posframe
  :load-path "~/repos/github.com/Ladicle/hydra-posframe"
  :hook (after-init . hydra-posframe-enable)
  :custom-face
  (hydra-posframe-face ((t (:background "#282a36"))))
  (hydra-posframe-border-face ((t (:background "white"))))
  :custom
  (hydra-posframe-border-width 2))

(use-package hydra
  :ensure t
  :bind
  (("C-z" . hydra-main/body)))

(defhydra hydra-main (:hint nil :exit t)
"
^Main^                        ^Ivy/Counsel^                     ^Other^
^^^^^^------------------------------------------------------------------------------------------------
_e_: eval-buffer              _a_: counsel-rg                   _r_: anzu-query-replace
_d_: describe-key             _f_: counsel-fzf                  _R_: quickrun
_g_: magit-status             _v_: counsel-describe-variable    _o_: origami-toggle-node
_p_: paradox-list-packages    _i_: counsel-imenu                _c_: origami-toggle-all-nodes
_t_: generate-tmp-buffer      _G_: counsel-git                  _P_: presentation-mode
_E_: eshell-new

_q_: exit
"
  ("e" eval-buffer)
  ("E" eshell-new)
  ("d" describe-key)
  ("g" magit-status)
  ("p" paradox-list-packages)
  ("b" buffer-expose)
  ("I" imenu-list-smart-toggle)
  ("t" generate-tmp-buffer)
  ("D" posframe-delete-all)
  ("m" make-frame-command)
  ("s" split-window-horizontally)
  ("0" delete-window)

  ("a" counsel-rg)
  ("f" counsel-fzf)
  ("v" counsel-describe-variable)
  ("i" counsel-imenu)
  ("G" counsel-git)
  ("j" counsel-git-grep)

  ("r" anzu-query-replace)
  ("R" quickrun)
  ("o" origami-recursively-toggle-node)
  ("c" origami-toggle-all-nodes)
  ("P" presentation-mode)

  ("q" _exit)
  ("z" nil "leave"))

(defhydra hydra-smerge (:hint nil)
"
^Move^             ^Edit^
^^^^^^~~-----------------------------------
_n_: next          _b_: keep-base
_p_: prev          _c_: keep-current
                 ^^_a_: keep-all
                 ^^_l_: keep-lower
                 ^^_u_: keep-upper
                 ^^_m_: keep-mine
                 ^^_o_: keep-other
                 ^^_r_: resolve
                 ^^_R_: refine
                 ^^_g_: magit-status
                 ^^_S_: smerge-mode

"
  ("n" smerge-next)
  ("p" smerge-prev)

  ("b" smerge-keep-base)
  ("c" smerge-keep-current)
  ("a" smerge-keep-all)
  ("l" smerge-keep-lower)
  ("u" smerge-keep-upper)
  ("m" smerge-keep-mine)
  ("o" smerge-keep-other)
  ("r" smerge-resolve)
  ("R" smerge-refine)
  ("g" magit-status)
  ("S" smerge-mode)

  ("z" nil "leave"))

(use-package smerge-mode
  :defer t
  :commands
  (smerge-mode)
  :bind
  (:map smerge-mode-map
        ("C-z" .  hydra-smerge/body)))