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.

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