HOME | EDIT | RSS | INDEX | ABOUT | GITHUB

Literal Programming Emacs Configure Literal Programming Emacs Configure

UI

Fonts

Download JetBrain Mono font.

(if (member "JetBrains Mono" (font-family-list))
    (set-frame-font "JetBrains Mono 11"))

(global-prettify-symbols-mode 1)
                                        ;(load-theme 'misterioso t)
t

Theme

(load-theme 'misterioso)
t

Default Settings

;; Setting
;; (load-theme 'misterioso t)
(server-start)
;; (keyboard-translate ?\C-h ?\C-?)
(column-number-mode 1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(menu-bar-mode -1)
(delete-selection-mode 1)
(global-auto-revert-mode 1)
(electric-indent-mode t)

(setq-default
 make-backup-files nil
 indent-tabs-mode nil)
;; make unix lineendings default
(setq default-buffer-file-coding-system 'utf-8-unix)
(when (eq system-type 'darwin)
  (setq mac-option-modifier 'alt)
  (setq mac-option-modifier 'super) ; make opt key do Super
  (setq mac-command-modifier 'meta))
meta
(when (eq system-type 'darwin)
  (add-to-list 'exec-path "/run/current-system/sw/bin")
  (add-to-list 'exec-path (expand-file-name "~/.nix-profile/bin"))
  (setenv "PATH" "/Users/jichao.ouyang/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin")
  )
/Users/jichao.ouyang/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin

Modes

ace jump mode

You can move your cursor to ANY position ( across window and frame ) in emacs by using only 3 times key press.

(use-package ace-jump-mode
  :ensure t
  :bind
  ("C-c SPC" . ace-jump-mode)
  ("C-c u SPC" . ace-jump-mode-pop-mark)
  ("C-c l SPC" . ace-jump-line-mode))
ace-jump-line-mode

company

text completion framework

(use-package company
  :config
  (add-hook 'after-init-hook 'global-company-mode)
  )
t

Dhall

(use-package dhall-mode
  :ensure t
  :hook
  (dhall-mode . lsp)
  :config
  (setq
   ;; uncomment the next line to disable automatic format
   ;;dhall-format-at-save nil

   ;; comment the next line to use unicode syntax
   ;; dhall-format-arguments (\` ("--ascii"))

   ;; header-line is obsoleted by lsp-mode
   dhall-use-header-line nil
   dhall-type-check-inactivity-timeout 10
   ))

lsp

expand region

(use-package expand-region
  :bind
  ("C-8" . er/expand-region)
  ("C--" . er/contract-region))
er/contract-region

forge

;;(use-package forge
;;:after magit)

Go

(use-package go-mode
  :hook
  (go-mode . lsp)
  :config
  (setq lsp-go-gopls-server-path (expand-file-name "~/go/bin/gopls")))
(use-package protobuf-mode)

Haskell

(use-package lsp-haskell
  :config
  (lsp-make-interactive-code-action wingman-fill-hole "")
  (lsp-make-interactive-code-action wingman-case-split "Wingman: Case split on sec")
  ;; (lsp-make-interactive-code-action wingman-refine "refactor.wingman.refine")
  ;; (lsp-make-interactive-code-action wingman-split-func-args "refactor.wingman.spltFuncArgs")
  ;; (lsp-make-interactive-code-action wingman-use-constructor "refactor.wingman.useConstructor")
  (setq haskell-stylish-on-save t)
  :hook
  (haskell-mode . lsp))
lsp

helm


(use-package helm
  :ensure t
  :bind
  ("M-x" . helm-M-x)
  ("C-x b" . helm-mini)
  ("M-y" . helm-show-kill-ring)
  :bind (:map helm-map
              ("<tab>" . helm-execute-persistent-action) ; rebind tab to run persistent action
              ("C-i" . helm-execute-persistent-action) ; make TAB works in terminal
              ("C-z" . helm-select-action))
  :config

  (helm-autoresize-mode 1)
  (setq 
   helm-M-x-fuzzy-match t
   helm-buffers-fuzzy-matching t
   helm-recentf-fuzzy-match t
   helm-ag-fuzzy-match t ;(ref: ag-fuzzy-match)
   helm-locate-fuzzy-match t
   )
  )
(use-package helm-swoop
  :ensure t
  :bind (("M-m" . helm-multi-swoop-projectile)
         ("M-M" . helm-swoop-back-to-last-point))
  :init
  (bind-key "M-m" 'helm-swoop-from-isearch isearch-mode-map))

(use-package projectile
  :ensure t
  :bind-keymap
  ("C-c p" . projectile-command-map)
  :config
  (projectile-global-mode)
  (setq projectile-indexing-method 'alien
        projectile-enable-caching t
        projectile-completion-system 'helm))

(use-package helm-projectile
  :ensure t
  :config
  (helm-projectile-on)
  )

ido

(use-package ido
  :config
  (setq ido-everywhere t
        ido-enable-flex-matching t
        ido-max-directory-size 100000
        ido-default-file-method 'selected-window
        ido-default-buffer-method 'selected-window)
  (ido-mode 1))
t

indent guide

(use-package indent-guide
  :hook (prog-mode . indent-guide-mode))
indent-guide-mode rainbow-delimiters-mode (lambda nil (flyspell-prog-mode) (setq company-backends (delete 'company-ispell company-backends)) (message company-ispell disable))

key chord

(use-package key-chord
  :config
  (key-chord-mode 1)
  (setq key-chord-two-keys-delay 0.03)
  (key-chord-define-global "vr"     'vr/replace)
  (key-chord-define-global "ln"     'display-line-numbers-mode)
  (key-chord-define-global ",."     "<>\C-b")
  (key-chord-define-global " u"     'capitalize-word)
  )
t

Langtool

Install LanguageTool version 3.0 or later (and java) https://languagetool.org/

extract them into /usr/local/share/LanguageTool

(use-package langtool
  :config
  (setq langtool-language-tool-jar "/usr/local/share/LanguageTool/languagetool-commandline.jar"
        langtool-disabled-rules '("WHITESPACE_RULE"
                                  "EN_UNPAIRED_BRACKETS"
                                  "COMMA_PARENTHESIS_WHITESPACE"
                                  "EN_QUOTES")
        langtool-default-language "en-US")
  )

t

lsp

(use-package lsp-mode
  :config
  (setq lsp-prefer-flymake nil
   lsp-enable-file-watchers nil
   lsp-lens-enable nil
   lsp-ui-doc-show-with-cursor t
   lsp-ui-sideline-show-code-actions t
   lsp-ui-sideline-enable t
   lsp-signature-auto-activate t
   lsp-completion-show-detail t )
  )

;; Add metals backend for lsp-mode
;; (use-package lsp-metals)

;; Enable nice rendering of documentation on hover
(use-package lsp-ui)

magit

(use-package magit
  :bind
  ("C-x g" . magit-status))
magit-status

multi cursor

(use-package multiple-cursors
  :bind
  ("C-<" . mc/mark-previous-like-this)
  ("C->" . mc/mark-next-like-this)
  ("C-*" . mc/mark-all-like-this))
mc/mark-all-like-this

Nya mode

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

on screen

(use-package on-screen
  :ensure t
  :config
  (on-screen-global-mode 1)
  (setq on-screen-highlight-method 'narrow-line))

narrow-line

org mode

  • Commond settings
    (use-package org
      :init
      (setq org-agenda-files (quote ("~/SynologyDrive/Documents/notes"))
            org-refile-targets (quote ((nil :maxlevel . 9)
                                       (org-agenda-files :maxlevel . 9)))
            org-directory "~/SynologyDrive/Documents/notes"
            org-default-notes-file (concat org-directory "/refile.org")
            org-refile-use-outline-path t
            org-outline-path-complete-in-steps nil
            org-completion-use-ido t
            org-indirect-buffer-display 'current-window
            org-hide-emphasis-markers t
            org-startup-folded 'content
            org-startup-indented nil
            org-startup-with-inline-images t
            org-startup-truncated nil
            org-src-tab-acts-natively t
            org-fontify-done-headline t
            org-pretty-entities t
            org-odd-levels-only t
            )
      :hook
      (org-mode . visual-line-mode)
      (org-mode . (lambda ()
                    (variable-pitch-mode 1)
                    (mapc
                     (lambda (face)
                       (set-face-attribute face nil :inherit 'fixed-pitch))
                     (list 'org-code
                           'org-link 
                           'org-block
                           'org-table
                           'org-block-begin-line
                           'org-block-end-line
                           'org-meta-line
                           'org-property-value
                           'org-tag
                           'org-document-info-keyword))))
      :config
      (custom-theme-set-faces
       'user
       '(variable-pitch ((t (:family "ETBembo" :weight thin :height 1.25 ))))
       '(fixed-pitch ((t ( :family "JetBrains Mono" :weight thin  :height 0.8 )))))
      (global-set-key (kbd "C-c c") 'org-capture)
      (global-set-key (kbd "C-c a") 'org-agenda)
      )
    
    
    
  • Bullet
    (use-package org-bullets
      :hook (org-mode . org-bullets-mode))
    
  • Encryption
    (use-package org-crypt
      :config 
      (org-crypt-use-before-save-magic)
      (setq org-crypt-key "A506C38D5CC847D0DF01134ADA8B833B52604E63")
      (setq org-tags-exclude-from-inheritance '("crypt"))
      )
    
    t
    
  • Org Protocol
    
    ;; Capture templates for: TODO tasks, Notes, appointments, phone calls, meetings, and org-protocol
    (use-package org-protocol
      :config
      (setq org-capture-templates
            (quote (("t" "Todo" entry (file+headline (lambda () (concat org-directory "/refile.org")) "Todos")
                     "* TODO %?\n%U\n%a\n" :clock-in t :clock-resume t)
                    ("n" "Note" entry (file+headline (lambda () (concat org-directory "/notes.org")) "Notes")
                     "* %?\n%U\n%a\n" :clock-in t :clock-resume t)
                    ("w" "Work" entry (file+headline (lambda () (concat org-directory "/myob.org")) "Work Notes"))
                    ("x" "protocol" entry (file+headline (lambda () (concat org-directory "/refile.org")) "Org Capture")
                     "* %a\nCaptured On: %U\nWebsite: %l\n\n%i\n%?")
                    )))
      )
    
    
    selected-window
    

prompt

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

PureScript

(use-package psc-ide
  :init
  (setq psc-ide-use-npm-bin t)
  :config
  (add-hook 'purescript-mode-hook
            (lambda ()
              (psc-ide-mode)
              (company-mode)
              (flycheck-mode)
              (turn-on-purescript-indentation)))

  )

rainbow delimiter

(use-package rainbow-delimiters
  :hook (prog-mode . rainbow-delimiters-mode))
rainbow-delimiters-mode (lambda nil (flyspell-prog-mode) (setq company-backends (delete 'company-ispell company-backends)) (message company-ispell disable))

Restclient

(use-package restclient
  :config
  (add-to-list 'company-backends 'company-restclient))
(use-package restclient-jq)
(use-package restclient-helm)
;; :config
;; ;
                                        ; 
;; :hook (company-mode))
t

shell-mode

(setq comint-output-filter-functions
      (remove 'ansi-color-process-output comint-output-filter-functions))

smartparens

(use-package smartparens
  :init
  (require 'smartparens-config)
  :config
  (smartparens-global-mode t)
  (show-smartparens-global-mode t))

textmate

(use-package textmate
  :init
  (textmate-mode)
  (bind-keys
   :map *textmate-mode-map*
   ("M--" . text-scale-decrease)
   ("M-=" . text-scale-increase)
   ("M-}" . textmate-shift-right)
   ("M-<backspace>" . kill-whole-line)
   ("M-c" . kill-ring-save)
   ("M-{" . textmate-shift-left)
   ("M-/" . comment-line)
   ("M-l" . textmate-select-line)
   ))
textmate-select-line

typescript

(use-package typescript-mode
  :hook
  (typescript-mode . lsp))
lsp

unicode

(use-package unicode-fonts
  :config
  (unicode-fonts-setup))
t

web-mode

(use-package web-mode
  :mode "\\.html$'" "\\.jsx$" "\\.tsx$"
  :init 
  (setq web-mode-markup-indent-offset 2)
  (setq web-mode-css-indent-offset 2)
  (setq web-mode-code-indent-offset 2)
  )

which key

(use-package which-key
  :config
  (which-key-mode)
  (setq which-key-use-C-h-commands t)
  (setq which-key-paging-key "<f5>")
  )
t

yasnippet

(use-package yasnippet
:config
(yas-global-mode 1))

r