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.

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