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