HOME | EDIT | RSS | ABOUT | GITHUB

Literal Programming Emacs Configure Literal Programming Emacs Configure

UI

Theme

dracula dark theme

(use-package dracula-theme
  :config
  (load-theme 'dracula t))

Fonts

download monoid font

(if (member "Monoid" (font-family-list))
    (set-default-font "Monoid-14:width=condensed:weight=light"))

(when (eq system-type 'gnu/linux)
  (dolist (charset '(kana han symbol cjk-misc bopomofo))
    (set-fontset-font (frame-parameter nil 'font) charset
                      (font-spec :family "Noto Sans CJK SC"))))

(global-prettify-symbols-mode 1)

Default Settings

;; Setting
(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)
(nyan-mode t)
(electric-indent-mode t)
(setq-default
 make-backup-files nil
 indent-tabs-mode nil)
;; make unix lineendings default
(unicode-fonts-setup)
(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))
    (if (eq system-type 'gnu/linux)
(let ((path-from-shell (shell-command-to-string "/usr/bin/fish -c \"echo -n \\$PATH[1]; for val in \\$PATH[2..-1];echo -n \\\":\\$val\\\";end\"")))
  (setenv "PATH" path-from-shell)
  (setq exec-path (split-string path-from-shell ":")))
(let ((path-from-shell (shell-command-to-string "/usr/local/bin/fish -c \"echo -n \\$PATH[1]; for val in \\$PATH[2..-1];echo -n \\\":\\$val\\\";end\"")))
  (setenv "PATH" path-from-shell)
  (setq exec-path (split-string path-from-shell ":")))
        )

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
:bind
("C-c SPC" . ace-jump-mode)
("C-c u SPC" . ace-jump-mode-pop-mark)
("C-c l SPC" . ace-jump-line-mode))

company

text completion framework

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

forge

(use-package forge
:after magit)

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
    :config
    (helm-projectile-on)
    )

textmate

(use-package textmate
:config
(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)
 ))

ido

(use-package ido
  :bind
  :config
  (setq ido-everywhere t
        ido-enable-flex-matching t)
  (ido-mode 1))

typescript

(defun setup-tide-mode ()
   (interactive)
   (tide-setup)
   (flycheck-mode +1)
   (setq flycheck-check-syntax-automatically '(save mode-enabled))
   (eldoc-mode +1)
   (tide-hl-identifier-mode +1)
   ;; company is an optional dependency. You have to
   ;; install it separately via package-install
   ;; `M-x package-install [ret] company`
   (company-mode +1))

 ;; aligns annotation to the right hand side
 (setq company-tooltip-align-annotations t)

 ;; formats the buffer before saving


 (add-hook 'typescript-mode-hook #'setup-tide-mode)
 (require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-hook 'web-mode-hook
         (lambda ()
           (when (and (buffer-file-name)
(string-equal "tsx" (file-name-extension buffer-file-name)))
             (setup-tide-mode))))

js2 mode

(use-package js2-mode
:config
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.sjs$" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.es6$" . js2-mode))
(setq js2-allow-rhino-new-expr-initializer nil)
(setq js2-enter-indents-newline t)
(setq js2-global-externs '("module" "require" "buster" "sinon" "assert" "refute" "setTimeout" "clearTimeout" "setInterval" "clearInterval" "location" "__dirname" "console" "JSON"))
(setq js2-idle-timer-delay 0.1)
(setq js2-indent-on-enter-key nil)
(setq js2-mirror-mode nil)
(setq js2-strict-inconsistent-return-warning nil)
(setq js2-auto-indent-p t)
(setq js2-include-rhino-externs nil)
(setq js2-include-gears-externs nil)
(setq js2-concat-multiline-strings 'eol)
(setq js2-rebind-eol-bol-keys nil)
(setq js2-mode-show-parse-errors t)
(setq js2-mode-show-strict-warnings nil))

on screen

(on-screen-global-mode 1)
(setq on-screen-highlight-method 'narrow-line)

org mode

(setq org-startup-folded 'nofold)
(setq org-startup-indented t)
(setq org-startup-with-inline-images t)
(setq org-startup-truncated t)
(setq org-src-tab-acts-natively t)
(setq js-indent-level 2)

key chord

(use-package key-chord
  :config
  (key-chord-mode 1)
  (setq key-chord-two-keys-delay 0.03))

magit

(use-package magit
:bind
("C-x g" . 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))

expand region

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

pallet

(use-package pallet
:config
(pallet-mode t))

smartparens

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

Scala Metals

(use-package scala-mode
  :mode "\\.s\\(cala\\|bt\\)$")

(use-package sbt-mode
  :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))

;; Enable nice rendering of diagnostics like compile errors.
(use-package flycheck
  :init (global-flycheck-mode))

(use-package lsp-mode
  ;; Optional - enable lsp-mode automatically in scala files
  :hook (scala-mode . lsp)
  :config (setq lsp-prefer-flymake nil))

(use-package lsp-ui)

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

Flyspell

wsdf sjd js is

  (use-package flycheck
    :init
    (global-flycheck-mode)
:config
    (dolist (hook '(text-mode-hook))
      (add-hook hook (lambda () 
(flyspell-mode 1)
(add-to-list 'company-backends 'company-ispell)
(message "company-ispell enable")
)
))
    (dolist (hook '(prog-mode-hook))
      (add-hook hook (lambda () 
(flyspell-prog-mode)
(setq company-backends (delete 'company-ispell company-backends))
(message "company-ispell disable")
)))
)

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")
)

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
:config
(add-hook 'purescript-mode-hook
  (lambda ()
    (psc-ide-mode)
    (company-mode)
    (flycheck-mode)
    (turn-on-purescript-indentation)))
)

yasnippet

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