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.

861 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
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. )))
  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. (use-package org-journal
  435. :ensure t
  436. :defer t
  437. :custom
  438. (org-journal-dir MY--PATH_ORG_JOURNAl)
  439. (org-journal-enable-agenda-integration t))
  440. #+END_SRC
  441. * ivy / counsel / swiper
  442. :PROPERTIES:
  443. :ID: c2146a70-03f4-4f60-9bce-094eec28cefe
  444. :END:
  445. #+BEGIN_SRC emacs-lisp
  446. ; (require 'ivy)
  447. (use-package ivy
  448. :ensure t
  449. :diminish
  450. (ivy-mode . "")
  451. :init
  452. (ivy-mode 1)
  453. :bind
  454. ("C-r" . ivy-resume) ;; overrides isearch-backwards binding
  455. :config
  456. (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer
  457. ivy-height 20 ;; height of ivy window
  458. ivy-count-format "%d/%d" ;; current and total number
  459. ivy-re-builders-alist ;; regex replaces spaces with *
  460. '((t . ivy--regex-plus))))
  461. (use-package counsel
  462. :ensure t
  463. :bind*
  464. (("M-x" . counsel-M-x)
  465. ("C-x C-f" . counsel-find-file)
  466. ("C-x C-r" . counsel-recentf)
  467. ("C-c C-f" . counsel-git)
  468. ("C-c h f" . counsel-describe-function)
  469. ("C-c h v" . counsel-describe-variable)
  470. ("M-i" . counsel-imenu)))
  471. (use-package swiper
  472. :ensure t
  473. :bind
  474. ("C-s" . swiper))
  475. (use-package ivy-hydra
  476. :ensure t)
  477. #+END_SRC
  478. * company
  479. :PROPERTIES:
  480. :ID: 1630ac5e-7467-458c-940c-4f724e283813
  481. :END:
  482. #+BEGIN_SRC emacs-lisp
  483. ; (require 'company)
  484. (use-package company
  485. :defer 1
  486. :bind
  487. (:map company-active-map
  488. ("RET" . nil)
  489. ([return] . nil)
  490. ("TAB" . company-complete-selection)
  491. ([tab] . company-complete-selection)
  492. ("<right>" . company-complete-common))
  493. :config
  494. (global-company-mode 1)
  495. (setq-default
  496. company-idle-delay .2
  497. company-minimum-prefix-length 1
  498. company-require-match nil
  499. company-show-numbers t
  500. company-tooltip-align-annotations t))
  501. ; (require 'company-statistics)
  502. (use-package company-statistics
  503. :ensure t
  504. :after company
  505. :init
  506. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  507. :config
  508. (company-statistics-mode 1))
  509. (use-package company-dabbrev
  510. :ensure nil
  511. :after company
  512. :config
  513. (setq-default company-dabbrev-downcase nil))
  514. (use-package company-box
  515. :ensure t
  516. :init
  517. (add-hook 'company-mode-hook 'company-box-mode))
  518. #+END_SRC
  519. ** company backends
  520. :PROPERTIES:
  521. :ID: 6ac59f9d-54e3-422d-883f-128fb172468d
  522. :END:
  523. #+BEGIN_SRC emacs-lisp
  524. (defun company/org-mode-hook()
  525. (set (make-local-variable 'company-backends)
  526. '(company-capf company-files))
  527. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  528. (message "company/org-mode-hook"))
  529. (defun company/elisp-mode-hook()
  530. (set (make-local-variable 'company-backends)
  531. '((company-elisp company-dabbrev) company-capf company-files))
  532. (message "company/elisp-mode-hook"))
  533. (defun company/beancount-mode-hook()
  534. (set (make-local-variable 'company-backends)
  535. '(company-beancount)))
  536. #+END_SRC
  537. * Programming
  538. ** Magit / Git
  539. :PROPERTIES:
  540. :ID: a947f806-181d-4d33-9734-435849385b0b
  541. :END:
  542. Little crash course in magit:
  543. - magit-init to init a git project
  544. - magit-status (C-x g) to call the status window
  545. In status buffer:
  546. - s stage files
  547. - u unstage files
  548. - U unstage all files
  549. - a apply changes to staging
  550. - c c commit (type commit message, then C-c C-c to commit)
  551. - b b switch to another branch
  552. - P u git push
  553. - F u git pull
  554. #+BEGIN_SRC emacs-lisp
  555. (use-package magit
  556. :ensure t
  557. :defer t
  558. :init
  559. ; set git-path in work environment
  560. (if (string-equal user-login-name "POH")
  561. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  562. )
  563. :bind (("C-x g" . magit-status))
  564. )
  565. #+END_SRC
  566. ** LSP
  567. :PROPERTIES:
  568. :ID: d529d096-ec38-42e6-91c9-099c1d8bdd06
  569. :END:
  570. Configuration for the language server protocol
  571. *ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp
  572. Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden.
  573. Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad.
  574. TODO Unterverzeichnisse wurden noch nicht getestet
  575. #+BEGIN_SRC emacs-lisp
  576. (use-package lsp-mode
  577. :defer t
  578. :commands lsp
  579. :custom
  580. (lsp-auto-guess-root nil)
  581. (lsp-prefer-flymake nil) ; use flycheck instead
  582. (lsp-file-watch-threshold 2000)
  583. :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
  584. :hook ((python-mode
  585. js-mode
  586. js2-mode
  587. typescript-mode
  588. web-mode) . lsp))
  589. (use-package lsp-ui
  590. :after lsp-mode
  591. :ensure t
  592. :diminish
  593. :commands lsp-ui-mode
  594. :config
  595. (setq lsp-ui-doc-enable t
  596. lsp-ui-doc-header t
  597. lsp-ui-doc-include-signature t
  598. lsp-ui-doc-position 'top
  599. lsp-ui-doc-border (face-foreground 'default)
  600. lsp-ui-sideline-enable nil
  601. lsp-ui-sideline-ignore-duplicate t
  602. lsp-ui-sideline-show-code-actions nil)
  603. (when (display-graphic-p)
  604. (setq lsp-ui-doc-use-webkit t))
  605. ;; workaround hide mode-line of lsp-ui-imenu buffer
  606. (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
  607. (setq mode-line-format nil)))
  608. (use-package company-lsp
  609. :requires company
  610. :defer t
  611. :ensure t
  612. :config
  613. ;;disable client-side cache because lsp server does a better job
  614. (setq company-transformers nil
  615. company-lsp-async t
  616. company-lsp-cache-candidates nil))
  617. #+END_SRC
  618. ** flycheck
  619. :PROPERTIES:
  620. :ID: c8090ddb-4f22-49ba-8ab1-1de132e1d772
  621. :END:
  622. #+BEGIN_SRC emacs-lisp
  623. (use-package flycheck
  624. :ensure t
  625. :hook
  626. ((css-mode . flycheck-mode)
  627. (emacs-lisp-mode . flycheck-mode)
  628. (python-mode . flycheck-mode))
  629. :init
  630. (setq flycheck-emacs-lisp-load-path 'inherit)
  631. :config
  632. (setq-default
  633. flycheck-check-synta-automatically '(save mode-enabled)
  634. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  635. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  636. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  637. #+END_SRC
  638. ** Projectile
  639. :PROPERTIES:
  640. :ID: 3cc5c1d2-1a5d-4d1a-bfeb-48de8172dd63
  641. :END:
  642. Manage projects and jump quickly between its files
  643. #+BEGIN_SRC emacs-lisp
  644. (use-package projectile
  645. :ensure t
  646. :defer t
  647. :bind
  648. (("C-c p p" . projectile-switch-project)
  649. ("C-c p c" . projectile-command-map)
  650. ("C-c p s s" . projectile-ag))
  651. :init
  652. (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache")
  653. projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks"))
  654. :config
  655. (projectile-mode t)
  656. (setq-default projectile-completion-system 'ivy
  657. projectile-enable-caching t
  658. projectile-mode-line '(:eval (projectile-project-name))))
  659. #+END_SRC
  660. ** smartparens
  661. :PROPERTIES:
  662. :ID: 04be375f-d100-47e7-99f1-af47a3139a54
  663. :END:
  664. #+BEGIN_SRC emacs-lisp
  665. (use-package smartparens
  666. :ensure t
  667. :diminish smartparens-mode
  668. :config
  669. (setq sp-show-pair-from-inside nil)
  670. (require 'smartparens-config))
  671. #+END_SRC
  672. ** lisp
  673. :PROPERTIES:
  674. :ID: e5ce0263-3b21-460e-a037-3fe27d6e836a
  675. :END:
  676. #+BEGIN_SRC emacs-lisp
  677. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  678. #+END_SRC
  679. ** web
  680. :PROPERTIES:
  681. :ID: 5649b885-839f-48db-8b4f-8d594df7ebd8
  682. :END:
  683. apt install npm
  684. sudo npm install -g vscode-html-languageserver-bin
  685. evtl alternativ typescript-language-server?
  686. #+BEGIN_SRC emacs-lisp
  687. (use-package web-mode
  688. :ensure t
  689. :defer t
  690. :mode
  691. ("\\.phtml\\'"
  692. "\\.tpl\\.php\\'"
  693. "\\.djhtml\\'"
  694. "\\.[t]?html?\\'")
  695. :config
  696. (setq web-mode-enable-auto-closing t
  697. web-mode-enable-auto-pairing t)
  698. (add-hook 'web-mode-hook 'smartparens-mode))
  699. #+END_SRC
  700. ** Python
  701. :PROPERTIES:
  702. :ID: cd4bbd1f-9980-42c9-a5af-aa808779d524
  703. :END:
  704. Systemseitig muss python-language-server installiert sein:
  705. pip3 install 'python-language-server[all]'
  706. für andere language servers
  707. https://github.com/emacs-lsp/lsp-mode#install-language-server
  708. #+BEGIN_SRC emacs-lisp
  709. (if (string-equal system-type "gnu/linux")
  710. (use-package pyvenv
  711. :ensure t
  712. :config
  713. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  714. (add-hook 'pyvenv-post-activate-hooks #'my/postactivatehook))
  715. (defun my/postactivatehook ()
  716. (setq lsp-python-ms-extra-paths pyvenv-virtual-env))
  717. (use-package virtualenvwrapper
  718. :ensure t
  719. :hook (venv-postmkvirtualenv . (lambda() (shell-command "pip3 install importmagic epc")))
  720. :config
  721. (setq venv-location (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  722. (use-package lsp-python-ms
  723. :ensure t
  724. :after lsp-mode python))
  725. ; :custom (lsp-python-executable-cmd "python3"))
  726. #+END_SRC
  727. * beancount
  728. ** Installation
  729. :PROPERTIES:
  730. :ID: 0c5f3396-4b08-4549-ac68-0c516cfd4435
  731. :END:
  732. #+BEGIN_SRC shell
  733. sudo su
  734. cd /opt
  735. python3 -m venv beancount
  736. source ./beancount/bin/activate
  737. pip3 install wheel
  738. pip3 install beancount
  739. sleep 100
  740. echo "shell running!"
  741. deactivate
  742. #+END_SRC
  743. #+BEGIN_SRC emacs-lisp
  744. (if (string-equal system-type "gnu/linux")
  745. (use-package beancount
  746. :load-path "user-local/elisp"
  747. ; :ensure t
  748. :defer t
  749. :mode
  750. ("\\.beancount$" . beancount-mode)
  751. :init
  752. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  753. ; (add-hook 'beancount-mode-hook (pyvenv-activate "/opt/beancount"))
  754. ; (setenv "PATH"
  755. ; (concat "/opt/beancount/bin:"
  756. ; (getenv "PATH")))
  757. :config
  758. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount")))
  759. #+END_SRC
  760. To support org-babel, check if it can find the symlink to ob-beancount.el
  761. #+BEGIN_SRC shell
  762. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  763. beansym="$orgpath/ob-beancount.el
  764. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  765. if [ -h "$beansym" ]
  766. then
  767. echo "$beansym found"
  768. elif [ -e "$bean" ]
  769. then
  770. echo "creating symlink"
  771. ln -s "$bean" "$beansym"
  772. else
  773. echo "$bean not found, symlink creation aborted"
  774. fi
  775. #+END_SRC
  776. Fava is strongly recommended.
  777. #+BEGIN_SRC shell
  778. cd /opt
  779. python3 -m venv fava
  780. source ./fava/bin/activate
  781. pip3 install wheel
  782. pip3 install fava
  783. deactivate
  784. #+END_SRC
  785. Start fava with fava my_file.beancount
  786. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  787. Beancount-mode can start fava and open the URL right away.