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.

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