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.

315 lines
10 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. (defun me/tangle-init ()
  2. "If the current buffer is 'init.org',
  3. the code blocks are tangled, and the tangled file is compiled."
  4. (when (equal (buffer-file-name)
  5. (expand-file-name (concat user-emacs-directory "init.org")))
  6. ;; avoid running hooks
  7. (let ((prog-mode-hook nil))
  8. (org-babel-tangle)
  9. (byte-compile-file (concat user-emacs-directory "init.el"))
  10. (load-file user-init-file))))
  11. (add-hook 'after-save-hook 'me/tangle-init)
  12. (require 'package)
  13. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  14. (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
  15. (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
  16. (package-initialize)
  17. (unless (package-installed-p 'use-package)
  18. (package-refresh-contents)
  19. (package-install 'use-package))
  20. (setq use-package-verbose nil)
  21. ;(eval-when-compile
  22. (require 'use-package);)
  23. (defvar MY--PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/"))
  24. (defvar MY--PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/"))
  25. (defvar MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/"))
  26. (defvar MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/"))
  27. (defvar MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/"))
  28. (setq bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks"))
  29. (setq recentf-save-file (concat MY--PATH_USER_LOCAL "recentf"))
  30. (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings
  31. (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_defs"))
  32. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  33. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  34. (setq save-abbrevs 'silently) ;; don't bother me with asking for abbrev saving
  35. (setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode
  36. (defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n
  37. (setq custom-safe-themes t) ;; don't ask me if I want to load a theme
  38. (setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence.
  39. (delete-selection-mode t) ;; delete selected region when typing
  40. (setq locale-coding-system 'utf-8)
  41. (set-terminal-coding-system 'utf-8)
  42. (set-keyboard-coding-system 'utf-8)
  43. (set-selection-coding-system 'utf-8)
  44. (if (eq system-type 'windows-nt)
  45. (prefer-coding-system 'utf-8dos)
  46. (prefer-coding-system 'utf-8))
  47. (blink-cursor-mode -1) ;; turn off blinking cursor
  48. (show-paren-mode t) ;; show other part of brackets
  49. (column-number-mode t)
  50. (setq uniquify-buffer-name-style 'forward)
  51. (setq-default indent-tabs-mode nil) ;; avoid tabs in place of multiple spaces (they look bad in tex)
  52. (setq-default indicate-empty-lines t) ;; show empty lines
  53. (setq scroll-margin 5 ;; smooth scrolling
  54. scroll-conservatively 10000
  55. scroll-preserve-screen-position 1
  56. scroll-step 1)
  57. (global-hl-line-mode t) ;; highlight current line
  58. (menu-bar-mode 0) ;; disable menu bar
  59. (tool-bar-mode 0) ;; disable tool bar
  60. (scroll-bar-mode 0) ;; disable scroll bar
  61. (set-face-font 'default "Hack Nerd Font Mono-10")
  62. (global-visual-line-mode)
  63. (diminish 'visual-line-mode)
  64. (use-package adaptive-wrap
  65. :ensure t
  66. :init
  67. (when (fboundp 'adaptive-wrap-prefix-mode)
  68. (defun my/activate-adaptive-wrap-prefix-mode ()
  69. "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  70. (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  71. (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode)))
  72. (use-package display-line-numbers
  73. :init
  74. (add-hook 'prog-mode-hook 'display-line-numbers-mode)
  75. (add-hook 'org-src-mode-hook 'display-line-numbers-mode)
  76. :config
  77. (setq-default display-line-numbers-type 'visual
  78. display-line-numbers-current-absolute t
  79. display-line-numbers-with 4
  80. display-line-numbers-widen t))
  81. ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode)
  82. (use-package magit
  83. :ensure t
  84. :defer t
  85. :init
  86. ; set git-path in work environment
  87. (if (string-equal user-login-name "POH")
  88. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  89. )
  90. :bind (("C-x g" . magit-status))
  91. )
  92. (require 'undo-tree)
  93. (use-package undo-tree
  94. :ensure t
  95. :diminish undo-tree-mode
  96. :init
  97. (global-undo-tree-mode 1))
  98. (use-package imenu-list
  99. :ensure t
  100. :config
  101. (setq imenu-list-focus-after-activation t
  102. imenu-list-auto-resize t
  103. imenu-list-position 'right)
  104. :bind
  105. (:map global-map
  106. ([f9] . imenu-list-smart-toggle))
  107. )
  108. (require 'which-key)
  109. (use-package which-key
  110. :ensure t
  111. :diminish which-key-mode
  112. :config
  113. (which-key-mode)
  114. (which-key-setup-side-window-right-bottom)
  115. (which-key-setup-minibuffer)
  116. (setq which-key-idle-delay 0.5))
  117. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  118. (use-package flycheck
  119. ;;:ensure t
  120. :hook
  121. ((css-mode . flycheck-mode)
  122. (emacs-lisp-mode . flycheck-mode)
  123. (python-mode . flycheck-mode))
  124. :init
  125. (setq flycheck-emacs-lisp-load-path 'inherit)
  126. :config
  127. (setq-default
  128. flycheck-check-synta-automatically '(save mode-enabled)
  129. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  130. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  131. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  132. (use-package org
  133. :ensure org-plus-contrib
  134. :init
  135. (add-hook 'org-mode-hook 'company/org-mode-hook)
  136. :config
  137. ;; (require 'org-id)
  138. (add-to-list 'org-modules "org-id")
  139. (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")
  140. org-agenda-files (list MY--PATH_ORG_FILES
  141. MY--PATH_ORG_FILES_MOBILE)
  142. org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations")
  143. org-log-into-drawer "LOGBOOK"))
  144. (org-id-update-id-locations)
  145. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  146. ;; (add-to-list 'org-modules "org-habit")
  147. (setq org-habit-graph-column 80
  148. org-habit-preceding-days 30
  149. org-habit-following-days 7
  150. org-habit-show-habits-only-for-today nil)
  151. (use-package org-journal
  152. :ensure t
  153. :defer t
  154. :custom
  155. (org-journal-dir MY--PATH_ORG_JOURNAl)
  156. (org-journal-enable-agenda-integration t))
  157. (require 'ivy)
  158. (use-package ivy
  159. :ensure t
  160. :diminish
  161. (ivy-mode . "")
  162. :init
  163. (ivy-mode 1)
  164. :bind
  165. ("C-r" . ivy-resume) ;; overrides isearch-backwards binding
  166. :config
  167. (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer
  168. ivy-height 20 ;; height of ivy window
  169. ivy-count-format "%d/%d" ;; current and total number
  170. ivy-re-builders-alist ;; regex replaces spaces with *
  171. '((t . ivy--regex-plus))))
  172. (use-package counsel
  173. :ensure t
  174. :bind*
  175. (("M-x" . counsel-M-x)
  176. ("C-x C-f" . counsel-find-file)
  177. ("C-x C-r" . counsel-recentf)
  178. ("C-c C-f" . counsel-git)
  179. ("C-c h f" . counsel-describe-function)
  180. ("C-c h v" . counsel-describe-variable)
  181. ("M-i" . counsel-imenu)))
  182. (use-package swiper
  183. :ensure t
  184. :bind
  185. ("C-s" . swiper))
  186. (use-package ivy-hydra
  187. :ensure t)
  188. (require 'company)
  189. (use-package company
  190. :defer 1
  191. :bind
  192. (:map company-active-map
  193. ("RET" . nil)
  194. ([return] . nil)
  195. ("TAB" . company-complete-selection)
  196. ([tab] . company-complete-selection)
  197. ("<right>" . company-complete-common))
  198. :config
  199. (global-company-mode 1)
  200. (setq-default
  201. company-idle-delay .2
  202. company-minimum-prefix-length 1
  203. company-require-match nil
  204. company-show-numbers t
  205. company-tooltip-align-annotations t))
  206. (require 'company-statistics)
  207. (use-package company-statistics
  208. :ensure t
  209. :after company
  210. :init
  211. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  212. :config
  213. (company-statistics-mode 1))
  214. (use-package company-dabbrev
  215. :ensure nil
  216. :after company
  217. :config
  218. (setq-default company-dabbrev-downcase nil))
  219. (use-package company-box
  220. :ensure nil
  221. :init
  222. (add-hook 'company-mode-hook 'company-box-mode))
  223. (defun company/org-mode-hook()
  224. (set (make-local-variable 'company-backends)
  225. '(company-capf company-files))
  226. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  227. (message "company/org-mode-hook"))
  228. (defun company/elisp-mode-hook()
  229. (set (make-local-variable 'company-backends)
  230. '((company-elisp company-dabbrev) company-capf company-files))
  231. (message "company/elisp-mode-hook"))
  232. (defun company/beancount-mode-hook()
  233. (set (make-local-variable 'company-backends)
  234. '(company-beancount)))
  235. (use-package beancount
  236. :load-path "user-local/elisp"
  237. :defer t
  238. :mode
  239. ("\\.beancount$" . beancount-mode)
  240. :init
  241. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  242. (setenv "PATH"
  243. (concat "/opt/beancount/bin:"
  244. (getenv "PATH")))
  245. :config
  246. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))
  247. (use-package lsp-mode
  248. :ensure t
  249. :init
  250. (add-to-list 'exec-path "/home/marc/.local/bin")
  251. :config
  252. (setq lsp-prefer-flymake nil) ;; prefer lsp-ui (flycheck) over flymake
  253. (add-hook 'python-mode-hook #'lsp))
  254. (use-package lsp-ui
  255. :requires lsp-mode flycheck
  256. :ensure t
  257. :config
  258. (setq lsp-ui-doc-enable t
  259. lsp-ui-doc-use-childframe t
  260. lsp-ui-doc-position 'top
  261. lsp-ui-doc-include-signature t
  262. lsp-ui-sideline-enable nil
  263. lsp-ui-flycheck-enable t
  264. lsp-ui-flycheck-list-position 'right
  265. lsp-ui-flycheck-live-reporting t
  266. lsp-ui-peek-enable t
  267. lsp-ui-peek-list-width 60
  268. lsp-ui-peek-list-height 25)
  269. (add-hook 'lsp-mode-hook 'lsp-ui-mode))
  270. (use-package company-lsp
  271. :requires company
  272. :ensure t
  273. :config
  274. (push 'company-lsp company-backends)
  275. ;;disable client-side cache because lsp server does a better job
  276. (setq company-transformers nil
  277. company-lsp-async t
  278. company-lsp-cache-candidates nil))