source: dotfiles/emacs/.emacs.d/.emacs-config.org@ fc6fa17

Last change on this file since fc6fa17 was fc6fa17, checked in by Mikhail Kirillov <w96k@…>, on Sep 6, 2024 at 3:49:57 AM

Update mostly only fonts

  • Property mode set to 100644
File size: 36.1 KB
Line 
1#+TITLE: Emacs configuration
2#+AUTHOR: Kirillov <w96k.dev> Mikhail
3#+OPTIONS: toc:nil
4#+PROPERTY: header-args:elisp :results silent
5#+STARTUP: showeverything
6
7* About this Emacs configuration
8
9Configuration uses org-mode to tangle its contents to init.el and then
10be used by emacs. I use guix home for my emacs config on gnu guix
11system.
12
13If you see :tangle nil it means that snippet is not used anymore, but
14it is left because it might be valuable in a future for me.
15
16This configuration is available here:
17https://w96k.dev/emacs.html
18
19The git source code is hosted on Sourcehut:
20https://git.sr.ht/~w96k/dotfiles/tree/master/item/emacs
21
22The license of emacs config and dotfiles is CC0 which is Public Domain.
23
24** Packets
25Only needed when I need to install a package from Melpa and not GNU Guix
26#+begin_src elisp :tangle nil
27 (require 'package)
28
29 (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
30 ("melpa" . "http://melpa.org/packages/")))
31
32 (when (< emacs-major-version 27)
33 (package-initialize))
34
35 (require 'gnutls)
36#+end_src
37
38** EXWM
39
40#+begin_src emacs-lisp :tangle nil
41 (require 'exwm)
42 (require 'exwm-config)
43 (exwm-config-example)
44#+end_src
45
46
47** Init.el
48#+begin_src emacs-lisp :tangle init.el
49 ;; -*- lexical-binding: t -*-
50
51 ;; Show/Hide errors
52 ;; (setq debug-on-error nil)
53 ;; (setq debug-on-quit nil)
54
55 ;; Timer
56 (add-hook 'emacs-startup-hook
57 (lambda ()
58 (message
59 "Emacs ready in %s with %d garbage collections."
60 (format "%.2f seconds"
61 (float-time
62 (time-subtract after-init-time before-init-time)))
63 gcs-done)))
64
65 ;; Dont ask when following symlinks
66 (setq vc-follow-symlinks t)
67
68 ;; Load your custom settings
69 (setq custom-file "~/.emacs.d/custom-settings.el")
70 (load custom-file t)
71#+end_src
72
73* Meta
74** About me
75#+BEGIN_SRC emacs-lisp :tangle init.el
76 ;; Information about me
77 (setq user-full-name "Mikhail Kirillov"
78 user-mail-address "w96k@runbox.com")
79#+END_SRC
80
81** Configuration
82#+BEGIN_SRC emacs-lisp :tangle init.el
83 (setq config-dotfiles-path "/home/w96k/projects/dotfiles/emacs/.emacs.d/"
84 config-path "~/.emacs.d/"
85 config-name ".emacs-config.org")
86
87 (defun config-visit ()
88 (interactive)
89 (find-file (concat config-path config-name)))
90
91 (defun config-tangle ()
92 (interactive)
93 (org-babel-tangle-file (concat config-dotfiles-path config-name))
94 ;; Configuration stored in another directory,
95 ;; so I need to move files .emacs.d manually
96 ;; (rename-file (concat config-dotfiles-path "early-init.el") config-path t)
97 (rename-file (concat config-dotfiles-path "init.el") config-path t))
98#+END_SRC
99
100* Appereance
101
102** Line numbers
103Изначально они отключены, но можно вызвать по клавише F7.
104#+BEGIN_SRC emacs-lisp :tangle init.el
105 (define-key global-map
106 (kbd "<f7>") 'global-display-line-numbers-mode)
107
108 (define-key global-map
109 (kbd "<f6>") 'whitespace-mode)
110#+END_SRC
111
112* Editing
113** Dired
114#+BEGIN_SRC emacs-lisp :tangle init.el
115 ;; Show files in KiB
116 (setq dired-listing-switches "-hlap"
117 dired-kill-when-opening-new-dired-buffer t)
118
119 (customize-set-variable 'global-auto-revert-non-file-buffers t)
120 (global-auto-revert-mode 1)
121#+END_SRC
122
123** Linter
124I use Flymake and Flycheck
125*** Flymake
126#+BEGIN_SRC emacs-lisp :tangle nil
127 (add-hook 'prog-mode-hook 'flymake-mode)
128
129 (require 'psalm)
130
131 (define-prefix-command 'flymake-map)
132 (global-set-key (kbd "C-q") 'flymake-map)
133 (define-key flymake-map (kbd "n") 'flymake-goto-next-error)
134 (define-key flymake-map (kbd "p") 'flymake-goto-prev-error)
135 (define-key flymake-map (kbd "l") 'flymake-show-diagnostics-buffer)
136 (define-key flymake-map (kbd "e") 'flymake-show-diagnostic)
137#+END_SRC
138
139*** Flycheck
140#+BEGIN_SRC emacs-lisp :tangle nil
141 ;; (require 'psalm)
142
143 (when (package-loaded? "flycheck")
144
145 (defun flycheck-phanclient-start-daemon ()
146 "Start the phan daemon"
147 (interactive)
148 (let* ((default-directory (php-project-get-root-dir))
149 (phan-executable (or flycheck-phanclient--phan-executable
150 (if (file-exists-p "vendor/bin/phan")
151 (concat default-directory "vendor/bin/phan")
152 (executable-find "phan"))))
153 (cmd (list phan-executable "--daemonize-tcp-port" "4846" "--quick")))
154 (apply #'start-process "PhanDaemon" "*phan daemon*" cmd)))
155
156 (flycheck-define-checker php-phanclient
157 "Phan"
158 :command ("phan_client" "-l" source-original "-f" source)
159 :error-patterns
160 ((warning line-start (or "Parse" "Fatal" "syntax" "Phan") " error" (any ":" ",") " " (message) " in " (file-name) " on line " line line-end))
161 :modes (php-mode php+-mode))
162
163 (add-to-list 'flycheck-checkers 'php-phanclient)
164
165 (flycheck-add-next-checker 'php '(warning . php-phanclient))
166
167 (add-hook 'prog-mode-hook 'flycheck-mode))
168#+END_SRC
169
170** Imenu List
171#+begin_src emacs-lisp :tangle init.el
172
173 (setq imenu-list-focus-after-activation nil
174 imenu-list-auto-resize nil
175 imenu-list-mode-line-format '()
176 imenu-list-size 0.4)
177 (global-set-key (kbd "C-x C-d") #'imenu-list-smart-toggle)
178#+end_src
179
180** Version Control System
181Модуль VC + Magit.
182
183| Operation | VC | Magit |
184|----------------+-----------------------------------------+----------------------|
185| Project status | project-vc-dir (C-x p v) | magit-status (C-x g) |
186| Pull | vc-update (F, in my case) | magit-pull (F p) |
187| New branch | vc-retrieve-tag (C-u B s) | magit-branch (b c) |
188| Commit | vc-next-action (C-x v v) | magit-commit (c c) |
189| Rebase | shell-command (M-!) + git rebase master | magit-rebase (r p) |
190| Push | vc-push (P or C-u P) | magit-push (P p) |
191| Stash | mu-vc-git-stash (z) | magit-stash (z) |
192| Log | vc-print-root-log (L) | magit-log (l l) |
193https://www.manueluberti.eu//emacs/2021/11/27/vc/
194
195#+BEGIN_SRC emacs-lisp :tangle init.el
196 (setq vc-command-messages t)
197
198 (global-set-key "\C-xvB" 'git-branch-next-action)
199
200 ;; Use magit only when built-in VC fails
201
202 (use-package magit
203 :defer t
204 :bind (("C-x g" . magit-status)))
205
206 (use-package git-timemachine :defer t)
207#+END_SRC
208
209** Jumps
210#+BEGIN_SRC emacs-lisp :tangle init.el
211 ;; Jumps by highlighting symbols on screen
212 (use-package avy
213 :defer t
214 :bind (("M-s M-s" . avy-goto-char)
215 ("M-s s" . avy-goto-char)
216 ("M-s g" . avy-goto-line)
217 ("M-s l" . avy-goto-char-in-line)
218 ("M-s M-l" . avy-goto-char-in-line)
219
220 ("M-g g" . avy-goto-line)
221 ("M-s M-g" . avy-goto-line)))
222
223 (use-package link-hint
224 :defer t
225 :bind (("M-s j" . link-hint-open-link)))
226
227 ;; Jumps to last change
228 (use-package goto-chg
229 :defer t
230 :bind (("C-z" . goto-last-change)
231 ("M-z" . goto-last-change-reverse)))
232
233 ;; Jumps using grep and similar tools
234 (use-package dumb-jump
235 :defer t
236 :bind (("C-." . dumb-jump-go)))
237
238#+END_SRC
239
240** Проекты
241Использую встроенный project.el
242I use built-in project.el
243** Ограничение ширины строки
244#+BEGIN_SRC emacs-lisp :tangle init.el
245 (add-hook 'prog-mode-hook 'display-fill-column-indicator-mode)
246
247 ;;; Set column width to 79 according to pep8 for python
248 (add-hook 'python-mode-hook
249 (lambda () (set-fill-column 79)))
250#+END_SRC
251
252** Ввод парных скобок и кавычек (electric)
253#+BEGIN_SRC emacs-lisp :tangle init.el
254 ;;; Input of pair delimiters
255 (electric-pair-mode)
256 (add-hook 'prog-mode-hook 'electric-pair-mode)
257 (add-hook 'prog-mode-hook 'electric-indent-mode)
258#+END_SRC
259
260** Kill-ring
261#+BEGIN_SRC emacs-lisp :tangle init.el
262 (use-package browse-kill-ring
263 :defer t
264 :bind ("C-M-y" . browse-kill-ring))
265#+END_SRC
266
267** Tags
268Для прыжков и поиска функций/классов и т.д.
269#+BEGIN_SRC emacs-lisp :tangle nil
270 (setq path-to-ctags "~/.guix-profile/bin/ctags")
271
272 (defun tags-create (dir-name)
273 "Create tags file."
274 (interactive "DDirectory: ")
275 (shell-command
276 (format "%s -f TAGS -e -R %s" path-to-ctags
277 (directory-file-name dir-name))))
278
279 (defun tags-create-python (dir-name)
280 "Create tags with python interpreter"
281 (interactive "DDirectory: ")
282 (shell-command
283 (format "%s -f TAGS -e -R --fields=+l --languages=python --python-kinds=-iv $(python -c \"import os, sys; print(' '.join('{}'.format(d) for d in sys.path if os.path.isdir(d)))\") %s" path-to-ctags
284 (directory-file-name dir-name))))
285#+END_SRC
286
287** Дебаггер
288#+begin_src emacs-lisp :tangle nil
289 (when (package-loaded? "realgud")
290 (load "~/.emacs.d/site-lisp/realgud-xdebug/realgud-xdebug.el"))
291#+end_src
292
293#+begin_src emacs-lisp :tangle nil
294 (when (package-loaded? "geben")
295 (setq geben-dbgp-default-port 9003))
296#+end_src
297
298*** Автодополнение кода и документация
299По большей части я использую дефолтный Completion Buffer и Corfu
300#+begin_src elisp :tangle nil
301 (when (package-loaded? "corfu")
302 (progn
303 (setq corfu-preview-current 'nil
304 corfu-popupinfo-delay t)
305 (corfu-mode 1)
306 (corfu-popupinfo-mode 1)
307 (defun show-default-completion-buffer ()
308 (interactive)
309 (corfu-quit)
310 (corfu-mode -1)
311 (completion-at-point)
312 (corfu-mode 1)
313 (corfu-popupinfo-mode 1))
314 (define-key corfu-map (kbd "M-TAB") 'show-default-completion-buffer)
315 (define-key corfu-map (kbd "TAB") 'show-default-completion-buffer)
316 (define-key corfu-map (kbd "C-M-i") 'show-default-completion-buffer)
317 (corfu-mode -1)
318 (add-hook 'prog-mode-hook 'corfu-mode)
319
320 (defun corfu-send-shell (&rest _)
321 "Send completion candidate when inside comint/eshell."
322 (cond
323 ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
324 (eshell-send-input))
325 ((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
326 (comint-send-input))))
327
328 (advice-add #'corfu-insert :after #'corfu-send-shell)
329
330 (add-hook 'eshell-mode-hook 'corfu-mode)))
331
332#+end_src
333*** Агрессивный дефолтный комплит
334#+BEGIN_SRC emacs-lisp :tangle nil
335 (setq aggressive-completion-delay 0.5)
336 (aggressive-completion-mode t)
337#+END_SRC
338** Полнотекстовый поиск
339Для выхода из поиска -- C-c C-q
340#+begin_src emacs-lisp :tangle nil
341 (load "deft-autoloads")
342
343 (define-key global-map
344 (kbd "C-c n s") 'deft)
345
346 (setq deft-recursive t
347 deft-use-filter-string-for-filename t
348 deft-default-extension "org md"
349 deft-directory "~/projects/at-w96k/content/digarden")
350#+end_src
351
352** Визуализирование откатов
353При помощи пакета undo-tree
354#+begin_src emacs-lisp :tangle init.el
355 (use-package undo-tree
356 :defer t
357 :hook
358 (prog-mode . undo-tree-mode)
359 (org-mode . undo-tree-mode))
360#+end_src
361
362** Сниппеты
363#+begin_src emacs-lisp :tangle nil
364 (when (package-loaded? "yasnippet")
365 (progn
366 (add-hook 'prog-mode-hook #'yas-minor-mode)))
367#+end_src
368
369** Клиент LSP
370#+begin_src emacs-lisp :tangle init.el
371 ;; (with-eval-after-load 'eglot
372 ;; (add-to-list 'eglot-server-programs '((php-mode phps-mode) . ("~/projects/phpactor/bin/phpactor" "language-server" "-vvv")))
373 ;; (add-to-list 'eglot-server-programs '((php-mode phps-mode) . ("intelephense" "--stdio")))
374
375 ;; ;; No event buffers, disable providers cause a lot of hover traffic. Shutdown unused servers.
376 ;; (setq eglot-events-buffer-size 0
377 ;; eglot-ignored-server-capabilities '(:hoverProvider
378 ;; :documentHighlightProvider)
379 ;; eglot-autoshutdown t))
380
381 ;; Show all of the available eldoc information when we want it. This way Flymake errors
382 ;; don't just get clobbered by docstrings.
383 (add-hook 'eglot-managed-mode-hook
384 (lambda ()
385 "Make sure Eldoc will show us all of the feedback at point."
386 (setq-local eldoc-documentation-strategy
387 #'eldoc-documentation-compose)))
388#+end_src
389
390** Линтеры
391#+begin_src emacs-lisp :tangle nil
392 (defun my-php-mode-setup ()
393 "My PHP-mode hook."
394 (require 'flycheck-phpstan)
395 (flycheck-mode t))
396
397 (add-hook 'php-mode-hook 'my-php-mode-setup)
398#+end_src
399
400#+BEGIN_SRC emacs-lisp :tangle nil
401 ;; (add-hook 'php-mode-hook 'flymake-php-load)
402 ;; (add-hook 'php-mode-hook 'flymake-phpstan-turn-on)
403
404 ;; (require 'flycheck-phpstan)
405
406
407 ;;(add-to-list 'auto-mode-alist '("\\.\\(php\\|phtml\\)\\'" . phps-mode))
408
409 ;; (phps-mode-flycheck-setup)
410
411 ;; (setq phps-mode-async-process t)
412 ;; (setq phps-mode-async-process-using-async-el t)
413#+END_SRC
414
415** Выделение
416#+BEGIN_SRC emacs-lisp :tangle init.el
417 (use-package expand-region
418 :defer t
419 :bind (("C-=" . er/expand-region)))
420#+END_SRC
421
422** Сессия
423#+BEGIN_SRC emacs-lisp :tangle init.el
424 (desktop-save-mode 1)
425#+END_SRC
426** Скроллинг
427#+BEGIN_SRC emacs-lisp :tangle init.el
428 (setq scroll-margin 0)
429#+END_SRC
430** Поиск
431*** Isearch
432#+begin_src emacs-lisp :tangle init.el
433 (with-eval-after-load 'isearch
434 (define-key isearch-mode-map "\C-h" 'isearch-delete-char)
435 (define-key isearch-mode-map "\C-ch" 'isearch-help-for-help))
436#+end_src
437
438*** Подсчёт кандидатов
439#+BEGIN_SRC emacs-lisp :tangle init.el
440 (use-package anzu
441 :config
442 (global-anzu-mode t))
443#+END_SRC
444*** Swiper (не используется)
445#+BEGIN_SRC emacs-lisp :result nil :tangle nil
446 (load "swiper-autoloads")
447 (global-set-key (kbd "C-s") 'swiper)
448
449 (setq swiper-include-line-number-in-search t
450 swiper-use-visual-line t
451 swiper-stay-on-quit t)
452#+END_SRC
453** Which function
454#+begin_src emacs-lisp :tangle init.el
455 (which-function-mode t)
456#+end_src
457
458** Подсказка биндов
459Пакет Which-key
460#+begin_src elisp :tangle nil
461 (load "which-key-autoloads")
462 (which-key-setup-side-window-right)
463 (which-key-mode)
464
465 (setq which-key-side-window-max-width 0.5
466 which-key-show-remaining-keys t
467 which-key-max-display-columns 50
468 which-key-max-description-length 35
469 which-key-sort-order 'which-key-local-then-key-order
470 which-key-idle-delay 0.25)
471#+end_src
472
473** Права суперпользователя
474Sudo-edit
475#+begin_src emacs-lisp :tangle init.el
476 (use-package sudo-edit
477 :defer t)
478#+end_src
479
480** Промежуточный код
481Показывает собранное состояние будь то собранный куски на ассемблере
482или байт-код при помощи пакета RMSbolt.
483#+begin_src emacs-lisp :tangle init.el
484 (use-package rmsbolt
485 :defer t)
486#+end_src
487
488** Быстрый запуск программы
489#+begin_src emacs-lisp :tangle nil
490 ;; (when (package-loaded? "quickrun")
491 ;; (define-key global-map (kbd "C-c C-c") 'quickrun))
492#+end_src
493
494
495* Языки программирования
496** Common Lisp
497*** REPL
498#+BEGIN_SRC emacs-lisp :tangle nil
499 (load "sly-autoloads")
500
501 (setq sly-lisp-implementations
502 '((clisp ("clisp"))
503 (cmucl ("cmucl" "-quiet"))
504 (sbcl ("/opt/sbcl/bin/sbcl") :coding-system utf-8-unix)))
505#+END_SRC
506
507** Ruby
508#+BEGIN_SRC emacs-lisp :tangle nil
509 (when (package-loaded? "inf-ruby")
510 (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode))
511
512 (when (package-loaded? "inf-ruby")
513 (add-hook 'ruby-mode-hook 'robe-mode))
514#+END_SRC
515
516** Scheme
517#+BEGIN_SRC emacs-lisp :tangle init.el
518 (setq geiser-active-implementations '("guile"))
519#+END_SRC
520
521** Python
522*** Автодополнение и линт
523#+BEGIN_SRC emacs-lisp :tangle nil
524 (when (package-loaded? "anaconda-mode")
525 (progn
526 (add-hook 'python-mode-hook 'anaconda-mode)
527 (add-hook 'python-mode-hook 'anaconda-eldoc-mode)))
528
529 ;; (when (load "flymake" t)
530 ;; (defun flymake-pylint-init ()
531 ;; (let* ((temp-file (flymake-init-create-temp-buffer-copy
532 ;; 'flymake-create-temp-inplace))
533 ;; (local-file (file-relative-name
534 ;; temp-file
535 ;; (file-name-directory buffer-file-name))))
536 ;; (list "epylint" (list local-file))))
537
538 ;; (add-to-list 'flymake-allowed-file-name-masks
539 ;; '("\\.py\\'" flymake-pylint-init)))
540
541 ;; (add-hook 'python-mode-hook 'flymake-mode)
542#+END_SRC
543*** Прыжки в функции стандартной библиотеки на си
544** SML
545#+BEGIN_SRC emacs-lisp :tangle nil
546 (add-hook 'sml-mode-hook 'sml-mode)
547#+END_SRC
548
549** PHP
550*** PHP-Mode
551Необходимо скачать и распаковать мануал PHP (в формате html) в
552директорию ~~/.emacs.d/php-manual/~.
553#+begin_src emacs-lisp :tangle nil
554 ;; (add-to-list 'load-path "~/.emacs.d/site-lisp/realgud-xdebug/")
555 ;; (require 'realgud-xdebug)
556
557 ;; (defun init-php-mode ()
558 ;; (eglot-ensure))
559
560 (with-eval-after-load 'php-mode
561
562 ;; (add-hook 'php-mode-hook #'init-php-mode)
563 )
564
565 (when (package-loaded? "php-mode")
566 (progn
567 (add-hook 'php-mode-hook 'php-enable-symfony2-coding-style)
568 (setq lsp-intelephense-php-version "8.1.16")
569 (defvar phpactor-executable "~/.bin/phpactor")
570 (custom-set-variables '(lsp-phpactor-path "~/usr/local/bin/phpactor"))
571
572 (add-hook 'php-mode-hook
573 '(lambda ()
574 ;; (require 'yasnippet)
575 ;; (require 'yasnippet-snippets)
576
577 (set-fill-column 120)
578
579 ;; (make-local-variable 'eldoc-documentation-function)
580 ;; (setq eldoc-documentation-function
581 ;; 'phpactor-hover)
582 ;; (yas-minor-mode t)
583 (define-key php-mode-map (kbd "C-c h") 'php-quickhelp-at-point)))
584
585 (setq php-manual-path
586 "~/php/php-manual/"
587 php-quickhelp-dir "~/php/php-manual/"
588 php-quickhelp--dest "~/.emacs.d/php-manual/php_manual_en.json")
589
590
591 ;; (add-hook 'php-mode-hook
592 ;; '(lambda ()
593 ;; ;; (auto-complete-mode t)
594
595 ;; ;; (require 'ac-php)
596 ;; (require 'php-quickhelp)
597 ;; (require 'company)
598 ;; (company-mode t)
599 ;; (require 'company-php)
600 ;; (require 'company-quickhelp)
601
602 ;; (require 'yasnippet)
603 ;; (require 'yasnippet-snippets)
604
605 ;; (set (make-local-variable 'company-backends)
606 ;; '((company-ac-php-backend company-dabbrev-code)
607 ;; php-quickhelp-company-php
608 ;; company-capf company-files))
609
610 ;; (company-quickhelp-mode t)
611
612 ;; (define-key php-mode-map (kbd "C-M-i") 'company-complete)
613 ;; (define-key company-mode-map (kbd "M-TAB") 'company-complete)
614
615 ;; ;; (setq ac-sources '(ac-source-php php-quickhelp-company-php))
616 ;; ;; (setq eldoc-documentation-function
617 ;; ;; 'php-quickhelp-eldoc-func)
618
619 ;; (yas-minor-mode t)
620
621 ;; ;; (define-key php-mode-map (kbd "C-M-i") 'auto-complete)
622 ;; ;; (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
623
624 ;; (define-key php-mode-map (kbd "C-c H")
625 ;; 'php-local-manual-search)
626
627 ;; (define-key php-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
628 ;; (define-key company-mode-map (kbd "C-c h") 'php-quickhelp-at-point)
629
630 ;; ;; (define-key php-mode-map (kbd "C-c t") 'ac-php-show-tip)
631
632 ;; ;; Jump to definition (optional)
633 ;; (define-key php-mode-map
634 ;; (kbd "M-.") 'ac-php-find-symbol-at-point)
635
636 ;; ;; Return back (optional)
637 ;; (define-key php-mode-map
638 ;; (kbd "M-,") 'ac-php-location-stack-back)))
639 ))
640#+end_src
641
642*** Composer
643#+begin_src emacs-lisp :tangle init.el
644 (setq composer-executable-bin "~/.bin/composer")
645#+end_src
646
647*** Flymake PHP
648*** REPL
649*** LSP сервер
650PHPactor
651#+begin_src emacs-lisp :tangle nil
652 (setq phpactor-executable "~/.bin/phpactor")
653 (custom-set-variables '(lsp-phpactor-path "~/.bin/phpactor"))
654
655 (use-package phpactor :ensure t)
656 (use-package company-phpactor :ensure t)
657
658
659
660 ;; (with-eval-after-load 'php-mode
661 ;; (define-key php-mode-map (kbd "M-.") #'phpactor-goto-definition)
662 ;; (define-key php-mode-map (kbd "M-?") #'phpactor-find-references))
663#+end_src
664
665*** Transient меню
666#+begin_src emacs-lisp :tangle nil
667 (require 'transient)
668 (define-transient-command php-menu ()
669 "Php"
670 [["Class"
671 ("cc" "Copy" phpactor-copy-class)
672 ("cn" "New" phpactor-create-new-class)
673 ("cr" "Move" phpactor-move-class)
674 ("ci" "Inflect" phpactor-inflect-class)
675 ("n" "Namespace" phpactor-fix-namespace)]
676 ["Properties"
677 ("a" "Accessor" phpactor-generate-accessors)
678 ("pc" "Constructor" phpactor-complete-constructor)
679 ("pm" "Add missing props" phpactor-complete-properties)
680 ("r" "Rename var locally" phpactor-rename-variable-local)
681 ("R" "Rename var in file" phpactor-rename-variable-file)]
682 ["Extract"
683 ("ec" "constant" phpactor-extract-constant)
684 ("ee" "expression" phpactor-extract-expression)
685 ("em" "method" phpactor-extract-method)]
686 ["Methods"
687 ("i" "Implement Contracts" phpactor-implement-contracts)
688 ("m" "Generate method" phpactor-generate-method)]
689 ["Navigate"
690 ("x" "List refs" phpactor-list-references)
691 ("X" "Replace refs" phpactor-replace-references)
692 ("." "Goto def" phpactor-goto-definition)]
693 ["Phpactor"
694 ("s" "Status" phpactor-status)
695 ("u" "Install" phpactor-install-or-update)]])
696#+end_src
697* Языки декларирования
698** SQL
699 to install lsp-server called sqls
700https://emacs-lsp.github.io/lsp-mode/page/lsp-sqls/
701#+BEGIN_SRC emacs-lisp :tangle nil
702 ;; Empty for now (was using emacsql)
703 (setq lsp-sqls-server "~/go/bin/sqls")
704
705 ;; (setq lsp-sqls-workspace-config-path nil)
706
707 (setq lsp-sqls-connections
708 '(((driver . "mysql") (dataSourceName . "dbuser:mangoworms@tcp(localhost:3306)/profile24"))))
709#+END_SRC
710
711The main way to interact with SQL is using org-mode
712#+begin_src emacs-lisp :tangle nil
713 (when (package-loaded? "org-sql")
714 (setq org-sql-files "~/projects/profile24/org"))
715
716 (add-hook 'sql-interactive-mode-hook
717 (lambda ()
718 (sql-connect "profile24")
719 (toggle-truncate-lines t)))
720
721 (setq sql-connection-alist
722 '((profile24
723 (sql-product 'mysql)
724 (sql-server "localhost")
725 (sql-user "dbuser")
726 (sql-password "123456")
727 (sql-database "testdb")
728 (sql-port 3306))))
729#+end_src
730
731
732** Веб шаблоны
733*** Web-mode
734#+BEGIN_SRC emacs-lisp :tangle init.el
735 (use-package web-mode
736 :defer t
737 :config
738 (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
739 (add-to-list 'auto-mode-alist '("\\.twig.html\\'" . web-mode))
740 (setq web-mode-markup-indent-offset 2)
741 (setq web-mode-enable-auto-pairing t)
742 (setq web-mode-enable-css-colorization t)
743 (setq web-mode-enable-block-face t)
744 (setq web-mode-enable-current-element-highlight t))
745#+END_SRC
746
747** Org
748*** Org-mode
749#+BEGIN_SRC emacs-lisp :tangle init.el
750 (use-package org
751 :defer t
752 :config
753 (org-babel-do-load-languages
754 'org-babel-load-languages
755 '((R . t)
756 (ditaa . t)
757 (dot . t)
758 ;; (php . t)
759 (emacs-lisp . t)
760 (gnuplot . t)
761 (haskell . nil)
762 (latex . t)
763 ;;(ledger . t)
764 (ocaml . nil)
765 (octave . t)
766 (python . t)
767 (ruby . t)
768 (screen . nil)
769 (shell . t)
770 (sql . t)
771 (js . t)))
772 (setq org-default-notes-file "~/Documents/todo.org"
773 system-time-locale "C"
774 org-use-speed-commands t
775 org-adapt-indentation nil
776 org-return-follows-link t
777 org-agenda-include-diary t
778 org-display-remote-inline-images 'download
779 org-agenda-start-with-log-mode t
780 org-image-actual-width (list 400)
781 org-hide-emphasis-markers t
782 org-outline-path-complete-in-steps nil
783 org-src-tab-acts-natively t
784 org-id-track-globally t
785 org-confirm-babel-evaluate nil)
786 (setq org-todo-keywords
787 (quote ((sequence "TODO(t)"
788 "MIGRATE(m)"
789 "IN PROGRESS(p)"
790 "DONE(d)")
791 (sequence "BLOCKED(w@/!)"
792 "HOLD(h@/!)" "|"
793 "CANCELLED(c@/!)"
794 "PHONE"
795 "MEETING"
796 "NEED CLARIFICATION(t)"
797 ))))
798 (setq org-todo-keyword-faces
799 (quote (("TODO" :foreground "red" :weight bold)
800 ("NEXT" :foreground "blue" :weight bold)
801 ("DONE" :foreground "forest green" :weight bold)
802 ("WAITING" :foreground "orange" :weight bold)
803 ("HOLD" :foreground "magenta" :weight bold)
804 ("CANCELLED" :foreground "forest green" :weight bold)
805 ("MEETING" :foreground "forest cyan" :weight bold)
806 ("PHONE" :foreground "blue" :weight bold))))
807 :bind
808 ("C-c l" . org-store-link)
809 ("C-c a" . org-agenda)
810 ("C-c c" . org-capture)
811 )
812
813 (defun org-babel-edit-prep:sql (babel-info)
814 (setq-local buffer-file-name (->> babel-info caddr (alist-get :tangle)))
815 (setq-local lsp-buffer-uri (->> babel-info caddr (alist-get :tangle) lsp--path-to-uri))
816 (setq-local lsp-headerline-breadcrumb-enable nil)
817 (lsp))
818
819 ;; (global-set-key (kbd "M-f") 'org-metaright)
820 ;; (global-set-key (kbd "M-b") 'org-metaleft)
821 ;; (global-set-key (kbd "M-p") 'org-metaup)
822 ;; (global-set-key (kbd "M-n") 'org-metadown)
823#+END_SRC
824
825
826*** Org-ref
827#+begin_src emacs-lisp :tangle nil
828 (load "org-ref-autoloads")
829
830 (setq reftex-default-bibliography '("~/Documents/bibliography/references.bib"))
831
832 ;; see org-ref for use of these variables
833 (setq org-ref-bibliography-notes "~/Documents/bibliography/notes.org"
834 org-ref-default-bibliography '("~/Documents/Bibliography/references.bib")
835 org-ref-pdf-directory "~/Documents/bibliography/bibtex-pdfs/")
836#+end_src
837
838*** Org-roam
839#+begin_src emacs-lisp :tangle init.el
840 (use-package org-roam
841 :defer t
842 :bind
843 ("C-c n l" . org-roam-node-insert)
844 ("C-c n b" . org-roam-buffer-toggle)
845 ("C-c n f" . org-roam-node-find)
846 ("C-c n t t" . org-roam-tag-add)
847 ("C-c n t r" . org-roam-tag-remove)
848 ("C-c n i" . org-roam-jump-to-index)
849 ("C-c n g" . org-roam-graph)
850 ("C-c n d" . org-roam-db-build-cache)
851 ("C-c n r" . org-roam-node-random)
852 ("C-c n j" . org-roam-dailies-find-date)
853 :config
854 (setq org-roam-directory (file-truename "~/Zettelkasten")
855 org-roam-v2-ack t
856 org-roam-completion-everywhere t
857 org-roam-index-file (concat org-roam-directory "/20210409054712-жизнь.org")
858 org-roam-dailies-directory (concat org-roam-directory "journals/"))
859
860 (org-roam-db-autosync-mode t))
861
862 (defun org-roam-jump-to-index ()
863 "Stub of recreating the function from V1"
864 (interactive)
865 (let
866 ((org-roam-index org-roam-index-file))
867 (find-file org-roam-index)))
868
869 (use-package org
870 :defer t
871 :config
872 (customize-set-variable 'org-link-descriptive t)
873
874 (add-to-list 'org-agenda-files
875 "~/Documents/todo.org")
876
877 (setq org-directory "~/Documents"
878 org-default-notes-file (concat org-directory "/todo.org")))
879#+end_src
880
881** YAML
882#+begin_src emacs-lisp :tangle init.el
883 (use-package yaml-mode
884 :defer t)
885#+end_src
886
887* Коммуникации
888** Gnus
889#+begin_src emacs-lisp :tangle init.el
890
891#+end_src
892
893** Telega
894#+BEGIN_SRC emacs-lisp :tangle init.el
895 (use-package telega
896 :bind (("C-c t" . telega-prefix-map)))
897#+END_SRC
898
899** Mastodon
900#+begin_src emacs-lisp :tangle init.el
901 (use-package mastodon
902 :defer t
903 :config
904 (setq mastodon-active-user "w96k"
905 mastodon-instance-url "https://fosstodon.org/"))
906#+end_src
907
908* Разное
909** *Highlight
910#+BEGIN_SRC emacs-lisp :tangle init.el
911 (use-package highlight
912 :defer t)
913#+end_src
914** Минорные твики дефолтного имакса
915*** Короткие ответы на вопросы
916#+begin_src emacs-lisp :tangle init.el
917 (if (boundp 'use-short-answers)
918 (setq use-short-answers t)
919 (advice-add 'yes-or-no-p :override #'y-or-n-p))
920#+end_src
921
922*** Не сохранять дубликаты в killring
923
924*** Подсвечивать текущую строку
925#+begin_src emacs-lisp :tangle nil
926 (global-hl-line-mode t)
927#+end_src
928
929*** Автодополнение в echo при M-x и других командах
930#+begin_src emacs-lisp :tangle init.el
931 (icomplete-mode t)
932#+end_src
933*** Проверять орфографию
934#+begin_src emacs-lisp :tangle init.el
935 (flyspell-mode t)
936#+end_src
937
938*** Не спрашивать о несуществующих буферах
939#+BEGIN_SRC emacs-lisp :tangle init.el
940 (setq-default confirm-nonexistent-file-or-buffer t)
941#+END_SRC
942
943*** Переключение буферов
944#+BEGIN_SRC emacs-lisp :tangle init.el
945 (global-set-key (kbd "M-o") 'mode-line-other-buffer)
946#+END_SRC
947
948*** Минорные твики
949#+begin_src emacs-lisp :tangle init.el
950 ;; (setq redisplay-dont-pause t)
951
952 (setq select-enable-clipboard t
953 select-enable-primary t)
954
955 (setq completions-detailed nil)
956
957 (setq kill-buffer-delete-auto-save-files t)
958 (setq next-error-message-highlight t)
959
960 (setq mode-line-compact 'long)
961
962 (setq completions-group t)
963
964 ;;(set-frame-parameter nil 'internal-border-width 0)
965
966 ;; (set-window-buffer nil (current-buffer))
967
968 (setq default-directory "~/"
969 custom-safe-themes t
970 delete-old-versions t
971 enable-local-variables t)
972#+end_src
973
974*** Shell
975#+begin_src emacs-lisp :tangle init.el
976 (setq ansi-color-for-comint-mode t)
977 (setq shell-command-prompt-show-cwd t)
978#+end_src
979
980*** Переменная PATH в eshell
981#+BEGIN_SRC emacs-lisp :tangle nil
982 (setq exec-path-from-shell-variables
983 '("PATH" "MANPATH"))
984
985 (when (and (memq window-system '(mac ns x))
986 (not (eq system-type 'berkeley-unix)))
987 (exec-path-from-shell-initialize))
988#+END_SRC
989
990*** Отображение номера колонки
991#+BEGIN_SRC emacs-lisp :tangle init.el
992 (column-number-mode)
993#+END_SRC
994
995*** nobreak символы
996#+BEGIN_SRC emacs-lisp :tangle init.el
997 (setq nobreak-char-display nil)
998#+END_SRC
999
1000*** Меню
1001*** Сохранять временные файлы не в той же директории
1002#+BEGIN_SRC emacs-lisp :tangle init.el
1003 (defvar backup-dir "~/.emacs.d/backups/")
1004
1005 (setq
1006 backup-by-copying t
1007 backup-directory-alist
1008 '(("~/.emacs.d/backups/"))
1009 version-control nil)
1010#+END_SRC
1011
1012*** Календарь
1013Делаем начало недели в понедельник.
1014#+BEGIN_SRC emacs-lisp :tangle init.el
1015 (setq calendar-week-start-day 1)
1016#+END_SRC
1017
1018*** Вернуться в предыдущий буфер
1019#+BEGIN_SRC emacs-lisp :tangle nil
1020 (define-key global-map (kbd "C-q C-q") 'previous-buffer)
1021 (define-key global-map (kbd "C-S-q C-S-q") 'next-buffer)
1022#+END_SRC
1023*** Смена раскладки (EN / RU) и поддержка биндов на других языках
1024Работает на C-\
1025#+begin_src elisp :tangle init.el
1026 (set-input-method "russian-computer")
1027 (toggle-input-method)
1028#+end_src
1029
1030*** Требовать создания последней пустой строки
1031#+begin_src emacs-lisp :tangle init.el
1032 (setq require-final-newline t)
1033#+end_src
1034
1035*** Стирать текст на C-h как в Bash
1036И переназначаем старые бинды
1037#+begin_src emacs-lisp :tangle nil
1038 (define-key global-map (kbd "C-h") 'delete-backward-char)
1039 (define-key global-map (kbd "C-c h") 'help-command)
1040#+end_src
1041
1042*** Поддержка CamelCase в навигации
1043#+begin_src emacs-lisp :tangle init.el
1044 (global-subword-mode 1)
1045#+end_src
1046
1047*** Kills
1048#+begin_src emacs-lisp :tangle init.el
1049 (use-package whole-line-or-region
1050 :bind (("C-k" . kill-region)
1051 ("C-w" . backward-kill-word))
1052 :config
1053 (whole-line-or-region-global-mode))
1054#+end_src
1055
1056
1057** Браузер
1058#+begin_src emacs-lisp :tangle nil
1059 (setq browse-url-browser-function #'eww-browse-url)
1060
1061 (add-hook 'eww-mode-hook
1062 (lambda ()
1063 (set-fill-column 80)
1064 (display-fill-column-indicator-mode)
1065 (visual-fill-column-mode)))
1066#+end_src
1067
1068** Tramp
1069#+begin_src emacs-lisp :tangle nil
1070 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1071#+end_src
1072
1073** Docker
1074#+begin_src emacs-lisp :tangle init.el
1075 (use-package docker :defer t)
1076 (use-package docker-compose-mode :defer t)
1077#+end_src
1078** Debian
1079Инструменты для работы с пакетным менеджером Debian'а apt'ом и смежными
1080инструментами.
1081#+begin_src elisp :tangle nil
1082 (load "debian-el-autoloads")
1083 (load "dpkg-dev-el-autoloads")
1084#+end_src
1085
1086** Guix
1087#+begin_src emacs-lisp :tangle init.el
1088 ;; (use-package geiser-guile :defer t)
1089
1090 (use-package guix
1091 :defer t
1092 :config
1093 (setq geiser-guile-binary "guile")
1094 (with-eval-after-load 'geiser-guile
1095 (progn
1096 (add-to-list 'geiser-guile-load-path "~/projects/guix/")))
1097
1098 (let ((guix-copyright "~/projects/guix/etc/copyright.el"))
1099 (if (file-exists-p guix-copyright)
1100 (load-file "~/projects/guix/etc/copyright.el")))
1101
1102 (setq copyright-names-regexp
1103 (format "%s <%s>" user-full-name user-mail-address)))
1104#+end_src
1105
1106** Nix
1107#+begin_src emacs-lisp :tangle init.el
1108 (use-package nix)
1109#+end_src
1110
1111** Direnv
1112#+BEGIN_SRC emacs-lisp :tangle nil
1113 (when (package-loaded? "direnv")
1114 (direnv-mode))
1115#+END_SRC
1116
1117** Баг-трекеры
1118*** Debbugs
1119** PDF
1120
1121** Увеличение/уменьшение шрифта
1122#+BEGIN_SRC emacs-lisp :tangle nil
1123 (defun zoom-in ()
1124 (interactive)
1125 (let ((x (+ (face-attribute 'default :height)
1126 10)))
1127 (set-face-attribute 'default nil :height x)
1128 (set-face-attribute 'mode-line nil :height x)
1129 (set-face-attribute 'mode-line-inactive nil :height x)
1130 (set-face-attribute 'mode-line-position-face nil :height x)))
1131
1132 (defun zoom-out ()
1133 (interactive)
1134 (let ((x (- (face-attribute 'default :height)
1135 10)))
1136 (set-face-attribute 'default nil :height x)
1137 (set-face-attribute 'mode-line nil :height x)
1138 (set-face-attribute 'mode-line-inactive nil :height x)
1139 (set-face-attribute 'mode-line-position-face nil :height x)))
1140
1141 (define-key global-map (kbd "C-=") 'zoom-in)
1142 (define-key global-map (kbd "C-+") 'zoom-out)
1143
1144#+END_SRC
1145
1146** Автокомплит у yes-or-no
1147** Полный экран
1148Открывать Emacs на полный экран
1149#+begin_src emacs-lisp :tangle nil
1150 (add-to-list 'default-frame-alist '(fullscreen . maximized))
1151#+end_src
1152
1153** Фуллскрин
1154Отображать ровно столько строчек, сколько вмещает экран.
1155
1156Не работает с native-comp.
1157
1158#+begin_src elisp :tangle nil
1159 (toggle-frame-fullscreen)
1160
1161 (defun fullscreen ()
1162 "Fullscreen."
1163 (interactive)
1164 (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
1165 ;; if first parameter is '1', can't toggle fullscreen status
1166 '(1 "_NET_WM_STATE_FULLSCREEN" 0)))
1167#+end_src
1168** Удаление буфера и файла
1169#+begin_src elisp :tangle init.el
1170 (defun delete-file-and-buffer ()
1171 "Kill the current buffer and deletes the file it is visiting."
1172 (interactive)
1173 (let ((filename (buffer-file-name)))
1174 (if filename
1175 (if (y-or-n-p (concat "Do you really want to delete file " filename " ?"))
1176 (progn
1177 (delete-file filename)
1178 (message "Deleted file %s." filename)
1179 (kill-buffer)))
1180 (message "Not a file visiting buffer!"))))
1181#+end_src
1182
1183** Длинные строки
1184#+begin_src emacs-lisp :tangle nil
1185 ;; Better support for files with long lines
1186 (setq-default bidi-paragraph-direction 'left-to-right)
1187 (setq-default bidi-inhibit-bpa t)
1188 (global-so-long-mode 1)
1189#+end_src
1190
1191** Make shebang (#!) file executable when saved
1192#+begin_src emacs-lisp :tangle init.el
1193 (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
1194#+end_src
1195
1196** Enable savehist-mode for command history
1197#+begin_src emacs-lisp :tangle init.el
1198 (savehist-mode 1)
1199#+end_src
1200
1201** Ignore case sensitive in completions, search and etc
1202#+begin_src emacs-lisp :tangle init.el
1203 (setq completion-ignore-case t
1204 read-buffer-completion-ignore-case t
1205 read-file-name-completion-ignore-case t)
1206#+end_src
1207
1208** Make scripts executable automatically
1209#+begin_src emacs-lisp :tangle init.el
1210 (add-hook 'after-save-hook
1211 'executable-make-buffer-file-executable-if-script-p)
1212#+end_src
1213
1214** F1 for M-x shell and F2 for grep
1215#+begin_src emacs-lisp :tangle init.el
1216 (global-set-key (kbd "<f1>") 'shell)
1217 (global-set-key (kbd "<f2>") 'rgrep)
1218#+end_src
1219
1220** Hippie expand
1221#+begin_src emacs-lisp :tangle init.el
1222 (global-set-key [remap dabbrev-expand] 'hippie-expand)
1223#+end_src
1224
1225** Window Divider
1226#+begin_src emacs-lisp :tangle init.el
1227 (window-divider-mode t)
1228#+end_src
1229
1230** Use specific font for major modes
1231#+begin_src emacs-lisp :tangle init.el
1232 (buffer-face-mode t)
1233
1234 (defun set-normal-font ()
1235 "Set normal weight font in current buffer"
1236 (interactive)
1237 (buffer-face-mode 1)
1238 (setq buffer-face-mode-face '(:weight normal))
1239 (buffer-face-mode))
1240
1241 ;; Use monospaced font faces in current buffer
1242 (defun set-bold-font ()
1243 "Sets a bold font in current buffer"
1244 (interactive)
1245 (buffer-face-mode 1)
1246 (setq buffer-face-mode-face '(:weight bold))
1247 (buffer-face-mode))
1248
1249 (add-hook 'dired-mode-hook 'set-normal-font)
1250 (add-hook 'org-mode-hook 'set-normal-font)
1251#+end_src
Note: See TracBrowser for help on using the repository browser.