source: dotfiles/emacs/.emacs@ accb3c9

Last change on this file since accb3c9 was accb3c9, checked in by Mikhail Kirillov <w96k@…>, on Dec 20, 2019 at 7:11:27 PM

Add lilypond

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