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.

357 lines
11 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
  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 rainbow-mode
  83. :diminish
  84. :hook ((org-mode
  85. emacs-lisp-mode) . rainbow-mode))
  86. (require 'undo-tree)
  87. (use-package undo-tree
  88. :ensure t
  89. :diminish undo-tree-mode
  90. :init
  91. (global-undo-tree-mode 1))
  92. (use-package imenu-list
  93. :ensure t
  94. :config
  95. (setq imenu-list-focus-after-activation t
  96. imenu-list-auto-resize t
  97. imenu-list-position 'right)
  98. :bind
  99. (:map global-map
  100. ([f9] . imenu-list-smart-toggle))
  101. )
  102. (require 'which-key)
  103. (use-package which-key
  104. :ensure t
  105. :diminish which-key-mode
  106. :config
  107. (which-key-mode)
  108. (which-key-setup-side-window-right-bottom)
  109. (which-key-setup-minibuffer)
  110. (setq which-key-idle-delay 0.5))
  111. (use-package org
  112. :ensure org-plus-contrib
  113. :init
  114. (add-hook 'org-mode-hook 'company/org-mode-hook)
  115. :config
  116. ;; (require 'org-id)
  117. (add-to-list 'org-modules "org-id")
  118. (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")
  119. org-agenda-files (list MY--PATH_ORG_FILES
  120. MY--PATH_ORG_FILES_MOBILE)
  121. org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations")
  122. org-log-into-drawer "LOGBOOK"))
  123. (org-id-update-id-locations)
  124. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  125. ;; (add-to-list 'org-modules "org-habit")
  126. (setq org-habit-graph-column 80
  127. org-habit-preceding-days 30
  128. org-habit-following-days 7
  129. org-habit-show-habits-only-for-today nil)
  130. (use-package org-journal
  131. :ensure t
  132. :defer t
  133. :custom
  134. (org-journal-dir MY--PATH_ORG_JOURNAl)
  135. (org-journal-enable-agenda-integration t))
  136. (require 'ivy)
  137. (use-package ivy
  138. :ensure t
  139. :diminish
  140. (ivy-mode . "")
  141. :init
  142. (ivy-mode 1)
  143. :bind
  144. ("C-r" . ivy-resume) ;; overrides isearch-backwards binding
  145. :config
  146. (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer
  147. ivy-height 20 ;; height of ivy window
  148. ivy-count-format "%d/%d" ;; current and total number
  149. ivy-re-builders-alist ;; regex replaces spaces with *
  150. '((t . ivy--regex-plus))))
  151. (use-package counsel
  152. :ensure t
  153. :bind*
  154. (("M-x" . counsel-M-x)
  155. ("C-x C-f" . counsel-find-file)
  156. ("C-x C-r" . counsel-recentf)
  157. ("C-c C-f" . counsel-git)
  158. ("C-c h f" . counsel-describe-function)
  159. ("C-c h v" . counsel-describe-variable)
  160. ("M-i" . counsel-imenu)))
  161. (use-package swiper
  162. :ensure t
  163. :bind
  164. ("C-s" . swiper))
  165. (use-package ivy-hydra
  166. :ensure t)
  167. (require 'company)
  168. (use-package company
  169. :defer 1
  170. :bind
  171. (:map company-active-map
  172. ("RET" . nil)
  173. ([return] . nil)
  174. ("TAB" . company-complete-selection)
  175. ([tab] . company-complete-selection)
  176. ("<right>" . company-complete-common))
  177. :config
  178. (global-company-mode 1)
  179. (setq-default
  180. company-idle-delay .2
  181. company-minimum-prefix-length 1
  182. company-require-match nil
  183. company-show-numbers t
  184. company-tooltip-align-annotations t))
  185. (require 'company-statistics)
  186. (use-package company-statistics
  187. :ensure t
  188. :after company
  189. :init
  190. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  191. :config
  192. (company-statistics-mode 1))
  193. (use-package company-dabbrev
  194. :ensure nil
  195. :after company
  196. :config
  197. (setq-default company-dabbrev-downcase nil))
  198. (use-package company-box
  199. :ensure nil
  200. :init
  201. (add-hook 'company-mode-hook 'company-box-mode))
  202. (defun company/org-mode-hook()
  203. (set (make-local-variable 'company-backends)
  204. '(company-capf company-files))
  205. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  206. (message "company/org-mode-hook"))
  207. (defun company/elisp-mode-hook()
  208. (set (make-local-variable 'company-backends)
  209. '((company-elisp company-dabbrev) company-capf company-files))
  210. (message "company/elisp-mode-hook"))
  211. (defun company/beancount-mode-hook()
  212. (set (make-local-variable 'company-backends)
  213. '(company-beancount)))
  214. (use-package magit
  215. :ensure t
  216. :defer t
  217. :init
  218. ; set git-path in work environment
  219. (if (string-equal user-login-name "POH")
  220. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  221. )
  222. :bind (("C-x g" . magit-status))
  223. )
  224. (use-package lsp-mode
  225. :defer t
  226. :commands lsp
  227. :custom
  228. (lsp-auto-guess-root nil)
  229. (lsp-prefer-flymake nil) ; use flycheck instead
  230. (lsp-file-watch-threshold 2000)
  231. :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
  232. :hook ((python-mode
  233. js-mode
  234. js2-mode
  235. typescript-mode
  236. web-mode) . lsp))
  237. (use-package lsp-ui
  238. :after lsp-mode
  239. :diminish
  240. :commands lsp-ui-mode
  241. :config
  242. (setq lsp-ui-doc-enable t
  243. lsp-ui-doc-header t
  244. lsp-ui-doc-include-signature t
  245. lsp-ui-doc-position 'top
  246. lsp-ui-doc-border (face-foreground 'default)
  247. lsp-ui-sideline-enable nil
  248. lsp-ui-sideline-ignore-duplicate t
  249. lsp-ui-sideline-show-code-actions nil)
  250. (when (display-graphic-p)
  251. (setq lsp-ui-doc-use-webkit t))
  252. ;; workaround hide mode-line of lsp-ui-imenu buffer
  253. (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
  254. (setq mode-line-format nil)))
  255. (use-package company-lsp
  256. :requires company
  257. :defer t
  258. :ensure t
  259. :config
  260. ;;disable client-side cache because lsp server does a better job
  261. (setq company-transformers nil
  262. company-lsp-async t
  263. company-lsp-cache-candidates nil))
  264. (use-package flycheck
  265. ;;:ensure t
  266. :hook
  267. ((css-mode . flycheck-mode)
  268. (emacs-lisp-mode . flycheck-mode)
  269. (python-mode . flycheck-mode))
  270. :init
  271. (setq flycheck-emacs-lisp-load-path 'inherit)
  272. :config
  273. (setq-default
  274. flycheck-check-synta-automatically '(save mode-enabled)
  275. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  276. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  277. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  278. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  279. (use-package web-mode
  280. :ensure t
  281. :defer t
  282. :mode
  283. ("\\.phtml\\'"
  284. "\\.tpl\\.php\\'"
  285. "\\.djhtml\\'"
  286. "\\.[t]?html?\\'"))
  287. (use-package pyvenv
  288. :ensure t
  289. :config
  290. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  291. (add-hook 'pyvenv-post-activate-hooks #'my/postactivatehook))
  292. (defun my/postactivatehook ()
  293. (setq lsp-python-ms-extra-paths pyvenv-virtual-env))
  294. (use-package virtualenvwrapper
  295. :ensure t
  296. :hook (venv-postmkvirtualenv . (lambda() (shell-command "pip3 install importmagic epc")))
  297. :config
  298. (setq venv-location (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  299. (use-package lsp-python-ms
  300. :ensure t
  301. :after lsp-mode python)
  302. ; :custom (lsp-python-executable-cmd "python3"))
  303. (use-package beancount
  304. :load-path "user-local/elisp"
  305. :defer t
  306. :mode
  307. ("\\.beancount$" . beancount-mode)
  308. :init
  309. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  310. ; (add-hook 'beancount-mode-hook (pyvenv-activate "/opt/beancount"))
  311. ; (setenv "PATH"
  312. ; (concat "/opt/beancount/bin:"
  313. ; (getenv "PATH")))
  314. :config
  315. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))