diff --git a/init.org b/init.org index fc3721f..a63ef9a 100644 --- a/init.org +++ b/init.org @@ -21,11 +21,24 @@ - visual-regexp - org configuration: paths - org custom agenda + - org-ql (related to org agendas) - org configuration: everything else - beancount configuration from config.org - CONTINUE TODO from config.org at Programming - + - all-the-icons? + +* Header + :PROPERTIES: + :ID: a14d7c89-24ea-41ae-b185-944bab49aa02 + :END: +Emacs variables are dynamically scoped. That's unusual for most languages, so disable it here, too +#+begin_src emacs-lisp +;;; init.el --- -*- lexical-binding: t -*- +#+end_src * First start + :PROPERTIES: + :ID: 1c24d48e-0124-4a0b-8e78-82e4c531e818 + :END: 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 #+BEGIN_SRC emacs-lisp :tangle no @@ -81,29 +94,52 @@ #+END_SRC * Default settings + :PROPERTIES: + :ID: 3512d679-d111-4ccd-8372-6fc2acbc0374 + :END: #+BEGIN_SRC emacs-lisp -(setq *home_desktop* (string-equal (system-name) "marc") - ,*home_laptop* (string-equal (system-name) "laptop") - ,*work_local* (string-equal (system-name) "PMPCNEU08") - ,*work_remote* (string-equal (system-name) "PMTS01") - ,*linux* (string-equal system-type 'gnu/linux) - ,*windows* (string-equal system-type 'windows-nt)) +(defconst *sys/gui* + (display-graphic-p) + "Is emacs running in a gui?") + +(defconst *sys/linux* + (string-equal system-type 'gnu/linux) + "Is the system running Linux?") + +(defconst *sys/windows* + (string-equal system-type 'windows-nt) + "Is the system running Windows?") + +(defconst *home_desktop* + (string-equal (system-name) "marc") + "Is emacs running on my desktop?") + +(defconst *home_laptop* + (string-equal (system-name) "laptop") + "Is emacs running on my laptop?") + +(defconst *work_local* + (string-equal (system-name) "PMPCNEU08") + "Is emacs running at work on the local system?") + +(defconst *work_remote* + (string-equal (system-name) "PMTS01") + "Is emacs running at work on the remote system?") #+END_SRC #+BEGIN_SRC emacs-lisp (defvar MY--PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/")) (defvar MY--PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/")) -(when *linux* - (defvar MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/")) - (defvar MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/")) - (defvar MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/"))) +(when *sys/linux* + (defconst MY--PATH_ORG_FILES (expand-file-name "~/Archiv/Organisieren/")) + (defconst MY--PATH_ORG_FILES_MOBILE (expand-file-name "~/Archiv/Organisieren/mobile/"))) + (defconst MY--PATH_ORG_JOURNAl (expand-file-name "~/Archiv/Organisieren/Journal/")) (when *work_remote* - (defvar MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/") - (defvar MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error - (defvar MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error - (defvar MY--PATH_START "p:/Eigene Dateien/Notizen/")) - + (defconst MY--PATH_ORG_FILES "p:/Eigene Dateien/Notizen/") + (defconst MY--PATH_ORG_FILES_MOBILE nil) ;; hacky way to prevent "free variable" compiler error + (defconst MY--PATH_ORG_JOURNAL nil) ;; hacky way to prevent "free variable" compiler error + (defconst MY--PATH_START "p:/Eigene Dateien/Notizen/")) (setq bookmark-default-file (concat MY--PATH_USER_LOCAL "bookmarks")) (setq recentf-save-file (concat MY--PATH_USER_LOCAL "recentf")) (setq custom-file (concat MY--PATH_USER_LOCAL "custom.el")) ;; don't spam init.e with saved customization settings @@ -123,7 +159,7 @@ (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) -(if *windows* +(if *sys/windows* (prefer-coding-system 'utf-8-dos) (prefer-coding-system 'utf-8)) @@ -145,7 +181,7 @@ Some windows specific stuff #+BEGIN_SRC emacs-lisp - (when (eq system-type 'windows-nt) + (when *sys/windows* (remove-hook 'find-file-hooks 'vc-refresh-state) (progn (setq gc-cons-threshold (* 511 1024 1024) @@ -159,19 +195,25 @@ Some windows specific stuff #+END_SRC * visuals ** Font + :PROPERTIES: + :ID: dc8eb670-e6bb-4bfb-98f0-aae1860234fb + :END: #+BEGIN_SRC emacs-lisp -(when *linux* +(when *sys/linux* (set-face-font 'default "Hack-10")) (when *work_remote* (set-face-font 'default "Lucida Sans Typewriter-11")) #+END_SRC ** Themes + :PROPERTIES: + :ID: 9ccf37c0-6837-43cb-bed8-5a353799d8b1 + :END: #+BEGIN_SRC emacs-lisp (defun my/toggle-theme () (interactive) - (when *windows* + (when (or *sys/windows* *sys/linux*) (if (eq (car custom-enabled-themes) 'tango-dark) (progn (disable-theme 'tango-dark) (load-theme 'tango)) @@ -184,10 +226,13 @@ Some windows specific stuff Windows Theme: #+BEGIN_SRC emacs-lisp -(when *windows* +(when (or *sys/windows* *sys/linux*) (load-theme 'tango)) #+END_SRC ** line wrappings + :PROPERTIES: + :ID: 14ae933e-2941-4cc3-82de-38f90f91bfd3 + :END: #+BEGIN_SRC emacs-lisp (global-visual-line-mode) (diminish 'visual-line-mode) @@ -203,6 +248,9 @@ Windows Theme: ; (add-hook 'visual-line-mode-hook 'my/activate-adaptive-wrap-prefix-mode))) #+END_SRC ** line numbers + :PROPERTIES: + :ID: 7b969436-98c9-4b61-ba7a-9fb22c9781ad + :END: #+BEGIN_SRC emacs-lisp (use-package display-line-numbers :init @@ -216,6 +264,9 @@ Windows Theme: ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode) #+END_SRC ** misc + :PROPERTIES: + :ID: a2873138-16ee-4990-89a2-26eab778ea74 + :END: #+BEGIN_SRC emacs-lisp (use-package rainbow-mode :ensure t @@ -224,6 +275,9 @@ Windows Theme: emacs-lisp-mode) . rainbow-mode)) #+END_SRC * undo + :PROPERTIES: + :ID: d57621b2-5472-4c89-a520-b4133db0b9af + :END: #+BEGIN_SRC emacs-lisp (use-package undo-tree :ensure t @@ -232,6 +286,9 @@ Windows Theme: (global-undo-tree-mode 1)) #+END_SRC * imenu-list + :PROPERTIES: + :ID: 0ae27ec9-5d77-43cf-ac76-5e12cc959046 + :END: A minor mode to show imenu in a sidebar. Call imenu-list-smart-toggle. [[https://github.com/bmag/imenu-list][Source]] @@ -249,6 +306,9 @@ Windows Theme: ) #+END_SRC * which-key + :PROPERTIES: + :ID: a880f079-b3a3-4706-bf1e-5f6c680101f1 + :END: #+BEGIN_SRC emacs-lisp (use-package which-key :ensure t @@ -261,6 +321,9 @@ Windows Theme: #+END_SRC * Evil + :PROPERTIES: + :ID: 80ca70e2-a146-46db-b581-418d655dc1fc + :END: #+BEGIN_SRC emacs-lisp (use-package evil @@ -270,6 +333,9 @@ Windows Theme: (evil-mode 1)) #+END_SRC * General (key mapper) + :PROPERTIES: + :ID: a20f183f-d41a-4dff-bc37-3bc4e25c8036 + :END: #+BEGIN_SRC emacs-lisp (use-package general :ensure t) @@ -283,6 +349,9 @@ Windows Theme: "q" '(imenu-list-quit-window :which-key "quit")) #+END_SRC * ivy / counsel / swiper + :PROPERTIES: + :ID: 55c74ba9-7761-4545-8ddd-087d6ee33e4b + :END: #+BEGIN_SRC emacs-lisp ; (require 'ivy) @@ -322,49 +391,53 @@ Windows Theme: #+END_SRC * company + :PROPERTIES: + :ID: 944563b6-b04a-44f2-9b21-a6a3e200867c + :END: #+BEGIN_SRC emacs-lisp -; (require 'company) - (use-package company - :defer 1 - :bind - (:map company-active-map - ("RET" . nil) - ([return] . nil) - ("TAB" . company-complete-selection) - ([tab] . company-complete-selection) - ("" . company-complete-common)) - :config - (global-company-mode 1) - (setq-default - company-idle-delay .2 - company-minimum-prefix-length 1 - company-require-match nil - company-show-numbers t - company-tooltip-align-annotations t)) - -; (require 'company-statistics) - (use-package company-statistics - :ensure t - :after company - :init - (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el") - :config - (company-statistics-mode 1)) +(use-package company + :defer 1 + :bind + (:map company-active-map + ("RET" . nil) + ([return] . nil) + ("TAB" . company-complete-selection) + ([tab] . company-complete-selection) + ("" . company-complete-common)) + :hook + (after-init . global-company-mode) + :config + (setq company-idle-delay .2 + company-minimum-prefix-length 1 + company-require-match nil + company-show-numbers t + company-tooltip-align-annotations t)) - (use-package company-dabbrev - :ensure nil - :after company - :config - (setq-default company-dabbrev-downcase nil)) +(use-package company-statistics + :ensure t + :after company + :init + (setq company-statistics-file (concat MY--PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el") + :config + (company-statistics-mode 1)) - (use-package company-box - :ensure t - :init - (add-hook 'company-mode-hook 'company-box-mode)) +(use-package company-dabbrev + :ensure nil + :after company + :config + (setq-default company-dabbrev-downcase nil)) + +(use-package company-box + :ensure t + :init + (add-hook 'company-mode-hook 'company-box-mode)) #+END_SRC ** company backends + :PROPERTIES: + :ID: 4ce2e728-276d-41f9-9538-84e6e08afd8d + :END: #+BEGIN_SRC emacs-lisp (defun company/org-mode-hook() @@ -384,6 +457,9 @@ Windows Theme: #+END_SRC * orgmode ** org + :PROPERTIES: + :ID: b89d7639-080c-4168-8884-bd5d8965f466 + :END: #+BEGIN_SRC emacs-lisp (use-package org :ensure org-plus-contrib @@ -400,7 +476,7 @@ Windows Theme: org-agenda-files (list (concat MY--PATH_ORG_FILES "notes.org") (concat MY--PATH_ORG_FILES "projects.org") (concat MY--PATH_ORG_FILES "todo.org"))) - (when *linux* + (when *sys/linux* (setq org-agenda-files (list org-agenda-files MY--PATH_ORG_FILES_MOBILE))) (setq org-id-locations-file (concat MY--PATH_USER_LOCAL ".org-id-locations") @@ -418,33 +494,31 @@ Windows Theme: org-src-tab-acts-natively t)) #+END_SRC ** languages -#+BEGIN_SRC emacs-lisp - (org-babel-do-load-languages - 'org-babel-load-languages - '((emacs-lisp . t) - (gnuplot . t) - (js . t) - (latex . t) - (lisp . t) - (python . t) - (shell . t) - (sqlite . t) - (org . t) - (R . t) - (scheme . t) - )) - - (defun me--org-confirm-babel-evaluate (lang body) - "Do not confirm evaluation for these languages." - (not (or (string= lang "python") - (string= lang "ipython") - (string= lang "emacs-lisp") - (string= lang "R") - (string= lang "latex") - (string= lang "sqlite")))) - (setq org-confirm-babel-evaluate 'me--org-confirm-babel-evaluate) + :PROPERTIES: + :ID: ad3af718-d0db-448c-9f75-eb9e250c2862 + :END: +Set some languages and disable confirmation for evaluating code blocks C-c C-c +#+BEGIN_SRC emacs-lisp +(org-babel-do-load-languages + 'org-babel-load-languages + '((emacs-lisp . t) + (gnuplot . t) + (js . t) + (latex . t) + (lisp . t) + (python . t) + (shell . t) + (sqlite . t) + (org . t) + (R . t) + (scheme . t))) + +(setq org-confirm-babel-evaluate nil) #+END_SRC ** habits + :PROPERTIES: + :ID: fcc91d0a-d040-4910-b2cf-3221496a3842 + :END: #+BEGIN_SRC emacs-lisp (require 'org-habit) ;;TODO Lösung ohne require finden, scheint mir nicht ideal zu sein, nur um ein org-modul zu aktivieren ;; (add-to-list 'org-modules "org-habit") @@ -454,6 +528,9 @@ Windows Theme: org-habit-show-habits-only-for-today nil) #+END_SRC ** org-id + :PROPERTIES: + :ID: c4017c45-d650-410c-8bd4-bc3cf42bbbb9 + :END: Currently it causes some debugger errors "not a standard org time string", so it's disabled #+BEGIN_SRC emacs-lisp ;; (use-package org-id @@ -463,6 +540,9 @@ Currently it causes some debugger errors "not a standard org time string", so it #+END_SRC ** org-agenda + :PROPERTIES: + :ID: 03b67efb-4179-41e5-bc2e-c472b13f8be6 + :END: Custom keywords, depending on environment #+BEGIN_SRC emacs-lisp (when *work_remote* @@ -519,6 +599,9 @@ Customize the org agenda org-super-agenda ** org-caldav + :PROPERTIES: + :ID: 6bd24369-0d04-452f-85a0-99914dfb74ff + :END: Vorerst deaktiviert, Nutzen evtl. nicht vorhanden #+BEGIN_SRC emacs-lisp ;;(use-package org-caldav @@ -530,20 +613,26 @@ Vorerst deaktiviert, Nutzen evtl. nicht vorhanden ;; org-caldav-files (concat MY--PATH_ORG_FILES "tasks"))) #+END_SRC ** journal + :PROPERTIES: + :ID: a1951e18-d862-4198-9652-016e979053c8 + :END: [[https://github.com/bastibe/org-journal][Source]] #+BEGIN_SRC emacs-lisp -(when *linux* - (use-package org-journal - :ensure t - :defer t - :config - (setq org-journal-dir MY--PATH_ORG_JOURNAL - org-journal-enable-agenda-integration t))) +(use-package org-journal + :if *sys/linux* + :ensure t + :defer t + :config + (setq org-journal-dir MY--PATH_ORG_JOURNAl + org-journal-enable-agenda-integration t)) #+END_SRC * Programming ** Magit / Git + :PROPERTIES: + :ID: d3589460-317f-40f6-9056-053be9ba3217 + :END: Little crash course in magit: - magit-init to init a git project - magit-status (C-x g) to call the status window @@ -572,6 +661,9 @@ In status buffer: #+END_SRC ** LSP + :PROPERTIES: + :ID: 06ad00e0-44a6-4bfb-ba6f-b1672811e053 + :END: Configuration for the language server protocol *ACHTUNG* Dateipfad muss absolut sein, symlink im Pfad führt zumindest beim ersten Start zu Fehlern beim lsp Sobald der lsp einmal lief, kann zukünftig der symlink-Pfad genommen werden. @@ -607,7 +699,7 @@ TODO Unterverzeichnisse wurden noch nicht getestet lsp-ui-sideline-enable nil lsp-ui-sideline-ignore-duplicate t lsp-ui-sideline-show-code-actions nil) - (when (display-graphic-p) + (when *sys/gui* (setq lsp-ui-doc-use-webkit t)) ;; workaround hide mode-line of lsp-ui-imenu buffer (defadvice lsp-ui-imenu (after hide-lsp-ui-imenu-mode-line activate) @@ -624,7 +716,43 @@ TODO Unterverzeichnisse wurden noch nicht getestet company-lsp-cache-candidates nil)) #+END_SRC +** yasnippet + :PROPERTIES: + :ID: 935d89ef-645e-4e92-966f-2fe3bebb2880 + :END: +For useful snippet either install yasnippet-snippets or get them from here +[[https://github.com/AndreaCrotti/yasnippet-snippets][Github]] + +#+begin_src emacs-lisp +(use-package yasnippet + :ensure t + :diminish yas-minor-mode + :config + (setq yas-snippet-dirs (list (concat MY--PATH_USER_GLOBAL "snippets"))) + (yas-global-mode t) + (yas-reload-all) + (unbind-key "TAB" yas-minor-mode-map) + (unbind-key "" yas-minor-mode-map)) +#+end_src + +** hippie expand + :PROPERTIES: + :ID: c55245bc-813d-4816-a0ca-b4e2e793e28b + :END: +With hippie expand I am able to use yasnippet and emmet at the same time with the same key. +#+begin_src emacs-lisp +(use-package hippie-exp + :defer t + :bind + ("C-" . hippie-expand) + :config + (setq hippie-expand-try-functions-list + '(yas-hippie-try-expand emmet-expand-line))) +#+end_src ** flycheck + :PROPERTIES: + :ID: 3d8f2547-c5b3-46d0-91b0-9667f9ee5c47 + :END: #+BEGIN_SRC emacs-lisp (use-package flycheck :ensure t @@ -643,6 +771,9 @@ TODO Unterverzeichnisse wurden noch nicht getestet #+END_SRC ** Projectile + :PROPERTIES: + :ID: a90329fd-4d36-435f-8308-a2771ac4c320 + :END: Manage projects and jump quickly between its files #+BEGIN_SRC emacs-lisp (use-package projectile @@ -663,20 +794,41 @@ Manage projects and jump quickly between its files #+END_SRC ** smartparens + :PROPERTIES: + :ID: 997ec416-33e6-41ed-8c7c-75a7bc47d285 + :END: #+BEGIN_SRC emacs-lisp (use-package smartparens :ensure t :diminish smartparens-mode + :bind + (:map smartparens-mode-map + ("C-M-f" . sp-forward-sexp) + ("C-M-b" . sp-backward-sexp) + ("C-M-a" . sp-backward-down-sexp) + ("C-M-e" . sp-up-sexp) + ("C-M-w" . sp-copy-sexp) + ("M-k" . sp-kill-sexp) + ("C-M-" . sp-slice-sexp-killing-backward) + ("C-S-" . sp-slice-sexp-killing-around) + ("C-]" . sp-select-next-thing-exchange)) :config - (setq sp-show-pair-from-inside nil) + (setq sp-show-pair-from-inside nil + sp-escape-quotes-after-insert nil) (require 'smartparens-config)) #+END_SRC ** lisp + :PROPERTIES: + :ID: a2bc3e08-b203-49d3-b337-fb186a14eecb + :END: #+BEGIN_SRC emacs-lisp (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook) #+END_SRC ** web + :PROPERTIES: + :ID: c0b0b4e4-2162-429f-b80d-6e5334b1290e + :END: apt install npm sudo npm install -g vscode-html-languageserver-bin @@ -697,7 +849,34 @@ Manage projects and jump quickly between its files (add-hook 'web-mode-hook 'smartparens-mode)) #+END_SRC +Emmet offers snippets, similar to yasnippet. +Default completion is C-j +[[https://github.com/smihica/emmet-mode#usage][Github]] + +#+begin_src emacs-lisp +(use-package emmet-mode + :ensure t + :defer t + :hook + ((web-mode . emmet-mode) + (css-mode . emmet-mode)) + :config + (unbind-key "C-" emmet-mode-keymap)) +#+end_src +** YAML + :PROPERTIES: + :ID: 95413247-04d5-4e02-8431-06c162ec8f3b + :END: +#+begin_src emacs-lisp +(use-package yaml-mode + :if *sys/linux* + :ensure t + :mode ("\\.yml$" . yaml-mode)) +#+end_src ** Python + :PROPERTIES: + :ID: 8c76fcd1-c57c-48ab-8af0-aa782de6337f + :END: Systemseitig muss python-language-server installiert sein: pip3 install 'python-language-server[all]' @@ -705,7 +884,7 @@ Manage projects and jump quickly between its files https://github.com/emacs-lsp/lsp-mode#install-language-server #+BEGIN_SRC emacs-lisp -(if (string-equal system-type "gnu/linux") +(if *sys/linux* (defun my/postactivatehook () (setq lsp-python-ms-extra-paths pyvenv-virtual-env)) @@ -730,6 +909,9 @@ Manage projects and jump quickly between its files #+END_SRC * beancount ** Installation + :PROPERTIES: + :ID: 2c329043-b7a9-437d-a5cf-f2ad6514be91 + :END: #+BEGIN_SRC shell sudo su cd /opt @@ -743,21 +925,21 @@ deactivate #+END_SRC #+BEGIN_SRC emacs-lisp - (if (string-equal system-type "gnu/linux") - (use-package beancount - :load-path "user-global/elisp" -; :ensure t - :defer t - :mode - ("\\.beancount$" . beancount-mode) - :init - (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) +(use-package beancount + :if *sys/linux* + :load-path "user-global/elisp" +; :ensure t + :defer t + :mode + ("\\.beancount$" . beancount-mode) + :init + (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) ; (add-hook 'beancount-mode-hook (pyvenv-activate "/opt/beancount")) ; (setenv "PATH" ; (concat "/opt/beancount/bin:" ; (getenv "PATH"))) - :config - (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount"))) + :config + (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount")) #+END_SRC To support org-babel, check if it can find the symlink to ob-beancount.el