My Emacs settings
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.
 
 
 

914 lines
27 KiB

  1. ;;; init.el --- user-init-file -*- lexical-binding: t -*-
  2. ;; Bootstrap quelpa
  3. (package-initialize)
  4. (unless (package-installed-p 'quelpa)
  5. (with-temp-buffer
  6. (url-insert-file-contents "https://github.com/quelpa/quelpa/raw/master/quelpa.el")
  7. (eval-buffer)
  8. (quelpa-self-upgrade))
  9. ;; Install all selected packages
  10. ; Load custom.el to get the list of selected packages
  11. (let ((custom-file (expand-file-name "custom.el" user-emacs-directory)))
  12. (when (file-exists-p custom-file)
  13. (load custom-file))
  14. (load "custom.el"))
  15. (mapc #'quelpa package-selected-packages))
  16. (progn ; startup
  17. (package-initialize)
  18. (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
  19. (defvar before-user-init-time (current-time)
  20. "Value of `current-time' when Emacs begins loading `user-init-file'.")
  21. (message "Loading Emacs...done (%.3fs)"
  22. (float-time (time-subtract before-user-init-time
  23. before-init-time)))
  24. (setq user-init-file (or load-file-name buffer-file-name))
  25. (setq user-emacs-directory (file-name-directory user-init-file))
  26. (message "Loading %s..." user-init-file)
  27. (setq inhibit-startup-buffer-menu t)
  28. (setq inhibit-startup-screen t)
  29. (setq inhibit-startup-echo-area-message "locutus")
  30. (setq initial-buffer-choice t)
  31. (setq initial-scratch-message "")
  32. (setq load-prefer-newer t)
  33. (defalias 'yes-or-no-p 'y-or-n-p)
  34. (scroll-bar-mode 0)
  35. (tool-bar-mode 0)
  36. (menu-bar-mode 0)
  37. (delete-selection-mode 1)
  38. (column-number-mode 1))
  39. (progn ; `use-package'
  40. (require 'use-package)
  41. (setq use-package-verbose t)
  42. (setq use-package-always-defer t)
  43. (setq use-package-enable-imenu-support t))
  44. (use-package auto-compile
  45. :demand t
  46. :config
  47. (auto-compile-on-load-mode)
  48. (auto-compile-on-save-mode)
  49. (setq auto-compile-display-buffer nil)
  50. (setq auto-compile-mode-line-counter t)
  51. (setq auto-compile-source-recreate-deletes-dest t)
  52. (setq auto-compile-toggle-deletes-nonlib-dest t)
  53. (setq auto-compile-update-autoloads t)
  54. (add-hook 'auto-compile-inhibit-compile-hook
  55. 'auto-compile-inhibit-compile-detached-git-head))
  56. (use-package bash-completion
  57. :demand t
  58. :config (progn
  59. (bash-completion-setup)))
  60. (use-package custom
  61. :config
  62. (setq custom-file (expand-file-name "custom.el" user-emacs-directory))
  63. (when (file-exists-p custom-file)
  64. (load custom-file)))
  65. (use-package server
  66. :config (or (server-running-p) (server-mode)))
  67. (progn ; startup
  68. (message "Loading early birds...done (%.3fs)"
  69. (float-time (time-subtract (current-time)
  70. before-user-init-time))))
  71. ;;; Long tail
  72. (use-package abbrev
  73. :config
  74. (setq save-abbrevs 'silently)
  75. (setq-default abbrev-mode t))
  76. (use-package auth-source-pass
  77. :demand t
  78. :after auth-source
  79. :init
  80. (progn
  81. (setq auth-sources '(password-store))))
  82. (use-package autorevert
  83. :config
  84. (global-auto-revert-mode 1)
  85. ;; auto-update dired buffers
  86. (setq global-auto-revert-non-file-buffers t
  87. auto-revert-verbose nil))
  88. (use-package avy
  89. :bind (("C-c C-j" . avy-goto-char-2)
  90. ("M-g g" . avy-goto-line))
  91. :config
  92. (progn
  93. ;; Home row
  94. (setq avy-keys '(?a ?r ?s ?t ?d ?h ?n ?e ?i ?o))
  95. (setq avy-style 'at-full)
  96. (setq avy-all-windows t)))
  97. (use-package beginend
  98. :demand t
  99. :config
  100. (beginend-global-mode))
  101. (use-package browse-url
  102. :config
  103. (setq browse-url-generic-program (executable-find "nightly")))
  104. (use-package buffer-move
  105. :bind (("<s-up>" . buf-move-up)
  106. ("<s-down>" . buf-move-down)
  107. ("<s-left>" . buf-move-left)
  108. ("<s-right>" . buf-move-right)))
  109. (use-package buffer-watcher
  110. :demand t)
  111. (use-package clojure-mode
  112. :mode "\\.clj\\'")
  113. (use-package cider
  114. :after clojure-mode
  115. :init (progn
  116. (defun setup-clojure-buffer ()
  117. (eldoc-mode)
  118. (clj-refactor-mode 1)
  119. (paredit-mode 1)
  120. (setq indent-tabs-mode nil))
  121. (add-hook 'clojure-mode-hook #'setup-clojure-buffer)
  122. (add-hook 'cider-mode-hook #'cider-turn-on-eldoc-mode))
  123. :config (progn
  124. (setq cider-repl-use-clojure-font-lock t
  125. cider-repl-use-pretty-printing t
  126. cider-repl-wrap-history t
  127. cider-repl-history-size 3000)))
  128. (use-package clj-refactor
  129. :after clojure-mode
  130. :config (cljr-add-keybindings-with-prefix "C-c C-r"))
  131. (use-package company
  132. :init (progn
  133. (add-hook 'prog-mode-hook 'company-mode))
  134. :config (progn
  135. (setq company-idle-delay 0.5)
  136. (setq company-tooltip-limit 10)
  137. (setq company-minimum-prefix-length 2)
  138. (setq company-tooltip-flip-when-above t)))
  139. (use-package company-dabbrev
  140. :config (progn
  141. (setq company-dabbrev-ignore-case t)
  142. (setq company-dabbrev-downcase nil)))
  143. (use-package company-go
  144. :after go-mode
  145. :config (progn
  146. (add-to-list 'company-backends #'company-go)
  147. (setq company-go-show-annotation t)))
  148. (use-package company-nixos-options
  149. :after nix-mode
  150. :config (progn
  151. (add-to-list 'company-backends #'company-nixos-options)))
  152. (use-package compile
  153. :hook (compilation-filter . my/colorize-compilation-buffer)
  154. :config
  155. (progn
  156. ;; http://stackoverflow.com/questions/13397737
  157. (defun my/colorize-compilation-buffer ()
  158. (require 'ansi-color)
  159. (let ((inhibit-read-only t))
  160. (ansi-color-apply-on-region compilation-filter-start (point))))))
  161. (use-package counsel
  162. :demand t
  163. :bind (("M-x" . counsel-M-x)
  164. ("C-x C-f" . counsel-find-file)
  165. ("M-i" . counsel-imenu)
  166. ("M-y" . counsel-yank-pop))
  167. :init (progn
  168. (setq counsel-linux-app-format-function
  169. #'counsel-linux-app-format-function-name-only)))
  170. (use-package dabbrev
  171. :bind (("S-SPC" . dabbrev-expand)))
  172. (use-package dash
  173. :config (dash-enable-font-lock))
  174. (use-package diff-hl
  175. :hook ((prog-mode . diff-hl-mode)
  176. (magit-post-refresh . diff-hl-magit-post-refresh)))
  177. (use-package direnv
  178. :config (progn
  179. (direnv-mode)
  180. (setq direnv-always-show-summary nil)))
  181. (use-package dired
  182. :bind (:map dired-mode-map
  183. ("M-s" . find-name-dired)
  184. ("C-k" . dired-kill-subdir))
  185. :init (progn
  186. (add-hook 'dired-mode-hook #'dired-hide-details-mode))
  187. :config (progn
  188. (setq dired-listing-switches "-alh")
  189. (setq dired-dwim-target t)
  190. (put 'dired-find-alternate-file 'disabled nil)))
  191. (use-package dired-du
  192. :after dired)
  193. (use-package dired-x
  194. :demand t
  195. :after dired
  196. :init (progn
  197. (add-hook 'dired-mode-hook #'dired-omit-mode))
  198. :config (progn
  199. (setq dired-omit-files "^\\...+$")))
  200. (use-package drag-stuff
  201. :demand t
  202. :config (progn
  203. (drag-stuff-global-mode t)
  204. (drag-stuff-define-keys)
  205. (add-to-list 'drag-stuff-except-modes 'org-mode)
  206. (add-to-list 'drag-stuff-except-modes 'rebase-mode)
  207. (add-to-list 'drag-stuff-except-modes 'emacs-lisp-mode)))
  208. (use-package duplicate-thing
  209. :bind ("M-D" . duplicate-thing))
  210. (use-package ediff
  211. :config (progn
  212. ;; window positioning & frame setup
  213. (setq ediff-window-setup-function 'ediff-setup-windows-plain
  214. ediff-split-window-function 'split-window-horizontally)))
  215. (use-package editorconfig
  216. :demand t
  217. :init (editorconfig-mode 1))
  218. (use-package elbank)
  219. (use-package eldoc
  220. :config (global-eldoc-mode))
  221. (use-package elec-pair
  222. :demand t
  223. :config (electric-pair-mode t))
  224. (use-package electric
  225. :demand t
  226. :config (electric-indent-mode t))
  227. (use-package elisp-mode
  228. :hook (emacs-lisp-mode . (lambda () (setq indent-tabs-mode nil))))
  229. (use-package embrace
  230. :bind (("C-c e" . embrace-commander))
  231. :hook (emacs-lisp-mode . embrace-emacs-lisp-mode-hook))
  232. (use-package erc
  233. :init (progn
  234. (setq erc-nick "NicolasPetton"
  235. erc-autojoin-channels-alist '(("freenode.net" . ("#emacs"))))))
  236. (use-package esh-mode
  237. :hook (eshell-mode . my/configure-esh-mode)
  238. :config
  239. (progn
  240. ;; We can't use use-package's :bind here as eshell insists on
  241. ;; recreating a fresh eshell-mode-map for each new eshell buffer.
  242. (defun my/configure-esh-mode ()
  243. (bind-key "M-p" #'counsel-esh-history eshell-mode-map))))
  244. (use-package em-cmpl
  245. :hook (eshell-mode . eshell-cmpl-initialize))
  246. (use-package em-smart
  247. :hook (eshell-mode . eshell-smart-initialize)
  248. :config
  249. (progn
  250. (add-to-list 'eshell-smart-display-navigate-list #'counsel-esh-history)))
  251. (use-package em-term
  252. :config
  253. (progn
  254. (nconc eshell-visual-subcommands
  255. '(("docker" "build")
  256. ("git" "log" "diff" "show")
  257. ("npm" "init" "install")
  258. ("yarn" "init" "install")))
  259. (add-to-list 'eshell-command-completions-alist
  260. '("gunzip" "gz\\'"))
  261. (add-to-list 'eshell-command-completions-alist
  262. '("tar" "\\(\\.tar|\\.tgz\\|\\.tar\\.gz\\)\\'"))
  263. (setenv "PAGER" "cat")
  264. (setenv "SUDO_ASKPASS" (executable-find "pass-root-password.sh"))))
  265. (use-package pcomplete
  266. :config (progn
  267. (defvar pcomplete-man-user-commands
  268. (split-string
  269. (shell-command-to-string
  270. "apropos -s 1 .|while read -r a b; do echo \" $a\";done;"))
  271. "p-completion candidates for `man' command")
  272. (defun pcomplete/man ()
  273. "Completion rules for the `man' command."
  274. (pcomplete-here pcomplete-man-user-commands))))
  275. (use-package pcmpl-git
  276. :after pcomplete)
  277. (use-package expand-region
  278. :bind (("C-=" . er/expand-region)))
  279. (use-package flycheck
  280. :commands (flycheck-mode)
  281. :init (add-hook 'prog-mode-hook #'flycheck-mode))
  282. (use-package flyspell
  283. :bind (:map flyspell-mode-map
  284. ("C-;" . nil))
  285. :init (progn
  286. ;; (add-hook 'prog-mode-hook #'flyspell-prog-mode)
  287. (dolist (mode-hook '(text-mode-hook org-mode-hook LaTeX-mode-hook))
  288. (add-hook mode-hook #'flyspell-mode))))
  289. (use-package flyspell-correct-ivy
  290. :bind* (("C-." . flyspell-correct-word-generic)))
  291. (use-package go-eldoc
  292. :after go-mode
  293. :hook (go-mode . setup-go-mode)
  294. :config (progn
  295. (defun setup-go-mode ()
  296. (add-hook 'before-save-hook #'gofmt nil t)
  297. (go-eldoc-setup))))
  298. (use-package go-mode
  299. :bind (:map go-mode-map
  300. ("M-." . godef-jump)
  301. ("C-c d" . godoc-at-point))
  302. :init (progn
  303. (add-to-list 'exec-path (format "%s/.local/share/go/bin" (getenv "HOME")))
  304. (setenv "GOPATH" (format "%s/.local/share/go" (getenv "HOME")))))
  305. (use-package gnus-dired
  306. :bind (:map gnus-dired-mode-map
  307. ("C-x C-a" . gnus-dired-attach))
  308. :config (add-hook 'dired-mode-hook #'turn-on-gnus-dired-mode))
  309. (use-package help
  310. :config (temp-buffer-resize-mode))
  311. (use-package helpful
  312. :bind (("C-h ." . helpful-at-point)
  313. ("C-h k" . helpful-key)
  314. ("C-h v" . helpful-variable)
  315. ("C-h f" . helpful-callable)))
  316. (use-package ibuffer
  317. :bind (("C-x C-b" . ibuffer)))
  318. ;; Fix dead characters
  319. (use-package iso-transl
  320. :demand t)
  321. (use-package ispell
  322. :config
  323. (defun ispell-word-then-abbrev (p)
  324. "Call `ispell-word', then create an abbrev for it.
  325. With prefix P, create local abbrev. Otherwise it will
  326. be global."
  327. (interactive "P")
  328. (let (bef aft)
  329. (save-excursion
  330. (while (progn
  331. (backward-word)
  332. (and (setq bef (thing-at-point 'word))
  333. (not (ispell-word nil 'quiet)))))
  334. (setq aft (thing-at-point 'word)))
  335. (when (and aft bef (not (equal aft bef)))
  336. (setq aft (downcase aft))
  337. (setq bef (downcase bef))
  338. (define-abbrev
  339. (if p local-abbrev-table global-abbrev-table)
  340. bef aft)
  341. (write-abbrev-file)
  342. (message "\"%s\" now expands to \"%s\" %sally"
  343. bef aft (if p "loc" "glob")))))
  344. (define-key ctl-x-map "\C-i" #'ispell-word-then-abbrev))
  345. (use-package ivy
  346. :demand t
  347. :bind (("C-c r" . ivy-resume))
  348. :config (progn
  349. (ivy-mode 1)
  350. (setq ivy-use-virtual-buffers t)
  351. (setq ivy-count-format "(%d/%d) ")
  352. (setq ivy-use-selectable-prompt t)))
  353. (progn ; `isearch'
  354. (setq isearch-allow-scroll t))
  355. (use-package js2-mode
  356. :mode "\\.js\\'"
  357. :config (progn
  358. (define-key js2-mode-map (kbd "C-c C-o") nil))
  359. :config
  360. (defun js2-show-node-at-point ()
  361. (interactive)
  362. (js2-show-node (js2-node-at-point)))
  363. (defun js2-show-node-parent-at-point ()
  364. (interactive)
  365. (js2-show-node (js2-node-parent (js2-node-at-point))))
  366. (defun js2-show-node (node)
  367. (let* ((buf (get-buffer-create "*js2-node-at-point*"))
  368. (node-contents (buffer-substring (js2-node-abs-pos node) (js2-node-abs-end node))))
  369. (with-current-buffer
  370. (set-buffer buf)
  371. (delete-region (point-min) (point-max))
  372. (insert node-contents)))))
  373. (use-package emacs-js
  374. :commands (setup-js-buffer)
  375. :init
  376. (progn
  377. (add-hook 'js-mode-hook #'setup-js-buffer)))
  378. (use-package finsit-bugref
  379. :demand t
  380. :config
  381. (progn
  382. (finsit-bugref-setup)))
  383. (use-package finsit-prodigy
  384. :demand t
  385. :after prodigy
  386. :config (progn
  387. (finsit-prodigy-setup)))
  388. (use-package finsit-elcouch
  389. :demand t
  390. :after elcouch
  391. :config
  392. (progn
  393. (finsit-elcouch-setup)))
  394. (use-package finsit-basecamp
  395. :demand t
  396. :config
  397. (progn
  398. (finsit-basecamp-setup)))
  399. (use-package finsit-magit
  400. :demand t
  401. :after magit
  402. :config
  403. (progn
  404. (finsit-magit-setup)))
  405. (use-package finsit-prodigy
  406. :demand t
  407. :after prodigy)
  408. (use-package finsit-yasnippet
  409. :demand t
  410. :after yasnippet
  411. :config
  412. (progn
  413. (finsit-yasnippet-setup)))
  414. (use-package klassified
  415. :init (add-hook 'js2-mode-hook #'klassified-interaction-js-mode))
  416. (use-package less-css-mode)
  417. (use-package lisp-mode
  418. :config
  419. (add-hook 'emacs-lisp-mode-hook 'outline-minor-mode)
  420. (defun indent-spaces-mode ()
  421. (setq indent-tabs-mode nil))
  422. (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode))
  423. (use-package magit
  424. :bind (("C-x g" . magit-status)
  425. ("C-x M-g" . magit-dispatch-popup)
  426. :map magit-mode-map
  427. ("C" . magit-commit-add-log))
  428. :config (progn
  429. ;; (magit-add-section-hook 'magit-status-sections-hook
  430. ;; 'magit-insert-modules
  431. ;; 'magit-insert-unpulled-from-upstream)
  432. (magit-define-popup-action 'magit-commit-popup
  433. ?x "Absorb" #'magit-commit-absorb-popup)
  434. (setq magit-branch-prefer-remote-upstream '("master"))
  435. (setq magit-branch-adjust-remote-upstream-alist '(("origin/master" "master")))
  436. (setq magit-branch-arguments nil)))
  437. (use-package man
  438. :config (setq Man-width 80))
  439. (use-package multiple-cursors
  440. :bind (("M-RET" . mc/edit-lines)
  441. ("C-<" . mc/mark-previous-like-this)
  442. ("C->" . mc/mark-next-like-this)
  443. ("C-M-<" . mc/unmark-next-like-this)
  444. ("C-M->" . mc/unmark-previous-like-this)
  445. ("C-c C-<" . mc/mark-all-like-this)))
  446. (use-package nix-mode
  447. :config (progn
  448. (defun nixfmt-fix ()
  449. (interactive)
  450. (when (executable-find "nixfmt")
  451. (let ((point (point)))
  452. (unwind-protect
  453. (call-process-region (point-min) (point-max) "nixfmt" t t)
  454. (goto-char point)))))
  455. (define-minor-mode nixfmt-fix-mode
  456. "Use nixfmt to automatically format nix files."
  457. :lighter " nixfmt"
  458. (if nixfmt-fix-mode
  459. (add-hook 'before-save-hook #'nixfmt-fix nil t)
  460. (remove-hook 'before-save-hook #'nixfmt-fix t))))
  461. :hook (nix-mode . nixfmt-fix-mode))
  462. (use-package no-littering
  463. :demand t
  464. :config (progn
  465. (require 'recentf)
  466. (add-to-list 'recentf-exclude no-littering-var-directory)
  467. (add-to-list 'recentf-exclude no-littering-etc-directory)
  468. (setq delete-old-versions t
  469. kept-new-versions 6
  470. kept-old-versions 2
  471. version-control t)
  472. (setq backup-directory-alist
  473. `((".*" . ,(no-littering-expand-var-file-name "backup/"))))
  474. (setq auto-save-file-name-transforms
  475. `((".*" ,(no-littering-expand-var-file-name "auto-save/") t)))
  476. (setq create-lockfiles nil)))
  477. (use-package nov
  478. :mode ("\\.epub\\'" . nov-mode)
  479. :config (progn
  480. (defun my-nov-font-setup ()
  481. (face-remap-add-relative 'variable-pitch
  482. :family "Gentium Book Basic"
  483. :height 1.3))
  484. (add-hook 'nov-mode-hook 'my-nov-font-setup)
  485. (setq nov-text-width 62)))
  486. (use-package omnisharp
  487. :after csharp-mode
  488. :bind (:map omnisharp-mode-map
  489. ("C-c r" . omnisharp-run-code-action-refactoring)
  490. ("M-." . omnisharp-go-to-definition)
  491. ;; ("M-." . omnisharp-find-implementations)
  492. ("M-?" . omnisharp-find-usages))
  493. :hook ((omnisharp-mode . configure-omnisharp)
  494. (csharp-mode . omnisharp-mode))
  495. :config
  496. (progn
  497. (add-to-list 'company-backends #'company-omnisharp)
  498. (setq omnisharp-imenu-support t)
  499. (defun configure-omnisharp ()
  500. (local-set-key (kbd "C-c C-c") #'recompile))))
  501. (use-package csharp-mode
  502. :hook ((csharp-mode . configure-csharp))
  503. :config (progn
  504. (defun configure-csharp ()
  505. (setq indent-tabs-mode nil)
  506. (setq c-syntactic-indentation t)
  507. (c-set-style "ellemtel")
  508. (setq c-basic-offset 4)
  509. (setq truncate-lines t)
  510. (setq tab-width 4))))
  511. (use-package open-url-at-point
  512. :bind ("C-c C-o" . open-url-at-point))
  513. (use-package ox-twbs
  514. :demand t
  515. :after org)
  516. (use-package paredit
  517. :demand t
  518. :bind (:map paredit-mode-map
  519. ("M-s" . nil))
  520. :config
  521. (add-hook 'emacs-lisp-mode-hook #'paredit-mode)
  522. (add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode))
  523. (use-package paren
  524. :demand t
  525. :config (show-paren-mode))
  526. (use-package pass
  527. :mode ("org/reference/password-store/" . pass-view-mode)
  528. :bind ("C-x p" . pass)
  529. :config (progn
  530. (add-to-list 'auto-mode-alist '("\\<password-store\\>/.*\\.gpg\\'" . pass-view-mode))))
  531. (use-package pdf-tools
  532. :demand t
  533. :bind (:map pdf-view-mode-map
  534. ("C-s" . isearch-forward))
  535. :config (progn
  536. (pdf-tools-install)))
  537. (use-package counsel-projectile
  538. :demand t
  539. :after projectile
  540. :config (progn
  541. (counsel-projectile-mode)
  542. (define-key projectile-mode-map
  543. [remap projectile-ag]
  544. #'counsel-projectile-rg)))
  545. (use-package projectile
  546. :demand t
  547. :bind (:map projectile-mode-map
  548. ("C-c p" . projectile-command-map))
  549. :config (progn
  550. (projectile-mode)
  551. (projectile-register-project-type
  552. 'monitor
  553. '("gulpfile.js")
  554. :compile "cd ~/work/ftgp/monitor/monitor/Monitor.Web.Ui/Client && gulp lint"
  555. :test "cd ~/work/ftgp/monitor/monitor/Monitor.Web.Ui/Client && gulp karma"
  556. :test-suffix "-tests")))
  557. (use-package prog-mode
  558. :config (progn
  559. (global-prettify-symbols-mode)
  560. (defun indicate-buffer-boundaries-left ()
  561. (setq indicate-buffer-boundaries 'left))
  562. (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left)))
  563. (use-package quelpa
  564. :config (progn
  565. (setq quelpa-upgrade-p nil)
  566. (add-to-list 'quelpa-melpa-recipe-stores "~/.emacs.d/etc/quelpa/recipes/")))
  567. (use-package rainbow-mode
  568. :init (progn
  569. (add-hook 'css-mode-hook 'rainbow-mode)
  570. (add-hook 'less-mode-hook 'rainbow-mode)))
  571. (use-package recentf
  572. :demand t
  573. :init
  574. (progn
  575. (setq recentf-auto-cleanup 300)
  576. (setq recentf-max-saved-items 4000))
  577. :config
  578. (progn
  579. (add-to-list 'recentf-exclude "^/\\(?:ssh\\|su\\|sudo\\)?:")
  580. (recentf-mode)))
  581. (use-package company-restclient
  582. :after restclient
  583. :config (progn
  584. (add-to-list 'company-backend 'company-restclient)
  585. (add-hook 'restclient-mode-hook #'company-mode-on)))
  586. (use-package savehist
  587. :config (savehist-mode))
  588. (use-package saveplace
  589. :config (save-place-mode))
  590. (use-package shell-switcher
  591. :bind (("C-'" . shell-switcher-switch-buffer)
  592. ("C-M-'" . shell-switcher-new-shell))
  593. :config (progn
  594. (setq shell-switcher-new-shell-function #'vterm)))
  595. (use-package simple
  596. :config (column-number-mode))
  597. (use-package subword
  598. :init (global-subword-mode))
  599. (use-package swiper
  600. :bind (("C-s" . swiper-isearch)))
  601. (use-package tabify
  602. :config
  603. (defun tabify-buffer ()
  604. (interactive)
  605. (tabify (point-min) (point-max)))
  606. (defun untabify-buffer ()
  607. (interactive)
  608. (untabify (point-min) (point-max))))
  609. (use-package term
  610. :bind (
  611. :map term-mode-map
  612. ("C-c C-t" . my/term-toggle-line-mode)
  613. :map term-raw-map
  614. ("C-c C-t" . my/term-toggle-line-mode))
  615. :init (progn
  616. (defun my/term-toggle-line-mode ()
  617. "Toggle between char and line modes."
  618. (interactive)
  619. (if (term-in-char-mode)
  620. (term-line-mode)
  621. (term-char-mode)))))
  622. (progn ; `text-mode'
  623. (add-hook 'text-mode-hook #'indicate-buffer-boundaries-left))
  624. (use-package time-stamp
  625. :init (progn
  626. (defvar-local time-stamp-target nil
  627. "File in which time-stamps should be written.")
  628. (put 'time-stamp-target 'safe-local-variable 'string-or-null-p)
  629. (defun time-stamp-target ()
  630. "Update the time-stamp in `time-stamp-target' if non-nil."
  631. (when (and time-stamp-target
  632. (file-exists-p time-stamp-target))
  633. (with-current-buffer (find-file-noselect time-stamp-target)
  634. (time-stamp))))))
  635. (use-package tramp
  636. :config (progn
  637. (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
  638. (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
  639. (add-to-list 'tramp-default-proxies-alist
  640. (list (regexp-quote (system-name)) nil nil))))
  641. (use-package transmission
  642. :config (progn
  643. (defun transmission-add-magnet (url)
  644. "Like `transmission-add', but with no file completion."
  645. (interactive "sMagnet url: ")
  646. (transmission-add url))))
  647. (use-package uniquify
  648. :config
  649. (setq uniquify-buffer-name-style 'forward))
  650. (use-package url-vars
  651. :init
  652. (progn
  653. (setq url-privacy-level 'high)))
  654. (use-package web-mode
  655. :init (progn
  656. (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
  657. (add-to-list 'auto-mode-alist '("\\.htm\\'" . web-mode))
  658. (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
  659. (add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
  660. (add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
  661. (add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
  662. (add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
  663. (add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
  664. (add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode)))
  665. (setq web-mode-css-indent-offset 2))
  666. (use-package whitespace
  667. :config
  668. (setq whitespace-display-mappings
  669. '(
  670. (space-mark 32 [183] [46]) ; normal space, ·
  671. (space-mark 160 [164] [95])
  672. (space-mark 2208 [2212] [95])
  673. (space-mark 2336 [2340] [95])
  674. (space-mark 3616 [3620] [95])
  675. (space-mark 3872 [3876] [95])
  676. (newline-mark 10 [182 10]) ; newlne, ¶
  677. (tab-mark 9 [9655 9] [92 9]) ; tab, ▷
  678. )))
  679. (progn ;; `window'
  680. (bind-key "C-;" #'other-window))
  681. (use-package winner
  682. :bind (("C-|". winner-undo)))
  683. (use-package workflow
  684. :commands (work-clock-out
  685. work-back-from-lunch
  686. work-coffee
  687. work-start
  688. work-stop
  689. work-lunch
  690. work-clock-in
  691. work-send-weekly-email))
  692. (use-package ws-butler
  693. :init
  694. (add-hook 'prog-mode-hook #'ws-butler-mode))
  695. (use-package yasnippet
  696. :demand t
  697. :init (progn
  698. (yas-global-mode)))
  699. (use-package zerodark-theme
  700. :demand t
  701. :config
  702. (progn
  703. (defun set-selected-frame-dark ()
  704. (interactive)
  705. (let ((frame-name (cdr (assq 'name (frame-parameters (selected-frame))))))
  706. (call-process-shell-command
  707. (format
  708. "xprop -f _GTK_THEME_VARIANT 8u -set _GTK_THEME_VARIANT 'dark' -name '%s'"
  709. frame-name))))
  710. (when (window-system)
  711. (load-theme 'zerodark t)
  712. (zerodark-setup-modeline-format)
  713. (set-selected-frame-dark)
  714. (setq frame-title-format '(buffer-file-name "%f" ("%b"))))))
  715. (use-package minions
  716. :demand t
  717. :config (unless minions-mode
  718. (minions-mode)))
  719. (use-package zoom-frm
  720. :bind (("C-+" . zoom-frm-in)
  721. ("C--" . zoom-frm-out)))
  722. (progn ; startup
  723. (message "Loading %s...done (%.3fs)" user-init-file
  724. (float-time (time-subtract (current-time)
  725. before-user-init-time)))
  726. (add-hook 'after-init-hook
  727. (lambda ()
  728. (message
  729. "Loading %s...done (%.3fs) [after-init]" user-init-file
  730. (float-time (time-subtract (current-time)
  731. before-user-init-time))))
  732. t))
  733. (progn ; local packages
  734. (let ((dir (expand-file-name "local" user-emacs-directory)))
  735. (when (file-exists-p dir)
  736. (add-to-list 'load-path dir))))
  737. (progn ; personalize
  738. (let ((file (expand-file-name (concat (user-real-login-name) ".el")
  739. user-emacs-directory)))
  740. (when (file-exists-p file)
  741. (load file))))
  742. (progn ; host-specific setup
  743. (let* ((host (substring (shell-command-to-string "hostname") 0 -1))
  744. (host-dir (concat "~/.emacs.d/hosts/" host))
  745. (host-file (expand-file-name "init.el" host-dir)))
  746. (when (file-exists-p host-dir)
  747. (let ((default-directory host-dir))
  748. (add-to-list 'load-path host-dir)
  749. (normal-top-level-add-subdirs-to-load-path)))
  750. (when (file-exists-p host-file)
  751. (load host-file))))
  752. (progn ; private modules
  753. (let ((private-dir "~/.priv/elisp"))
  754. (when (file-exists-p private-dir)
  755. (add-to-list 'load-path private-dir)
  756. (require 'private-modules nil t))))
  757. ;; display line numbers in buffers visiting a file
  758. ;; (dolist (mode-hook '(prog-mode-hook text-mode-hook))
  759. ;; (add-hook mode-hook (lambda ()
  760. ;; (when buffer-file-name
  761. ;; (setq display-line-numbers t)))))
  762. (defun goto-line-with-line-numbers ()
  763. (interactive)
  764. (let ((display-line-numbers t))
  765. (call-interactively #'goto-line)))
  766. (global-set-key [remap goto-line] #'goto-line-with-line-numbers)
  767. ;; Local Variables:
  768. ;; indent-tabs-mode: nil
  769. ;; eval: (flycheck-mode -1)
  770. ;; no-byte-compile: t
  771. ;; End:
  772. ;;; init.el ends here