source: dotfiles/emacs/.emacs@ 7c65a3f

Last change on this file since 7c65a3f was 7c65a3f, checked in by Mikhail Kirillov <w96k@…>, on Jan 7, 2020 at 7:06:00 AM

Switch doom-modeline to mood-line

  • Property mode set to 100644
File size: 18.6 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(add-to-list 'load-path "~/.guix-profile/share/emacs/site-lisp/")
53
54;; Information about me
55(setq user-full-name "Mikhail Kirillov"
56 user-mail-address "w96k@posteo.net")
57
58;;;; VISUALS
59
60;;; Color parens
61(use-package rainbow-delimiters
62 :hook ((prog-mode . rainbow-delimiters-mode)))
63
64;;; Display numbers
65(global-display-line-numbers-mode)
66
67;;; Display current line
68(global-hl-line-mode)
69
70;;; Set Theme
71(use-package color-theme-sanityinc-tomorrow
72 :demand
73 :config (load-theme 'sanityinc-tomorrow-eighties t))
74
75;;; Mood modeline
76(use-package mood-line
77 :config
78 (mood-line-mode))
79
80;;; Org-mode
81(use-package org
82 :config
83 (setq org-publish-project-alist
84 `(("blog" :components ("blog-content" "blog-styles"))
85 ("blog-styles"
86 :base-directory "~/github/blog/public"
87 :base-extension "jpg\\|gif\\|png\\|ico\\|css"
88 :publishing-directory "~/github/blog/dist/public/"
89 :recursive t
90 :publishing-function org-publish-attachment
91 )
92 ("blog-content"
93 :base-directory "~/github/blog/content"
94 :publishing-directory "~/github/blog/dist"
95 :recursive t
96 :publishing-function org-html-publish-to-html
97
98 :html-doctype "xhtml5"
99
100 :with-title nil
101 :with-author t
102 :with-creator nil
103 :with-date t
104 :with-email t
105 :with-footnotes t
106 :html-html5-fancy t
107 :html-preamble "
108<header class=\"navbar\">
109<a href=\"/\" class=\"logo\">@w96k</a>
110<a class=\"button\" href=\"/about.html\">Обо мне</a>
111<a class=\"button\" href=\"/cv.html\">CV</a>
112</header>"
113
114 :html-head "
115<link rel=\"shortcut icon\" href=\"/public/favicon.ico\">
116<link rel=\"stylesheet\" href=\"/public/css/mini.css\" type=\"text/css\"/>
117<link rel=\"stylesheet\" href=\"/public/css/custom.css\" type=\"text/css\"/>
118"
119
120 :html-container "article"
121 :html-postamble "
122 <div class=\"row\">
123 <div class=\"col-sm-12 col-md-4\">
124 <p class=\"licenses\">
125 <a href=\"https://creativecommons.org/licenses/by/4.0/\">
126 <img alt=\"Лицензия Creative Commons\" src=\"/public/images/cc.png\" />
127</a>
128 <a href=\"https://www.gnu.org/licenses/gpl-3.0.txt\">
129 <img src=\"/public/images/gpl.png\">
130 </a>
131 </p>
132 </div>
133
134 <div id=\"copyright\" class=\"col-sm-12 col-md-4\">
135 <p>© 2020 <i>Mikhail Kirillov</i></p>
136 <p>
137 Сайт работает в <a href=\"https://anybrowser.org/campaign/\">любом браузере</a>
138 </p>
139 </div>
140
141 <div class=\"col-sm-12 col-md-4\" id=\"meta\">
142 <p><span class=\"icon-settings\"></span> %c</p>
143 <p><span class=\"icon-calendar\"></span> %C</p>
144 </div>
145 </div>
146
147 <br>
148 <div align=\"center\">
149 <small>
150 <p>Содержимое данного сайта доступно по лицензии
151 <a href=\"https://creativecommons.org/licenses/by/4.0/\">
152 Creative Commons «Attribution» («Атрибуция») 4.0 Всемирная
153 </a>
154 </p>
155 <p>Исходный код данного сайта доступен по лицензии GNU General Public License Version 3</p>
156 </small>
157 </div>"
158
159 :section-numbers nil
160 :with-sub-superscript nil
161
162 ;; sitemap - list of blog articles
163 :auto-sitemap t
164 :sitemap-filename "sitemap.org"
165 :sitemap-title "@w96k"
166 :sitemap-sort-files anti-chronologically))))
167
168(use-package simple-httpd)
169
170;;; Bullets for org-mode
171(use-package org-bullets
172 :if window-system
173 :commands org-bullets-mode
174 :hook (org-mode . org-bullets-mode))
175
176;;;; EDITING
177
178;;; Easy undo system
179(use-package undo-tree
180 :diminish
181 :commands
182 (global-undo-tree-mode)
183 :init
184 (setq
185 undo-tree-visualizer-timestamps t
186 undo-tree-enable-undo-in-region nil
187 undo-tree-history-directory-alist
188 `(("." . ,(expand-file-name "undo" user-emacs-directory))))
189 (global-undo-tree-mode))
190
191;;; Jump to defenition
192(use-package dumb-jump
193 :bind (("M-g o" . dumb-jump-go-other-window)
194 ("M-g j" . dumb-jump-go)
195 ("M-g i" . dumb-jump-go-prompt)
196 ("M-g x" . dumb-jump-go-prefer-external)
197 ("M-g z" . dumb-jump-go-prefer-external-other-window))
198 :config (setq dumb-jump-selector 'ivy) ;; (setq dumb-jump-selector 'helm)
199 :ensure)
200
201(progn
202 (show-paren-mode))
203
204;;; Edit with root user
205(use-package sudo-edit)
206
207;;; Look eslint config
208(defun my/use-eslint-from-node-modules ()
209 (let* ((root (locate-dominating-file
210 (or (buffer-file-name) default-directory)
211 "node_modules"))
212 (eslint
213 (and root
214 (expand-file-name "node_modules/.bin/eslint"
215 root))))
216 (when (and eslint (file-executable-p eslint))
217 (setq-local flycheck-javascript-eslint-executable eslint))))
218
219;;; Live-checking text
220(use-package flycheck
221 :config
222 (add-hook 'after-init-hook #'global-flycheck-mode)
223 (add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
224 (setq-default flycheck-disabled-checkers
225 (append flycheck-disabled-checkers
226 '(javascript-jshint)))
227 (flycheck-add-mode 'javascript-eslint 'web-mode)
228 (setq-default flycheck-temp-prefix ".flycheck"))
229
230;;; No tabs
231(setq-default indent-tabs-mode nil)
232
233;;; Version control
234(use-package magit
235 :defer 2
236 :bind ("C-x g" . magit-status)
237 :config (setq magit-refresh-status-buffer nil))
238
239;;; Magit forge (magit integration with git hostings)
240(use-package forge
241 :after magit)
242
243;;; Git flow
244(use-package magit-gitflow
245 :after magit
246 :init (add-hook 'magit-mode-hook 'turn-on-magit-gitflow))
247
248;;; Show added & removed git lines
249(use-package git-gutter+
250 :ensure t
251 :init (global-git-gutter+-mode)
252 :config
253 (progn
254 (define-key git-gutter+-mode-map (kbd "C-x n") 'git-gutter+-next-hunk)
255 (define-key git-gutter+-mode-map (kbd "C-x p") 'git-gutter+-previous-hunk)
256 (define-key git-gutter+-mode-map (kbd "C-x v =") 'git-gutter+-show-hunk)
257 (define-key git-gutter+-mode-map (kbd "C-x r") 'git-gutter+-revert-hunks)
258 (define-key git-gutter+-mode-map (kbd "C-x t") 'git-gutter+-stage-hunks)
259 (define-key git-gutter+-mode-map (kbd "C-x c") 'git-gutter+-commit)
260 (define-key git-gutter+-mode-map (kbd "C-x C") 'git-gutter+-stage-and-commit)
261 (define-key git-gutter+-mode-map (kbd "C-x C-y") 'git-gutter+-stage-and-commit-whole-buffer)
262 (define-key git-gutter+-mode-map (kbd "C-x U") 'git-gutter+-unstage-whole-buffer))
263 :diminish (git-gutter+-mode . "gg"))
264
265;;; Autoformatting code
266(use-package aggressive-indent
267 :config (global-aggressive-indent-mode))
268
269;;; 80 column width limit highlighter
270(use-package column-enforce-mode
271 :defer t
272 :diminish
273 :config (80-column-rule)
274 :hook (prog-mode . column-enforce-mode))
275
276;;; General autocomplete
277(use-package ivy
278 :demand
279 :diminish
280 :config
281 (ivy-mode)
282 (setq ivy-use-virtual-buffers t)
283 (setq enable-recursive-minibuffers t)
284 (global-set-key "\C-s" 'swiper)
285 (global-set-key (kbd "C-c C-r") 'ivy-resume)
286 (global-set-key (kbd "<f6>") 'ivy-resume))
287
288(use-package counsel
289 :demand
290 :config
291 (global-set-key (kbd "M-x") 'counsel-M-x)
292 (global-set-key (kbd "C-x C-f") 'counsel-find-file)
293 (global-set-key (kbd "<f1> f") 'counsel-describe-function)
294 (global-set-key (kbd "<f1> v") 'counsel-describe-variable)
295 (global-set-key (kbd "<f1> l") 'counsel-find-library)
296 (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
297 (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
298 (global-set-key (kbd "C-c g") 'counsel-git)
299 (global-set-key (kbd "C-c j") 'counsel-git-grep)
300 (global-set-key (kbd "C-x b") 'counsel-ibuffer)
301 (global-set-key (kbd "C-c k") 'counsel-ag)
302 (global-set-key (kbd "C-x l") 'counsel-locate)
303 (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
304 (define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history))
305
306(use-package ivy-hydra)
307
308(use-package company
309 :demand
310 :diminish
311 :custom
312 (company-require-match nil)
313 (company-minimum-prefix-length 1)
314 (company-idle-delay 0.1)
315 (company-tooltip-align-annotation t)
316 :hook ((prog-mode . company-mode))
317 :config
318 (add-hook 'after-init-hook 'global-company-mode)
319 :bind (:map company-active-map
320 ("C-n" . company-select-next)
321 ("C-p" . company-select-previous)))
322
323;;;; LANGUAGES
324
325;;; Python
326(use-package elpy
327 :init
328 (elpy-enable)
329 :config
330 (setq elpy-rpc-python-command "python3")
331 (when (load "flycheck" t t)
332 (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
333 (add-hook 'elpy-mode-hook 'flycheck-mode)))
334
335;;; Vue
336(use-package vue-mode
337 :config (setq mmm-submode-decoration-level 0))
338
339;;; PHP
340(use-package php-mode)
341
342;;; Templates
343(use-package web-mode
344 :config
345 (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
346 (setq web-mode-markup-indent-offset 2)
347 (setq web-mode-enable-auto-pairing t)
348 (setq web-mode-enable-current-element-highlight t)
349 (setq web-mode-enable-current-column-highlight t))
350
351;;; Javascript
352(use-package js2-mode
353 :config
354 (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
355 (setq-default js2-basic-offset 2)
356 (add-hook 'js2-mode-hook
357 (lambda ()
358 (define-key js-mode-map (kbd "C-x C-e") 'nodejs-repl-send-last-expression)
359 (define-key js-mode-map (kbd "C-c C-j") 'nodejs-repl-send-line)
360 (define-key js-mode-map (kbd "C-c C-r") 'nodejs-repl-send-region)
361 (define-key js-mode-map (kbd "C-c C-l") 'nodejs-repl-load-file)
362 (define-key js-mode-map (kbd "C-c C-z") 'nodejs-repl-switch-to-repl))))
363
364;;; Eslint
365(use-package eslint-fix
366 :ensure-system-package (eslint . "npm install -g eslint")
367 :config
368 (eval-after-load 'js2-mode
369 '(add-hook 'js2-mode-hook (lambda () (add-hook 'after-save-hook 'eslint-fix nil t)))))
370
371(use-package json-mode)
372
373(use-package rjsx-mode
374 :config
375 (add-to-list 'auto-mode-alist '(".*\.js\'" . rjsx-mode)))
376
377;;; Yasnippet
378(use-package yasnippet
379 :demand
380 :diminish
381 :init (yas-global-mode 1))
382
383(use-package yasnippet-snippets
384 :diminish
385 :after yasnippet)
386
387;;; LSP
388(use-package lsp-mode
389 :hook
390 (ruby-mode . lsp)
391 (javascript-mode . lsp)
392 (vue-mode . lsp)
393 :commands lsp)
394
395;;; LSP Flycheck
396(use-package lsp-ui
397 :after (lsp-mode)
398 :hook lsp-mode
399 :commands lsp-ui-mode)
400
401(use-package company-lsp
402 :after (lsp-mode lsp-ui)
403 :commands company-lsp)
404
405;;; Debugger
406(use-package dap-mode
407 :config
408 (dap-mode 1)
409 (dap-ui-mode 1))
410
411;;; Ruby On Rails
412(use-package rinari)
413
414;;; Node.js Repl
415(use-package nodejs-repl)
416
417;;; Haskell
418(use-package haskell-mode)
419
420;;; Haskell support
421(use-package intero
422 :config (add-hook 'haskell-mode-hook 'intero-mode))
423
424;;; Typescript support
425(use-package typescript-mode)
426
427(use-package tide
428 :ensure t
429 :diminish
430 :after (typescript-mode company flycheck)
431 :hook ((typescript-mode . tide-setup)
432 (typescript-mode . tide-hl-identifier-mode)
433 (before-save . tide-format-before-save)))
434
435;;; Clojure REPL
436(use-package cider)
437
438;;;; Emacs Lisp Helping Libraries
439(use-package s)
440
441;;;; MISC
442
443;;; Show last key and command in modeline
444(use-package keycast
445 :config (keycast-mode))
446
447;;; IRC
448(use-package erc
449 :config
450 (erc-autojoin-enable)
451 (setq erc-autojoin-channels-alist
452 '(("freenode.net" "#emacs" "#wiki" "#next-browser"))))
453
454;;; Show TODO, FIX in comments
455(use-package fic-mode)
456
457(electric-pair-mode)
458
459;;; Rest client
460(use-package restclient)
461
462;;; Telegram
463(use-package telega
464 :config (telega-mode-line-mode 1))
465
466(use-package exec-path-from-shell
467 :config
468 (when (memq window-system '(mac ns x))
469 (exec-path-from-shell-initialize)
470 (exec-path-from-shell-copy-env "PATH")))
471
472;; Kill whole line
473(global-set-key (kbd "C-u") 'kill-whole-line)
474
475;;; Volume management using thinkpad volume buttons
476(use-package volume
477 :config
478 (global-set-key (kbd "<XF86AudioRaiseVolume>") 'volume-raise-10)
479 (global-set-key (kbd "<XF86AudioLowerVolume>") 'volume-lower-10))
480
481;;; Screenshot
482(use-package frameshot
483 :if window-system
484 :config (frameshot-setup
485 '((name . "w96k")
486 (height . 800)
487 (width . 1280))))
488
489;;; Change Move to end & beginning of the line behavior
490(use-package mwim
491 :config
492 (global-set-key (kbd "C-a") 'mwim-beginning)
493 (global-set-key (kbd "C-e") 'mwim-end))
494
495(use-package command-log-mode)
496
497;;; Benchmark init
498(use-package benchmark-init
499 :demand
500 :ensure t
501 :config
502 ;; To disable collection of benchmark data after init is done.
503 (add-hook 'after-init-hook 'benchmark-init/deactivate))
504
505;;; Bug-Tracker DebBugs
506(use-package debbugs)
507
508;;; Icons
509(use-package all-the-icons
510 :if window-system)
511
512;;; Icons for dired
513(use-package all-the-icons-dired
514 :if window-system
515 :diminish
516 :after all-the-icons
517 :config
518 (add-hook 'dired-mode-hook 'all-the-icons-dired-mode))
519
520;;; Sidebar File-Manager
521(use-package dired-sidebar
522 :after exwm
523 :bind (("C-x C-n" . dired-sidebar-toggle-sidebar))
524 :diminish
525 :after all-the-icons
526 :commands (dired-sidebar-toggle-sidebar)
527 :init
528 (add-hook 'dired-sidebar-mode-hook
529 (lambda ()
530 (unless (file-remote-p default-directory)
531 (auto-revert-mode))))
532 :config
533 (push 'toggle-window-split dired-sidebar-toggle-hidden-commands)
534 (push 'rotate-windows dired-sidebar-toggle-hidden-commands)
535 (setq dired-sidebar-subtree-line-prefix "__")
536 (setq dired-sidebar-use-term-integration t)
537 (setq dired-sidebar-use-custom-font t))
538
539;;; Manage docker in emacs
540(use-package docker
541 :bind ("C-c d" . docker))
542
543;;; hide some minor modes
544(use-package diminish
545 :demand)
546
547;;; org
548(use-package org
549 :config
550 (setq org-todo-keywords
551 (quote ((sequence "TODO(t)" "MIGRATE(m)" "|" "DONE(d)")
552 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))
553 (setq org-todo-keyword-faces
554 (quote (("TODO" :foreground "red" :weight bold)
555 ("NEXT" :foreground "blue" :weight bold)
556 ("DONE" :foreground "forest green" :weight bold)
557 ("WAITING" :foreground "orange" :weight bold)
558 ("HOLD" :foreground "magenta" :weight bold)
559 ("CANCELLED" :foreground "forest green" :weight bold)
560 ("MEETING" :foreground "forest cyan" :weight bold)
561 ("PHONE" :foreground "blue" :weight bold)))))
562
563;;; Smart mode line
564(use-package smart-mode-line
565 :demand
566 :config
567 (setq sml/no-confirm-load-theme t)
568 (setq sml/theme 'respectful)
569 (sml/setup))
570
571;;; Delete trailing whitespace on save
572(use-package whitespace-cleanup-mode
573 :diminish
574 :config (global-whitespace-cleanup-mode))
575
576;;; convert org to html in gnus
577(use-package org-mime)
578
579;;; Presentation
580(use-package epresent)
581
582;;; Email
583(use-package pinentry
584 :config
585 (setq epa-pinentry-mode 'loopback)
586 (pinentry-start))
587
588;;; Guru mode (disable arrows and stuff)
589(use-package guru-mode
590 :diminish
591 :config (guru-global-mode +1))
592
593;;; Hackernews
594(use-package hackernews)
595
596;;; PDF Tools
597(use-package pdf-tools
598 :if window-system
599 :demand
600 :config (pdf-loader-install))
601
602;;; Twitter
603(use-package twittering-mode
604 :config (setq twittering-use-master-password t))
605
606;;; Short messages
607(defalias 'yes-or-no-p 'y-or-n-p)
608
609(setq-default confirm-nonexistent-file-or-buffer t)
610
611(setq
612 save-place-forget-unreadable-files t
613 save-place-limit 200)
614
615(save-place-mode 1)
616
617;;; Show Emoji in emacs
618(use-package emojify
619 :if window-system
620 :config (add-hook 'after-init-hook #'global-emojify-mode))
621
622
623;;; Server for editing web-forms in emacs
624(use-package edit-server
625 :if window-system
626 :config (edit-server-start))
627
628;;; Markdown preview
629(use-package flymd)
630
631;;; AG Search
632(use-package ag)
633
634;;; Remove permission info from dired
635(defun dired-mode-setup ()
636 "to be run as hook for `dired-mode'."
637 (dired-hide-details-mode 1))
638(add-hook 'dired-mode-hook 'dired-mode-setup)
639
640;;; Dired Ranger like
641(use-package peep-dired)
642
643;;; Project Management
644(use-package projectile
645 :diminish
646 :bind (("s-p" . projectile-command-map)
647 ("C-c p" . projectile-command-map))
648 :config
649 (projectile-global-mode))
650
651;;; Editor Config support
652(use-package editorconfig
653 :ensure t
654 :diminish
655 :config
656 (editorconfig-mode 1))
657
658;;; Parens editing
659(use-package paredit)
660
661;;; Parens colorizing
662(use-package rainbow-delimiters)
663
664;;; Break line at 80 symbols
665(use-package visual-fill-column
666 :config
667 (setq fill-column 80)
668 (global-visual-fill-column-mode)
669 (global-visual-line-mode))
670
671;;; Disable mouse
672(use-package disable-mouse
673 :diminish
674 :defer 5
675 :config (global-disable-mouse-mode))
676
677
678(setq create-lockfiles nil)
679(setq
680 make-backup-files nil ; disable backup files
681 auto-save-list-file-name nil ; disable .saves files
682 auto-save-default nil ; disable auto saving
683 ring-bell-function 'ignore) ; turn off alarms completely
684
685;;; No savefiles
686(progn
687 (setq make-backup-files nil)
688 (setq auto-save-default nil)
689 (setq create-lockfiles nil))
690
691;;; Org-mode Setup
692(setq org-agenda-files (list
693 "~/Documents/life.org"))
694
695;;; Pomodoro technique tracking for org-mode
696(use-package org-pomodoro)
697
698;;; Hugo org exporter
699(use-package ox-hugo
700 :after oxxb
701 :config
702 (setq org-hugo-default-section-directory "posts")
703 (setq HUGO_BASE_DIR "~/github/w96k.gitlab.io/content/"))
704
705;;; Accounting
706(use-package ledger-mode)
707
708;;; Diary
709(use-package org-journal)
710
711;;; Lilypond
712(progn
713 (autoload 'lilypond "lilypond")
714 (autoload 'lilypond-mode "lilypond-mode")
715 (setq auto-mode-alist
716 (cons '("\\.ly$" . LilyPond-mode) auto-mode-alist))
717 (add-hook 'LilyPond-mode-hook (lambda () (turn-on-font-lock))))
718
719;;; Flycheck lilypond
720(use-package flycheck-lilypond)
721
722;;; Publishing system
723(use-package muse)
724
725;; (global-set-key [(control ?h)] 'delete-backward-char)
Note: See TracBrowser for help on using the repository browser.