You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

411 lines
18 KiB

(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(LaTeX-command "xelatex")
'(LaTeX-command-style
(quote
(("" "%(latex) %(file-line-error) %(extraopts) %S%(PDFout)"))))
'(TeX-engine (quote xetex))
'(custom-safe-themes
(quote
("a24c5b3c12d147da6cef80938dca1223b7c7f70f2f382b26308eba014dc4833a" "4aee8551b53a43a883cb0b7f3255d6859d766b6c5e14bcb01bed572fcbef4328" default)))
'(package-selected-packages
(quote
(helm-make helm-hoogle company-shell company company-dcd company-ghci company-ghc d-mode pyimpsort py-import-check yasnippet company-auctex auctex haskell-mode ruby-dev ruby-electric ruby-end ruby-tools tldr w3 yafolding xwidgete color-theme-sanityinc-solarized xkcd yalinum helm pdf-tools tablist projectile helm-projectile ac-helm mediawiki wiki-summary fcitx wc-mode spaceline color-theme-modern nyan-mode fancy-battery use-package vigenere flymd markdown-preview-mode markdown-mode+ markdown-mode material-theme gh-md sed-mode helm-rubygems-org zossima enh-ruby-mode emms-bilibili company-inf-ruby cmake-mode cmake-font-lock git-commit magit jedi company-jedi jedi-direx py-autopep8 px pulseaudio-control py-smart-operator pyimport py-isort eshell-prompt-extras csv-mode helm-systemd systemd ack))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(fset 'yes-or-no-p 'y-or-n-p)
(setq confirm-nonexistent-file-or-buffer nil)
(setq inhibit-startup-screen t)
(setq next-line-add-newlines t)
(load-theme 'material t t)
(enable-theme 'material)
(require 'yalinum)
(global-yalinum-mode t)
(global-set-key (kbd "C-x C-b") 'ibuffer)
; (setq ido-enable-flex-matching t)
; (setq ido-everywhere t)
; (ido-mode 1)
(require 'helm-config)
(helm-mode 1)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "<menu>") 'helm-M-x)
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(setq helm-M-x-fuzzy-match t)
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))
(require 'ac-helm)
(global-set-key (kbd "C-:") 'ac-complete-with-helm)
(define-key ac-complete-mode-map (kbd "C-:") 'ac-complete-with-helm)
;;(pdf-tools-install)
;;(setq pdf-info-epdfinfo-program "/usr/bin/epdfinfo2")
(require 'yafolding)
(defvar yafolding-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "<C-S-return>") 'yafolding-hide-parent-element)
(define-key map (kbd "<C-M-return>") 'yafolding-toggle-all)
(define-key map (kbd "<C-return>") 'yafolding-toggle-element)
map))
(add-hook 'prog-mode-hook
(lambda () (yafolding-mode)))
;; (require 'auto-complete)
;; (add-hook 'prog-mode-hook
;; (lambda () (auto-complete-mode)))
(require 'wc-mode)
(add-hook 'text-mode-hook
(lambda () (wc-mode)))
(require 'company)
;; (add-hook 'prog-mode-hook
;; (lambda () (company-mode)))
(global-company-mode)
(require 'helm-company)
(eval-after-load 'company
'(progn
(define-key company-mode-map (kbd "C-:") 'helm-company)
(define-key company-active-map (kbd "C-:") 'helm-company)))
(require 'tide)
(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))
(setq company-tooltip-align-annotations t)
(add-hook 'before-save-hook 'tide-format-before-save)
(add-hook 'typescript-mode-hook #'setup-tide-mode)
(when window-system
(set-frame-font "Fira Code Medium-11"))
(add-hook 'after-make-frame-functions (lambda (frame) (set-fontset-font t '(#Xe100 . #Xe16f) "Fira Code Symbol")))
(set-fontset-font t '(#Xe100 . #Xe16f) "Fira Code Symbol")
(defun my-correct-symbol-bounds (pretty-alist)
"Prepend a TAB character to each symbol in this alist,
this way compose-region called by prettify-symbols-mode
will use the correct width of the symbols
instead of the width measured by char-width."
(mapcar (lambda (el)
(setcdr el (string ?\t (cdr el)))
el)
pretty-alist))
(defun my-ligature-list (ligatures codepoint-start)
"Create an alist of strings to replace with
codepoints starting from codepoint-start."
(let ((codepoints (-iterate '1+ codepoint-start (length ligatures))))
(-zip-pair ligatures codepoints)))
;; list can be found at https://github.com/i-tu/Hasklig/blob/master/GlyphOrderAndAliasDB#L1588
(setq my-fira-code-ligatures
(let* ((ligs '("www" "**" "***" "**/" "*>" "*/" "\\\\" "\\\\\\"
"{-" "[]" "::" ":::" ":=" "!!" "!=" "!==" "-}"
"--" "---" "-->" "->" "->>" "-<" "-<<" "-~"
"#{" "#[" "##" "###" "####" "#(" "#?" "#_" "#_("
".-" ".=" ".." "..<" "..." "?=" "??" ";;" "/*"
"/**" "/=" "/==" "/>" "//" "///" "&&" "||" "||="
"|=" "|>" "^=" "$>" "++" "+++" "+>" "=:=" "=="
"===" "==>" "=>" "=>>" "<=" "=<<" "=/=" ">-" ">="
">=>" ">>" ">>-" ">>=" ">>>" "<*" "<*>" "<|" "<|>"
"<$" "<$>" "<!--" "<-" "<--" "<->" "<+" "<+>" "<="
"<==" "<=>" "<=<" "<>" "<<" "<<-" "<<=" "<<<" "<~"
"<~~" "</" "</>" "~@" "~-" "~=" "~>" "~~" "~~>" "%%"
"x" ":" "+" "+" "*")))
(my-correct-symbol-bounds (my-ligature-list ligs #Xe100))))
;; nice glyphs with fira code
(defun my-set-fira-code-ligatures ()
"Add fira code ligatures for use with prettify-symbols-mode."
(setq prettify-symbols-alist
(append my-fira-code-ligatures prettify-symbols-alist))
(prettify-symbols-mode))
(when (window-system)
(add-hook 'prog-mode-hook 'my-set-fira-code-ligatures)
(add-hook 'tex-mode-hook 'my-set-fira-code-ligatures))
;;(when (window-system)
;; (set-frame-font "Fira Code"))
;; (let ((alist '((33 . ".\\(?:\\(?:==\\|!!\\)\\|[!=]\\)")
;; (35 . ".\\(?:###\\|##\\|_(\\|[#(?[_{]\\)")
;; (36 . ".\\(?:>\\)")
;; (37 . ".\\(?:\\(?:%%\\)\\|%\\)")
;; (38 . ".\\(?:\\(?:&&\\)\\|&\\)")
;; (42 . ".\\(?:\\(?:\\*\\*/\\)\\|\\(?:\\*[*/]\\)\\|[*/>]\\)")
;; (43 . ".\\(?:\\(?:\\+\\+\\)\\|[+>]\\)")
;; (45 . ".\\(?:\\(?:-[>-]\\|<<\\|>>\\)\\|[<>}~-]\\)")
;; (46 . ".\\(?:\\(?:\\.[.<]\\)\\|[.=-]\\)")
;; (47 . ".\\(?:\\(?:\\*\\*\\|//\\|==\\)\\|[*/=>]\\)")
;; (48 . ".\\(?:x[a-zA-Z]\\)")
;; (58 . ".\\(?:::\\|[:=]\\)")
;; (59 . ".\\(?:;;\\|;\\)")
;; (60 . ".\\(?:\\(?:!--\\)\\|\\(?:~~\\|->\\|\\$>\\|\\*>\\|\\+>\\|--\\|<[<=-]\\|=[<=>]\\||>\\)\\|[*$+~/<=>|-]\\)")
;; (61 . ".\\(?:\\(?:/=\\|:=\\|<<\\|=[=>]\\|>>\\)\\|[<=>~]\\)")
;; (62 . ".\\(?:\\(?:=>\\|>[=>-]\\)\\|[=>-]\\)")
;; (63 . ".\\(?:\\(\\?\\?\\)\\|[:=?]\\)")
;; (91 . ".\\(?:]\\)")
;; (92 . ".\\(?:\\(?:\\\\\\\\\\)\\|\\\\\\)")
;; (94 . ".\\(?:=\\)")
;; (119 . ".\\(?:ww\\)")
;; (123 . ".\\(?:-\\)")
;; (124 . ".\\(?:\\(?:|[=|]\\)\\|[=>|]\\)")
;; (126 . ".\\(?:~>\\|~~\\|[>=@~-]\\)")
;; )
;; ))
;; (dolist (char-regexp alist)
;; (set-char-table-range composition-function-table (car char-regexp)
;; `([,(cdr char-regexp) 0 font-shape-gstring]))))
;; ;;; Fira code
;; ;; This works when using emacs --daemon + emacsclient
;; (add-hook 'after-make-frame-functions (lambda (frame) (set-fontset-font t '(#Xe100 . #Xe16f) "Fira Code Symbol")))
;; ;; This works when using emacs without server/client
;; (set-fontset-font t '(#Xe100 . #Xe16f) "Fira Code Symbol")
;; ;; I haven't found one statement that makes both of the above situations work, so I use both for now
;; (defconst fira-code-font-lock-keywords-alist
;; (mapcar (lambda (regex-char-pair)
;; `(,(car regex-char-pair)
;; (0 (prog1 ()
;; (compose-region (match-beginning 1)
;; (match-end 1)
;; ;; The first argument to concat is a string containing a literal tab
;; ,(concat " " (list (decode-char 'ucs (cadr regex-char-pair)))))))))
;; '(("\\(www\\)" #Xe100)
;; ("[^/]\\(\\*\\*\\)[^/]" #Xe101)
;; ("\\(\\*\\*\\*\\)" #Xe102)
;; ("\\(\\*\\*/\\)" #Xe103)
;; ("\\(\\*>\\)" #Xe104)
;; ("[^*]\\(\\*/\\)" #Xe105)
;; ("\\(\\\\\\\\\\)" #Xe106)
;; ("\\(\\\\\\\\\\\\\\)" #Xe107)
;; ("\\({-\\)" #Xe108)
;; ("\\(\\[\\]\\)" #Xe109)
;; ("\\(::\\)" #Xe10a)
;; ("\\(:::\\)" #Xe10b)
;; ("[^=]\\(:=\\)" #Xe10c)
;; ("\\(!!\\)" #Xe10d)
;; ("\\(!=\\)" #Xe10e)
;; ("\\(!==\\)" #Xe10f)
;; ("\\(-}\\)" #Xe110)
;; ("\\(--\\)" #Xe111)
;; ("\\(---\\)" #Xe112)
;; ("\\(-->\\)" #Xe113)
;; ("[^-]\\(->\\)" #Xe114)
;; ("\\(->>\\)" #Xe115)
;; ("\\(-<\\)" #Xe116)
;; ("\\(-<<\\)" #Xe117)
;; ("\\(-~\\)" #Xe118)
;; ("\\(#{\\)" #Xe119)
;; ("\\(#\\[\\)" #Xe11a)
;; ("\\(##\\)" #Xe11b)
;; ("\\(###\\)" #Xe11c)
;; ("\\(####\\)" #Xe11d)
;; ("\\(#(\\)" #Xe11e)
;; ("\\(#\\?\\)" #Xe11f)
;; ("\\(#_\\)" #Xe120)
;; ("\\(#_(\\)" #Xe121)
;; ("\\(\\.-\\)" #Xe122)
;; ("\\(\\.=\\)" #Xe123)
;; ("\\(\\.\\.\\)" #Xe124)
;; ("\\(\\.\\.<\\)" #Xe125)
;; ("\\(\\.\\.\\.\\)" #Xe126)
;; ("\\(\\?=\\)" #Xe127)
;; ("\\(\\?\\?\\)" #Xe128)
;; ("\\(;;\\)" #Xe129)
;; ("\\(/\\*\\)" #Xe12a)
;; ("\\(/\\*\\*\\)" #Xe12b)
;; ("\\(/=\\)" #Xe12c)
;; ("\\(/==\\)" #Xe12d)
;; ("\\(/>\\)" #Xe12e)
;; ("\\(//\\)" #Xe12f)
;; ("\\(///\\)" #Xe130)
;; ("\\(&&\\)" #Xe131)
;; ("\\(||\\)" #Xe132)
;; ("\\(||=\\)" #Xe133)
;; ("[^|]\\(|=\\)" #Xe134)
;; ("\\(|>\\)" #Xe135)
;; ("\\(\\^=\\)" #Xe136)
;; ("\\(\\$>\\)" #Xe137)
;; ("\\(\\+\\+\\)" #Xe138)
;; ("\\(\\+\\+\\+\\)" #Xe139)
;; ("\\(\\+>\\)" #Xe13a)
;; ("\\(=:=\\)" #Xe13b)
;; ("[^!/]\\(==\\)[^>]" #Xe13c)
;; ("\\(===\\)" #Xe13d)
;; ("\\(==>\\)" #Xe13e)
;; ("[^=]\\(=>\\)" #Xe13f)
;; ("\\(=>>\\)" #Xe140)
;; ("\\(<=\\)" #Xe141)
;; ("\\(=<<\\)" #Xe142)
;; ("\\(=/=\\)" #Xe143)
;; ("\\(>-\\)" #Xe144)
;; ("\\(>=\\)" #Xe145)
;; ("\\(>=>\\)" #Xe146)
;; ("[^-=]\\(>>\\)" #Xe147)
;; ("\\(>>-\\)" #Xe148)
;; ("\\(>>=\\)" #Xe149)
;; ("\\(>>>\\)" #Xe14a)
;; ("\\(<\\*\\)" #Xe14b)
;; ("\\(<\\*>\\)" #Xe14c)
;; ("\\(<|\\)" #Xe14d)
;; ("\\(<|>\\)" #Xe14e)
;; ("\\(<\\$\\)" #Xe14f)
;; ("\\(<\\$>\\)" #Xe150)
;; ("\\(<!--\\)" #Xe151)
;; ("\\(<-\\)" #Xe152)
;; ("\\(<--\\)" #Xe153)
;; ("\\(<->\\)" #Xe154)
;; ("\\(<\\+\\)" #Xe155)
;; ("\\(<\\+>\\)" #Xe156)
;; ("\\(<=\\)" #Xe157)
;; ("\\(<==\\)" #Xe158)
;; ("\\(<=>\\)" #Xe159)
;; ("\\(<=<\\)" #Xe15a)
;; ("\\(<>\\)" #Xe15b)
;; ("[^-=]\\(<<\\)" #Xe15c)
;; ("\\(<<-\\)" #Xe15d)
;; ("\\(<<=\\)" #Xe15e)
;; ("\\(<<<\\)" #Xe15f)
;; ("\\(<~\\)" #Xe160)
;; ("\\(<~~\\)" #Xe161)
;; ("\\(</\\)" #Xe162)
;; ("\\(</>\\)" #Xe163)
;; ("\\(~@\\)" #Xe164)
;; ("\\(~-\\)" #Xe165)
;; ("\\(~=\\)" #Xe166)
;; ("\\(~>\\)" #Xe167)
;; ("[^<]\\(~~\\)" #Xe168)
;; ("\\(~~>\\)" #Xe169)
;; ("\\(%%\\)" #Xe16a)
;; ;; ("\\(x\\)" #Xe16b) This ended up being hard to do properly so i'm leaving it out.
;; ("[^:=]\\(:\\)[^:=]" #Xe16c)
;; ("[^\\+<>]\\(\\+\\)[^\\+<>]" #Xe16d)
;; ("[^\\*/<>]\\(\\*\\)[^\\*/<>]" #Xe16f))))
;; (defun add-fira-code-symbol-keywords ()
;; (font-lock-add-keywords nil fira-code-font-lock-keywords-alist))
;; (add-hook 'prog-mode-hook
;; #'add-fira-code-symbol-keywords)
(nyan-mode)
(use-package spaceline
:init
(progn
(require 'spaceline-config)
(setq powerline-default-separator 'slant)
(setq spaceline-window-numbers-unicode t)
(setq spaceline-workspace-numbers-unicode t)
(setq spaceline-separator-dir-left '(left . left))
(setq spaceline-separator-dir-right '(right . right))
(setq powerline-height 27)
(spaceline-toggle-battery-on)
(spaceline-toggle-buffer-encoding-abbrev-on)
(spaceline-toggle-buffer-modified-on)
(spaceline-toggle-major-mode-on)
(spaceline-toggle-minor-modes-on)
(spaceline-toggle-hud-on)
(spaceline-toggle-projectile-root-on)
(spaceline-toggle-line-column-on)
(spaceline-toggle-input-method-on)
(spaceline-toggle-nyan-cat-on)
(spaceline-emacs-theme)))
(add-hook 'text-mode-hook #'wc-mode)
(add-hook 'text-mode-hook #'ispell-minor-mode)
(add-hook 'after-init-hook #'fancy-battery-mode)
(setq read-quoted-char-radix 16)
(setq default-input-method "chinese-py-punct")
(setq company-minimum-prefix-length 1)
(global-set-key (kbd "<mouse-8>") 'describe-function)
(global-set-key (kbd "<mouse-9>") 'company-ispell)
;; make these keys behave like normal browser
;; (define-key xwidget-webkit-mode-map [mouse-4] 'xwidget-webkit-scroll-down)
;; (define-key xwidget-webkit-mode-map [mouse-5] 'xwidget-webkit-scroll-up)
;; (define-key xwidget-webkit-mode-map (kbd "<up>") 'xwidget-webkit-scroll-down)
;; (define-key xwidget-webkit-mode-map (kbd "<down>") 'xwidget-webkit-scroll-up)
;; (define-key xwidget-webkit-mode-map (kbd "M-w") 'xwidget-webkit-copy-selection-as-kill)
;; (define-key xwidget-webkit-mode-map (kbd "C-c") 'xwidget-webkit-copy-selection-as-kill)
;; adapt webkit according to window configuration chagne automatically
;; without this hook, every time you change your window configuration,
;; you must press 'a' to adapt webkit content to new window size
(add-hook 'window-configuration-change-hook (lambda ()
(when (equal major-mode 'xwidget-webkit-mode)
(xwidget-webkit-adjust-size-dispatch))))
;; by default, xwidget reuses previous xwidget window,
;; thus overriding your current website, unless a prefix argument
;; is supplied
;;
;; This function always opens a new website in a new window
(defun xwidget-browse-url-no-reuse (url &optional session)
(interactive (progn
(require 'browse-url)
(browse-url-interactive-arg "xwidget-webkit URL: "
)))
(xwidget-webkit-browse-url url t))
;; make xwidget default browser
(setq browse-url-browser-function (lambda (url session)
(other-window 1)
(xwidget-browse-url-no-reuse url)))
(setq LaTeX-using-Biber t)
(eval-after-load "ruby-mode"
'(add-hook 'ruby-mode-hook 'ruby-electric-mode))
(add-to-list 'company-backends 'company-jedi)
(pulseaudio-control-default-keybindings)
(add-hook 'python-mode-hook 'py-smart-operator-mode)
(add-hook 'python-mode-hook 'py-autopep8-enable-on-save)
(add-hook 'python-mode-hook 'jedi:setup)
(add-hook 'before-save-hook 'py-isort-before-save)
(with-eval-after-load "esh-opt"
(autoload 'epe-theme-lambda "eshell-prompt-extras")
(setq eshell-highlight-prompt nil
eshell-prompt-function 'epe-theme-lambda))