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.

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