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.

864 lines
26 KiB

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