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.

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