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.

801 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
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
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. Set some languages and disable confirmation for evaluating code blocks C-c C-c
  383. #+BEGIN_SRC emacs-lisp
  384. (org-babel-do-load-languages
  385. 'org-babel-load-languages
  386. '((emacs-lisp . t)
  387. (gnuplot . t)
  388. (js . t)
  389. (latex . t)
  390. (lisp . t)
  391. (python . t)
  392. (shell . t)
  393. (sqlite . t)
  394. (org . t)
  395. (R . t)
  396. (scheme . t)))
  397. (setq org-confirm-babel-evaluate nil)
  398. #+END_SRC
  399. ** habits
  400. #+BEGIN_SRC emacs-lisp
  401. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  402. ;; (add-to-list 'org-modules "org-habit")
  403. (setq org-habit-graph-column 80
  404. org-habit-preceding-days 30
  405. org-habit-following-days 7
  406. org-habit-show-habits-only-for-today nil)
  407. #+END_SRC
  408. ** org-id
  409. Currently it causes some debugger errors "not a standard org time string", so it's disabled
  410. #+BEGIN_SRC emacs-lisp
  411. ;; (use-package org-id
  412. ;; :config
  413. ;; (setq org-id-link-to-org-use-id t)
  414. ;; (org-id-update-id-locations)) ;; update id file .org-id-locations on startup
  415. #+END_SRC
  416. ** org-agenda
  417. Custom keywords, depending on environment
  418. #+BEGIN_SRC emacs-lisp
  419. (when *work_remote*
  420. (setq org-todo-keywords
  421. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE"))))
  422. #+END_SRC
  423. Add some key bindings
  424. #+BEGIN_SRC emacs-lisp
  425. (bind-key "C-c l" 'org-store-link)
  426. (bind-key "C-c c" 'org-capture)
  427. (bind-key "C-c a" 'org-agenda)
  428. #+END_SRC
  429. Sort agenda by deadline and priority
  430. #+BEGIN_SRC emacs-lisp
  431. (setq org-agenda-sorting-strategy
  432. (quote
  433. ((agenda deadline-up priority-down)
  434. (todo priority-down category-keep)
  435. (tags priority-down category-keep)
  436. (search category-keep))))
  437. #+END_SRC
  438. Customize the org agenda
  439. #+BEGIN_SRC emacs-lisp
  440. (defun me--org-skip-subtree-if-priority (priority)
  441. "Skip an agenda subtree if it has a priority of PRIORITY.
  442. PRIORITY may be one of the characters ?A, ?B, or ?C."
  443. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  444. (pri-value (* 1000 (- org-lowest-priority priority)))
  445. (pri-current (org-get-priority (thing-at-point 'line t))))
  446. (if (= pri-value pri-current)
  447. subtree-end
  448. nil)))
  449. (setq org-agenda-custom-commands
  450. '(("c" "Simple agenda view"
  451. ((tags "PRIORITY=\"A\""
  452. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  453. (org-agenda-overriding-header "Hohe Priorität:")))
  454. (agenda ""
  455. ((org-agenda-span 7)
  456. (org-agenda-start-on-weekday nil)
  457. (org-agenda-overriding-header "Nächste 7 Tage:")))
  458. (alltodo ""
  459. ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A)
  460. (org-agenda-skip-if nil '(scheduled deadline))))
  461. (org-agenda-overriding-header "Sonstige Aufgaben:")))))))
  462. #+END_SRC
  463. ** *TODO*
  464. org-super-agenda
  465. ** org-caldav
  466. Vorerst deaktiviert, Nutzen evtl. nicht vorhanden
  467. #+BEGIN_SRC emacs-lisp
  468. ;;(use-package org-caldav
  469. ;; :ensure t
  470. ;; :config
  471. ;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc"
  472. ;; org-caldav-calendar-id "orgmode"
  473. ;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox")
  474. ;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks")))
  475. #+END_SRC
  476. ** journal
  477. [[https://github.com/bastibe/org-journal][Source]]
  478. #+BEGIN_SRC emacs-lisp
  479. (use-package org-journal
  480. :if *linux*
  481. :ensure t
  482. :defer t
  483. :config
  484. (setq org-journal-dir MY--PATH_ORG_JOURNAl
  485. org-journal-enable-agenda-integration t))
  486. #+END_SRC
  487. * Programming
  488. ** Magit / Git
  489. Little crash course in magit:
  490. - magit-init to init a git project
  491. - magit-status (C-x g) to call the status window
  492. In status buffer:
  493. - s stage files
  494. - u unstage files
  495. - U unstage all files
  496. - a apply changes to staging
  497. - c c commit (type commit message, then C-c C-c to commit)
  498. - b b switch to another branch
  499. - P u git push
  500. - F u git pull
  501. #+BEGIN_SRC emacs-lisp
  502. (use-package magit
  503. :ensure t
  504. :defer t
  505. :init
  506. ; set git-path in work environment
  507. (if (string-equal user-login-name "POH")
  508. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  509. )
  510. :bind (("C-x g" . magit-status))
  511. )
  512. #+END_SRC
  513. ** LSP
  514. Configuration for the language server protocol
  515. *ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp
  516. Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden.
  517. Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad.
  518. TODO Unterverzeichnisse wurden noch nicht getestet
  519. #+BEGIN_SRC emacs-lisp
  520. (use-package lsp-mode
  521. :defer t
  522. :commands lsp
  523. :custom
  524. (lsp-auto-guess-root nil)
  525. (lsp-prefer-flymake nil) ; use flycheck instead
  526. (lsp-file-watch-threshold 2000)
  527. :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
  528. :hook ((python-mode
  529. js-mode
  530. js2-mode
  531. typescript-mode
  532. web-mode) . lsp))
  533. (use-package lsp-ui
  534. :after lsp-mode
  535. :ensure t
  536. :diminish
  537. :commands lsp-ui-mode
  538. :config
  539. (setq lsp-ui-doc-enable t
  540. lsp-ui-doc-header t
  541. lsp-ui-doc-include-signature t
  542. lsp-ui-doc-position 'top
  543. lsp-ui-doc-border (face-foreground 'default)
  544. lsp-ui-sideline-enable nil
  545. lsp-ui-sideline-ignore-duplicate t
  546. lsp-ui-sideline-show-code-actions nil)
  547. (when (display-graphic-p)
  548. (setq lsp-ui-doc-use-webkit t))
  549. ;; workaround hide mode-line of lsp-ui-imenu buffer
  550. (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
  551. (setq mode-line-format nil)))
  552. (use-package company-lsp
  553. :requires company
  554. :defer t
  555. :ensure t
  556. :config
  557. ;;disable client-side cache because lsp server does a better job
  558. (setq company-transformers nil
  559. company-lsp-async t
  560. company-lsp-cache-candidates nil))
  561. #+END_SRC
  562. ** yasnippet
  563. #+begin_src emacs-lisp
  564. (use-package yasnippet
  565. :ensure t
  566. :diminish yas-minor-mode
  567. :config
  568. (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets")))
  569. (yas-global-mode t)
  570. (yas-reload-all))
  571. #+end_src
  572. ** flycheck
  573. #+BEGIN_SRC emacs-lisp
  574. (use-package flycheck
  575. :ensure t
  576. :hook
  577. ((css-mode . flycheck-mode)
  578. (emacs-lisp-mode . flycheck-mode)
  579. (python-mode . flycheck-mode))
  580. :init
  581. (setq flycheck-emacs-lisp-load-path 'inherit)
  582. :config
  583. (setq-default
  584. flycheck-check-synta-automatically '(save mode-enabled)
  585. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  586. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  587. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  588. #+END_SRC
  589. ** Projectile
  590. Manage projects and jump quickly between its files
  591. #+BEGIN_SRC emacs-lisp
  592. (use-package projectile
  593. :ensure t
  594. :defer t
  595. :bind
  596. (("C-c p p" . projectile-switch-project)
  597. ("C-c p c" . projectile-command-map)
  598. ("C-c p s s" . projectile-ag))
  599. :init
  600. (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache")
  601. projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks"))
  602. :config
  603. (projectile-mode t)
  604. (setq-default projectile-completion-system 'ivy
  605. projectile-enable-caching t
  606. projectile-mode-line '(:eval (projectile-project-name))))
  607. #+END_SRC
  608. ** smartparens
  609. #+BEGIN_SRC emacs-lisp
  610. (use-package smartparens
  611. :ensure t
  612. :diminish smartparens-mode
  613. :config
  614. (setq sp-show-pair-from-inside nil)
  615. (require 'smartparens-config))
  616. #+END_SRC
  617. ** lisp
  618. #+BEGIN_SRC emacs-lisp
  619. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  620. #+END_SRC
  621. ** web
  622. apt install npm
  623. sudo npm install -g vscode-html-languageserver-bin
  624. evtl alternativ typescript-language-server?
  625. #+BEGIN_SRC emacs-lisp
  626. (use-package web-mode
  627. :ensure t
  628. :defer t
  629. :mode
  630. ("\\.phtml\\'"
  631. "\\.tpl\\.php\\'"
  632. "\\.djhtml\\'"
  633. "\\.[t]?html?\\'")
  634. :config
  635. (setq web-mode-enable-auto-closing t
  636. web-mode-enable-auto-pairing t)
  637. (add-hook 'web-mode-hook 'smartparens-mode))
  638. #+END_SRC
  639. ** Python
  640. Systemseitig muss python-language-server installiert sein:
  641. pip3 install 'python-language-server[all]'
  642. für andere language servers
  643. https://github.com/emacs-lsp/lsp-mode#install-language-server
  644. #+BEGIN_SRC emacs-lisp
  645. (if (string-equal system-type "gnu/linux")
  646. (defun my/postactivatehook ()
  647. (setq lsp-python-ms-extra-paths pyvenv-virtual-env))
  648. (use-package pyvenv
  649. :ensure t
  650. :config
  651. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  652. (add-hook 'pyvenv-post-activate-hooks 'my/postactivatehook))
  653. (use-package virtualenvwrapper
  654. :ensure t
  655. :hook (venv-postmkvirtualenv . (lambda() (shell-command "pip3 install importmagic epc")))
  656. :config
  657. (setq venv-location (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  658. (use-package lsp-python-ms
  659. :ensure t
  660. :after lsp-mode python))
  661. ; :custom (lsp-python-executable-cmd "python3"))
  662. #+END_SRC
  663. * beancount
  664. ** Installation
  665. #+BEGIN_SRC shell
  666. sudo su
  667. cd /opt
  668. python3 -m venv beancount
  669. source ./beancount/bin/activate
  670. pip3 install wheel
  671. pip3 install beancount
  672. sleep 100
  673. echo "shell running!"
  674. deactivate
  675. #+END_SRC
  676. #+BEGIN_SRC emacs-lisp
  677. (if (string-equal system-type "gnu/linux")
  678. (use-package beancount
  679. :load-path "user-global/elisp"
  680. ; :ensure t
  681. :defer t
  682. :mode
  683. ("\\.beancount$" . beancount-mode)
  684. :init
  685. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  686. ; (add-hook 'beancount-mode-hook (pyvenv-activate "/opt/beancount"))
  687. ; (setenv "PATH"
  688. ; (concat "/opt/beancount/bin:"
  689. ; (getenv "PATH")))
  690. :config
  691. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount")))
  692. #+END_SRC
  693. To support org-babel, check if it can find the symlink to ob-beancount.el
  694. #+BEGIN_SRC shell
  695. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  696. beansym="$orgpath/ob-beancount.el
  697. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  698. if [ -h "$beansym" ]
  699. then
  700. echo "$beansym found"
  701. elif [ -e "$bean" ]
  702. then
  703. echo "creating symlink"
  704. ln -s "$bean" "$beansym"
  705. else
  706. echo "$bean not found, symlink creation aborted"
  707. fi
  708. #+END_SRC
  709. Fava is strongly recommended.
  710. #+BEGIN_SRC shell
  711. cd /opt
  712. python3 -m venv fava
  713. source ./fava/bin/activate
  714. pip3 install wheel
  715. pip3 install fava
  716. deactivate
  717. #+END_SRC
  718. Start fava with fava my_file.beancount
  719. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  720. Beancount-mode can start fava and open the URL right away.