dotfiles
/
config.org
338 строк · 10.0 Кб
1#+TITLE: Emacs config
2#+STARTUP: showeverything
3#+OPTIONS: toc:2
4* TABLE OF CONTENTS :toc:
5- [[#load-first][Load first]]
6- [[#package-manager][Package Manager]]
7- [[#quelpa][Quelpa]]
8- [[#helpers][Helpers]]
9- [[#sudo-open][Sudo open]]
10- [[#look-and-feel][Look and feel]]
11- [[#general][General]]
12- [[#key-bindings][Key bindings]]
13- [[#neotree][NeoTree]]
14- [[#autocomplete][Autocomplete]]
15- [[#font][Font]]
16- [[#ivy][Ivy]]
17- [[#ido][IDO]]
18- [[#code][Code]]
19- [[#perl][Perl]]
20- [[#cc][C/C++]]
21- [[#gdb][GDB]]
22- [[#git][Git]]
23- [[#svn][SVN]]
24- [[#cmake][CMake]]
25- [[#org-mode][Org mode]]
26- [[#general-1][General]]
27- [[#babel][Babel]]
28- [[#table-of-contents][Table of Contents]]
29- [[#enable-org-bullets][Enable Org Bullets]]
30
31* Load first
32** Package Manager
33#+begin_src emacs-lisp
34(defvar elpaca-installer-version 0.6)
35(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
36(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
37(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
38(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
39:ref nil
40:files (:defaults "elpaca-test.el" (:exclude "extensions"))
41:build (:not elpaca--activate-package)))
42(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
43(build (expand-file-name "elpaca/" elpaca-builds-directory))
44(order (cdr elpaca-order))
45(default-directory repo))
46(add-to-list 'load-path (if (file-exists-p build) build repo))
47(unless (file-exists-p repo)
48(make-directory repo t)
49(when (< emacs-major-version 28) (require 'subr-x))
50(condition-case-unless-debug err
51(if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
52((zerop (call-process "git" nil buffer t "clone"
53(plist-get order :repo) repo)))
54((zerop (call-process "git" nil buffer t "checkout"
55(or (plist-get order :ref) "--"))))
56(emacs (concat invocation-directory invocation-name))
57((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
58"--eval" "(byte-recompile-directory \".\" 0 'force)")))
59((require 'elpaca))
60((elpaca-generate-autoloads "elpaca" repo)))
61(progn (message "%s" (buffer-string)) (kill-buffer buffer))
62(error "%s" (with-current-buffer buffer (buffer-string))))
63((error) (warn "%s" err) (delete-directory repo 'recursive))))
64(unless (require 'elpaca-autoloads nil t)
65(require 'elpaca)
66(elpaca-generate-autoloads "elpaca" repo)
67(load "./elpaca-autoloads")))
68(add-hook 'after-init-hook #'elpaca-process-queues)
69(elpaca `(,@elpaca-order))
70
71;; Install a package via the elpaca macro
72;; See the "recipes" section of the manual for more details.
73
74;; (elpaca example-package)
75
76;; Install use-package support
77(elpaca elpaca-use-package
78;; Enable :elpaca use-package keyword.
79(elpaca-use-package-mode)
80;; Assume :elpaca t unless otherwise specified.
81(setq elpaca-use-package-by-default t))
82
83;; Block until current queue processed.
84(elpaca-wait)
85
86;; fix for magit
87(defun +elpaca-unload-seq (e)
88(and (featurep 'seq) (unload-feature 'seq t))
89(elpaca--continue-build e))
90
91(defun +elpaca-seq-build-steps ()
92(append (butlast (if (file-exists-p (expand-file-name "seq" elpaca-builds-directory))
93elpaca--pre-built-steps elpaca-build-steps))
94(list '+elpaca-unload-seq 'elpaca--activate-package)))
95
96(use-package seq :elpaca `(seq :build ,(+elpaca-seq-build-steps)))
97;; Don't install anything. Defer execution of BODY
98;; (elpaca nil (message "deferred"))
99
100#+end_src
101** Quelpa
102#+begin_src emacs-lisp
103(use-package quelpa
104:ensure t
105:demand t
106:custom (quelpa-update-melpa-p nil))
107
108(use-package quelpa-use-package
109:ensure t
110:demand t)
111#+end_src
112
113* Helpers
114** Sudo open
115#+begin_src emacs-lisp
116(defun sudo-find-file (file-name)
117"Like find file, but opens the file as root."
118(interactive "FSudo Find File: ")
119(let ((tramp-file-name (concat "/sudo::" (expand-file-name file-name))))
120(find-file tramp-file-name)))
121#+end_src
122
123* Look and feel
124** General
125#+begin_src emacs-lisp
126(setq visible-bell t)
127(setq-default indent-tabs-mode nil)
128(setq tab-width 4) ;; ширина табов
129(setq-default truncate-lines t)
130(setq-default truncate-partial-width-windows t)
131
132(setq backup-directory-alist `(("." . "~/.saves")))
133(setq inhibit-startup-message t) ;;не показывать сообщение при старте
134(fset 'yes-or-no-p 'y-or-n-p) ;;не заставляйте меня печать yes целиком
135(setq-default tab-width 4) ;;поумолчанию
136(customize-set-variable 'menu-bar-mode nil)
137(customize-set-variable 'tool-bar-mode nil)
138(customize-set-variable 'scroll-bar-mode nil)
139
140(global-display-line-numbers-mode 1) ;; номер строки слева
141;; (global-visual-line-mode nil)
142
143(load-theme 'tango-dark t)
144#+end_src
145** Key bindings
146#+begin_src emacs-lisp
147(use-package general
148:config
149(general-define-key
150"M-<up>" 'windmove-up
151"M-<down>" 'windmove-down
152"M-<right>" 'windmove-right
153"M-<left>" 'windmove-left
154"C-x C-b" 'switch-to-buffer
155"C-x f" 'find-file
156"C-<f8>" 'neotree-project-dir)
157(general-def c-mode-base-map
158"C-c o" 'ff-find-other-file
159"<C-tab>" (function company-complete)
160"M-," 'rtags-location-stack-back
161"M-/" 'rtags-location-stack-forward
162"M-." 'rtags-find-symbol-at-point
163"M-\\" 'rtags-find-references-at-point
164"M-'" 'rtags-find-virtuals-at-point)
165(general-def org-mode-map
166"M-<up>" 'windmove-up
167"M-<down>" 'windmove-down
168"M-<right>" 'windmove-right
169"M-<left>" 'windmove-left)
170)
171#+end_src
172** NeoTree
173#+begin_src emacs-lisp
174(use-package all-the-icons
175:if (display-graphic-p))
176(use-package find-file-in-project
177:ensure t)
178(use-package neotree
179:ensure t
180:init
181(setq neo-theme (if (display-graphic-p) 'icons))
182(setq neo-window-width 40)
183:config
184(add-hook 'neo-after-create-hook
185(lambda (&rest _) (display-line-numbers-mode -1)))
186
187(defun neotree-project-dir ()
188"Open NeoTree using the git root."
189(interactive)
190(let ((project-dir (ffip-project-root))
191(file-name (buffer-file-name)))
192(if project-dir
193(progn
194(neotree-dir project-dir)
195(neotree-find file-name))
196(message "Could not find git project root.")))))
197#+end_src
198
199** Autocomplete
200#+begin_src emacs-lisp
201(use-package company
202:after (rtags)
203:custom (company-dabbrev-downcase nil)
204:config (global-company-mode))
205(use-package company-rtags
206:after (rtags company)
207:config (push 'company-rtags company-backends))
208#+end_src
209** Font
210#+begin_src emacs-lisp
211(set-face-attribute 'default nil
212:font "Hack"
213:height 110
214:weight 'normal)
215(set-face-attribute 'font-lock-comment-face nil
216:slant 'italic)
217(set-face-attribute 'font-lock-keyword-face nil
218:slant 'italic)
219#+end_src
220** Ivy
221#+begin_src emacs-lisp
222(use-package ivy
223:ensure t
224:demand t)
225(use-package ivy-rtags
226:ensure t
227:demand t
228:after (ivy rtags))
229#+end_src
230** IDO
231#+begin_src emacs-lisp
232(use-package ido
233:elpaca nil
234:custom
235(ido-auto-merge-work-directories-length -1)
236(ido-everywhere t)
237(ido-enable-flex-matching t)
238(ido-all-frames nil)
239:config
240(ido-mode 1))
241#+end_src
242
243
244
245* Code
246** Perl
247#+begin_src emacs-lisp
248(defvaralias 'cperl-indent-level 'tab-width)
249(setq-default indent-tabs-mode nil)
250(defalias 'perl-mode 'cperl-mode)
251(add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\|t\\)\\'" . cperl-mode))
252(defalias 'perl-mode 'cperl-mode)
253#+end_src
254
255** C/C++
256#+begin_src emacs-lisp
257(defvaralias 'c-basic-offset 'tab-width)
258(use-package c-mode
259:elpaca nil
260:no-require t
261:config
262(c-set-offset 'member-init-intro 8)
263(c-set-offset 'member-init-cont 0)
264(c-set-offset 'case-label 4)
265(c-set-offset 'arglist-cont-nonempty 8))
266
267(use-package rtags
268:ensure t
269:demand t
270:after (ivy)
271:custom
272(rtags-display-result-backend 'ivy))
273(use-package modern-cpp-font-lock
274:ensure t)
275#+end_src
276** GDB
277#+begin_src emacs-lisp
278(use-package gdb-mi
279:elpaca (gdb-mi :host github
280:repo "dvzubarev/emacs-gdb"
281;; :repo "weirdNox/emacs-gdb"
282:files (:defaults "*.el" "*.c" "*.h" "Makefile"))
283:ensure t :demand t
284:init
285(fmakunbound 'gdb)
286(fmakunbound 'gdb-enable-debug))
287#+end_src
288** Git
289#+begin_src emacs-lisp
290(use-package magit
291:ensure t
292:demand t)
293#+end_src
294** SVN
295#+begin_src emacs-lisp
296(use-package psvn
297:elpaca (psvn :repo "~/devel/emacs/psvn")
298:custom
299(svn-status-verbose nil))
300#+end_src
301** CMake
302#+begin_src emacs-lisp
303(use-package cmake-mode
304:ensure t)
305#+end_src
306* Org mode
307** General
308#+begin_src emacs-lisp
309(use-package org
310:mode (("\\.org$" . org-mode))
311:elpaca nil
312:config
313(progn
314(setq org-support-shift-select 1)))
315#+end_src
316** Babel
317#+begin_src emacs-lisp
318(use-package org-babel
319:no-require
320:elpaca nil
321:config
322(org-babel-do-load-languages
323'org-babel-load-languages
324'((sqlite . t))))
325#+end_src
326** Table of Contents
327#+begin_src emacs-lisp
328(use-package toc-org
329:commands toc-org-enable
330:init (add-hook 'org-mode-hook 'toc-org-enable))
331#+end_src
332
333** Enable Org Bullets
334#+begin_src emacs-lisp
335(add-hook 'org-mode-hook 'org-indent-mode)
336(use-package org-bullets)
337(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
338#+end_src
339