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.

1493 lines
41 KiB

5 years ago
3 years ago
3 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
3 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. #+TITLE: Emacs configuration file
  2. #+AUTHOR: Marc
  3. #+BABEL: :cache yes
  4. #+PROPERTY: header-args :tangle yes
  5. * TODOS
  6. - early-init.el? What to outsource here?
  7. - Paket exec-path-from-shell, um PATH aus Linux auch in emacs zu haben
  8. - Smart mode line?
  9. - Theme
  10. - evil-collection or custom in init file?
  11. - Hydra
  12. - General
  13. - (defalias 'list-buffers 'ibuffer) ;; change default to ibuffer
  14. - ido?
  15. - treemacs (for linux)
  16. - treemacs-evil?
  17. - treemacs-projectile
  18. windmove?
  19. - tramp (in linux)
  20. - visual-regexp
  21. - org configuration: paths
  22. - org custom agenda
  23. - org-ql (related to org agendas)
  24. - org configuration: everything else
  25. - beancount configuration from config.org
  26. - CONTINUE TODO from config.org at Programming
  27. - all-the-icons?
  28. - lispy? [[https://github.com/abo-abo/lispy]]
  29. * Header
  30. :PROPERTIES:
  31. :ID: a14d7c89-24ea-41ae-b185-944bab49aa02
  32. :END:
  33. Emacs variables are dynamically scoped. That's unusual for most languages, so disable it here, too
  34. #+begin_src emacs-lisp
  35. ;;; init.el --- -*- lexical-binding: t -*-
  36. #+end_src
  37. * First start
  38. :PROPERTIES:
  39. :ID: 1c24d48e-0124-4a0b-8e78-82e4c531e818
  40. :END:
  41. These functions updates config.el whenever changes in config.org are made. The update will be active after saving.
  42. #+BEGIN_SRC emacs-lisp
  43. (defun me/tangle-config ()
  44. "Export code blocks from the literate config file
  45. asynchronously."
  46. (interactive)
  47. ;; prevent emacs from killing until tangle-process finished
  48. (add-to-list 'kill-emacs-query-functions
  49. (lambda ()
  50. (or (not (process-live-p (get-process "tangle-process")))
  51. (y-or-n-p "\"me/tangle-config\" is running; kill it? "))))
  52. ;; tangle config asynchronously
  53. (me/async-process
  54. (format "emacs %s --batch --eval '(org-babel-tangle nil \"%s\")'" config-org config-el)
  55. "tangle-process")
  56. (message "reloading user-init-file")
  57. (load-file config-el))
  58. (add-hook 'org-mode-hook
  59. (lambda ()
  60. (if (equal (buffer-file-name) config-org)
  61. (me/add-local-hook 'after-save-hook 'me/tangle-config))))
  62. (defun me/add-local-hook (hook function)
  63. "Add buffer-local hook."
  64. (add-hook hook function :local t))
  65. (defun me/async-process (command &optional name filter)
  66. "Start an async process by running the COMMAND string with bash. Return the
  67. process object for it.
  68. NAME is name for the process. Default is \"async-process\".
  69. FILTER is function that runs after the process is finished, its args should be
  70. \"(process output)\". Default is just messages the output."
  71. (make-process
  72. :command `("bash" "-c" ,command)
  73. :name (if name name
  74. "async-process")
  75. :filter (if filter filter
  76. (lambda (process output) (message output)))))
  77. ; (lambda (process output) (message (s-trim output))))))
  78. ;; Examples:
  79. ;;
  80. ;; (me/async-process "ls")
  81. ;;
  82. ;; (me/async-process "ls" "my ls process"
  83. ;; (lambda (process output) (message "Output:\n\n%s" output)))
  84. ;;
  85. ;; (me/async-process "unknown command")
  86. #+END_SRC
  87. A small function to measure start up time.
  88. Compare that to
  89. emacs -q --eval='(message "%s" (emacs-init-time))'
  90. (roughly 0.27s)
  91. https://blog.d46.us/advanced-emacs-startup/
  92. #+begin_src emacs-lisp
  93. (add-hook 'emacs-startup-hook
  94. (lambda ()
  95. (message "Emacs ready in %s with %d garbage collections."
  96. (format "%.2f seconds"
  97. (float-time
  98. (time-subtract after-init-time before-init-time)))
  99. gcs-done)))
  100. ;(setq gc-cons-threshold (* 50 1000 1000))
  101. #+end_src
  102. #+BEGIN_SRC emacs-lisp
  103. (require 'package)
  104. (add-to-list 'package-archives '("elpa" . "https://elpa.gnu.org/packages/") t)
  105. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  106. (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
  107. (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
  108. ; fix for bug 34341
  109. (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
  110. (when (< emacs-major-version 27)
  111. (package-initialize))
  112. #+END_SRC
  113. #+BEGIN_SRC emacs-lisp
  114. (unless (package-installed-p 'use-package)
  115. (package-refresh-contents)
  116. (package-install 'use-package))
  117. (eval-when-compile
  118. (setq use-package-enable-imenu-support t)
  119. (require 'use-package))
  120. (require 'bind-key)
  121. (setq use-package-verbose nil)
  122. (use-package diminish
  123. :ensure t)
  124. #+END_SRC
  125. cl is deprecated in favor for cl-lib, some packages like emmet still depend on cl.
  126. Shut off the compiler warning about it.
  127. Maybe turn it on again at some point before the next major emacs upgrade
  128. #+begin_src emacs-lisp
  129. (setq byte-compile-warnings '(cl-functions))
  130. #+end_src
  131. * Performance Optimization
  132. ** Garbage Collection
  133. Make startup faster by reducing the frequency of garbage collection.
  134. Set gc-cons-threshold (default is 800kb) to maximum value available, to prevent any garbage collection from happening during load time.
  135. #+BEGIN_SRC emacs-lisp :tangle early-init.el
  136. (setq gc-cons-threshold most-positive-fixnum)
  137. #+END_SRC
  138. Restore it to reasonable value after init. Also stop garbage collection during minibuffer interaction (helm etc.)
  139. #+begin_src emacs-lisp
  140. (defconst 1mb 1048576)
  141. (defconst 20mb 20971520)
  142. (defconst 30mb 31457280)
  143. (defconst 50mb 52428800)
  144. (defun me/defer-garbage-collection ()
  145. (setq gc-cons-threshold most-positive-fixnum))
  146. (defun me/restore-garbage-collection ()
  147. (run-at-time 1 nil (lambda () (setq gc-cons-threshold 30mb))))
  148. (add-hook 'emacs-startup-hook 'me/restore-garbage-collection 100)
  149. (add-hook 'minibuffer-setup-hook 'me/defer-garbage-collection)
  150. (add-hook 'minibuffer-exit-hook 'me/restore-garbage-collection)
  151. (setq read-process-output-max 1mb) ;; lsp-mode's performance suggest
  152. #+end_src
  153. ** File Handler
  154. #+begin_src emacs-lisp :tangle early-init.el
  155. (defvar default-file-name-handler-alist file-name-handler-alist)
  156. (setq file-name-handler-alist nil)
  157. (add-hook 'emacs-startup-hook
  158. (lambda ()
  159. (setq file-name-handler-alist default-file-name-handler-alist)) 100)
  160. #+end_src
  161. ** Others
  162. #+begin_src emacs-lisp :tangle early-init.el
  163. ;; Resizing the emacs frame can be a terriblu expensive part of changing the font.
  164. ;; By inhibiting this, we easily hale startup times with fonts that are larger
  165. ;; than the system default.
  166. (setq frame-inhibit-implied-resize t)
  167. #+end_src
  168. * Default settings
  169. :PROPERTIES:
  170. :ID: 3512d679-d111-4ccd-8372-6fc2acbc0374
  171. :END:
  172. ** paths
  173. #+BEGIN_SRC emacs-lisp
  174. (defconst *sys/gui*
  175. (display-graphic-p)
  176. "Is emacs running in a gui?")
  177. (defconst *sys/linux*
  178. (string-equal system-type 'gnu/linux)
  179. "Is the system running Linux?")
  180. (defconst *sys/windows*
  181. (string-equal system-type 'windows-nt)
  182. "Is the system running Windows?")
  183. (defconst *home_desktop*
  184. (string-equal (system-name) "marc")
  185. "Is emacs running on my desktop?")
  186. (defconst *home_laptop*
  187. (string-equal (system-name) "laptop")
  188. "Is emacs running on my laptop?")
  189. (defconst *work_local*
  190. (string-equal (system-name) "PMPCNEU08")
  191. "Is emacs running at work on the local system?")
  192. (defconst *work_remote*
  193. (string-equal (system-name) "PMTS01")
  194. "Is emacs running at work on the remote system?")
  195. #+END_SRC
  196. #+BEGIN_SRC emacs-lisp
  197. (defvar MY--PATH_USER_LOCAL (concat user-emacs-directory "user-local/"))
  198. (defvar MY--PATH_USER_GLOBAL (concat user-emacs-directory "user-global/"))
  199. (add-to-list 'custom-theme-load-path (concat MY--PATH_USER_GLOBAL "themes"))
  200. (when *sys/linux*
  201. (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/"))
  202. (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/")))
  203. (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/"))
  204. (when *work_remote*
  205. (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  206. (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error
  207. (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error
  208. (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/"))
  209. (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings
  210. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  211. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  212. #+end_src
  213. ** sane defaults
  214. #+begin_src emacs-lisp
  215. (setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode
  216. (defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n
  217. (setq custom-safe-themes t) ;; don't ask me if I want to load a theme
  218. (setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence.
  219. (delete-selection-mode t) ;; delete selected region when typing
  220. (save-place-mode 1) ;; saves position in file when it's closed
  221. (setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position
  222. (global-set-key (kbd "RET") 'newline-and-indent) ;; indent after newline
  223. (setq save-interprogram-paste-before-kill t) ;; put replaced text into killring
  224. #+END_SRC
  225. ** Browser
  226. #+begin_src emacs-lisp
  227. (setq browse-url-function 'browse-url-generic
  228. browse-url-generic-program "firefox")
  229. #+end_src
  230. * Appearance
  231. ** Defaults
  232. #+begin_src emacs-lisp
  233. (set-charset-priority 'unicode)
  234. (setq-default locale-coding-system 'utf-8
  235. default-process-coding-system '(utf-8-unix . utf-8-unix))
  236. (set-terminal-coding-system 'utf-8)
  237. (set-keyboard-coding-system 'utf-8)
  238. (set-selection-coding-system 'utf-8)
  239. (if *sys/windows*
  240. (prefer-coding-system 'utf-8-dos)
  241. (prefer-coding-system 'utf-8))
  242. (setq-default bidi-paragraph-direction 'left-to-right
  243. bidi-inhibit-bpa t ;; both settings reduce line rescans
  244. uniquify-buffer-name-style 'forward
  245. indent-tabs-mode nil ;; avoid tabs in place of multiple spaces (they look bad in tex)
  246. indicate-empty-lines t ;; show empty lines
  247. scroll-margin 5 ;; smooth scrolling
  248. scroll-conservatively 10000
  249. scroll-preserve-screen-position 1
  250. scroll-step 1
  251. ring-bell-function 'ignore ;; disable pc speaker bell
  252. visible-bell t)
  253. (global-hl-line-mode t) ;; highlight current line
  254. (blink-cursor-mode -1) ;; turn off blinking cursor
  255. (column-number-mode t)
  256. #+end_src
  257. ** Remove redundant UI
  258. #+begin_src emacs-lisp :tangle early-init.el
  259. (menu-bar-mode -1) ;; disable menu bar
  260. (tool-bar-mode -1) ;; disable tool bar
  261. (scroll-bar-mode -1) ;; disable scroll bar
  262. #+end_src
  263. ** Font
  264. :PROPERTIES:
  265. :ID: dc8eb670-e6bb-4bfb-98f0-aae1860234fb
  266. :END:
  267. #+BEGIN_SRC emacs-lisp
  268. (when *sys/linux*
  269. (set-face-font 'default "Hack-10"))
  270. (when *work_remote*
  271. (set-face-font 'default "Lucida Sans Typewriter-11"))
  272. #+END_SRC
  273. ** Themes
  274. :PROPERTIES:
  275. :ID: 9ccf37c0-6837-43cb-bed8-5a353799d8b1
  276. :END:
  277. #+BEGIN_SRC emacs-lisp
  278. (defun my/toggle-theme ()
  279. (interactive)
  280. (when (or *sys/windows* *sys/linux*)
  281. (if (eq (car custom-enabled-themes) 'tango-dark)
  282. (progn (disable-theme 'tango-dark)
  283. (load-theme 'tango))
  284. (progn
  285. (disable-theme 'tango)
  286. (load-theme 'tango-dark)))))
  287. (bind-key "C-c t" 'my/toggle-theme)
  288. #+END_SRC
  289. Windows Theme:
  290. #+BEGIN_SRC emacs-lisp
  291. (when *sys/windows*
  292. (load-theme 'tango))
  293. (when *sys/linux*
  294. (load-theme 'plastic))
  295. #+END_SRC
  296. ** line wrappings
  297. :PROPERTIES:
  298. :ID: 14ae933e-2941-4cc3-82de-38f90f91bfd3
  299. :END:
  300. #+BEGIN_SRC emacs-lisp
  301. (global-visual-line-mode)
  302. (diminish 'visual-line-mode)
  303. (use-package adaptive-wrap
  304. :ensure t
  305. :hook
  306. (visual-line-mode . adaptive-wrap-prefix-mode))
  307. ; :init
  308. ; (when (fboundp 'adaptive-wrap-prefix-mode)
  309. ; (defun my/activate-adaptive-wrap-prefix-mode ()
  310. ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  311. ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  312. ; (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode)))
  313. #+END_SRC
  314. ** line numbers
  315. :PROPERTIES:
  316. :ID: 7b969436-98c9-4b61-ba7a-9fb22c9781ad
  317. :END:
  318. #+BEGIN_SRC emacs-lisp
  319. (use-package display-line-numbers
  320. :init
  321. :hook
  322. ((prog-mode
  323. org-src-mode) . display-line-numbers-mode)
  324. :config
  325. (setq-default display-line-numbers-type 'visual
  326. display-line-numbers-current-absolute t
  327. display-line-numbers-with 4
  328. display-line-numbers-widen t))
  329. #+END_SRC
  330. ** misc
  331. :PROPERTIES:
  332. :ID: a2873138-16ee-4990-89a2-26eab778ea74
  333. :END:
  334. #+BEGIN_SRC emacs-lisp
  335. (use-package rainbow-mode
  336. :ensure t
  337. :diminish
  338. :hook
  339. ((org-mode
  340. emacs-lisp-mode) . rainbow-mode))
  341. (use-package delight
  342. :ensure t)
  343. (show-paren-mode t) ;; show other part of brackets
  344. (use-package rainbow-delimiters
  345. :ensure t
  346. :hook
  347. (prog-mode . rainbow-delimiters-mode))
  348. #+END_SRC
  349. * Bookmarks
  350. Usage:
  351. - C-x r m (bookmark-set): add bookmark
  352. - C-x r l (list-bookmark): list bookmarks
  353. - C-x r b (bookmark-jump): open bookmark
  354. Edit bookmarks (while in bookmark file):
  355. - d: mark current item
  356. - x: delete marked items
  357. - r: rename current item
  358. - s: save changes
  359. #+begin_src emacs-lisp
  360. (use-package bookmark
  361. :custom
  362. (bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks")))
  363. #+end_src
  364. Some windows specific stuff
  365. #+BEGIN_SRC emacs-lisp
  366. (when *sys/windows*
  367. (remove-hook 'find-file-hook 'vc-refresh-state)
  368. ; (progn
  369. ; (setq gc-cons-threshold (* 511 1024 1024)
  370. ; gc-cons-percentage 0.5
  371. ; garbage-collection-messages t)
  372. ; (run-with-idle-timer 5 t #'garbage-collect))
  373. (when (boundp 'w32-pipe-read-delay)
  374. (setq w32-pipe-read-delay 0))
  375. (when (boundp 'w32-get-true-file-attributes)
  376. (setq w32-get-true-file-attributes nil)))
  377. #+END_SRC
  378. * recentf
  379. Exclude some dirs from spamming recentf
  380. #+begin_src emacs-lisp
  381. (use-package recentf
  382. :config
  383. (recentf-mode)
  384. :custom
  385. (recentf-exclude '(".*-autoloads\\.el\\'"
  386. "[/\\]\\elpa/"
  387. "COMMIT_EDITMSG\\'"))
  388. (recentf-save-file (concat MY--PATH_USER_LOCAL "recentf"))
  389. (recentf-max-menu-items 600)
  390. (recentf-max-saved-items 600))
  391. #+end_src
  392. * undo
  393. :PROPERTIES:
  394. :ID: d57621b2-5472-4c89-a520-b4133db0b9af
  395. :END:
  396. #+BEGIN_SRC emacs-lisp
  397. (use-package undo-tree
  398. :ensure t
  399. :diminish undo-tree-mode
  400. :init
  401. (global-undo-tree-mode 1))
  402. #+END_SRC
  403. * ace-window
  404. #+begin_src emacs-lisp
  405. (use-package ace-window
  406. :ensure t
  407. :bind
  408. (:map global-map
  409. ("C-x o" . ace-window)))
  410. #+end_src
  411. * imenu-list
  412. :PROPERTIES:
  413. :ID: 0ae27ec9-5d77-43cf-ac76-5e12cc959046
  414. :END:
  415. A minor mode to show imenu in a sidebar.
  416. Call imenu-list-smart-toggle.
  417. [[https://github.com/bmag/imenu-list][Source]]
  418. #+BEGIN_SRC emacs-lisp
  419. (use-package imenu-list
  420. :ensure t
  421. :defer t
  422. :config
  423. (setq imenu-list-focus-after-activation t
  424. imenu-list-auto-resize t
  425. imenu-list-position 'right)
  426. :bind
  427. (:map global-map
  428. ([f9] . imenu-list-smart-toggle))
  429. :custom
  430. (org-imenu-depth 4))
  431. #+END_SRC
  432. * which-key
  433. :PROPERTIES:
  434. :ID: a880f079-b3a3-4706-bf1e-5f6c680101f1
  435. :END:
  436. #+BEGIN_SRC emacs-lisp
  437. (use-package which-key
  438. :ensure t
  439. :diminish which-key-mode
  440. :defer t
  441. :hook
  442. (after-init . which-key-mode)
  443. :config
  444. (which-key-setup-side-window-bottom)
  445. (setq which-key-idle-delay 0.5))
  446. #+END_SRC
  447. * abbrev
  448. #+begin_src emacs-lisp
  449. (use-package abbrev
  450. :diminish abbrev-mode
  451. :hook
  452. ((text-mode org-mode) . abbrev-mode)
  453. :init
  454. (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_tables.el"))
  455. :config
  456. (if (file-exists-p abbrev-file-name)
  457. (quietly-read-abbrev-file))
  458. (setq save-abbrevs 'silently)) ;; don't bother me with asking for abbrev saving
  459. #+end_src
  460. * Evil
  461. :PROPERTIES:
  462. :ID: 80ca70e2-a146-46db-b581-418d655dc1fc
  463. :END:
  464. #+BEGIN_SRC emacs-lisp
  465. (use-package evil
  466. :ensure t
  467. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  468. :config
  469. (evil-mode 1))
  470. #+END_SRC
  471. * General (key mapper)
  472. :PROPERTIES:
  473. :ID: a20f183f-d41a-4dff-bc37-3bc4e25c8036
  474. :END:
  475. #+BEGIN_SRC emacs-lisp
  476. (use-package general
  477. :ensure t)
  478. (general-define-key
  479. :states 'normal
  480. :keymaps 'imenu-list-major-mode-map
  481. "RET" '(imenu-list-goto-entry :which-key "goto")
  482. "TAB" '(hs-toggle-hiding :which-key "collapse")
  483. "d" '(imenu-list-display-entry :which-key "show")
  484. "q" '(imenu-list-quit-window :which-key "quit"))
  485. #+END_SRC
  486. * ivy / counsel / swiper
  487. :PROPERTIES:
  488. :ID: 55c74ba9-7761-4545-8ddd-087d6ee33e4b
  489. :END:
  490. +BEGIN_SRC emacs-lisp
  491. ; (require 'ivy)
  492. (use-package ivy
  493. :ensure t
  494. :diminish
  495. (ivy-mode . "")
  496. :defer t
  497. :init
  498. (ivy-mode 1)
  499. :bind
  500. ("C-r" . ivy-resume) ;; overrides isearch-backwards binding
  501. :config
  502. (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer
  503. ivy-height 20 ;; height of ivy window
  504. ivy-count-format "%d/%d" ;; current and total number
  505. ivy-re-builders-alist ;; regex replaces spaces with *
  506. '((t . ivy--regex-plus))))
  507. ; make counsel-M-x more descriptive
  508. (use-package ivy-rich
  509. :ensure t
  510. :defer t
  511. :init
  512. (ivy-rich-mode 1))
  513. (use-package counsel
  514. :ensure t
  515. :defer t
  516. :bind
  517. (("M-x" . counsel-M-x)
  518. ("C-x C-f" . counsel-find-file)
  519. ("C-x C-r" . counsel-recentf)
  520. ("C-x b" . counsel-switch-buffer)
  521. ("C-c C-f" . counsel-git)
  522. ("C-c h f" . counsel-describe-function)
  523. ("C-c h v" . counsel-describe-variable)
  524. ("M-i" . counsel-imenu)))
  525. ; :map minibuffer-local-map ;;currently mapped to evil-redo
  526. ; ("C-r" . 'counsel-minibuffer-history)))
  527. (use-package swiper
  528. :ensure t
  529. :bind
  530. ("C-s" . swiper))
  531. (use-package ivy-hydra
  532. :ensure t)
  533. +END_SRC
  534. * Helm
  535. As an alternative to ivy/counsel/swiper?
  536. #+begin_src emacs-lisp
  537. (use-package helm
  538. :ensure t
  539. :hook
  540. (helm-mode . helm-autoresize-mode)
  541. :bind
  542. (("M-x" . helm-M-x)
  543. ("C-s" . helm-occur)
  544. ("C-x C-f" . helm-find-files)
  545. ("C-x C-b" . helm-buffers-list)
  546. ("C-x b" . helm-buffers-list)
  547. ("C-x C-r" . helm-recentf)
  548. ("C-x C-i" . helm-imenu))
  549. :config
  550. (helm-mode)
  551. :custom
  552. (helm-split-window-inside-p t) ;; open helm buffer inside current window
  553. (helm-move-to-line-cycle-in-source t)
  554. (helm-echo-input-in-header-line t)
  555. (helm-autoresize-max-height 20)
  556. (helm-autoresize-min-height 5)
  557. )
  558. #+end_src
  559. * misc
  560. #+begin_src emacs-lisp
  561. (use-package autorevert
  562. :diminish auto-revert-mode)
  563. #+end_src
  564. * company
  565. :PROPERTIES:
  566. :ID: 944563b6-b04a-44f2-9b21-a6a3e200867c
  567. :END:
  568. #+BEGIN_SRC emacs-lisp
  569. (use-package company
  570. :defer 1
  571. :diminish
  572. :defer t
  573. :bind
  574. (("C-<tab>" . company-complete)
  575. :map company-active-map
  576. ("RET" . nil)
  577. ([return] . nil)
  578. ("TAB" . company-complete-selection)
  579. ([tab] . company-complete-selection)
  580. ("<right>" . company-complete-common)
  581. ("<escape>" . company-abort))
  582. :hook
  583. (after-init . global-company-mode)
  584. (emacs-lisp-mode . my/company-elisp)
  585. (org-mode . my/company-org)
  586. :config
  587. (defun my/company-elisp ()
  588. (message "set up company for elisp")
  589. (set (make-local-variable 'company-backends)
  590. '(company-capf ;; capf needs to be before yasnippet, or lsp fucks up completion for elisp
  591. company-yasnippet
  592. company-dabbrev-code
  593. company-files)))
  594. (defun my/company-org ()
  595. (set (make-local-variable 'company-backends)
  596. '(company-capf company-files))
  597. ;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  598. (message "setup company for org"))
  599. (setq company-idle-delay .2
  600. company-minimum-prefix-length 1
  601. company-require-match nil
  602. company-show-numbers t
  603. company-tooltip-align-annotations t))
  604. (use-package company-statistics
  605. :ensure t
  606. :after company
  607. :defer t
  608. :init
  609. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  610. :config
  611. (company-statistics-mode 1))
  612. (use-package company-dabbrev
  613. :ensure nil
  614. :after company
  615. :defer t
  616. :config
  617. (setq-default company-dabbrev-downcase nil))
  618. ;; adds a info box right of the cursor with doc of the function
  619. (use-package company-box
  620. :ensure t
  621. :diminish
  622. :defer t
  623. :hook
  624. (company-mode . company-box-mode))
  625. ; :init
  626. ; (add-hook 'company-mode-hook 'company-box-mode))
  627. #+END_SRC
  628. * orgmode
  629. ** org
  630. :PROPERTIES:
  631. :ID: b89d7639-080c-4168-8884-bd5d8965f466
  632. :END:
  633. #+BEGIN_SRC emacs-lisp
  634. (use-package org
  635. :ensure org-plus-contrib
  636. :mode (("\.org$" . org-mode))
  637. :diminish org-indent-mode
  638. :defer t
  639. :hook
  640. (org-mode . org-indent-mode)
  641. (org-source-mode . smartparens-mode)
  642. ; :init
  643. ; (add-hook 'org-mode-hook 'company/org-mode-hook)
  644. ; (add-hook 'org-src-mode-hook 'smartparens-mode)
  645. ; (add-hook 'org-mode-hook 'org-indent-mode)
  646. :config
  647. (defun my/org-company ()
  648. (set (make-local-variable 'company-backends)
  649. '(company-capf company-files))
  650. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  651. (message "company/org-mode-hook"))
  652. (setq org-modules (quote (org-id
  653. org-habit
  654. org-tempo ;; easy templates
  655. )))
  656. (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")
  657. org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org")
  658. (concat MY--PATH_ORG_FILES "projects.org")
  659. (concat MY--PATH_ORG_FILES "tasks.org")))
  660. (when *sys/linux*
  661. (nconc org-agenda-files
  662. (directory-files-recursively MY--PATH_ORG_FILES_MOBILE "\\.org$")))
  663. (setq org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations")
  664. org-log-into-drawer "LOGBOOK")
  665. ;; some display customizations
  666. (setq org-pretty-entities t
  667. org-startup-truncated t
  668. org-startup-align-all-tables t)
  669. ;; some source code blocks customizations
  670. (setq org-src-window-setup 'current-window ;; C-c ' opens in current window
  671. org-src-fontify-natively t ;; use syntax highlighting in code blocks
  672. org-src-preserve-indentation t ;; no extra indentation
  673. org-src-tab-acts-natively t)
  674. (setq org-log-done 'time)) ;; create timestamp when task is done
  675. #+END_SRC
  676. ** languages
  677. :PROPERTIES:
  678. :ID: ad3af718-d0db-448c-9f75-eb9e250c2862
  679. :END:
  680. Set some languages and disable confirmation for evaluating code blocks C-c C-c
  681. +BEGIN_SRC emacs-lisp
  682. (org-babel-do-load-languages
  683. 'org-babel-load-languages
  684. '((emacs-lisp . t)
  685. (gnuplot . t)
  686. (js . t)
  687. (latex . t)
  688. (lisp . t)
  689. (python . t)
  690. (shell . t)
  691. (sqlite . t)
  692. (org . t)
  693. (R . t)
  694. (scheme . t)))
  695. (setq org-confirm-babel-evaluate nil)
  696. +END_SRC
  697. Another setup, because org-babel-do-load-languages requires eager loading
  698. #+begin_src emacs-lisp
  699. (use-package ob-org
  700. :defer t
  701. :ensure org-plus-contrib
  702. :commands
  703. (org-babel-execute:org
  704. org-babel-expand-body:org))
  705. (use-package ob-python
  706. :defer t
  707. :ensure org-plus-contrib
  708. :commands (org-babel-execute:python))
  709. (use-package ob-js
  710. :defer t
  711. :ensure org-plus-contrib
  712. :commands (org-babel-execute:js))
  713. (use-package ob-shell
  714. :defer t
  715. :ensure org-plus-contrib
  716. :commands
  717. (org-babel-execute:sh
  718. org-babel-expand-body:sh
  719. org-babel-execute:bash
  720. org-babel-expand-body:bash))
  721. (use-package ob-emacs-lisp
  722. :defer t
  723. :ensure org-plus-contrib
  724. :commands
  725. (org-babel-execute:emacs-lisp
  726. org-babel-expand-body:emacs-lisp))
  727. (use-package ob-lisp
  728. :defer t
  729. :ensure org-plus-contrib
  730. :commands
  731. (org-babel-execute:lisp
  732. org-babel-expand-body:lisp))
  733. (use-package ob-gnuplot
  734. :defer t
  735. :ensure org-plus-contrib
  736. :commands
  737. (org-babel-execute:gnuplot
  738. org-babel-expand-body:gnuplot))
  739. (use-package ob-sqlite
  740. :defer t
  741. :ensure org-plus-contrib
  742. :commands
  743. (org-babel-execute:sqlite
  744. org-babel-expand-body:sqlite))
  745. (use-package ob-latex
  746. :defer t
  747. :ensure org-plus-contrib
  748. :commands
  749. (org-babel-execute:latex
  750. org-babel-expand-body:latex))
  751. (use-package ob-R
  752. :defer t
  753. :ensure org-plus-contrib
  754. :commands
  755. (org-babel-execute:R
  756. org-babel-expand-body:R))
  757. (use-package ob-scheme
  758. :defer t
  759. :ensure org-plus-contrib
  760. :commands
  761. (org-babel-execute:scheme
  762. org-babel-expand-body:scheme))
  763. #+end_src
  764. ** habits
  765. :PROPERTIES:
  766. :ID: fcc91d0a-d040-4910-b2cf-3221496a3842
  767. :END:
  768. #+BEGIN_SRC emacs-lisp
  769. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  770. ;; (add-to-list 'org-modules "org-habit")
  771. (setq org-habit-graph-column 80
  772. org-habit-preceding-days 30
  773. org-habit-following-days 7
  774. org-habit-show-habits-only-for-today nil)
  775. #+END_SRC
  776. ** org-id
  777. :PROPERTIES:
  778. :ID: c4017c45-d650-410c-8bd4-bc3cf42bbbb9
  779. :END:
  780. Currently it causes some debugger errors "not a standard org time string", so it's disabled
  781. #+BEGIN_SRC emacs-lisp
  782. ;; (use-package org-id
  783. ;; :config
  784. ;; (setq org-id-link-to-org-use-id t)
  785. ;; (org-id-update-id-locations)) ;; update id file .org-id-locations on startup
  786. #+END_SRC
  787. ** org-agenda
  788. :PROPERTIES:
  789. :ID: 03b67efb-4179-41e5-bc2e-c472b13f8be6
  790. :END:
  791. Custom keywords, depending on environment
  792. #+BEGIN_SRC emacs-lisp
  793. (when *work_remote*
  794. (setq org-todo-keywords
  795. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE" "CANCELLED"))))
  796. #+END_SRC
  797. Add some key bindings
  798. #+BEGIN_SRC emacs-lisp
  799. (bind-key "C-c l" 'org-store-link)
  800. (bind-key "C-c c" 'org-capture)
  801. (bind-key "C-c a" 'org-agenda)
  802. #+END_SRC
  803. Sort agenda by deadline and priority
  804. #+BEGIN_SRC emacs-lisp
  805. (setq org-agenda-sorting-strategy
  806. (quote
  807. ((agenda deadline-up priority-down)
  808. (todo priority-down category-keep)
  809. (tags priority-down category-keep)
  810. (search category-keep))))
  811. #+END_SRC
  812. Customize the org agenda
  813. #+BEGIN_SRC emacs-lisp
  814. (defun me--org-skip-subtree-if-priority (priority)
  815. "Skip an agenda subtree if it has a priority of PRIORITY.
  816. PRIORITY may be one of the characters ?A, ?B, or ?C."
  817. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  818. (pri-value (* 1000 (- org-lowest-priority priority)))
  819. (pri-current (org-get-priority (thing-at-point 'line t))))
  820. (if (= pri-value pri-current)
  821. subtree-end
  822. nil)))
  823. (setq org-agenda-custom-commands
  824. '(("c" "Simple agenda view"
  825. ((tags "PRIORITY=\"A\""
  826. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  827. (org-agenda-overriding-header "Hohe Priorität:")))
  828. (agenda ""
  829. ((org-agenda-span 7)
  830. (org-agenda-start-on-weekday nil)
  831. (org-agenda-overriding-header "Nächste 7 Tage:")))
  832. (alltodo ""
  833. ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A)
  834. (org-agenda-skip-if nil '(scheduled deadline))))
  835. (org-agenda-overriding-header "Sonstige Aufgaben:")))))))
  836. #+END_SRC
  837. ** *TODO*
  838. org-super-agenda
  839. ** org-caldav
  840. :PROPERTIES:
  841. :ID: 6bd24369-0d04-452f-85a0-99914dfb74ff
  842. :END:
  843. Vorerst deaktiviert, Nutzen evtl. nicht vorhanden
  844. #+BEGIN_SRC emacs-lisp
  845. ;;(use-package org-caldav
  846. ;; :ensure t
  847. ;; :config
  848. ;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc"
  849. ;; org-caldav-calendar-id "orgmode"
  850. ;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox")
  851. ;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks")))
  852. #+END_SRC
  853. ** journal
  854. :PROPERTIES:
  855. :ID: a1951e18-d862-4198-9652-016e979053c8
  856. :END:
  857. [[https://github.com/bastibe/org-journal][Source]]
  858. #+BEGIN_SRC emacs-lisp
  859. (use-package org-journal
  860. :if *sys/linux*
  861. :ensure t
  862. :defer t
  863. :config
  864. ;; feels hacky, but this way compiler error "assignment to free variable" disappears
  865. (when (and (boundp 'org-journal-dir)
  866. (boundp 'org-journal-enable-agenda-integration))
  867. (setq org-journal-dir MY--PATH_ORG_JOURNAl
  868. org-journal-enable-agenda-integration t)))
  869. #+END_SRC
  870. * Programming
  871. ** misc
  872. #+begin_src emacs-lisp
  873. (use-package eldoc
  874. :diminish eldoc-mode
  875. :defer t)
  876. #+end_src
  877. ** Magit / Git
  878. :PROPERTIES:
  879. :ID: d3589460-317f-40f6-9056-053be9ba3217
  880. :END:
  881. Little crash course in magit:
  882. - magit-init to init a git project
  883. - magit-status (C-x g) to call the status window
  884. In status buffer:
  885. - s stage files
  886. - u unstage files
  887. - U unstage all files
  888. - a apply changes to staging
  889. - c c commit (type commit message, then C-c C-c to commit)
  890. - b b switch to another branch
  891. - P u git push
  892. - F u git pull
  893. #+BEGIN_SRC emacs-lisp
  894. (use-package magit
  895. :ensure t
  896. :defer t
  897. :init
  898. ; set git-path in work environment
  899. (if (string-equal user-login-name "POH")
  900. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  901. )
  902. :bind (("C-x g" . magit-status)))
  903. #+END_SRC
  904. ** LSP
  905. :PROPERTIES:
  906. :ID: 06ad00e0-44a6-4bfb-ba6f-b1672811e053
  907. :END:
  908. Configuration for the language server protocol
  909. *ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp
  910. Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden.
  911. Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad.
  912. TODO Unterverzeichnisse wurden noch nicht getestet
  913. #+BEGIN_SRC emacs-lisp
  914. (setq read-process-output-max (* 1024 1024)) ;; support reading large blobs of data for LSP's sake
  915. (use-package lsp-mode
  916. :defer t
  917. :commands (lsp lsp-execute-code-action)
  918. :custom
  919. (lsp-auto-guess-root nil)
  920. (lsp-prefer-flymake nil) ; use flycheck instead
  921. (lsp-prefer-capf t)
  922. (lsp-file-watch-threshold 5000)
  923. (lsp-print-performance t)
  924. (lsp-log-io nil) ; enable log only for debug
  925. (lsp-enable-folding t) ; default, maybe evil-matchit instead for performance?
  926. (lsp-diagnostics-modeline-scope :project)
  927. (lsp-enable-file-watchers nil)
  928. :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
  929. :hook
  930. (((python-mode
  931. js-mode
  932. js2-mode
  933. typescript-mode
  934. web-mode
  935. ) . lsp-deferred)
  936. (lsp-mode . lsp-enable-which-key-integration)
  937. (lsp-mode . lsp-diagnostics-modeline-mode)
  938. (web-mode . #'lsp-flycheck-enable)) ;; enable flycheck-lsp for web-mode locally
  939. :config
  940. (setq lsp-diagnostics-package :none)) ; disable flycheck-lsp for most modes
  941. ;; (add-hook 'web-mode-hook #'lsp-flycheck-enable)) ; enable flycheck-lsp for web-mode locally
  942. (use-package lsp-ui
  943. :after lsp-mode
  944. :ensure t
  945. :defer t
  946. :diminish
  947. :commands lsp-ui-mode
  948. :config
  949. (setq lsp-ui-doc-enable t
  950. lsp-ui-doc-header t
  951. lsp-ui-doc-include-signature t
  952. lsp-ui-doc-position 'top
  953. lsp-ui-doc-border (face-foreground 'default)
  954. lsp-ui-sideline-enable t
  955. lsp-ui-sideline-ignore-duplicate t
  956. lsp-ui-sideline-show-code-actions nil)
  957. (when *sys/gui*
  958. (setq lsp-ui-doc-use-webkit t))
  959. ;; workaround hide mode-line of lsp-ui-imenu buffer
  960. (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
  961. (setq mode-line-format nil)))
  962. ;;NO LONGER SUPPORTED, USE company-capf / completion-at-point
  963. ;(use-package company-lsp
  964. ; :requires company
  965. ; :defer t
  966. ; :ensure t
  967. ; :config
  968. ; ;;disable client-side cache because lsp server does a better job
  969. ; (setq company-transformers nil
  970. ; company-lsp-async t
  971. ; company-lsp-cache-candidates nil))
  972. #+END_SRC
  973. ** yasnippet
  974. :PROPERTIES:
  975. :ID: 935d89ef-645e-4e92-966f-2fe3bebb2880
  976. :END:
  977. For useful snippet either install yasnippet-snippets or get them from here
  978. [[https://github.com/AndreaCrotti/yasnippet-snippets][Github]]
  979. #+begin_src emacs-lisp
  980. (use-package yasnippet
  981. :ensure t
  982. :defer t
  983. :diminish yas-minor-mode
  984. :config
  985. (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets")))
  986. (yas-global-mode t)
  987. (yas-reload-all)
  988. (unbind-key "TAB" yas-minor-mode-map)
  989. (unbind-key "<tab>" yas-minor-mode-map))
  990. #+end_src
  991. ** hippie expand
  992. :PROPERTIES:
  993. :ID: c55245bc-813d-4816-a0ca-b4e2e793e28b
  994. :END:
  995. With hippie expand I am able to use yasnippet and emmet at the same time with the same key.
  996. #+begin_src emacs-lisp
  997. (use-package hippie-exp
  998. :defer t
  999. :bind
  1000. ("C-<return>" . hippie-expand)
  1001. :config
  1002. (setq hippie-expand-try-functions-list
  1003. '(yas-hippie-try-expand emmet-expand-line)))
  1004. #+end_src
  1005. ** flycheck
  1006. :PROPERTIES:
  1007. :ID: 3d8f2547-c5b3-46d0-91b0-9667f9ee5c47
  1008. :END:
  1009. #+BEGIN_SRC emacs-lisp
  1010. (use-package flycheck
  1011. :ensure t
  1012. :hook
  1013. ((css-mode . flycheck-mode)
  1014. (emacs-lisp-mode . flycheck-mode)
  1015. (python-mode . flycheck-mode))
  1016. :defer 1.0
  1017. :init
  1018. (setq flycheck-emacs-lisp-load-path 'inherit)
  1019. :config
  1020. (setq-default
  1021. flycheck-check-synta-automatically '(save mode-enabled)
  1022. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  1023. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  1024. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  1025. #+END_SRC
  1026. ** Projectile
  1027. :PROPERTIES:
  1028. :ID: a90329fd-4d36-435f-8308-a2771ac4c320
  1029. :END:
  1030. Manage projects and jump quickly between its files
  1031. #+BEGIN_SRC emacs-lisp
  1032. (use-package projectile
  1033. :ensure t
  1034. ; :defer 1.0
  1035. :diminish
  1036. :bind
  1037. (("C-c p" . projectile-command-map))
  1038. ;:preface
  1039. :init
  1040. (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache")
  1041. projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks"))
  1042. :config
  1043. (projectile-mode)
  1044. ; (add-hook 'projectile-after-switch-project-hook #'set-workon_home)
  1045. (setq-default projectile-completion-system 'ivy
  1046. projectile-enable-caching t
  1047. projectile-mode-line '(:eval (projectile-project-name))))
  1048. ;; requires ripgrep on system for rg functions
  1049. ;(use-package counsel-projectile
  1050. ; :ensure t
  1051. ; :config (counsel-projectile-mode))
  1052. (use-package helm-projectile
  1053. :ensure t
  1054. :hook
  1055. (projectile-mode . helm-projectile))
  1056. #+END_SRC
  1057. ** smartparens
  1058. :PROPERTIES:
  1059. :ID: 997ec416-33e6-41ed-8c7c-75a7bc47d285
  1060. :END:
  1061. #+BEGIN_SRC emacs-lisp
  1062. (use-package smartparens
  1063. :ensure t
  1064. :diminish smartparens-mode
  1065. :bind
  1066. (:map smartparens-mode-map
  1067. ("C-M-f" . sp-forward-sexp)
  1068. ("C-M-b" . sp-backward-sexp)
  1069. ("C-M-a" . sp-backward-down-sexp)
  1070. ("C-M-e" . sp-up-sexp)
  1071. ("C-M-w" . sp-copy-sexp)
  1072. ("M-k" . sp-kill-sexp)
  1073. ("C-M-<backspace>" . sp-slice-sexp-killing-backward)
  1074. ("C-S-<backspace>" . sp-slice-sexp-killing-around)
  1075. ("C-]" . sp-select-next-thing-exchange))
  1076. :config
  1077. (setq sp-show-pair-from-inside nil
  1078. sp-escape-quotes-after-insert nil)
  1079. (require 'smartparens-config))
  1080. #+END_SRC
  1081. ** lisp
  1082. :PROPERTIES:
  1083. :ID: a2bc3e08-b203-49d3-b337-fb186a14eecb
  1084. :END:
  1085. #+BEGIN_SRC emacs-lisp
  1086. (use-package elisp-mode
  1087. :defer t)
  1088. #+END_SRC
  1089. ** web
  1090. :PROPERTIES:
  1091. :ID: c0b0b4e4-2162-429f-b80d-6e5334b1290e
  1092. :END:
  1093. apt install npm
  1094. sudo npm install -g vscode-html-languageserver-bin
  1095. evtl alternativ typescript-language-server?
  1096. Unter Windows:
  1097. Hier runterladen: https://nodejs.org/dist/latest/
  1098. und in ein Verzeichnis entpacken.
  1099. Optional: PATH erweitern unter Windows (so kann exec-path-from-shell den Pfad ermitteln):
  1100. PATH=P:\path\to\node;%path%
  1101. #+BEGIN_SRC emacs-lisp
  1102. (use-package web-mode
  1103. :ensure t
  1104. :defer t
  1105. :mode
  1106. ("\\.phtml\\'"
  1107. "\\.tpl\\.php\\'"
  1108. "\\.djhtml\\'"
  1109. "\\.[t]?html?\\'")
  1110. :hook
  1111. (web-mode . smartparens-mode)
  1112. :init
  1113. (if *work_remote*
  1114. (setq exec-path (append exec-path '("P:/Tools/node"))))
  1115. :config
  1116. (setq web-mode-enable-auto-closing t
  1117. web-mode-enable-auto-pairing t))
  1118. #+END_SRC
  1119. Emmet offers snippets, similar to yasnippet.
  1120. Default completion is C-j
  1121. [[https://github.com/smihica/emmet-mode#usage][Github]]
  1122. #+begin_src emacs-lisp
  1123. (use-package emmet-mode
  1124. :ensure t
  1125. :defer t
  1126. :hook
  1127. ((web-mode . emmet-mode)
  1128. (css-mode . emmet-mode))
  1129. :config
  1130. (unbind-key "C-<return>" emmet-mode-keymap))
  1131. #+end_src
  1132. *** JavaScript
  1133. npm install -g typescript-language-server typescript
  1134. maybe only typescript?
  1135. npm install -g prettier
  1136. #+begin_src emacs-lisp
  1137. (use-package rjsx-mode
  1138. :ensure t
  1139. :mode ("\\.js\\'"
  1140. "\\.jsx'"))
  1141. ; :config
  1142. ; (setq js2-mode-show-parse-errors nil
  1143. ; js2-mode-show-strict-warnings nil
  1144. ; js2-basic-offset 2
  1145. ; js-indent-level 2)
  1146. ; (setq-local flycheck-disabled-checkers (cl-union flycheck-disable-checkers
  1147. ; '(javascript-jshint)))) ; jshint doesn"t work for JSX
  1148. (use-package tide
  1149. :ensure t
  1150. :after (rjsx-mode company flycheck)
  1151. ; :hook (rjsx-mode . setup-tide-mode)
  1152. :config
  1153. (defun setup-tide-mode ()
  1154. "Setup function for tide."
  1155. (interactive)
  1156. (tide-setup)
  1157. (flycheck-mode t)
  1158. (setq flycheck-check-synta-automatically '(save mode-enabled))
  1159. (tide-hl-identifier-mode t)))
  1160. ;; needs npm install -g prettier
  1161. (use-package prettier-js
  1162. :ensure t
  1163. :after (rjsx-mode)
  1164. :defer t
  1165. :diminish prettier-js-mode
  1166. :hook ((js2-mode rsjx-mode) . prettier-js-mode))
  1167. #+end_src
  1168. ** YAML
  1169. :PROPERTIES:
  1170. :ID: 95413247-04d5-4e02-8431-06c162ec8f3b
  1171. :END:
  1172. #+begin_src emacs-lisp
  1173. (use-package yaml-mode
  1174. :if *sys/linux*
  1175. :ensure t
  1176. :defer t
  1177. :mode ("\\.yml$" . yaml-mode))
  1178. #+end_src
  1179. ** R
  1180. #+BEGIN_SRC emacs-lisp
  1181. (use-package ess
  1182. :ensure t
  1183. :defer t
  1184. :init
  1185. (if *work_remote*
  1186. (setq exec-path (append exec-path '("P:/Tools/R/bin/x64"))
  1187. org-babel-R-command "P:/Tools/R/bin/x64/R --slave --no-save")))
  1188. #+END_SRC
  1189. ** Python
  1190. :PROPERTIES:
  1191. :ID: 8c76fcd1-c57c-48ab-8af0-aa782de6337f
  1192. :END:
  1193. Systemseitig muss python-language-server installiert sein:
  1194. apt install python3-pip python3-setuptools python3-wheel
  1195. apt install build-essential python3-dev
  1196. pip3 install 'python-language-server[all]'
  1197. Statt obiges: npm install -g pyright
  1198. für andere language servers
  1199. https://github.com/emacs-lsp/lsp-mode#install-language-server
  1200. #+BEGIN_SRC emacs-lisp
  1201. ;(use-package lsp-python-ms
  1202. ; :if *sys/linux*
  1203. ; :ensure t
  1204. ; :defer t
  1205. ; :custom (lsp-python-ms-auto-install-server t))
  1206. (use-package lsp-pyright
  1207. :ensure t
  1208. :after lsp-mode
  1209. :defer t
  1210. ; :custom
  1211. ; (lsp-pyright-auto-import-completions nil)
  1212. ; (lsp-pyright-typechecking-mode "off")
  1213. )
  1214. (use-package python
  1215. :if *sys/linux*
  1216. :delight "π "
  1217. :defer t
  1218. :bind (("M-[" . python-nav-backward-block)
  1219. ("M-]" . python-nav-forward-block)))
  1220. (use-package pyvenv
  1221. :if *sys/linux*
  1222. :ensure t
  1223. :defer t
  1224. :after python
  1225. :hook ((python-mode . pyvenv-mode)
  1226. (python-mode . (lambda ()
  1227. (if-let ((pyvenv-directory (find-pyvenv-directory (buffer-file-name))))
  1228. (pyvenv-activate pyvenv-directory))
  1229. (lsp))))
  1230. :custom
  1231. (pyvenv-default-virtual-env-name "env")
  1232. (pyvenv-mode-line-indicator '(pyvenv-virtual-env-name ("[venv:" pyvenv-virtual-env-name "]")))
  1233. :preface
  1234. (defun find-pyvenv-directory (path)
  1235. "Check if a pyvenv directory exists."
  1236. (cond
  1237. ((not path) nil)
  1238. ((file-regular-p path) (find-pyvenv-directory (file-name-directory path)))
  1239. ((file-directory-p path)
  1240. (or
  1241. (seq-find
  1242. (lambda (path) (file-regular-p (expand-file-name "pyvenv.cfg" path)))
  1243. (directory-files path t))
  1244. (let ((parent (file-name-directory (directory-file-name path))))
  1245. (unless (equal parent path) (find-pyvenv-directory parent))))))))
  1246. ;; manage multiple python version
  1247. ;; needs to be installed on system
  1248. ; (use-package pyenv-mode
  1249. ; :ensure t
  1250. ; :after python
  1251. ; :hook ((python-mode . pyenv-mode)
  1252. ; (projectile-switch-project . projectile-pyenv-mode-set))
  1253. ; :custom (pyenv-mode-set "3.8.5")
  1254. ; :preface
  1255. ; (defun projectile-pyenv-mode-set ()
  1256. ; "Set pyenv version matching project name."
  1257. ; (let ((project (projectile-project-name)))
  1258. ; (if (member project (pyenv-mode-versions))
  1259. ; (pyenv-mode-set project)
  1260. ; (pyenv-mode-unset)))))
  1261. ;)
  1262. #+END_SRC
  1263. * beancount
  1264. ** Installation
  1265. :PROPERTIES:
  1266. :ID: 2c329043-b7a9-437d-a5cf-f2ad6514be91
  1267. :END:
  1268. #+BEGIN_SRC shell
  1269. sudo su
  1270. cd /opt
  1271. python3 -m venv beancount
  1272. source ./beancount/bin/activate
  1273. pip3 install wheel
  1274. pip3 install beancount
  1275. sleep 100
  1276. echo "shell running!"
  1277. deactivate
  1278. #+END_SRC
  1279. #+BEGIN_SRC emacs-lisp
  1280. (use-package beancount
  1281. :if *sys/linux*
  1282. :load-path "user-global/elisp"
  1283. ; :ensure t
  1284. :defer t
  1285. :mode
  1286. ("\\.beancount$" . beancount-mode)
  1287. :hook
  1288. (beancount-mode . my/beancount-company)
  1289. :init
  1290. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  1291. :config
  1292. (defun my/beancount-company ()
  1293. (set (make-local-variable 'company-backends)
  1294. '(company-beancount)))
  1295. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))
  1296. #+END_SRC
  1297. To support org-babel, check if it can find the symlink to ob-beancount.el
  1298. #+BEGIN_SRC shell
  1299. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  1300. beansym="$orgpath/ob-beancount.el
  1301. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  1302. if [ -h "$beansym" ]
  1303. then
  1304. echo "$beansym found"
  1305. elif [ -e "$bean" ]
  1306. then
  1307. echo "creating symlink"
  1308. ln -s "$bean" "$beansym"
  1309. else
  1310. echo "$bean not found, symlink creation aborted"
  1311. fi
  1312. #+END_SRC
  1313. Fava is strongly recommended.
  1314. #+BEGIN_SRC shell
  1315. cd /opt
  1316. python3 -m venv fava
  1317. source ./fava/bin/activate
  1318. pip3 install wheel
  1319. pip3 install fava
  1320. deactivate
  1321. #+END_SRC
  1322. Start fava with fava my_file.beancount
  1323. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  1324. Beancount-mode can start fava and open the URL right away.
  1325. * Stuff after everything else
  1326. Set garbage collector to a smaller value to let it kick in faster.
  1327. Maybe a problem on Windows?
  1328. #+begin_src emacs-lisp
  1329. ;(setq gc-cons-threshold (* 2 1000 1000))
  1330. #+end_src