source: dotfiles/emacs/.emacs@ c39b1a4

Last change on this file since c39b1a4 was c39b1a4, checked in by Mikhail Kirillov <w96k.ru@…>, on Aug 30, 2019 at 1:47:39 AM

Add gnu stow categories

  • Property mode set to 100644
File size: 15.0 KB
Line 
1;;;; My config for Emacs that I use in day-to-day work
2;;;;
3;;;; https://w96k.com/
4;;;; 2018-2019 (c) Mikhail w96k Kirillov
5
6;;;; INIT
7
8;;; Add Melpa repository +
9;;; Load use-package & enable installing all packages by default
10;;; You need to manually install use-package from melpa
11;;; (it's the only package you need to install manually)
12;;; Rest packages will be installed automatically
13;;;
14;;; You need to have "INIT" section and execute:
15;;; M-x package-install RET use-package RET
16
17(eval-when-compile
18 ;; increase GC-limit up to 100M for boot speedup
19 (setq gc-cons-threshold 500000000)
20
21 ;;; Disable emacs gui
22 (menu-bar-mode -1)
23 (scroll-bar-mode -1)
24 (tool-bar-mode -1)
25 (tooltip-mode -1)
26
27 (require 'package)
28
29 (setq package-archives
30 '(("gnu" . "http://elpa.gnu.org/packages/")
31 ("melpa" . "http://melpa.org/packages/")))
32
33 (package-initialize)
34
35 ;; restore GC-limit after timeout
36 (run-with-idle-timer
37 15 nil
38 (lambda ()
39 (setq gc-cons-threshold 100000)))
40
41 ;; Optimize loading
42 (setq load-prefer-newer t
43 package-user-dir "~/.emacs.d/elpa"
44 package--init-file-ensured t
45 package-enable-at-startup nil)
46
47 (require 'use-package))
48
49(use-package use-package
50 :defer nil
51 :config
52 (setq use-package-verbose t)
53 (setq use-package-always-defer t)
54 (setq use-package-always-ensure nil))
55
56(use-package use-package-ensure-system-package :ensure)
57
58;;;; VISUALS
59
60;;; Display numbers
61(global-display-line-numbers-mode)
62
63;; Display whitespace
64(global-whitespace-mode)
65
66;;; Set font
67(set-frame-font "Terminus" nil t)
68
69;;; Display current line
70(global-hl-line-mode)
71
72;;; Set Theme
73(use-package color-theme-sanityinc-tomorrow
74 :demand
75 :if window-system
76 :config (load-theme 'sanityinc-tomorrow-eighties t))
77
78;;; Powerline
79(use-package powerline
80 :demand
81 :config (powerline-default-theme))
82
83;;; Bullets for org-mode
84(use-package org-bullets
85 :ensure t
86 :commands org-bullets-mode
87 :hook (org-mode . org-bullets-mode))
88
89;;;; EDITING
90
91
92;;; Easy undo system
93(use-package undo-tree
94 :after general
95 :commands
96 (global-undo-tree-mode)
97 :init
98 (setq
99 undo-tree-visualizer-timestamps t
100 undo-tree-enable-undo-in-region nil
101 undo-tree-history-directory-alist
102 `(("." . ,(expand-file-name "undo" user-emacs-directory))))
103 :config
104 (global-undo-tree-mode)
105 :diminish undo-tree-mode)
106
107;;; Jump to defenition
108(use-package dumb-jump
109 :bind (("M-g o" . dumb-jump-go-other-window)
110 ("M-g j" . dumb-jump-go)
111 ("M-g i" . dumb-jump-go-prompt)
112 ("M-g x" . dumb-jump-go-prefer-external)
113 ("M-g z" . dumb-jump-go-prefer-external-other-window))
114 :config (setq dumb-jump-selector 'ivy) ;; (setq dumb-jump-selector 'helm)
115 :ensure)
116
117(progn
118 (show-paren-mode))
119
120;;; Edit with root user
121(use-package sudo-edit)
122
123;;; Look eslint config
124(defun my/use-eslint-from-node-modules ()
125 (let* ((root (locate-dominating-file
126 (or (buffer-file-name) default-directory)
127 "node_modules"))
128 (eslint
129 (and root
130 (expand-file-name "node_modules/.bin/eslint"
131 root))))
132 (when (and eslint (file-executable-p eslint))
133 (setq-local flycheck-javascript-eslint-executable eslint))))
134
135;;; Live-checking text
136(use-package flycheck
137 :config
138 (add-hook 'after-init-hook #'global-flycheck-mode)
139 (add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
140 (setq-default flycheck-disabled-checkers
141 (append flycheck-disabled-checkers
142 '(javascript-jshint)))
143 (flycheck-add-mode 'javascript-eslint 'web-mode)
144 (setq-default flycheck-temp-prefix ".flycheck"))
145
146;;; No tabs
147(setq-default indent-tabs-mode nil)
148
149;;; Version control
150(use-package magit
151 :defer 2
152 :bind ("C-x g" . magit-status)
153 :config (setq magit-refresh-status-buffer nil))
154
155;;; Magit' github integration
156(use-package magithub
157 :after magit)
158
159;;; Git flow
160(use-package magit-gitflow
161 :after magit
162 :init (add-hook 'magit-mode-hook 'turn-on-magit-gitflow))
163
164;;; Show added & removed git lines
165(use-package git-gutter+
166 :ensure t
167 :init (global-git-gutter+-mode)
168 :config (progn
169 (define-key git-gutter+-mode-map (kbd "C-x n") 'git-gutter+-next-hunk)
170 (define-key git-gutter+-mode-map (kbd "C-x p") 'git-gutter+-previous-hunk)
171 (define-key git-gutter+-mode-map (kbd "C-x v =") 'git-gutter+-show-hunk)
172 (define-key git-gutter+-mode-map (kbd "C-x r") 'git-gutter+-revert-hunks)
173 (define-key git-gutter+-mode-map (kbd "C-x t") 'git-gutter+-stage-hunks)
174 (define-key git-gutter+-mode-map (kbd "C-x c") 'git-gutter+-commit)
175 (define-key git-gutter+-mode-map (kbd "C-x C") 'git-gutter+-stage-and-commit)
176 (define-key git-gutter+-mode-map (kbd "C-x C-y") 'git-gutter+-stage-and-commit-whole-buffer)
177 (define-key git-gutter+-mode-map (kbd "C-x U") 'git-gutter+-unstage-whole-buffer))
178 :diminish (git-gutter+-mode . "gg"))
179
180;;; Autoformatting code
181(use-package aggressive-indent
182 :config (global-aggressive-indent-mode))
183
184;;; 80 column width limit highlighter
185(use-package column-enforce-mode
186 :defer t
187 :diminish
188 :config (80-column-rule)
189 :hook (prog-mode . column-enforce-mode))
190
191;;; General autocomplete
192(use-package ivy
193 :demand
194 :diminish
195 :config
196 (ivy-mode)
197 (setq ivy-use-virtual-buffers t)
198 (setq enable-recursive-minibuffers t)
199 (global-set-key "\C-s" 'swiper)
200 (global-set-key (kbd "C-c C-r") 'ivy-resume)
201 (global-set-key (kbd "<f6>") 'ivy-resume))
202
203(use-package counsel
204 :demand
205 :config
206 (global-set-key (kbd "M-x") 'counsel-M-x)
207 (global-set-key (kbd "C-x C-f") 'counsel-find-file)
208 (global-set-key (kbd "<f1> f") 'counsel-describe-function)
209 (global-set-key (kbd "<f1> v") 'counsel-describe-variable)
210 (global-set-key (kbd "<f1> l") 'counsel-find-library)
211 (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
212 (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
213 (global-set-key (kbd "C-c g") 'counsel-git)
214 (global-set-key (kbd "C-c j") 'counsel-git-grep)
215 (global-set-key (kbd "C-x b") 'counsel-ibuffer)
216 (global-set-key (kbd "C-c k") 'counsel-ag)
217 (global-set-key (kbd "C-x l") 'counsel-locate)
218 (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
219 (define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history))
220
221(use-package ivy-hydra)
222
223(use-package company
224 :demand
225 :diminish
226 :custom
227 (company-require-match nil)
228 (company-minimum-prefix-length 1)
229 (company-idle-delay 0.1)
230 (company-tooltip-align-annotation t)
231 :hook ((prog-mode . company-mode))
232 :config
233 (add-hook 'after-init-hook 'global-company-mode)
234 :bind (:map company-active-map
235 ("C-n" . company-select-next)
236 ("C-p" . company-select-previous)))
237
238;;;; LANGUAGES
239
240;;; Vue
241(use-package vue-mode
242 :config (setq mmm-submode-decoration-level 0))
243
244;;; PHP
245(use-package php-mode)
246
247;;; Templates
248(use-package web-mode
249 :config
250 (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
251 ())
252
253;;; Javascript
254(use-package js2-mode
255 :config
256 (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
257 (setq-default js2-basic-offset 2)
258 (add-hook 'js2-mode-hook
259 (lambda ()
260 (define-key js-mode-map (kbd "C-x C-e") 'nodejs-repl-send-last-expression)
261 (define-key js-mode-map (kbd "C-c C-j") 'nodejs-repl-send-line)
262 (define-key js-mode-map (kbd "C-c C-r") 'nodejs-repl-send-region)
263 (define-key js-mode-map (kbd "C-c C-l") 'nodejs-repl-load-file)
264 (define-key js-mode-map (kbd "C-c C-z") 'nodejs-repl-switch-to-repl))))
265
266;;; Eslint
267(use-package eslint-fix
268 :ensure-system-package (eslint . "npm install -g eslint")
269 :config
270 (eval-after-load 'js2-mode
271 '(add-hook 'js2-mode-hook (lambda () (add-hook 'after-save-hook 'eslint-fix nil t)))))
272
273(use-package json-mode)
274
275(use-package rjsx-mode
276 :config
277 (add-to-list 'auto-mode-alist '(".*\.js\'" . rjsx-mode)))
278
279;;; Yasnippet
280(use-package yasnippet
281 :demand
282 :diminish
283 :config (yas-global-mode 1))
284
285(use-package yasnippet-snippets
286 :diminish
287 :after yasnippet)
288
289;;; LSP
290(use-package lsp-mode
291 :hook
292 (ruby-mode . lsp)
293 (javascript-mode . lsp)
294 (vue-mode . lsp)
295 :commands lsp)
296
297;;; LSP Flycheck
298(use-package lsp-ui
299 :after (lsp-mode)
300 :hook lsp-mode
301 :commands lsp-ui-mode)
302
303(use-package company-lsp
304 :after (lsp-mode lsp-ui)
305 :commands company-lsp)
306
307;;; Debugger
308(use-package dap-mode
309 :config
310 (dap-mode 1)
311 (dap-ui-mode 1))
312
313;;; Ruby On Rails
314(use-package rinari)
315
316;;; Node.js Repl
317(use-package nodejs-repl)
318
319;;; Haskell support
320(use-package intero
321 :config (add-hook 'haskell-mode-hook 'intero-mode))
322
323;;; Typescript support
324(use-package typescript-mode)
325
326(use-package tide
327 :ensure t
328 :diminish
329 :after (typescript-mode company flycheck)
330 :hook ((typescript-mode . tide-setup)
331 (typescript-mode . tide-hl-identifier-mode)
332 (before-save . tide-format-before-save)))
333
334;;; Clojure REPL
335(use-package cider)
336
337;;;; MISC
338
339(use-package exec-path-from-shell
340 :config
341 (when (memq window-system '(mac ns x))
342 (exec-path-from-shell-initialize)
343 (exec-path-from-shell-copy-env "PATH")))
344
345;; Kill whole line
346(global-set-key (kbd "C-u") 'kill-whole-line)
347
348;;; Volume management using thinkpad volume buttons
349(use-package volume
350 :config
351 (global-set-key (kbd "<XF86AudioRaiseVolume>") 'volume-raise-10)
352 (global-set-key (kbd "<XF86AudioLowerVolume>") 'volume-lower-10))
353
354;;; Screenshot
355(use-package frameshot
356 :config (frameshot-setup
357 '((name . "w96k")
358 (height . 800)
359 (width . 1280))))
360
361;;; Change Move to end & beginning of the line behavior
362(use-package mvim
363 :config
364 (global-set-key (kbd "C-a") 'mwim-beginning)
365 (global-set-key (kbd "C-e") 'mwim-end))
366
367(use-package command-log-mode)
368
369;;; Benchmark init
370(use-package benchmark-init
371 :demand
372 :ensure t
373 :config
374 ;; To disable collection of benchmark data after init is done.
375 (add-hook 'after-init-hook 'benchmark-init/deactivate))
376
377;;; Bug-Tracker DebBugs
378(use-package debbugs)
379
380;;; Icons
381(use-package all-the-icons)
382
383;;; Icons for dired
384(use-package all-the-icons-dired
385 :diminish
386 :after all-the-icons
387 :config
388 (add-hook 'dired-mode-hook 'all-the-icons-dired-mode))
389
390;;; Sidebar File-Manager
391(use-package dired-sidebar
392 :after exwm
393 :bind (("C-x C-n" . dired-sidebar-toggle-sidebar))
394 :diminish
395 :after all-the-icons
396 :commands (dired-sidebar-toggle-sidebar)
397 :init
398 (add-hook 'dired-sidebar-mode-hook
399 (lambda ()
400 (unless (file-remote-p default-directory)
401 (auto-revert-mode))))
402 :config
403 (push 'toggle-window-split dired-sidebar-toggle-hidden-commands)
404 (push 'rotate-windows dired-sidebar-toggle-hidden-commands)
405 (setq dired-sidebar-subtree-line-prefix "__")
406 (setq dired-sidebar-use-term-integration t)
407 (setq dired-sidebar-use-custom-font t))
408
409;;; Manage docker in emacs
410(use-package docker
411 :bind ("C-c d" . docker))
412
413;;; hide some minor modes
414(use-package diminish
415 :demand)
416
417;;; org
418(use-package org
419 :config
420 (setq org-todo-keywords
421 (quote ((sequence "TODO(t)" "MIGRATE(m)" "|" "DONE(d)")
422 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
423 (setq org-todo-keyword-faces
424 (quote (("TODO" :foreground "red" :weight bold)
425 ("NEXT" :foreground "blue" :weight bold)
426 ("DONE" :foreground "forest green" :weight bold)
427 ("WAITING" :foreground "orange" :weight bold)
428 ("HOLD" :foreground "magenta" :weight bold)
429 ("CANCELLED" :foreground "forest green" :weight bold)
430 ("MEETING" :foreground "forest cyan" :weight bold)
431 ("PHONE" :foreground "blue" :weight bold)))))
432
433;;; Smart mode line
434(use-package smart-mode-line
435 :demand
436 :config
437 (setq sml/no-confirm-load-theme t)
438 (setq sml/theme 'respectful)
439 (sml/setup))
440
441;;; Delete trailing whitespace on save
442(use-package whitespace-cleanup-mode
443 :diminish
444 :config (global-whitespace-cleanup-mode))
445
446;;; convert org to html in gnus
447(use-package org-mime)
448
449;;; Presentation
450(use-package epresent)
451
452;;; Email
453(use-package pinentry
454 :config
455 (setq epa-pinentry-mode 'loopback)
456 (pinentry-start))
457
458;;; Guru mode (disable arrows and stuff)
459(use-package guru-mode
460 :diminish
461 :config (guru-global-mode +1))
462
463;;; Hackernews
464(use-package hackernews)
465
466;;; PDF Tools
467(use-package pdf-tools
468 :demand
469 :config (pdf-loader-install))
470
471;;; Twitter
472(use-package twittering-mode
473 :config (setq twittering-use-master-password t))
474
475;;; Short messages
476(defalias 'yes-or-no-p 'y-or-n-p)
477
478(setq-default confirm-nonexistent-file-or-buffer t)
479
480(setq
481 save-place-forget-unreadable-files t
482 save-place-limit 200)
483
484(save-place-mode 1)
485
486;;; Browser
487(use-package w3m)
488
489;;; Show Emoji in emacs
490(use-package emojify
491 :config (add-hook 'after-init-hook #'global-emojify-mode))
492
493
494;;; Server for editing web-forms in emacs
495(use-package edit-server
496 :if window-system
497 :config (edit-server-start))
498
499;;; Markdown preview
500(use-package flymd)
501
502;;; AG Search
503(use-package ag)
504
505;;; Remove permission info from dired
506(defun dired-mode-setup ()
507 "to be run as hook for `dired-mode'."
508 (dired-hide-details-mode 1))
509(add-hook 'dired-mode-hook 'dired-mode-setup)
510
511;;; Dired Ranger like
512(use-package peep-dired)
513
514;;; Project Management
515(use-package projectile
516 :diminish
517 :bind (("s-p" . projectile-command-map)
518 ("C-c p" . projectile-command-map))
519 :config
520 (projectile-global-mode))
521
522;;; Editor Config support
523(use-package editorconfig
524 :ensure t
525 :diminish
526 :config
527 (editorconfig-mode 1))
528
529;;; Parens editing
530(use-package paredit)
531
532;;; Parens colorizing
533(use-package rainbow-delimiters)
534
535;;; Break line at 80 symbols
536(setq fill-column 80)
537
538;;; Disable mouse
539(use-package disable-mouse
540 :diminish
541 :defer 5
542 :config (global-disable-mouse-mode))
543
544
545(setq create-lockfiles nil)
546(setq
547 make-backup-files nil ; disable backup files
548 auto-save-list-file-name nil ; disable .saves files
549 auto-save-default nil ; disable auto saving
550 ring-bell-function 'ignore) ; turn off alarms completely
551
552;;; No savefiles
553(progn
554 (setq make-backup-files nil)
555 (setq auto-save-default nil)
556 (setq create-lockfiles nil))
557
558;;; Org-mode Setup
559(setq org-agenda-files (list
560 "~/Documents/life.org"))
561
562;;; Pomodoro technique tracking for org-mode
563(use-package org-pomodoro)
564
565;;; Hugo org exporter
566(use-package ox-hugo
567 :after oxxb
568 :config
569 (setq org-hugo-default-section-directory "posts")
570 (setq HUGO_BASE_DIR "~/github/w96k.gitlab.io/content/"))
571
572;;; Accounting
573(use-package ledger-mode)
574
575;;; Diary
576(use-package org-journal)
577
578;;; Display whitespace
579(progn
580 (setq whitespace-style (quote (face spaces tabs
581 space-mark tab-mark newline-mark )))
582 (setq whitespace-display-mappings
583 '(
584 (space-mark 32 [183] [46])
585 (tab-mark 9 [9655 9] [92 9])
586 ))
587
588 (set-face-attribute 'whitespace-space nil :background nil
589 :foreground "gray30")
590 (set-face-attribute 'whitespace-newline nil :background nil
591 :foreground "gray30")
592 (set-face-attribute 'whitespace-tab nil :background nil
593 :foreground "gray30"))
594
595(add-to-list 'exec-path "~/.nodejs/bin/")
Note: See TracBrowser for help on using the repository browser.