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.

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