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.

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