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.

932 lines
27 KiB

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