You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

862 lines
26 KiB

5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
4 years ago
5 years ago
4 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
5 years ago
5 years ago
  1. #+TITLE: Emacs configuration file
  2. #+AUTHOR: Marc
  3. #+BABEL: :cache yes
  4. #+PROPERTY: header-args :tangle yes
  5. * TODOS
  6. - Paket exec-path-from-shell, um PATH aus Linux auch in emacs zu haben
  7. - Smart mode line?
  8. - Theme
  9. - evil-collection or custom in init file?
  10. - Hydra
  11. - General
  12. - (defalias 'list-buffers 'ibuffer) ;; change default to ibuffer
  13. - ido?
  14. - treemacs (for linux)
  15. - treemacs-evil?
  16. - treemacs-projectile
  17. - ace-window
  18. - windmove?
  19. - tramp (in linux)
  20. - visual-regexp
  21. - org configuration: paths
  22. - org custom agenda
  23. - org configuration: everything else
  24. - beancount configuration from config.org
  25. - CONTINUE TODO from config.org at Programming
  26. * First start
  27. :PROPERTIES:
  28. :ID: ec248005-527f-4fa1-bdef-9343f2fa28b0
  29. :END:
  30. When pulling the repository the first time, an initial init.el needs to be setup. After start it will replace itself with the configuration from init.org
  31. #+BEGIN_SRC emacs-lisp :tangle no
  32. (require 'org')
  33. (find-file (concat user-emacs-directory "init.org"))
  34. (org-babel-tangle)
  35. (load-file (concat user-emacs-directory "init.el"))
  36. (byte-compile-file (concat user-emacs-directory "init.el"))
  37. #+END_SRC
  38. This function updates init.el whenever changes in init.org are made. The update will be active after saving.
  39. #+BEGIN_SRC emacs-lisp
  40. (defun me/tangle-init ()
  41. "If the current buffer is 'init.org',
  42. the code blocks are tangled, and the tangled file is compiled."
  43. (when (equal (buffer-file-name)
  44. (expand-file-name (concat user-emacs-directory "init.org")))
  45. ;; avoid running hooks
  46. (let ((prog-mode-hook nil))
  47. (org-babel-tangle)
  48. (byte-compile-file (concat user-emacs-directory "init.el"))
  49. (load-file user-init-file))))
  50. (add-hook 'after-save-hook 'me/tangle-init)
  51. #+END_SRC
  52. #+BEGIN_SRC emacs-lisp
  53. (require 'package)
  54. ;; bug before emacs 26.3
  55. (when (version< emacs-version "26.3")
  56. (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
  57. (add-to-list 'package-archives '("elpa" . "https://elpa.gnu.org/packages/") t)
  58. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  59. (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
  60. (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
  61. (package-initialize)
  62. #+END_SRC
  63. #+BEGIN_SRC emacs-lisp
  64. (unless (package-installed-p 'use-package)
  65. (package-refresh-contents)
  66. (package-install 'use-package))
  67. (setq use-package-verbose nil)
  68. (eval-when-compile
  69. (require 'use-package))
  70. (require 'bind-key)
  71. (use-package diminish
  72. :ensure t)
  73. #+END_SRC
  74. * Default settings
  75. :PROPERTIES:
  76. :ID: 00b48602-2a95-492e-a90b-c1e3a94c1ecb
  77. :END:
  78. #+BEGIN_SRC emacs-lisp
  79. (defvar me/whoami
  80. (if (string-equal (system-name) "PMTS01")
  81. "work_remote"
  82. (if (string-equal (system-name) "laptop")
  83. "home_laptop"
  84. (if (string-equal (system-name) "PMPCNEU08")
  85. "work_local"
  86. "home_desktop"))))
  87. #+END_SRC
  88. #+BEGIN_SRC emacs-lisp
  89. (defvar MY--PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/"))
  90. (defvar MY--PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/"))
  91. (pcase me/whoami
  92. ("home"
  93. (progn
  94. (defvar MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/"))
  95. (defvar MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/"))
  96. (defvar MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/"))))
  97. ("home_laptop"
  98. (progn
  99. (defvar MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/"))
  100. (defvar MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/"))
  101. (defvar MY--PATH_ORG_JOURNAL (expand-file-name "~/Archiv/Organisieren/Journal/"))))
  102. ("work_remote"
  103. (progn
  104. (defvar MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  105. (defvar MY--PATH-ORG-JOURNAL "p:/Eigene Dateien/Notizen/Journal/")
  106. (defvar MY--PATH_START "p:/Eigene Dateien/Notizen/"))))
  107. (setq bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks"))
  108. (setq recentf-save-file (concat MY--PATH_USER_LOCAL "recentf"))
  109. (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings
  110. (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_defs"))
  111. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  112. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  113. (setq save-abbrevs 'silently) ;; don't bother me with asking for abbrev saving
  114. (setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode
  115. (defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n
  116. (setq custom-safe-themes t) ;; don't ask me if I want to load a theme
  117. (setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence.
  118. (delete-selection-mode t) ;; delete selected region when typing
  119. (save-place-mode 1) ;; saves position in file when it's closed
  120. (setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position
  121. (setq locale-coding-system 'utf-8)
  122. (set-terminal-coding-system 'utf-8)
  123. (set-keyboard-coding-system 'utf-8)
  124. (set-selection-coding-system 'utf-8)
  125. (if (eq system-type 'windows-nt)
  126. (prefer-coding-system 'utf-8-dos)
  127. (prefer-coding-system 'utf-8))
  128. (blink-cursor-mode -1) ;; turn off blinking cursor
  129. (show-paren-mode t) ;; show other part of brackets
  130. (column-number-mode t)
  131. (setq uniquify-buffer-name-style 'forward)
  132. (setq-default indent-tabs-mode nil) ;; avoid tabs in place of multiple spaces (they look bad in tex)
  133. (setq-default indicate-empty-lines t) ;; show empty lines
  134. (setq scroll-margin 5 ;; smooth scrolling
  135. scroll-conservatively 10000
  136. scroll-preserve-screen-position 1
  137. scroll-step 1)
  138. (global-hl-line-mode t) ;; highlight current line
  139. (menu-bar-mode 0) ;; disable menu bar
  140. (tool-bar-mode 0) ;; disable tool bar
  141. (scroll-bar-mode 0) ;; disable scroll bar
  142. #+END_SRC
  143. Some windows specific stuff
  144. #+BEGIN_SRC emacs-lisp
  145. (when (eq system-type 'windows-nt)
  146. (remove-hook 'find-file-hooks 'vc-refresh-state)
  147. (progn
  148. (setq gc-cons-threshold (* 511 1024 1024)
  149. gc-cons-percentage 0.5
  150. garbage-collection-messages t
  151. w32-pipe-read-delay 0
  152. w32-get-true-file-attributes nil)
  153. (run-with-idle-timer 5 t #'garbage-collect)))
  154. #+END_SRC
  155. * visuals
  156. ** Font
  157. :PROPERTIES:
  158. :ID: cdfaaf73-b027-4b86-8d27-ebdce4b85009
  159. :END:
  160. #+BEGIN_SRC emacs-lisp
  161. (if (string-equal system-type "gnu/linux")
  162. (set-face-font 'default "Hack-10"))
  163. #+END_SRC
  164. ** line wrappings
  165. :PROPERTIES:
  166. :ID: 60b1f231-ab1e-4c47-ac6d-262dc208a520
  167. :END:
  168. #+BEGIN_SRC emacs-lisp
  169. (global-visual-line-mode)
  170. (diminish 'visual-line-mode)
  171. (use-package adaptive-wrap
  172. :ensure t
  173. :config
  174. (add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode))
  175. ; :init
  176. ; (when (fboundp 'adaptive-wrap-prefix-mode)
  177. ; (defun my/activate-adaptive-wrap-prefix-mode ()
  178. ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  179. ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  180. ; (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode)))
  181. #+END_SRC
  182. ** line numbers
  183. :PROPERTIES:
  184. :ID: d3dfb79a-103a-4318-a5af-5a55e12674ce
  185. :END:
  186. #+BEGIN_SRC emacs-lisp
  187. (use-package display-line-numbers
  188. :init
  189. (add-hook 'prog-mode-hook 'display-line-numbers-mode)
  190. (add-hook 'org-src-mode-hook 'display-line-numbers-mode)
  191. :config
  192. (setq-default display-line-numbers-type 'visual
  193. display-line-numbers-current-absolute t
  194. display-line-numbers-with 4
  195. display-line-numbers-widen t))
  196. ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode)
  197. #+END_SRC
  198. ** misc
  199. :PROPERTIES:
  200. :ID: f0f774d6-db13-4871-9192-d36e78120dde
  201. :END:
  202. #+BEGIN_SRC emacs-lisp
  203. (use-package rainbow-mode
  204. :ensure t
  205. :diminish
  206. :hook ((org-mode
  207. emacs-lisp-mode) . rainbow-mode))
  208. #+END_SRC
  209. * undo
  210. :PROPERTIES:
  211. :ID: fde526fa-b053-48dd-9ac1-c443d987f4d2
  212. :END:
  213. #+BEGIN_SRC emacs-lisp
  214. (use-package undo-tree
  215. :ensure t
  216. :diminish undo-tree-mode
  217. :init
  218. (global-undo-tree-mode 1))
  219. #+END_SRC
  220. * imenu-list
  221. :PROPERTIES:
  222. :ID: 796d00db-aadb-412b-a291-619b029977f3
  223. :END:
  224. A minor mode to show imenu in a sidebar.
  225. Call imenu-list-smart-toggle.
  226. [[https://github.com/bmag/imenu-list][Source]]
  227. #+BEGIN_SRC emacs-lisp
  228. (use-package imenu-list
  229. :ensure t
  230. :config
  231. (setq imenu-list-focus-after-activation t
  232. imenu-list-auto-resize t
  233. imenu-list-position 'right)
  234. :bind
  235. (:map global-map
  236. ([f9] . imenu-list-smart-toggle))
  237. )
  238. #+END_SRC
  239. * which-key
  240. :PROPERTIES:
  241. :ID: 0a67aeb4-4060-4f4d-a7ff-61c70fe7ec7b
  242. :END:
  243. #+BEGIN_SRC emacs-lisp
  244. (use-package which-key
  245. :ensure t
  246. :diminish which-key-mode
  247. :config
  248. (which-key-mode)
  249. (which-key-setup-side-window-right-bottom)
  250. (which-key-setup-minibuffer)
  251. (setq which-key-idle-delay 0.5))
  252. #+END_SRC
  253. * Evil
  254. :PROPERTIES:
  255. :ID: a3389b7d-3833-42b7-97e1-413b8c4d9833
  256. :END:
  257. #+BEGIN_SRC emacs-lisp
  258. (use-package evil
  259. :ensure t
  260. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  261. :config
  262. (evil-mode 1))
  263. #+END_SRC
  264. * General (key mapper)
  265. :PROPERTIES:
  266. :ID: 027bdcf8-95c9-4e9b-88ba-6e9d3e5116c0
  267. :END:
  268. #+BEGIN_SRC emacs-lisp
  269. (use-package general
  270. :ensure t)
  271. (general-define-key
  272. :states 'normal
  273. :keymaps 'imenu-list-major-mode-map
  274. (kbd "RET") '(imenu-list-goto-entry :which-key "goto")
  275. (kbd "TAB") '(hs-toggle-hiding :which-key "collapse")
  276. "d" '(imenu-list-display-entry :which-key "show")
  277. "q" '(imenu-list-quit-window :which-key "quit"))
  278. #+END_SRC
  279. * orgmode
  280. ** org
  281. :PROPERTIES:
  282. :ID: 3877251e-5ece-4006-baa6-1f1b4846a8f3
  283. :END:
  284. #+BEGIN_SRC emacs-lisp
  285. (use-package org
  286. :ensure org-plus-contrib
  287. :mode (("\.org$" . org-mode))
  288. :init
  289. (add-hook 'org-mode-hook 'company/org-mode-hook)
  290. (add-hook 'org-src-mode-hook 'smartparens-mode)
  291. :config
  292. (setq org-modules (quote (org-id
  293. org-habit
  294. org-tempo ;; easy templates
  295. )))
  296. (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")
  297. org-agenda-files (list MY--PATH_ORG_FILES
  298. MY--PATH_ORG_FILES_MOBILE)
  299. org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations")
  300. org-log-into-drawer "LOGBOOK")
  301. ;; some display customizations
  302. (setq org-pretty-entities t
  303. org-startup-truncated t
  304. org-startup-align-all-tables t)
  305. ;; some source code blocks customizations
  306. (setq org-src-window-setup 'current-window ;; C-c ' opens in current window
  307. org-src-fontify-natively t ;; use syntax highlighting in code blocks
  308. org-src-preserve-indentation t ;; no extra indentation
  309. org-src-tab-acts-natively t))
  310. #+END_SRC
  311. ** languages
  312. :PROPERTIES:
  313. :ID: 467efd58-e928-4ccf-9ac4-d144eaede8ed
  314. :END:
  315. #+BEGIN_SRC emacs-lisp
  316. (org-babel-do-load-languages
  317. 'org-babel-load-languages
  318. '((emacs-lisp . t)
  319. (gnuplot . t)
  320. (js . t)
  321. (latex . t)
  322. (lisp . t)
  323. (python . t)
  324. (shell . t)
  325. (sqlite . t)
  326. (org . t)
  327. (R . t)
  328. (scheme . t)
  329. ))
  330. (defun me--org-confirm-babel-evaluate (lang body)
  331. "Do not confirm evaluation for these languages."
  332. (not (or (string= lang "python")
  333. (string= lang "ipython")
  334. (string= lang "emacs-lisp")
  335. (string= lang "R")
  336. (string= lang "latex")
  337. (string= lang "sqlite"))))
  338. (setq org-confirm-babel-evaluate 'me--org-confirm-babel-evaluate)
  339. #+END_SRC
  340. ** habits
  341. :PROPERTIES:
  342. :ID: 61735b0c-5016-4697-80c6-beb7b3f27a1b
  343. :END:
  344. #+BEGIN_SRC emacs-lisp
  345. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  346. ;; (add-to-list 'org-modules "org-habit")
  347. (setq org-habit-graph-column 80
  348. org-habit-preceding-days 30
  349. org-habit-following-days 7
  350. org-habit-show-habits-only-for-today nil)
  351. #+END_SRC
  352. ** org-id
  353. :PROPERTIES:
  354. :ID: 017ef411-8239-4bfe-bbef-66b98a2971a9
  355. :END:
  356. #+BEGIN_SRC emacs-lisp
  357. (use-package org-id
  358. :config
  359. (setq org-id-link-to-org-use-id t)
  360. (org-id-update-id-locations)) ;; update id file .org-id-locations on startup
  361. #+END_SRC
  362. ** org-agenda
  363. :PROPERTIES:
  364. :ID: 10e65f59-ba2c-47e4-a40c-3097c15544aa
  365. :END:
  366. Custom keywords, depending on environment
  367. #+BEGIN_SRC emacs-lisp
  368. (pcase me/whoami
  369. ("work_remote")
  370. (setq org-todo-keywords
  371. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE"))))
  372. #+END_SRC
  373. Add some key bindings
  374. #+BEGIN_SRC emacs-lisp
  375. (bind-key "C-c l" 'org-store-link)
  376. (bind-key "C-c c" 'org-capture)
  377. (bind-key "C-c a" 'org-agenda)
  378. #+END_SRC
  379. Sort agenda by deadline and priority
  380. #+BEGIN_SRC emacs-lisp
  381. (setq org-agenda-sorting-strategy
  382. (quote
  383. ((agenda deadline-up priority-down)
  384. (todo priority-down category-keep)
  385. (tags priority-down category-keep)
  386. (search category-keep))))
  387. #+END_SRC
  388. Customize the org agenda
  389. #+BEGIN_SRC emacs-lisp
  390. (defun me--org-skip-subtree-if-priority (priority)
  391. "Skip an agenda subtree if it has a priority of PRIORITY.
  392. PRIORITY may be one of the characters ?A, ?B, or ?C."
  393. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  394. (pri-value (* 1000 (- org-lowest-priority priority)))
  395. (pri-current (org-get-priority (thing-at-point 'line t))))
  396. (if (= pri-value pri-current)
  397. subtree-end
  398. nil)))
  399. (setq org-agenda-custom-commands
  400. '(("c" "Simple agenda view"
  401. ((tags "PRIORITY=\"A\""
  402. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  403. (org-agenda-overriding-header "Hohe Priorität:")))
  404. (agenda ""
  405. ((org-agenda-span 7)
  406. (org-agenda-start-on-weekday nil)
  407. (org-agenda-overriding-header "Nächste 7 Tage:")))
  408. (alltodo ""
  409. ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A)
  410. (org-agenda-skip-if nil '(scheduled deadline))))
  411. (org-agenda-overriding-header "Sonstige Aufgaben:")))))))
  412. #+END_SRC
  413. ** *TODO*
  414. org-super-agenda
  415. ** org-caldav
  416. :PROPERTIES:
  417. :ID: 58aa11ef-80f7-4629-a957-a9e00e070136
  418. :END:
  419. Vorerst deaktiviert, Nutzen evtl. nicht vorhanden
  420. #+BEGIN_SRC emacs-lisp
  421. ;;(use-package org-caldav
  422. ;; :ensure t
  423. ;; :config
  424. ;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc"
  425. ;; org-caldav-calendar-id "orgmode"
  426. ;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox")
  427. ;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks")))
  428. #+END_SRC
  429. ** journal
  430. :PROPERTIES:
  431. :ID: 0b7243ac-049f-4b9c-a062-7a349c515133
  432. :END:
  433. [[https://github.com/bastibe/org-journal][Source]]
  434. #+BEGIN_SRC emacs-lisp
  435. (use-package org-journal
  436. :ensure t
  437. :defer t
  438. :custom
  439. (org-journal-dir MY--PATH_ORG_JOURNAl)
  440. (org-journal-enable-agenda-integration t))
  441. #+END_SRC
  442. * ivy / counsel / swiper
  443. :PROPERTIES:
  444. :ID: c2146a70-03f4-4f60-9bce-094eec28cefe
  445. :END:
  446. #+BEGIN_SRC emacs-lisp
  447. ; (require 'ivy)
  448. (use-package ivy
  449. :ensure t
  450. :diminish
  451. (ivy-mode . "")
  452. :init
  453. (ivy-mode 1)
  454. :bind
  455. ("C-r" . ivy-resume) ;; overrides isearch-backwards binding
  456. :config
  457. (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer
  458. ivy-height 20 ;; height of ivy window
  459. ivy-count-format "%d/%d" ;; current and total number
  460. ivy-re-builders-alist ;; regex replaces spaces with *
  461. '((t . ivy--regex-plus))))
  462. (use-package counsel
  463. :ensure t
  464. :bind*
  465. (("M-x" . counsel-M-x)
  466. ("C-x C-f" . counsel-find-file)
  467. ("C-x C-r" . counsel-recentf)
  468. ("C-c C-f" . counsel-git)
  469. ("C-c h f" . counsel-describe-function)
  470. ("C-c h v" . counsel-describe-variable)
  471. ("M-i" . counsel-imenu)))
  472. (use-package swiper
  473. :ensure t
  474. :bind
  475. ("C-s" . swiper))
  476. (use-package ivy-hydra
  477. :ensure t)
  478. #+END_SRC
  479. * company
  480. :PROPERTIES:
  481. :ID: 1630ac5e-7467-458c-940c-4f724e283813
  482. :END:
  483. #+BEGIN_SRC emacs-lisp
  484. ; (require 'company)
  485. (use-package company
  486. :defer 1
  487. :bind
  488. (:map company-active-map
  489. ("RET" . nil)
  490. ([return] . nil)
  491. ("TAB" . company-complete-selection)
  492. ([tab] . company-complete-selection)
  493. ("<right>" . company-complete-common))
  494. :config
  495. (global-company-mode 1)
  496. (setq-default
  497. company-idle-delay .2
  498. company-minimum-prefix-length 1
  499. company-require-match nil
  500. company-show-numbers t
  501. company-tooltip-align-annotations t))
  502. ; (require 'company-statistics)
  503. (use-package company-statistics
  504. :ensure t
  505. :after company
  506. :init
  507. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  508. :config
  509. (company-statistics-mode 1))
  510. (use-package company-dabbrev
  511. :ensure nil
  512. :after company
  513. :config
  514. (setq-default company-dabbrev-downcase nil))
  515. (use-package company-box
  516. :ensure t
  517. :init
  518. (add-hook 'company-mode-hook 'company-box-mode))
  519. #+END_SRC
  520. ** company backends
  521. :PROPERTIES:
  522. :ID: 6ac59f9d-54e3-422d-883f-128fb172468d
  523. :END:
  524. #+BEGIN_SRC emacs-lisp
  525. (defun company/org-mode-hook()
  526. (set (make-local-variable 'company-backends)
  527. '(company-capf company-files))
  528. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  529. (message "company/org-mode-hook"))
  530. (defun company/elisp-mode-hook()
  531. (set (make-local-variable 'company-backends)
  532. '((company-elisp company-dabbrev) company-capf company-files))
  533. (message "company/elisp-mode-hook"))
  534. (defun company/beancount-mode-hook()
  535. (set (make-local-variable 'company-backends)
  536. '(company-beancount)))
  537. #+END_SRC
  538. * Programming
  539. ** Magit / Git
  540. :PROPERTIES:
  541. :ID: a947f806-181d-4d33-9734-435849385b0b
  542. :END:
  543. Little crash course in magit:
  544. - magit-init to init a git project
  545. - magit-status (C-x g) to call the status window
  546. In status buffer:
  547. - s stage files
  548. - u unstage files
  549. - U unstage all files
  550. - a apply changes to staging
  551. - c c commit (type commit message, then C-c C-c to commit)
  552. - b b switch to another branch
  553. - P u git push
  554. - F u git pull
  555. #+BEGIN_SRC emacs-lisp
  556. (use-package magit
  557. :ensure t
  558. :defer t
  559. :init
  560. ; set git-path in work environment
  561. (if (string-equal user-login-name "POH")
  562. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  563. )
  564. :bind (("C-x g" . magit-status))
  565. )
  566. #+END_SRC
  567. ** LSP
  568. :PROPERTIES:
  569. :ID: d529d096-ec38-42e6-91c9-099c1d8bdd06
  570. :END:
  571. Configuration for the language server protocol
  572. *ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp
  573. Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden.
  574. Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad.
  575. TODO Unterverzeichnisse wurden noch nicht getestet
  576. #+BEGIN_SRC emacs-lisp
  577. (use-package lsp-mode
  578. :defer t
  579. :commands lsp
  580. :custom
  581. (lsp-auto-guess-root nil)
  582. (lsp-prefer-flymake nil) ; use flycheck instead
  583. (lsp-file-watch-threshold 2000)
  584. :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
  585. :hook ((python-mode
  586. js-mode
  587. js2-mode
  588. typescript-mode
  589. web-mode) . lsp))
  590. (use-package lsp-ui
  591. :after lsp-mode
  592. :ensure t
  593. :diminish
  594. :commands lsp-ui-mode
  595. :config
  596. (setq lsp-ui-doc-enable t
  597. lsp-ui-doc-header t
  598. lsp-ui-doc-include-signature t
  599. lsp-ui-doc-position 'top
  600. lsp-ui-doc-border (face-foreground 'default)
  601. lsp-ui-sideline-enable nil
  602. lsp-ui-sideline-ignore-duplicate t
  603. lsp-ui-sideline-show-code-actions nil)
  604. (when (display-graphic-p)
  605. (setq lsp-ui-doc-use-webkit t))
  606. ;; workaround hide mode-line of lsp-ui-imenu buffer
  607. (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
  608. (setq mode-line-format nil)))
  609. (use-package company-lsp
  610. :requires company
  611. :defer t
  612. :ensure t
  613. :config
  614. ;;disable client-side cache because lsp server does a better job
  615. (setq company-transformers nil
  616. company-lsp-async t
  617. company-lsp-cache-candidates nil))
  618. #+END_SRC
  619. ** flycheck
  620. :PROPERTIES:
  621. :ID: c8090ddb-4f22-49ba-8ab1-1de132e1d772
  622. :END:
  623. #+BEGIN_SRC emacs-lisp
  624. (use-package flycheck
  625. :ensure t
  626. :hook
  627. ((css-mode . flycheck-mode)
  628. (emacs-lisp-mode . flycheck-mode)
  629. (python-mode . flycheck-mode))
  630. :init
  631. (setq flycheck-emacs-lisp-load-path 'inherit)
  632. :config
  633. (setq-default
  634. flycheck-check-synta-automatically '(save mode-enabled)
  635. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  636. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  637. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  638. #+END_SRC
  639. ** Projectile
  640. :PROPERTIES:
  641. :ID: 3cc5c1d2-1a5d-4d1a-bfeb-48de8172dd63
  642. :END:
  643. Manage projects and jump quickly between its files
  644. #+BEGIN_SRC emacs-lisp
  645. (use-package projectile
  646. :ensure t
  647. :defer t
  648. :bind
  649. (("C-c p p" . projectile-switch-project)
  650. ("C-c p c" . projectile-command-map)
  651. ("C-c p s s" . projectile-ag))
  652. :init
  653. (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache")
  654. projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks"))
  655. :config
  656. (projectile-mode t)
  657. (setq-default projectile-completion-system 'ivy
  658. projectile-enable-caching t
  659. projectile-mode-line '(:eval (projectile-project-name))))
  660. #+END_SRC
  661. ** smartparens
  662. :PROPERTIES:
  663. :ID: 04be375f-d100-47e7-99f1-af47a3139a54
  664. :END:
  665. #+BEGIN_SRC emacs-lisp
  666. (use-package smartparens
  667. :ensure t
  668. :diminish smartparens-mode
  669. :config
  670. (setq sp-show-pair-from-inside nil)
  671. (require 'smartparens-config))
  672. #+END_SRC
  673. ** lisp
  674. :PROPERTIES:
  675. :ID: e5ce0263-3b21-460e-a037-3fe27d6e836a
  676. :END:
  677. #+BEGIN_SRC emacs-lisp
  678. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  679. #+END_SRC
  680. ** web
  681. :PROPERTIES:
  682. :ID: 5649b885-839f-48db-8b4f-8d594df7ebd8
  683. :END:
  684. apt install npm
  685. sudo npm install -g vscode-html-languageserver-bin
  686. evtl alternativ typescript-language-server?
  687. #+BEGIN_SRC emacs-lisp
  688. (use-package web-mode
  689. :ensure t
  690. :defer t
  691. :mode
  692. ("\\.phtml\\'"
  693. "\\.tpl\\.php\\'"
  694. "\\.djhtml\\'"
  695. "\\.[t]?html?\\'")
  696. :config
  697. (setq web-mode-enable-auto-closing t
  698. web-mode-enable-auto-pairing t)
  699. (add-hook 'web-mode-hook 'smartparens-mode))
  700. #+END_SRC
  701. ** Python
  702. :PROPERTIES:
  703. :ID: cd4bbd1f-9980-42c9-a5af-aa808779d524
  704. :END:
  705. Systemseitig muss python-language-server installiert sein:
  706. pip3 install 'python-language-server[all]'
  707. für andere language servers
  708. https://github.com/emacs-lsp/lsp-mode#install-language-server
  709. #+BEGIN_SRC emacs-lisp
  710. (if (string-equal system-type "gnu/linux")
  711. (use-package pyvenv
  712. :ensure t
  713. :config
  714. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  715. (add-hook 'pyvenv-post-activate-hooks #'my/postactivatehook))
  716. (defun my/postactivatehook ()
  717. (setq lsp-python-ms-extra-paths pyvenv-virtual-env))
  718. (use-package virtualenvwrapper
  719. :ensure t
  720. :hook (venv-postmkvirtualenv . (lambda() (shell-command "pip3 install importmagic epc")))
  721. :config
  722. (setq venv-location (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  723. (use-package lsp-python-ms
  724. :ensure t
  725. :after lsp-mode python))
  726. ; :custom (lsp-python-executable-cmd "python3"))
  727. #+END_SRC
  728. * beancount
  729. ** Installation
  730. :PROPERTIES:
  731. :ID: 0c5f3396-4b08-4549-ac68-0c516cfd4435
  732. :END:
  733. #+BEGIN_SRC shell
  734. sudo su
  735. cd /opt
  736. python3 -m venv beancount
  737. source ./beancount/bin/activate
  738. pip3 install wheel
  739. pip3 install beancount
  740. sleep 100
  741. echo "shell running!"
  742. deactivate
  743. #+END_SRC
  744. #+BEGIN_SRC emacs-lisp
  745. (if (string-equal system-type "gnu/linux")
  746. (use-package beancount
  747. :load-path "user-local/elisp"
  748. ; :ensure t
  749. :defer t
  750. :mode
  751. ("\\.beancount$" . beancount-mode)
  752. :init
  753. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  754. ; (add-hook 'beancount-mode-hook (pyvenv-activate "/opt/beancount"))
  755. ; (setenv "PATH"
  756. ; (concat "/opt/beancount/bin:"
  757. ; (getenv "PATH")))
  758. :config
  759. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount")))
  760. #+END_SRC
  761. To support org-babel, check if it can find the symlink to ob-beancount.el
  762. #+BEGIN_SRC shell
  763. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  764. beansym="$orgpath/ob-beancount.el
  765. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  766. if [ -h "$beansym" ]
  767. then
  768. echo "$beansym found"
  769. elif [ -e "$bean" ]
  770. then
  771. echo "creating symlink"
  772. ln -s "$bean" "$beansym"
  773. else
  774. echo "$bean not found, symlink creation aborted"
  775. fi
  776. #+END_SRC
  777. Fava is strongly recommended.
  778. #+BEGIN_SRC shell
  779. cd /opt
  780. python3 -m venv fava
  781. source ./fava/bin/activate
  782. pip3 install wheel
  783. pip3 install fava
  784. deactivate
  785. #+END_SRC
  786. Start fava with fava my_file.beancount
  787. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  788. Beancount-mode can start fava and open the URL right away.