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.

798 lines
24 KiB

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