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.

844 lines
25 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
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 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-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. * Header
  29. Emacs variables are dynamically scoped. That's unusual for most languages, so disable it here, too
  30. #+begin_src emacs-lisp
  31. ;;; init.el --- -*- lexical-binding: t -*-
  32. #+end_src
  33. * First start
  34. 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
  35. #+BEGIN_SRC emacs-lisp :tangle no
  36. (require 'org')
  37. (find-file (concat user-emacs-directory "init.org"))
  38. (org-babel-tangle)
  39. (load-file (concat user-emacs-directory "init.el"))
  40. (byte-compile-file (concat user-emacs-directory "init.el"))
  41. #+END_SRC
  42. This function updates init.el whenever changes in init.org are made. The update will be active after saving.
  43. #+BEGIN_SRC emacs-lisp
  44. (defun me/tangle-init ()
  45. "If the current buffer is 'init.org',
  46. the code blocks are tangled, and the tangled file is compiled."
  47. (when (equal (buffer-file-name)
  48. (expand-file-name (concat user-emacs-directory "init.org")))
  49. ;; avoid running hooks
  50. (let ((prog-mode-hook nil))
  51. (org-babel-tangle)
  52. (byte-compile-file (concat user-emacs-directory "init.el"))
  53. (load-file user-init-file))))
  54. (add-hook 'after-save-hook 'me/tangle-init)
  55. #+END_SRC
  56. #+BEGIN_SRC emacs-lisp
  57. (require 'package)
  58. ;; bug before emacs 26.3
  59. (when (version< emacs-version "26.3")
  60. (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
  61. (add-to-list 'package-archives '("elpa" . "https://elpa.gnu.org/packages/") t)
  62. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  63. (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
  64. (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
  65. (package-initialize)
  66. #+END_SRC
  67. #+BEGIN_SRC emacs-lisp
  68. (unless (package-installed-p 'use-package)
  69. (package-refresh-contents)
  70. (package-install 'use-package))
  71. (setq use-package-verbose nil)
  72. (eval-when-compile
  73. (require 'use-package))
  74. (require 'bind-key)
  75. (use-package diminish
  76. :ensure t)
  77. #+END_SRC
  78. * Default settings
  79. #+BEGIN_SRC emacs-lisp
  80. (defconst *sys/gui*
  81. (display-graphic-p)
  82. "Is emacs running in a gui?")
  83. (defconst *sys/linux*
  84. (string-equal system-type 'gnu/linux)
  85. "Is the system running Linux?")
  86. (defconst *sys/windows*
  87. (string-equal system-type 'windows-nt)
  88. "Is the system running Windows?")
  89. (defconst *home_desktop*
  90. (string-equal (system-name) "marc")
  91. "Is emacs running on my desktop?")
  92. (defconst *home_laptop*
  93. (string-equal (system-name) "laptop")
  94. "Is emacs running on my laptop?")
  95. (defconst *work_local*
  96. (string-equal (system-name) "PMPCNEU08")
  97. "Is emacs running at work on the local system?")
  98. (defconst *work_remote*
  99. (string-equal (system-name) "PMTS01")
  100. "Is emacs running at work on the remote system?")
  101. #+END_SRC
  102. #+BEGIN_SRC emacs-lisp
  103. (defvar MY--PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/"))
  104. (defvar MY--PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/"))
  105. (when *sys/linux*
  106. (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/"))
  107. (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/")))
  108. (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/"))
  109. (when *work_remote*
  110. (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  111. (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error
  112. (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error
  113. (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/"))
  114. (setq bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks"))
  115. (setq recentf-save-file (concat MY--PATH_USER_LOCAL "recentf"))
  116. (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings
  117. (setq abbrev-file-name (concat MY--PATH_USER_GLOBAL "abbrev_defs"))
  118. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  119. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  120. (setq save-abbrevs 'silently) ;; don't bother me with asking for abbrev saving
  121. (setq-default create-lockfiles nil) ;; disable lock files, can cause trouble in e.g. lsp-mode
  122. (defalias 'yes-or-no-p 'y-or-n-p) ;; answer with y and n
  123. (setq custom-safe-themes t) ;; don't ask me if I want to load a theme
  124. (setq sentence-end-double-space nil) ;; don't coun two spaces after a period as the end of a sentence.
  125. (delete-selection-mode t) ;; delete selected region when typing
  126. (save-place-mode 1) ;; saves position in file when it's closed
  127. (setq save-place-forget-unreadable-files nil) ;; checks if file is readable before saving position
  128. (setq locale-coding-system 'utf-8)
  129. (set-terminal-coding-system 'utf-8)
  130. (set-keyboard-coding-system 'utf-8)
  131. (set-selection-coding-system 'utf-8)
  132. (if *sys/windows*
  133. (prefer-coding-system 'utf-8-dos)
  134. (prefer-coding-system 'utf-8))
  135. (blink-cursor-mode -1) ;; turn off blinking cursor
  136. (show-paren-mode t) ;; show other part of brackets
  137. (column-number-mode t)
  138. (setq uniquify-buffer-name-style 'forward)
  139. (setq-default indent-tabs-mode nil) ;; avoid tabs in place of multiple spaces (they look bad in tex)
  140. (setq-default indicate-empty-lines t) ;; show empty lines
  141. (setq scroll-margin 5 ;; smooth scrolling
  142. scroll-conservatively 10000
  143. scroll-preserve-screen-position 1
  144. scroll-step 1)
  145. (global-hl-line-mode t) ;; highlight current line
  146. (menu-bar-mode 0) ;; disable menu bar
  147. (tool-bar-mode 0) ;; disable tool bar
  148. (scroll-bar-mode 0) ;; disable scroll bar
  149. #+END_SRC
  150. Some windows specific stuff
  151. #+BEGIN_SRC emacs-lisp
  152. (when *sys/windows*
  153. (remove-hook 'find-file-hooks 'vc-refresh-state)
  154. (progn
  155. (setq gc-cons-threshold (* 511 1024 1024)
  156. gc-cons-percentage 0.5
  157. garbage-collection-messages t)
  158. (run-with-idle-timer 5 t #'garbage-collect))
  159. (when (boundp 'w32-pipe-read-delay)
  160. (setq w32-pipe-read-delay 0))
  161. (when (boundp 'w32-get-true-file-attributes)
  162. (setq )w32-get-true-file-attributes nil))
  163. #+END_SRC
  164. * visuals
  165. ** Font
  166. #+BEGIN_SRC emacs-lisp
  167. (when *sys/linux*
  168. (set-face-font 'default "Hack-10"))
  169. (when *work_remote*
  170. (set-face-font 'default "Lucida Sans Typewriter-11"))
  171. #+END_SRC
  172. ** Themes
  173. #+BEGIN_SRC emacs-lisp
  174. (defun my/toggle-theme ()
  175. (interactive)
  176. (when (or *sys/windows* *sys/linux*)
  177. (if (eq (car custom-enabled-themes) 'tango-dark)
  178. (progn (disable-theme 'tango-dark)
  179. (load-theme 'tango))
  180. (progn
  181. (disable-theme 'tango)
  182. (load-theme 'tango-dark)))))
  183. (bind-key "C-c t" 'my/toggle-theme)
  184. #+END_SRC
  185. Windows Theme:
  186. #+BEGIN_SRC emacs-lisp
  187. (when *sys/windows*
  188. (load-theme 'tango))
  189. #+END_SRC
  190. ** line wrappings
  191. #+BEGIN_SRC emacs-lisp
  192. (global-visual-line-mode)
  193. (diminish 'visual-line-mode)
  194. (use-package adaptive-wrap
  195. :ensure t
  196. :config
  197. (add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode))
  198. ; :init
  199. ; (when (fboundp 'adaptive-wrap-prefix-mode)
  200. ; (defun my/activate-adaptive-wrap-prefix-mode ()
  201. ; "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  202. ; (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  203. ; (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode)))
  204. #+END_SRC
  205. ** line numbers
  206. #+BEGIN_SRC emacs-lisp
  207. (use-package display-line-numbers
  208. :init
  209. (add-hook 'prog-mode-hook 'display-line-numbers-mode)
  210. (add-hook 'org-src-mode-hook 'display-line-numbers-mode)
  211. :config
  212. (setq-default display-line-numbers-type 'visual
  213. display-line-numbers-current-absolute t
  214. display-line-numbers-with 4
  215. display-line-numbers-widen t))
  216. ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode)
  217. #+END_SRC
  218. ** misc
  219. #+BEGIN_SRC emacs-lisp
  220. (use-package rainbow-mode
  221. :ensure t
  222. :diminish
  223. :hook ((org-mode
  224. emacs-lisp-mode) . rainbow-mode))
  225. #+END_SRC
  226. * undo
  227. #+BEGIN_SRC emacs-lisp
  228. (use-package undo-tree
  229. :ensure t
  230. :diminish undo-tree-mode
  231. :init
  232. (global-undo-tree-mode 1))
  233. #+END_SRC
  234. * imenu-list
  235. A minor mode to show imenu in a sidebar.
  236. Call imenu-list-smart-toggle.
  237. [[https://github.com/bmag/imenu-list][Source]]
  238. #+BEGIN_SRC emacs-lisp
  239. (use-package imenu-list
  240. :ensure t
  241. :config
  242. (setq imenu-list-focus-after-activation t
  243. imenu-list-auto-resize t
  244. imenu-list-position 'right)
  245. :bind
  246. (:map global-map
  247. ([f9] . imenu-list-smart-toggle))
  248. )
  249. #+END_SRC
  250. * which-key
  251. #+BEGIN_SRC emacs-lisp
  252. (use-package which-key
  253. :ensure t
  254. :diminish which-key-mode
  255. :config
  256. (which-key-mode)
  257. (which-key-setup-side-window-right-bottom)
  258. (which-key-setup-minibuffer)
  259. (setq which-key-idle-delay 0.5))
  260. #+END_SRC
  261. * Evil
  262. #+BEGIN_SRC emacs-lisp
  263. (use-package evil
  264. :ensure t
  265. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  266. :config
  267. (evil-mode 1))
  268. #+END_SRC
  269. * General (key mapper)
  270. #+BEGIN_SRC emacs-lisp
  271. (use-package general
  272. :ensure t)
  273. (general-define-key
  274. :states 'normal
  275. :keymaps 'imenu-list-major-mode-map
  276. (kbd "RET") '(imenu-list-goto-entry :which-key "goto")
  277. (kbd "TAB") '(hs-toggle-hiding :which-key "collapse")
  278. "d" '(imenu-list-display-entry :which-key "show")
  279. "q" '(imenu-list-quit-window :which-key "quit"))
  280. #+END_SRC
  281. * ivy / counsel / swiper
  282. #+BEGIN_SRC emacs-lisp
  283. ; (require 'ivy)
  284. (use-package ivy
  285. :ensure t
  286. :diminish
  287. (ivy-mode . "")
  288. :init
  289. (ivy-mode 1)
  290. :bind
  291. ("C-r" . ivy-resume) ;; overrides isearch-backwards binding
  292. :config
  293. (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer
  294. ivy-height 20 ;; height of ivy window
  295. ivy-count-format "%d/%d" ;; current and total number
  296. ivy-re-builders-alist ;; regex replaces spaces with *
  297. '((t . ivy--regex-plus))))
  298. (use-package counsel
  299. :ensure t
  300. :bind*
  301. (("M-x" . counsel-M-x)
  302. ("C-x C-f" . counsel-find-file)
  303. ("C-x C-r" . counsel-recentf)
  304. ("C-c C-f" . counsel-git)
  305. ("C-c h f" . counsel-describe-function)
  306. ("C-c h v" . counsel-describe-variable)
  307. ("M-i" . counsel-imenu)))
  308. (use-package swiper
  309. :ensure t
  310. :bind
  311. ("C-s" . swiper))
  312. (use-package ivy-hydra
  313. :ensure t)
  314. #+END_SRC
  315. * company
  316. #+BEGIN_SRC emacs-lisp
  317. (use-package company
  318. :defer 1
  319. :bind
  320. (:map company-active-map
  321. ("RET" . nil)
  322. ([return] . nil)
  323. ("TAB" . company-complete-selection)
  324. ([tab] . company-complete-selection)
  325. ("<right>" . company-complete-common))
  326. :hook
  327. (after-init . global-company-mode)
  328. :config
  329. (setq company-idle-delay .2
  330. company-minimum-prefix-length 1
  331. company-require-match nil
  332. company-show-numbers t
  333. company-tooltip-align-annotations t))
  334. (use-package company-statistics
  335. :ensure t
  336. :after company
  337. :init
  338. (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  339. :config
  340. (company-statistics-mode 1))
  341. (use-package company-dabbrev
  342. :ensure nil
  343. :after company
  344. :config
  345. (setq-default company-dabbrev-downcase nil))
  346. (use-package company-box
  347. :ensure t
  348. :init
  349. (add-hook 'company-mode-hook 'company-box-mode))
  350. #+END_SRC
  351. ** company backends
  352. #+BEGIN_SRC emacs-lisp
  353. (defun company/org-mode-hook()
  354. (set (make-local-variable 'company-backends)
  355. '(company-capf company-files))
  356. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  357. (message "company/org-mode-hook"))
  358. (defun company/elisp-mode-hook()
  359. (set (make-local-variable 'company-backends)
  360. '((company-elisp company-dabbrev) company-capf company-files))
  361. (message "company/elisp-mode-hook"))
  362. (defun company/beancount-mode-hook()
  363. (set (make-local-variable 'company-backends)
  364. '(company-beancount)))
  365. #+END_SRC
  366. * orgmode
  367. ** org
  368. #+BEGIN_SRC emacs-lisp
  369. (use-package org
  370. :ensure org-plus-contrib
  371. :mode (("\.org$" . org-mode))
  372. :init
  373. (add-hook 'org-mode-hook 'company/org-mode-hook)
  374. (add-hook 'org-src-mode-hook 'smartparens-mode)
  375. :config
  376. (setq org-modules (quote (org-id
  377. org-habit
  378. org-tempo ;; easy templates
  379. )))
  380. (setq org-default-notes-file (concat MY--PATH_ORG_FILES "notes.org")
  381. org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org")
  382. (concat MY--PATH_ORG_FILES "projects.org")
  383. (concat MY--PATH_ORG_FILES "todo.org")))
  384. (when *sys/linux*
  385. (setq org-agenda-files (list org-agenda-files
  386. MY--PATH_ORG_FILES_MOBILE)))
  387. (setq org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations")
  388. org-log-into-drawer "LOGBOOK")
  389. ;; some display customizations
  390. (setq org-pretty-entities t
  391. org-startup-truncated t
  392. org-startup-align-all-tables t)
  393. ;; some source code blocks customizations
  394. (setq org-src-window-setup 'current-window ;; C-c ' opens in current window
  395. org-src-fontify-natively t ;; use syntax highlighting in code blocks
  396. org-src-preserve-indentation t ;; no extra indentation
  397. org-src-tab-acts-natively t))
  398. #+END_SRC
  399. ** languages
  400. Set some languages and disable confirmation for evaluating code blocks C-c C-c
  401. #+BEGIN_SRC emacs-lisp
  402. (org-babel-do-load-languages
  403. 'org-babel-load-languages
  404. '((emacs-lisp . t)
  405. (gnuplot . t)
  406. (js . t)
  407. (latex . t)
  408. (lisp . t)
  409. (python . t)
  410. (shell . t)
  411. (sqlite . t)
  412. (org . t)
  413. (R . t)
  414. (scheme . t)))
  415. (setq org-confirm-babel-evaluate nil)
  416. #+END_SRC
  417. ** habits
  418. #+BEGIN_SRC emacs-lisp
  419. (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren
  420. ;; (add-to-list 'org-modules "org-habit")
  421. (setq org-habit-graph-column 80
  422. org-habit-preceding-days 30
  423. org-habit-following-days 7
  424. org-habit-show-habits-only-for-today nil)
  425. #+END_SRC
  426. ** org-id
  427. Currently it causes some debugger errors "not a standard org time string", so it's disabled
  428. #+BEGIN_SRC emacs-lisp
  429. ;; (use-package org-id
  430. ;; :config
  431. ;; (setq org-id-link-to-org-use-id t)
  432. ;; (org-id-update-id-locations)) ;; update id file .org-id-locations on startup
  433. #+END_SRC
  434. ** org-agenda
  435. Custom keywords, depending on environment
  436. #+BEGIN_SRC emacs-lisp
  437. (when *work_remote*
  438. (setq org-todo-keywords
  439. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE"))))
  440. #+END_SRC
  441. Add some key bindings
  442. #+BEGIN_SRC emacs-lisp
  443. (bind-key "C-c l" 'org-store-link)
  444. (bind-key "C-c c" 'org-capture)
  445. (bind-key "C-c a" 'org-agenda)
  446. #+END_SRC
  447. Sort agenda by deadline and priority
  448. #+BEGIN_SRC emacs-lisp
  449. (setq org-agenda-sorting-strategy
  450. (quote
  451. ((agenda deadline-up priority-down)
  452. (todo priority-down category-keep)
  453. (tags priority-down category-keep)
  454. (search category-keep))))
  455. #+END_SRC
  456. Customize the org agenda
  457. #+BEGIN_SRC emacs-lisp
  458. (defun me--org-skip-subtree-if-priority (priority)
  459. "Skip an agenda subtree if it has a priority of PRIORITY.
  460. PRIORITY may be one of the characters ?A, ?B, or ?C."
  461. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  462. (pri-value (* 1000 (- org-lowest-priority priority)))
  463. (pri-current (org-get-priority (thing-at-point 'line t))))
  464. (if (= pri-value pri-current)
  465. subtree-end
  466. nil)))
  467. (setq org-agenda-custom-commands
  468. '(("c" "Simple agenda view"
  469. ((tags "PRIORITY=\"A\""
  470. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  471. (org-agenda-overriding-header "Hohe Priorität:")))
  472. (agenda ""
  473. ((org-agenda-span 7)
  474. (org-agenda-start-on-weekday nil)
  475. (org-agenda-overriding-header "Nächste 7 Tage:")))
  476. (alltodo ""
  477. ((org-agenda-skip-function '(or (me--org-skip-subtree-if-priority ?A)
  478. (org-agenda-skip-if nil '(scheduled deadline))))
  479. (org-agenda-overriding-header "Sonstige Aufgaben:")))))))
  480. #+END_SRC
  481. ** *TODO*
  482. org-super-agenda
  483. ** org-caldav
  484. Vorerst deaktiviert, Nutzen evtl. nicht vorhanden
  485. #+BEGIN_SRC emacs-lisp
  486. ;;(use-package org-caldav
  487. ;; :ensure t
  488. ;; :config
  489. ;; (setq org-caldav-url "https://nextcloud.cloudsphere.duckdns.org/remote.php/dav/calendars/marc"
  490. ;; org-caldav-calendar-id "orgmode"
  491. ;; org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox")
  492. ;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks")))
  493. #+END_SRC
  494. ** journal
  495. [[https://github.com/bastibe/org-journal][Source]]
  496. #+BEGIN_SRC emacs-lisp
  497. (use-package org-journal
  498. :if *sys/linux*
  499. :ensure t
  500. :defer t
  501. :config
  502. (setq org-journal-dir MY--PATH_ORG_JOURNAl
  503. org-journal-enable-agenda-integration t))
  504. #+END_SRC
  505. * Programming
  506. ** Magit / Git
  507. Little crash course in magit:
  508. - magit-init to init a git project
  509. - magit-status (C-x g) to call the status window
  510. In status buffer:
  511. - s stage files
  512. - u unstage files
  513. - U unstage all files
  514. - a apply changes to staging
  515. - c c commit (type commit message, then C-c C-c to commit)
  516. - b b switch to another branch
  517. - P u git push
  518. - F u git pull
  519. #+BEGIN_SRC emacs-lisp
  520. (use-package magit
  521. :ensure t
  522. :defer t
  523. :init
  524. ; set git-path in work environment
  525. (if (string-equal user-login-name "POH")
  526. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  527. )
  528. :bind (("C-x g" . magit-status))
  529. )
  530. #+END_SRC
  531. ** LSP
  532. Configuration for the language server protocol
  533. *ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp
  534. Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden.
  535. Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad.
  536. TODO Unterverzeichnisse wurden noch nicht getestet
  537. #+BEGIN_SRC emacs-lisp
  538. (use-package lsp-mode
  539. :defer t
  540. :commands lsp
  541. :custom
  542. (lsp-auto-guess-root nil)
  543. (lsp-prefer-flymake nil) ; use flycheck instead
  544. (lsp-file-watch-threshold 2000)
  545. :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer))
  546. :hook ((python-mode
  547. js-mode
  548. js2-mode
  549. typescript-mode
  550. web-mode) . lsp))
  551. (use-package lsp-ui
  552. :after lsp-mode
  553. :ensure t
  554. :diminish
  555. :commands lsp-ui-mode
  556. :config
  557. (setq lsp-ui-doc-enable t
  558. lsp-ui-doc-header t
  559. lsp-ui-doc-include-signature t
  560. lsp-ui-doc-position 'top
  561. lsp-ui-doc-border (face-foreground 'default)
  562. lsp-ui-sideline-enable nil
  563. lsp-ui-sideline-ignore-duplicate t
  564. lsp-ui-sideline-show-code-actions nil)
  565. (when (display-graphic-p)
  566. (setq lsp-ui-doc-use-webkit t))
  567. ;; workaround hide mode-line of lsp-ui-imenu buffer
  568. (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate)
  569. (setq mode-line-format nil)))
  570. (use-package company-lsp
  571. :requires company
  572. :defer t
  573. :ensure t
  574. :config
  575. ;;disable client-side cache because lsp server does a better job
  576. (setq company-transformers nil
  577. company-lsp-async t
  578. company-lsp-cache-candidates nil))
  579. #+END_SRC
  580. ** yasnippet
  581. #+begin_src emacs-lisp
  582. (use-package yasnippet
  583. :ensure t
  584. :diminish yas-minor-mode
  585. :config
  586. (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets")))
  587. (yas-global-mode t)
  588. (yas-reload-all))
  589. #+end_src
  590. ** flycheck
  591. #+BEGIN_SRC emacs-lisp
  592. (use-package flycheck
  593. :ensure t
  594. :hook
  595. ((css-mode . flycheck-mode)
  596. (emacs-lisp-mode . flycheck-mode)
  597. (python-mode . flycheck-mode))
  598. :init
  599. (setq flycheck-emacs-lisp-load-path 'inherit)
  600. :config
  601. (setq-default
  602. flycheck-check-synta-automatically '(save mode-enabled)
  603. flycheck-disable-checkers '(emacs-lisp-checkdoc)
  604. eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck
  605. flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages
  606. #+END_SRC
  607. ** Projectile
  608. Manage projects and jump quickly between its files
  609. #+BEGIN_SRC emacs-lisp
  610. (use-package projectile
  611. :ensure t
  612. :defer t
  613. :bind
  614. (("C-c p p" . projectile-switch-project)
  615. ("C-c p c" . projectile-command-map)
  616. ("C-c p s s" . projectile-ag))
  617. :init
  618. (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL ".projectile-cache")
  619. projectile-known-projects-file (concat MY--PATH_USER_LOCAL ".projectile-bookmarks"))
  620. :config
  621. (projectile-mode t)
  622. (setq-default projectile-completion-system 'ivy
  623. projectile-enable-caching t
  624. projectile-mode-line '(:eval (projectile-project-name))))
  625. #+END_SRC
  626. ** smartparens
  627. #+BEGIN_SRC emacs-lisp
  628. (use-package smartparens
  629. :ensure t
  630. :diminish smartparens-mode
  631. :bind
  632. (:map smartparens-mode-map
  633. ("C-M-f" . sp-forward-sexp)
  634. ("C-M-b" . sp-backward-sexp)
  635. ("C-M-a" . sp-backward-down-sexp)
  636. ("C-M-e" . sp-up-sexp)
  637. ("C-M-w" . sp-copy-sexp)
  638. ("M-k" . sp-kill-sexp)
  639. ("C-M-<backspace>" . sp-slice-sexp-killing-backward)
  640. ("C-S-<backspace>" . sp-slice-sexp-killing-around)
  641. ("C-]" . sp-select-next-thing-exchange))
  642. :config
  643. (setq sp-show-pair-from-inside nil
  644. sp-escape-quotes-after-insert nil)
  645. (require 'smartparens-config))
  646. #+END_SRC
  647. ** lisp
  648. #+BEGIN_SRC emacs-lisp
  649. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  650. #+END_SRC
  651. ** web
  652. apt install npm
  653. sudo npm install -g vscode-html-languageserver-bin
  654. evtl alternativ typescript-language-server?
  655. #+BEGIN_SRC emacs-lisp
  656. (use-package web-mode
  657. :ensure t
  658. :defer t
  659. :mode
  660. ("\\.phtml\\'"
  661. "\\.tpl\\.php\\'"
  662. "\\.djhtml\\'"
  663. "\\.[t]?html?\\'")
  664. :config
  665. (setq web-mode-enable-auto-closing t
  666. web-mode-enable-auto-pairing t)
  667. (add-hook 'web-mode-hook 'smartparens-mode))
  668. #+END_SRC
  669. ** YAML
  670. #+begin_src emacs-lisp
  671. (use-package yaml-mode
  672. :if *sys/linux*
  673. :ensure t
  674. :mode ("\\.yml$" . yaml-mode))
  675. #+end_src
  676. ** Python
  677. Systemseitig muss python-language-server installiert sein:
  678. pip3 install 'python-language-server[all]'
  679. für andere language servers
  680. https://github.com/emacs-lsp/lsp-mode#install-language-server
  681. #+BEGIN_SRC emacs-lisp
  682. (if *sys/linux*
  683. (defun my/postactivatehook ()
  684. (setq lsp-python-ms-extra-paths pyvenv-virtual-env))
  685. (use-package pyvenv
  686. :ensure t
  687. :config
  688. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  689. (add-hook 'pyvenv-post-activate-hooks 'my/postactivatehook))
  690. (use-package virtualenvwrapper
  691. :ensure t
  692. :hook (venv-postmkvirtualenv . (lambda() (shell-command "pip3 install importmagic epc")))
  693. :config
  694. (setq venv-location (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  695. (use-package lsp-python-ms
  696. :ensure t
  697. :after lsp-mode python))
  698. ; :custom (lsp-python-executable-cmd "python3"))
  699. #+END_SRC
  700. * beancount
  701. ** Installation
  702. #+BEGIN_SRC shell
  703. sudo su
  704. cd /opt
  705. python3 -m venv beancount
  706. source ./beancount/bin/activate
  707. pip3 install wheel
  708. pip3 install beancount
  709. sleep 100
  710. echo "shell running!"
  711. deactivate
  712. #+END_SRC
  713. #+BEGIN_SRC emacs-lisp
  714. (use-package beancount
  715. :if *sys/linux*
  716. :load-path "user-global/elisp"
  717. ; :ensure t
  718. :defer t
  719. :mode
  720. ("\\.beancount$" . beancount-mode)
  721. :init
  722. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  723. ; (add-hook 'beancount-mode-hook (pyvenv-activate "/opt/beancount"))
  724. ; (setenv "PATH"
  725. ; (concat "/opt/beancount/bin:"
  726. ; (getenv "PATH")))
  727. :config
  728. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))
  729. #+END_SRC
  730. To support org-babel, check if it can find the symlink to ob-beancount.el
  731. #+BEGIN_SRC shell
  732. orgpath=`find /home/marc/.emacs.d/elpa/ -type d -name "org-plus*" -print`
  733. beansym="$orgpath/ob-beancount.el
  734. bean="/home/marc/Archiv/Programmierprojekte/Lisp/beancount-mode/ob-beancount.el"
  735. if [ -h "$beansym" ]
  736. then
  737. echo "$beansym found"
  738. elif [ -e "$bean" ]
  739. then
  740. echo "creating symlink"
  741. ln -s "$bean" "$beansym"
  742. else
  743. echo "$bean not found, symlink creation aborted"
  744. fi
  745. #+END_SRC
  746. Fava is strongly recommended.
  747. #+BEGIN_SRC shell
  748. cd /opt
  749. python3 -m venv fava
  750. source ./fava/bin/activate
  751. pip3 install wheel
  752. pip3 install fava
  753. deactivate
  754. #+END_SRC
  755. Start fava with fava my_file.beancount
  756. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  757. Beancount-mode can start fava and open the URL right away.