Skip to content

hawnzug/dot-emacs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contents

early init

Credit: /r/xjyuni

(setq frame-inhibit-implied-resize t)

Allow large garbage collection threshold when init.

(setq gc-cons-threshold 64000000)
(add-hook 'after-init-hook #'(lambda () (setq gc-cons-threshold 800000)))
(setq package-enable-at-startup nil)

Disable useless UIs.

(scroll-bar-mode -1)
(horizontal-scroll-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(menu-bar-mode -1)

init

Font setup.

(defun my:font-setup ()
  (let ( ;; (primary-font "Iosevka Curly Slab 16")
        (primary-font "Rec Mono Duotone 10"))
    (set-fontset-font t 'unicode "Iosevka Curly Slab")
    (set-fontset-font t 'unicode "Noto Color Emoji" nil 'append)
    (set-fontset-font t 'unicode "DejaVu Sans" nil 'append)

    (set-fontset-font t 'han "Iosevka Curly Slab")
    (set-fontset-font t 'han "HYZiKuTangSongKeBenLiKai" nil 'append)
    (set-fontset-font t 'han "HYKaiTiS" nil 'append)
    (set-fontset-font t 'han "FZNewShuSong-Z10S" nil 'append)
    (set-fontset-font t 'han "Source Han Sans CN 14" nil 'append)
    (set-fontset-font t 'cjk-misc "Iosevka Curly Slab")
    (set-fontset-font t 'cjk-misc "HYZiKuTangSongKeBenLiKai" nil 'append)
    (set-fontset-font t 'cjk-misc "HYKaiTiS" nil 'append)
    (set-fontset-font t 'cjk-misc "FZNewShuSong-Z10S" nil 'append)
    (set-fontset-font t 'cjk-misc "Source Han Sans CN 14" nil 'append)
    (set-fontset-font t 'chinese-gbk "Iosevka Curly Slab")
    (set-fontset-font t 'chinese-gbk "HYZiKuTangSongKeBenLiKai" nil 'append)
    (set-fontset-font t 'chinese-gbk "HYKaiTiS" nil 'append)
    (set-fontset-font t 'chinese-gbk "FZNewShuSong-Z10S" nil 'append)
    (set-fontset-font t 'chinese-gbk "Source Han Sans CN 14" nil 'append)
    (set-face-font 'default primary-font)
    (set-face-font 'fixed-pitch primary-font)
    (set-face-font 'fixed-pitch-serif primary-font)
    ;; (set-face-font 'variable-pitch "Recursive Sans Casual Static 14")
    (set-face-font 'variable-pitch "Alegreya 14")))
(defun my:font-setup-hook (frame)
  "Setup the font, then remove the hook."
  (select-frame frame)
  (my:font-setup)
  (remove-hook 'after-make-frame-functions 'my:font-setup-hook))
(setq use-default-font-for-symbols nil)
(setq inhibit-compacting-font-caches t)
(add-hook 'after-make-frame-functions 'my:font-setup-hook nil)
(my:font-setup)

Ligature

(let ((ligatures `((?-  . ,(regexp-opt '("->" "->>" "-->")))
                   (?*  . ,(regexp-opt '("*>")))
                   (?<  . ,(regexp-opt '("<-" "<<-" "<=>" "<|" "<||" "<|||::=" "<|>" "<:" "<>" "<-<"
                                         "<<<" "<==" "<<=" "<=<" "<==>" "<-|" "<<" "<~>" "<=|" "<~~" "<~"
                                         "<$>" "<$" "<+>" "<+" "</>" "</" "<*" "<*>" "<->" "<!--")))
                   (?:  . ,(regexp-opt '(":>" ":<" ":::" "::" ":?" ":?>" ":=")))
                   (?=  . ,(regexp-opt '("==>" "=>" "===" "=:=" "==")))
                   (?!  . ,(regexp-opt '("!==" "!!" "!=")))
                   (?|  . ,(regexp-opt '("|||>" "||>" "|>" "|=>")))
                   (?+  . ,(regexp-opt '("+++" "++")))
                   (?~  . ,(regexp-opt '("~~>" "~>"))))))
  (dolist (char-regexp ligatures)
    (set-char-table-range composition-function-table (car char-regexp)
                          `([,(cdr char-regexp) 0 font-shape-gstring]))))

Quiet startup

(setq inhibit-startup-screen t)
(setq inhibit-startup-message t)
(setq inhibit-startup-echo-area-message t)
(setq initial-scratch-message nil)
(setq initial-major-mode 'fundamental-mode)

Show paren pair.

(show-paren-mode 1)

Blink!

(blink-cursor-mode)

Automatically close parenthesis/brackets/…

(electric-pair-mode 1)

Disable backup.

(setq make-backup-files nil)

Auto save after 1 second idle.

(setq auto-save-default nil)
(setq auto-save-visited-interval 1)
(auto-save-visited-mode)

Trash instead of delete.

(setq trash-directory "~/Trash")
(setq delete-by-moving-to-trash t)
(defun system-move-file-to-trash (filename)
  (shell-command (concat "trash " (shell-quote-argument filename))))

Tab.

(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)

No wrap line.

(setq-default truncate-lines t)

Better word wrap for CJK

(setq word-wrap-by-category t)
(load "kinsoku.el")

Split window threshold (Split window vertically by default)

(setq split-width-threshold 100)

80 characters one line.

(setq-default fill-column 80)
(setq sentence-end-double-space nil)

Use straight single quote in help and messages.

(setq text-quoting-style 'straight)

y or n.

(defalias 'yes-or-no-p 'y-or-n-p)
(setq kill-buffer-query-functions nil)

Window divider on right.

(setq window-divider-default-right-width 1)
(setq window-divider-default-bottom-width 1)
(setq window-divider-default-places t)
(window-divider-mode t)

Avoid crash when open image in Emacs.

(setenv "MAGICK_OCL_DEVICE" "OFF")
(setq password-cache-expiry 1200)

Always select the help window.

(setq help-window-select t)

For lsp mode

(setq read-process-output-max (* 1024 1024))

use-package

(setq package-user-dir "~/.config/emacs/elpa")
(let ((default-directory package-user-dir))
  (normal-top-level-add-subdirs-to-load-path))
(require 'use-package)
(with-eval-after-load 'info
  (info-initialize)
  (dolist (dir (directory-files package-user-dir))
    (let ((fdir (concat (file-name-as-directory package-user-dir) dir)))
      (unless (or (member dir '("." ".." "archives" "gnupg"))
                  (not (file-directory-p fdir))
                  (not (file-exists-p (concat (file-name-as-directory fdir) "dir"))))
        (add-to-list 'Info-directory-list fdir)))))
(with-eval-after-load 'package
  (add-to-list 'package-archives '("ublt" . "https://elpa.ubolonton.org/packages/")) ;; tree-sitter
  (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t))

native compilation

(use-package comp
  :config
  (setq native-comp-async-report-warnings-errors 'silent)
  (setq comp-deferred-compilation-deny-list '("bibtex-actions.el")))

help functions

(defun my:show-trailing-space ()
  (setq show-trailing-whitespace t))
(add-hook 'prog-mode-hook #'my:show-trailing-space)
(defun my:other-window-or-buffer ()
  "Switch to other window or buffer"
  (interactive)
  (if (one-window-p) (switch-to-buffer (other-buffer)) (select-window (next-window))))

(defun my:syntax-color-hex ()
  (interactive)
  (font-lock-add-keywords
   nil
   '(("#[[:xdigit:]]\\{6\\}"
      (0 (put-text-property
          (match-beginning 0)
          (match-end 0)
          'face (list :background (match-string-no-properties 0)))))))
  (font-lock-flush))

(defun my:toggle-line-number ()
  "Toggle line number between relative and nil."
  (interactive)
  (setq display-line-numbers
        (pcase display-line-numbers
          ('relative nil)
          (_ 'relative))))
(defun my:toggle-transparency ()
  (interactive)
  (let ((transparency 90)
        (opacity 100)
        (old-alpha (frame-parameter nil 'alpha)))
    (if (and (numberp old-alpha) (< old-alpha opacity))
        (set-frame-parameter nil 'alpha opacity)
      (set-frame-parameter nil 'alpha transparency))))

theme

(load-theme 'fourma t)
(use-package modus-themes
  :ensure t
  :init
  (setq modus-themes-italic-constructs t)
  (setq modus-themes-syntax '(yellow-comments green-strings))
  (setq modus-themes-region '(bg-only no-extend))
  (setq modus-themes-org-blocks 'gray-background)
  (setq modus-themes-headings
        '((t . (monochrome overline background))))
  (setq modus-themes-mode-line '(accented))
  :config
  (modus-themes-load-operandi))
(use-package lab-themes
  :ensure t
  :config
  (lab-themes-load-style 'light))
(use-package flucui-themes
  :ensure t
  :config
  (flucui-themes-load-style 'light))

mode line

(use-package hide-mode-line
  :ensure t
  :config
  (setq hide-mode-line-excluded-modes nil)
  (global-hide-mode-line-mode))

moody

(use-package moody
  :ensure t
  :config
  (setq x-underline-at-descent-line t)
  (moody-replace-mode-line-buffer-identification)
  (moody-replace-vc-mode))

boon

(use-package boon-qwerty
  :load-path "~/Projects/boon"
  :config
  (boon-mode))

general.el

(use-package general :ensure t)
(general-def
  "C-x f" 'find-file
  "C-x b" 'consult-buffer
  "C-x g" 'magit-status)
(general-def 'override
  "C-=" 'text-scale-adjust
  "C--" 'text-scale-adjust)

completion

vertico

(use-package vertico
  :ensure t
  :config
  (vertico-mode))

vertico-directory

(use-package vertico-directory
  :after vertico
  :general
  (vertico-map
   "RET" 'vertico-directory-enter
   "DEL" 'vertico-directory-delete-char
   "M-DEL" 'vertico-directory-delete-word)
  :hook (rfn-eshadow-update-overlay . vertico-directory-tidy))

orderless

(use-package orderless
  :ensure t
  :init
  ;; (defun my:orderless-in-minibuffer ()
  ;;   (setq-local completion-styles '(orderless)))
  ;; (add-hook 'minibuffer-setup-hook
  ;;           'my:orderless-in-minibuffer)
  (setq completion-styles '(orderless basic))
  (setq completion-category-defaults nil)
  (setq completion-category-overrides
        '((file (styles . (partial-completion))))))

corfu

(use-package corfu
  :ensure t
  :config
  (setq corfu-auto t)
  (global-corfu-mode))
(use-package emacs
  :init
  (setq completion-cycle-threshold 3)
  (setq read-extended-command-predicate
        #'command-completion-default-include-p)
  (setq tab-always-indent 'complete))

cape

(use-package cape
  :ensure t
  :init
  (add-to-list 'completion-at-point-functions #'cape-dabbrev))

marginalia

(use-package marginalia
  :ensure t
  :config
  (marginalia-mode))

consult

(use-package consult
  :ensure t
  :commands
  (consult-line
   consult-buffer
   consult-ripgrep))
(use-package consult-xref
  :after (xref consult)
  :config
  (setq xref-show-xrefs-function #'consult-xref))
(use-package consult-org
  :after org
  :commands consult-org-heading)
(use-package consult-imenu
  :commands consult-imenu)
(use-package consult-flymake
  :after flymake
  :commands consult-flymake)
(use-package consult-register
  :commands
  (consult-register
   consult-register-load
   consult-register-store))

embark

(use-package embark
  :ensure t
  :general
  (:keymaps 'override
   "M-o" 'embark-act))
(use-package embark-consult
  :ensure t
  :after embark)

org

(use-package org
  :defer 4
  :mode ("\\.org\\'" . org-mode)
  :hook
  ;; (org-mode . variable-pitch-mode)
  (org-mode . my:show-trailing-space)
  (org-babel-after-execute . org-redisplay-inline-images)
  :config
  (use-package org-mouse)
  (use-package ob-shell)
  (add-to-list 'org-file-apps '(t . "xdg-open %s") t)
  (setq org-refile-targets
        '(("~/org/readings.org" . (:maxlevel . 2))))
  (setq
   org-capture-templates
   '(("j" "Journal" entry (file+datetree "~/org/journal.org")
      "* %<%H:%M> %?\n")))
  (setq org-refile-use-outline-path nil)
  (setq org-reverse-note-order t)
  (setq org-adapt-indentation nil)
  (setq org-startup-indented t)
  (setq org-startup-truncated t)
  (setq org-hide-emphasis-markers t)
  (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.4))
  (setq org-latex-pdf-process '("latexmk -f -pdf -outdir=%o %f"))
  (setq org-footnote-section nil))
(defun my:org-export-all ()
  "https://emacs.stackexchange.com/a/2260/21752
Export all subtrees that are *not* tagged with :noexport: to
separate files.

Note that subtrees must have the :EXPORT_FILE_NAME: property set
to a unique value for this to work properly."
  (interactive)
  (let ((org-html-doctype "html5")
        (org-html-html5-fancy t)
        (org-html-postamble nil)
        (org-html-head-include-default-style nil)
        ;; (org-html-mathjax-template "")
        (org-preview-latex-image-directory "~/org/build/images/"))
    (save-excursion
      (org-map-entries
       (lambda ()
         (org-set-property
          "EXPORT_FILE_NAME"
          (concat "build/" (org-id-get-create)))
         (org-html-export-to-html nil t))
       "-noexport"
       'file))))

(defun my:org-export-html-hook (backend)
  "Resolve all id links to html files"
  (goto-char (point-min))
  (while (eq t (org-next-link))
    (let ((link (org-element-context (org-element-at-point))))
      (when (string= (org-element-property :type link) "id")
        (let ((id (org-element-property :path link))
              (beg (org-element-property :begin link))
              (end (org-element-property :contents-begin link)))
          (delete-region (1+ beg) (1- end))
          (goto-char (1+ beg))
          (insert "[file:" id ".html]"))))))

(add-hook 'org-export-before-parsing-hook #'my:org-export-html-hook)

org-id

(use-package org-id
  :after org
  :config
  (setq org-id-link-to-org-use-id 'create-if-interactive))

org-checklist

(use-package org-checklist
  :after org)

org-maketoc

(use-package org-make-toc
  :ensure t
  :commands (org-make-toc))
(use-package org-superstar
  :ensure t
  :hook (org-mode . org-superstar-mode)
  :config
  (setq org-superstar-headline-bullets-list '("")))

keybindings

(general-def org-mode-map
  "M-h" 'org-metaleft
  "M-j" 'org-metadown
  "M-k" 'org-metaup
  "M-l" 'org-metaright
  "M-H" 'org-shiftmetaleft
  "M-J" 'org-shiftmetadown
  "M-K" 'org-shiftmetaup
  "M-L" 'org-shiftmetaright)

dired

(use-package dired
  :commands dired
  :hook ((dired-mode . dired-omit-mode)
         (dired-mode . dired-hide-details-mode))
  :config
  (setq dired-dwim-target t)
  (setq dired-recursive-copies 'always)
  (setq dired-recursive-deletes 'always)
  (setq dired-listing-switches "-alhvG --group-directories-first")
  (setq dired-isearch-filenames 'dwim))

dirvish

(use-package dirvish
  :ensure t)

packages

alert

(use-package alert
  :commands alert
  :ensure t
  :config
  (setq alert-default-style 'libnotify))

async

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

avy

(use-package avy
  :ensure t
  :commands avy-goto-char-timer
  :config
  (setq avy-timeout-seconds 0.3))

bibtex

(use-package bibtex-completion
  :ensure t
  :defer t
  :config
  (defun my:bibtex-open-pdf (file)
    (require 'async)
    (async-start-process "bibtex-pdf" "zathura" nil file))
  (setq bibtex-completion-bibliography
        '("~/org/refs.bib"
          "~/org/incomplete.bib"))
  (setq bibtex-completion-notes-path "~/org/readings.org")
  (setq bibtex-completion-pdf-field "file")
  (setq bibtex-completion-notes-template-one-file "\n* ${title}\n:PROPERTIES:\n:Custom_ID: ${=key=}\n:END:\n")
  (setq bibtex-completion-pdf-open-function #'my:bibtex-open-pdf)
  (setq bibtex-completion-library-path '("~/Documents/")))
(use-package consult-bibtex
  :load-path "~/.config/emacs/packages/consult-bibtex"
  :general
  ("C-x j" 'consult-bibtex)
  :config
  (with-eval-after-load 'embark
    (add-to-list 'embark-keymap-alist
                 '(bibtex-completion . consult-bibtex-embark-map))))
(use-package emacs
  :after bibtex
  :config
  (defun my:bibtex-insert-download-by-doi (doi)
    (require 'biblio)
    (interactive "sDOI: " bibtex-mode)
    (let ((biblio-synchronous t)
          (biblio-bibtex-use-autokey t)
          title)
      (insert "\n")
      (biblio-doi-insert-bibtex doi)
      (bibtex-beginning-of-entry)
      (setq title (bibtex-text-in-field "title"))
      (bibtex-beginning-first-field)
      (bibtex-make-field
       (list "file" nil (concat title ".pdf") nil))
      (let ((filename (file-name-concat
                       "~/Documents/"
                       (concat title ".pdf"))))
        (pcase (completing-read "PDF: " '("ACM" "SciHub" "SKIP") nil t)
          ("ACM"
           (url-copy-file (concat "https://dl.acm.org/doi/pdf/" doi) filename))
          ("SciHub"
           (require 'scihub)
           (scihub doi filename))
          (_
           (kill-new title)
           (message "Copied to clipboard: %s" title)))))))
(use-package citar
  :ensure t
  :general
  (my:global-def
    "c" 'citar-open)
  :config
  (setq citar-file-open-function #'my:bibtex-open-pdf))

bookmark

(use-package bookmark
  :config
  (setq bookmark-fontify nil))

burly

(use-package burly
  :ensure t
  :commands
  (burly-bookmark-windows
   burly-bookmark-handler
   burly-open-bookmark))

comint

(use-package comint
  :defer t
  :config
  (general-def comint-mode-map
    "M-n" nil
    "M-p" nil
    "M-k" 'comint-previous-input
    "M-j" 'comint-next-input))

company

(use-package company
  :ensure t
  :hook
  ((LaTeX-mode prog-mode) . company-mode)
  :config
  (setq company-minimum-prefix-length 2)
  (setq company-idle-delay 0)
  (use-package company-posframe
    :ensure t
    :config
    (setq company-posframe-font "Iosevka Curly Slab 16")
    (company-posframe-mode 1)))

demo-it

(use-package demo-it
  :ensure t
  :defer t)

docker

(use-package dockerfile-mode
  :ensure t
  :mode "Dockerfile\\'")

(use-package docker-tramp
  :ensure t
  :after tramp)

ediff

(use-package ediff
  :commands ediff
  :config
  (setq ediff-split-window-function 'split-window-horizontally)
  (setq ediff-window-setup-function 'ediff-setup-windows-plain))

elcord

(use-package elcord
  :ensure t
  :if (executable-find "discord")
  :commands elcord-mode)

eldoc

(use-package eldoc
  :defer t
  :config
  (setq eldoc-idle-delay 0)
  (setq eldoc-echo-area-use-multiline-p t)
  (setq eldoc-echo-area-display-truncation-message nil)
  (setq eldoc-echo-area-prefer-doc-buffer t))
(use-package eldoc-box
  :ensure t
  :hook
  (eldoc-mode . eldoc-box-hover-at-point-mode)
  :config
  (setq eldoc-box-max-pixel-width 3000)
  (setq eldoc-box-max-pixel-height 2000))

eglot

(use-package eglot
  :ensure t
  :commands eglot
  :init
  (add-hook
   'eglot-managed-mode-hook
   (lambda ()
     ;; Show flymake diagnostics first.
     (setq eldoc-documentation-functions
           (cons #'flymake-eldoc-function
                 (remove #'flymake-eldoc-function eldoc-documentation-functions)))
     ;; Show all eldoc feedback.
     (setq eldoc-documentation-strategy #'eldoc-documentation-compose))))
(use-package consult-eglot
  :ensure t
  :after (consult eglot))

vterm

(use-package vterm
  :ensure t)
(use-package vterm-toggle
  :ensure t
  :commands vterm-toggle
  :config
  (setq vterm-toggle-scope 'project))

exec-path-from-shell

(use-package exec-path-from-shell
  :ensure t
  :defer 1
  :config
  (setq exec-path-from-shell-check-startup-files nil)
  (exec-path-from-shell-copy-env "SSH_AGENT_PID")
  (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))

fcitx

(use-package fcitx
  :if (executable-find "fcitx5-remote")
  :ensure t
  :defer 2
  :config
  (setq fcitx-remote-command "fcitx5-remote")
  (fcitx-aggressive-setup))

find-file-in-project

(use-package find-file-in-project
  :ensure t
  :commands (find-file-in-project)
  :config
  (setq ffip-use-rust-fd t))

flymake

(use-package flymake
  :defer t)

project.el

(use-package project
  :defer t
  :config
  (defun my:find-project-root (dir)
    "Try to locate a project root."
    (when (locate-dominating-file
           dir
           (lambda (d)
             (seq-some (lambda (name) (file-exists-p (expand-file-name name d)))
                       '(".python-version"))))
      (cons 'transient dir)))
  (add-hook 'project-find-functions 'my:find-project-root nil nil))

help-mode

(use-package help-mode
  :defer t)

hl-todo

(use-package hl-todo
  :ensure t
  :hook (prog-mode . hl-todo-mode))

htmlize

(use-package htmlize
  :ensure t
  :commands (htmlize htmlize-file htmlize-region htmlize-buffer))

ibuffer

(use-package ibuffer
  :hook (ibuffer-mode . ibuffer-vc-set-filter-groups-by-vc-root)
  :general
  ('emacs ibuffer-mode-map
    "M-j" 'ibuffer-forward-filter-group
    "M-k" 'ibuffer-backward-filter-group
    "j" 'ibuffer-forward-line
    "k" 'ibuffer-backward-line)
  :config
  (setq
   ibuffer-formats
   '(("    " (name 24 24) " " (mode 24 24) " " filename-and-process)))
  (use-package ibuffer-vc :ensure t))

imenu-list

(use-package imenu-list
  :ensure t
  :commands imenu-list)

jieba

(use-package jieba
  :load-path "~/.config/emacs/packages/jieba.el"
  :commands jieba-mode)

ledger-mode

(use-package ledger-mode
  :ensure t
  :mode "\\.journal\\'"
  :commands ledger-mode
  :config
  (setq ledger-binary-path "ledger.sh")
  (setq ledger-mode-should-check-version nil)
  (setq ledger-report-links-in-register nil)
  (setq ledger-report-auto-width nil)
  (setq ledger-report-use-native-highlighting nil))

magit

(use-package magit
  :ensure t
  :commands magit-status
  :defer 5
  :config
  (setq
   magit-repolist-columns
   '(("Name" 15 magit-repolist-column-ident nil)
     ("Flag" 4 magit-repolist-column-flag nil)
     ("B<U" 3 magit-repolist-column-unpulled-from-upstream
      ((:right-align t)
       (:sort <)))
     ("B>U" 3 magit-repolist-column-unpushed-to-upstream
      ((:right-align t)
       (:sort <)))
     ("Branch" 15 magit-repolist-column-branch nil)
     ("Path" 99 magit-repolist-column-path nil))))
(use-package magit-delta
  :ensure t
  :after magit
  :hook (magit-mode . magit-delta-mode)
  :config
  (add-to-list 'magit-delta-delta-args "--max-line-length=2048"))

markdown

(use-package markdown-mode
  :ensure t
  :commands (gfm-view-mode markdown-view-mode)
  :mode (("README\\.md\\'" . gfm-mode)
         ("\\.md\\'" . markdown-mode)
         ("\\.mkd\\'" . markdown-mode)
         ("\\.markdown\\'" . markdown-mode)))

newcomment

(use-package newcomment
  :general
  ('override
   "M-;" nil
   "C-/" 'comment-dwim))

olivetti

(use-package olivetti
  :ensure t
  :commands olivetti-mode
  :config
  (setq olivetti-body-width 0.4)
  (setq olivetti-minimum-body-width 72))

outline

(use-package outline
  :hook ((LaTeX-mode agda2-mode) . outline-minor-mode))
(add-hook 'outline-minor-mode-hook #'evil-normalize-keymaps)

flypy-re

Steal from pinyinlib.el.

(use-package flypy-re
  :load-path "~/.config/emacs/packages/flypy-re"
  :config
  ;; orderless
  (with-eval-after-load 'orderless
    (defun completion--regex-pinyin (str)
      (orderless-regexp (flypy-re-build-regexp str)))
    (add-to-list 'orderless-matching-styles 'completion--regex-pinyin))
  ;; avy: overload avy-goto-char-timer
  (with-eval-after-load 'avy
    (defun avy-goto-char-timer (&optional arg)
      "Read one or many consecutive chars and jump to the first one.
The window scope is determined by `avy-all-windows' (ARG negates it)."
      (interactive "P")
      (let ((avy-all-windows (if arg
                                 (not avy-all-windows)
                               avy-all-windows)))
        (avy-with avy-goto-char-timer
                  (setq avy--old-cands (avy--read-candidates #'flypy-re-build-regexp))
                  (avy-process avy--old-cands))))))

recentf

(use-package recentf
  :config
  (recentf-mode))

scihub

(use-package scihub
  :load-path "~/.config/emacs/packages/scihub.el"
  :defer t
  :config
  (setq scihub-download-directory "~/Documents/")
  (setq scihub-open-after-download nil))

snippets

(use-package yasnippet
  :ensure t
  :hook (LaTeX-mode . yas-minor-mode))
(use-package aas
  :ensure t
  :hook (org-mode . aas-activate-for-major-mode)
  :hook (agda2-mode . aas-activate-for-major-mode)
  :config
  (aas-set-snippets 'org-mode
    "bsrc" (lambda () (interactive)
               (insert "#+BEGIN_SRC elisp\n#+END_SRC")
               (org-edit-special)))

  (defun my:agda-auto-script-condition ()
    "Condition used for auto-sub/superscript snippets."
    (not (or (bobp) (= (1- (point)) (point-min)) (eq ?\s (char-before)))))
  (aas-set-snippets 'agda2-mode
    :cond #'my:agda-auto-script-condition
    "'" ""
    "0" ""
    "1" ""
    "2" ""
    "3" ""
    "4" ""
    "5" ""
    "6" ""
    "7" ""
    "8" ""
    "9" ""))
(use-package laas
  :ensure t
  :hook (LaTeX-mode . laas-mode)
  :config
  (require 'yasnippet)
  (aas-set-snippets 'laas-mode
    :cond #'texmathp
    "Sum" (lambda () (interactive)
            (yas-expand-snippet "\\sum_{$1}^{$2} $0"))
    "fc/" (lambda () (interactive)
           (yas-expand-snippet "\\frac{$1}{$2}$0"))))

strokes

(use-package strokes
  :commands (strokes-do-stroke))
(general-def strokes-mode-map
  "<down-mouse-3>" 'strokes-do-stroke)

symbol-overlay

(use-package symbol-overlay
  :ensure t
  :commands symbol-overlay-put)

terminal-here

(use-package terminal-here
  :ensure t
  :commands terminal-here-launch
  :config
  (setq terminal-here-terminal-command
        '("alacritty")))

tramp

(use-package tramp
  :defer t)

vc-mode

(use-package vc
  :defer t
  :config
  (with-eval-after-load 'tramp
    (setq vc-ignore-dir-regexp
          (format "\\(%s\\)\\|\\(%s\\)"
                  vc-ignore-dir-regexp
                  tramp-file-name-regexp))))

wgrep

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

which-key

(use-package which-key
  :ensure t
  :init
  (setq which-key-add-column-padding 2)
  (setq which-key-idle-delay 0)
  (setq which-key-dont-use-unicode t)
  :config
  (which-key-mode 1))

winner-mode

(use-package winner
  :hook
  (after-init . winner-mode)
  (ediff-quit . winner-undo))

languages

cc-mode

(use-package cc-mode
  :mode
  (("\\.c\\'" . c-mode)
   ("\\.h\\'" . c-or-c++-mode))
  :config
  (setq c-basic-offset 4))
(use-package modern-cpp-font-lock
  :ensure t
  :hook (c++-mode . modern-c++-font-lock-mode))

tree-sitter

(use-package tree-sitter
  :ensure t
  :hook ((html-mode) . tree-sitter-hl-mode)
  :commands (tree-sitter-hl-mode))
(use-package tree-sitter-langs
  :ensure t
  :after tree-sitter)

Coq

(use-package proof-general
  :ensure t
  :mode ("\\.v\\'" . coq-mode)
  :config
  (setq proof-splash-enable nil))
(use-package company-coq
  :ensure t
  :after proof-site
  :hook (coq-mode . company-coq-mode)
  :config
  (setq company-coq-disabled-features '(smart-subscripts))
  (company-coq--init-refman-ltac-abbrevs-cache)
  (company-coq--init-refman-scope-abbrevs-cache)
  (company-coq--init-refman-tactic-abbrevs-cache)
  (company-coq--init-refman-vernac-abbrevs-cache)
  (defun my:company-coq-doc-search ()
    "Search identifier in coq refman"
    (interactive)
    (ivy-read
     "doc: "
     (append company-coq--refman-tactic-abbrevs-cache
             company-coq--refman-vernac-abbrevs-cache
             company-coq--refman-scope-abbrevs-cache
             company-coq--refman-ltac-abbrevs-cache)
     :preselect (ivy-thing-at-point)
     :action 'company-coq-doc-buffer-refman)))

CSV

(use-package csv-mode
  :ensure t
  :mode ("\\.[Cc][Ss][Vv]\\'" . csv-mode))

Haskell

(use-package haskell-mode
  :ensure t
  :mode "\\.hs\\'"
  :config
  (require 'haskell)
  (require 'haskell-doc))

HTML

(use-package sgml-mode
  :mode ("\\.html\\'" . html-mode)
  :config
  (defun my:html-mode-face-remap ()
    (face-remap-set-base
     'tree-sitter-hl-face:attribute
     :foreground "#AAAAAA")
    (face-remap-set-base
     'tree-sitter-hl-face:punctuation.bracket
     :foreground "#DDDDDD")
    (face-remap-add-relative
     'tree-sitter-hl-face:tag
     :foreground "#AAAAAA"))
  (add-hook 'html-mode-hook 'my:html-mode-face-remap))
(use-package emmet-mode
  :ensure t
  :hook (sgml-mode css-mode))

Typescript

(use-package typescript-mode
  :ensure t
  :mode ("\\.ts\\'" . typescript-mode))

JSON

(use-package json-mode
  :ensure t
  :mode "\\.json\\'")

Lua

(use-package lua-mode
  :ensure t
  :mode "\\.lua\\'")

Agda

(eval-and-compile
  (defun agda-mode-load-path ()
    (file-name-directory (shell-command-to-string "agda-mode locate"))))
(use-package agda2
  :load-path (lambda () (agda-mode-load-path))
  :mode ("\\.agda\\'" . agda2-mode)
  :config
  (setq outline-regexp "-- #+"))

Ocaml

(use-package tuareg
  :ensure t
  :mode ("\\.ml[ip]?\\'" . tuareg-mode)
  :defer t)
(eval-and-compile
  (defun opam-emacs-load-path ()
    (expand-file-name
     "share/emacs/site-lisp"
     (file-name-directory
      (shell-command-to-string "opam var share")))))
(use-package merlin
  :load-path (lambda () (opam-emacs-load-path))
  :hook
  (tuareg-mode . merlin-mode))
(use-package utop
  :load-path (lambda () (opam-emacs-load-path))
  :hook
  (tuareg-mode . utop-minor-mode))

SML

(use-package sml-mode
  :ensure t
  :mode "\\.sml\\'"
  :config
  (setq sml-indent-level 4)
  (setq sml-indent-args 2))

Prolog

(use-package prolog
  :mode ("\\.pl\\'" . prolog-mode)
  :init
  (setq prolog-system 'swi))

Python

(use-package python
  :mode ("\\.py\\'" . python-mode)
  :config
  (with-eval-after-load 'eglot
    (add-to-list
     'eglot-server-programs
     '(python-mode . ("pdm" "run"
                      "pyright-langserver" "--stdio")))))

Cubicaltt

(use-package cubicaltt
  :load-path "~/cubicaltt"
  :mode ("\\.ctt$" . cubicaltt-mode))

Shell

(use-package flymake-shellcheck
  :ensure t
  :hook (sh-mode . flymake-shellcheck-load))

LaTeX

(use-package tex-site
  :ensure auctex
  :mode ("\\.tex\\'" . TeX-latex-mode)
  :config
  (add-hook 'LaTeX-mode-hook 'my:show-trailing-space)
  (add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
  (add-hook 'LaTeX-mode-hook 'TeX-PDF-mode)
  (setq font-latex-fontify-sectioning 'color)
  (setq font-latex-fontify-script nil)
  (setq TeX-view-program-selection '((output-pdf "Zathura"))))
(use-package auctex-latexmk
  :ensure t
  :after tex-site
  :config
  (auctex-latexmk-setup))
(use-package cdlatex
  :ensure t
  :hook (LaTeX-mode . cdlatex-mode)
  :init
  (setq cdlatex-takeover-parenthesis nil))
(use-package xenops
  :hook (LaTeX-mode . xenops-mode)
  :ensure t)

YAML

(use-package yaml-mode
  :ensure t
  :mode "\\.yaml\\'")

Releases

No releases published

Packages

No packages published