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
25 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
5 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_START "p:/Eigene Dateien/Notizen/"))))
  106. (setq bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks"))
  107. (setq recentf-save-file (concat MY--PATH_USER_LOCAL "recentf"))
  108. (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings
  109. (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_defs"))
  110. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  111. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  112. (setq save-abbrevs 'silently) ;; don't bother me with asking for abbrev saving
  113. (setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode
  114. (defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n
  115. (setq custom-safe-themes t) ;; don't ask me if I want to load a theme
  116. (setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence.
  117. (delete-selection-mode t) ;; delete selected region when typing
  118. (save-place-mode 1) ;; saves position in file when it's closed
  119. (setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position
  120. (setq locale-coding-system 'utf-8)
  121. (set-terminal-coding-system 'utf-8)
  122. (set-keyboard-coding-system 'utf-8)
  123. (set-selection-coding-system 'utf-8)
  124. (if (eq system-type 'windows-nt)
  125. (prefer-coding-system 'utf-8-dos)
  126. (prefer-coding-system 'utf-8))
  127. (blink-cursor-mode -1) ;; turn off blinking cursor
  128. (show-paren-mode t) ;; show other part of brackets
  129. (column-number-mode t)
  130. (setq uniquify-buffer-name-style 'forward)
  131. (setq-default indent-tabs-mode nil) ;; avoid tabs in place of multiple spaces (they look bad in tex)
  132. (setq-default indicate-empty-lines t) ;; show empty lines
  133. (setq scroll-margin 5 ;; smooth scrolling
  134. scroll-conservatively 10000
  135. scroll-preserve-screen-position 1
  136. scroll-step 1)
  137. (global-hl-line-mode t) ;; highlight current line
  138. (menu-bar-mode 0) ;; disable menu bar
  139. (tool-bar-mode 0) ;; disable tool bar
  140. (scroll-bar-mode 0) ;; disable scroll bar
  141. #+END_SRC
  142. Some windows specific stuff
  143. #+BEGIN_SRC emacs-lisp
  144. (when (eq system-type 'windows-nt)
  145. (remove-hook 'find-file-hooks 'vc-refresh-state)
  146. (progn
  147. (setq gc-cons-threshold (* 511 1024 1024)
  148. gc-cons-percentage 0.5
  149. garbage-collection-messages t
  150. w32-pipe-read-delay 0
  151. w32-get-true-file-attributes nil)
  152. (run-with-idle-timer 5 t #'garbage-collect)))
  153. #+END_SRC
  154. * visuals
  155. ** Font
  156. :PROPERTIES:
  157. :ID: cdfaaf73-b027-4b86-8d27-ebdce4b85009
  158. :END:
  159. #+BEGIN_SRC emacs-lisp
  160. (if (string-equal system-type "gnu/linux")
  161. (set-face-font 'default "Hack-10"))
  162. #+END_SRC
  163. ** line wrappings
  164. :PROPERTIES:
  165. :ID: 60b1f231-ab1e-4c47-ac6d-262dc208a520
  166. :END:
  167. #+BEGIN_SRC emacs-lisp
  168. (global-visual-line-mode)
  169. (diminish 'visual-line-mode)
  170. (use-package adaptive-wrap
  171. :ensure t
  172. :config
  173. (add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode))
  174. ; :init
  175. ; (when (fboundp 'adaptive-wrap-prefix-mode)
  176. ; (defun my/activate-adaptive-wrap-prefix-mode ()
  177. ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  178. ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  179. ; (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode)))
  180. #+END_SRC
  181. ** line numbers
  182. :PROPERTIES:
  183. :ID: d3dfb79a-103a-4318-a5af-5a55e12674ce
  184. :END:
  185. #+BEGIN_SRC emacs-lisp
  186. (use-package display-line-numbers
  187. :init
  188. (add-hook 'prog-mode-hook 'display-line-numbers-mode)
  189. (add-hook 'org-src-mode-hook 'display-line-numbers-mode)
  190. :config
  191. (setq-default display-line-numbers-type 'visual
  192. display-line-numbers-current-absolute t
  193. display-line-numbers-with 4
  194. display-line-numbers-widen t))
  195. ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode)
  196. #+END_SRC
  197. ** misc
  198. :PROPERTIES:
  199. :ID: f0f774d6-db13-4871-9192-d36e78120dde
  200. :END:
  201. #+BEGIN_SRC emacs-lisp
  202. (use-package rainbow-mode
  203. :ensure t
  204. :diminish
  205. :hook ((org-mode
  206. emacs-lisp-mode) . rainbow-mode))
  207. #+END_SRC
  208. * undo
  209. :PROPERTIES:
  210. :ID: fde526fa-b053-48dd-9ac1-c443d987f4d2
  211. :END:
  212. #+BEGIN_SRC emacs-lisp
  213. (use-package undo-tree
  214. :ensure t
  215. :diminish undo-tree-mode
  216. :init
  217. (global-undo-tree-mode 1))
  218. #+END_SRC
  219. * imenu-list
  220. :PROPERTIES:
  221. :ID: 796d00db-aadb-412b-a291-619b029977f3
  222. :END:
  223. A minor mode to show imenu in a sidebar.
  224. Call imenu-list-smart-toggle.
  225. [[https://github.com/bmag/imenu-list][Source]]
  226. #+BEGIN_SRC emacs-lisp
  227. (use-package imenu-list
  228. :ensure t
  229. :config
  230. (setq imenu-list-focus-after-activation t
  231. imenu-list-auto-resize t
  232. imenu-list-position 'right)
  233. :bind
  234. (:map global-map
  235. ([f9] . imenu-list-smart-toggle))
  236. )
  237. #+END_SRC
  238. * which-key
  239. :PROPERTIES:
  240. :ID: 0a67aeb4-4060-4f4d-a7ff-61c70fe7ec7b
  241. :END:
  242. #+BEGIN_SRC emacs-lisp
  243. (use-package which-key
  244. :ensure t
  245. :diminish which-key-mode
  246. :config
  247. (which-key-mode)
  248. (which-key-setup-side-window-right-bottom)
  249. (which-key-setup-minibuffer)
  250. (setq which-key-idle-delay 0.5))
  251. #+END_SRC
  252. * Evil
  253. :PROPERTIES:
  254. :ID: a3389b7d-3833-42b7-97e1-413b8c4d9833
  255. :END:
  256. #+BEGIN_SRC emacs-lisp
  257. (use-package evil
  258. :ensure t
  259. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  260. :config
  261. (evil-mode 1))
  262. #+END_SRC
  263. * General (key mapper)
  264. :PROPERTIES:
  265. :ID: 027bdcf8-95c9-4e9b-88ba-6e9d3e5116c0
  266. :END:
  267. #+BEGIN_SRC emacs-lisp
  268. (use-package general
  269. :ensure t)
  270. (general-define-key
  271. :states 'normal
  272. :keymaps 'imenu-list-major-mode-map
  273. (kbd "RET") '(imenu-list-goto-entry :which-key "goto")
  274. (kbd "TAB") '(hs-toggle-hiding :which-key "collapse")
  275. "d" '(imenu-list-display-entry :which-key "show")
  276. "q" '(imenu-list-quit-window :which-key "quit"))
  277. #+END_SRC
  278. * orgmode
  279. ** org
  280. :PROPERTIES:
  281. :ID: 3877251e-5ece-4006-baa6-1f1b4846a8f3
  282. :END:
  283. #+BEGIN_SRC emacs-lisp
  284. (use-package org
  285. :ensure org-plus-contrib
  286. :mode (("\.org$" . org-mode))
  287. :init
  288. (add-hook 'org-mode-hook 'company/org-mode-hook)
  289. (add-hook 'org-src-mode-hook 'smartparens-mode)
  290. :config
  291. (setq org-modules (quote (org-id
  292. org-habit
  293. org-tempo ;; easy templates
  294. )))
  295. (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")
  296. org-agenda-files (list MY--PATH_ORG_FILES
  297. MY--PATH_ORG_FILES_MOBILE)
  298. org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations")
  299. org-log-into-drawer "LOGBOOK")
  300. ;; some display customizations
  301. (setq org-pretty-entities t
  302. org-startup-truncated t
  303. org-startup-align-all-tables t)
  304. ;; some source code blocks customizations
  305. (setq org-src-window-setup 'current-window ;; C-c ' opens in current window
  306. org-src-fontify-natively t ;; use syntax highlighting in code blocks
  307. org-src-preserve-indentation t ;; no extra indentation
  308. org-src-tab-acts-natively t))
  309. #+END_SRC
  310. ** languages
  311. :PROPERTIES:
  312. :ID: 467efd58-e928-4ccf-9ac4-d144eaede8ed
  313. :END:
  314. #+BEGIN_SRC emacs-lisp
  315. (org-babel-do-load-languages
  316. 'org-babel-load-languages
  317. '((emacs-lisp . t)
  318. (gnuplot . t)
  319. (js . t)
  320. (latex . t)
  321. (lisp . t)
  322. (python . t)
  323. (shell . t)
  324. (sqlite . t)
  325. (org . t)
  326. (R . t)
  327. (scheme . t)
  328. ))
  329. (defun me--org-confirm-babel-evaluate (lang body)
  330. "Do not confirm evaluation for these languages."
  331. (not (or (string= lang "python")
  332. (string= lang "ipython")
  333. (string= lang "emacs-lisp")
  334. (string= lang "R")
  335. (string= lang "latex")
  336. (string= lang "sqlite"))))
  337. (setq org-confirm-babel-evaluate 'me--org-confirm-babel-evaluate)
  338. #+END_SRC
  339. ** habits
  340. :PROPERTIES:
  341. :ID: 61735b0c-5016-4697-80c6-beb7b3f27a1b
  342. :END:
  343. #+BEGIN_SRC emacs-lisp
  344. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  345. ;; (add-to-list 'org-modules "org-habit")
  346. (setq org-habit-graph-column 80
  347. org-habit-preceding-days 30
  348. org-habit-following-days 7
  349. org-habit-show-habits-only-for-today nil)
  350. #+END_SRC
  351. ** org-id
  352. :PROPERTIES:
  353. :ID: 017ef411-8239-4bfe-bbef-66b98a2971a9
  354. :END:
  355. #+BEGIN_SRC emacs-lisp
  356. (use-package org-id
  357. :config
  358. (setq org-id-link-to-org-use-id t)
  359. (org-id-update-id-locations)) ;; update id file .org-id-locations on startup
  360. #+END_SRC
  361. ** org-agenda
  362. :PROPERTIES:
  363. :ID: 10e65f59-ba2c-47e4-a40c-3097c15544aa
  364. :END:
  365. Custom keywords, depending on environment
  366. #+BEGIN_SRC emacs-lisp
  367. (pcase me/whoami
  368. ("work_remote")
  369. (setq org-todo-keywords
  370. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE"))))
  371. #+END_SRC
  372. Add some key bindings
  373. #+BEGIN_SRC emacs-lisp
  374. (bind-key "C-c l" 'org-store-link)
  375. (bind-key "C-c c" 'org-capture)
  376. (bind-key "C-c a" 'org-agenda)
  377. #+END_SRC
  378. Sort agenda by deadline and priority
  379. #+BEGIN_SRC emacs-lisp
  380. (setq org-agenda-sorting-strategy
  381. (quote
  382. ((agenda deadline-up priority-down)
  383. (todo priority-down category-keep)
  384. (tags priority-down category-keep)
  385. (search category-keep))))
  386. #+END_SRC
  387. Customize the org agenda
  388. #+BEGIN_SRC emacs-lisp
  389. (defun me--org-skip-subtree-if-priority (priority)
  390. "Skip an agenda subtree if it has a priority of PRIORITY.
  391. PRIORITY may be one of the characters ?A, ?B, or ?C."
  392. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  393. (pri-value (* 1000 (- org-lowest-priority priority)))
  394. (pri-current (org-get-priority (thing-at-point 'line t))))
  395. (if (= pri-value pri-current)
  396. subtree-end
  397. nil)))
  398. (setq org-agenda-custom-commands
  399. '(("c" "Simple agenda view"
  400. ((tags "PRIORITY=\"A\""
  401. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  402. (org-agenda-overriding-header "Hohe Priorität:")))
  403. (agenda ""
  404. ((org-agenda-span 7)
  405. (org-agenda-start-on-weekday nil)
  406. (org-agenda-overriding-header "Nächste 7 Tage:")))
  407. (alltodo ""
  408. ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A)
  409. (org-agenda-skip-if nil '(scheduled deadline))))
  410. (org-agenda-overriding-header "Sonstige Aufgaben:")))))))
  411. #+END_SRC
  412. ** *TODO*
  413. org-super-agenda
  414. ** org-caldav
  415. :PROPERTIES:
  416. :ID: 58aa11ef-80f7-4629-a957-a9e00e070136
  417. :END:
  418. Vorerst deaktiviert, Nutzen evtl. nicht vorhanden
  419. #+BEGIN_SRC emacs-lisp
  420. ;;(use-package org-caldav
  421. ;; :ensure t
  422. ;; :config
  423. ;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc"
  424. ;; org-caldav-calendar-id "orgmode"
  425. ;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox")
  426. ;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks")))
  427. #+END_SRC
  428. ** journal
  429. :PROPERTIES:
  430. :ID: 0b7243ac-049f-4b9c-a062-7a349c515133
  431. :END:
  432. [[https://github.com/bastibe/org-journal][Source]]
  433. #+BEGIN_SRC emacs-lisp
  434. (unless (string-equal me/whoami "work-remote")
  435. (use-package org-journal
  436. :ensure t
  437. :defer t
  438. :config
  439. (setq 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.