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.

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