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.

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