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.

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