source: dotfiles/emacs/.emacs@ 29d34ed

Last change on this file since 29d34ed was 29d34ed, checked in by Mikhail Kirillov <w96k@…>, on Nov 29, 2019 at 8:38:02 PM

Add IRC; Add visual line;

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