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.

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