diff --git a/init.el b/init.el index 5c160c0..a2afaa1 100644 --- a/init.el +++ b/init.el @@ -92,16 +92,10 @@ display-line-numbers-with 4 display-line-numbers-widen t)) ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode) -(use-package magit - :ensure t - :defer t - :init - ; set git-path in work environment - (if (string-equal user-login-name "POH") - (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe") - ) - :bind (("C-x g" . magit-status)) -) +(use-package rainbow-mode + :diminish + :hook ((org-mode + emacs-lisp-mode) . rainbow-mode)) (require 'undo-tree) (use-package undo-tree @@ -131,23 +125,6 @@ display-line-numbers-widen t)) (which-key-setup-minibuffer) (setq which-key-idle-delay 0.5)) -(add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook) - -(use-package flycheck - ;;:ensure t - :hook - ((css-mode . flycheck-mode) - (emacs-lisp-mode . flycheck-mode) - (python-mode . flycheck-mode)) - :init - (setq flycheck-emacs-lisp-load-path 'inherit) - :config - (setq-default - flycheck-check-synta-automatically '(save mode-enabled) - flycheck-disable-checkers '(emacs-lisp-checkdoc) - eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck - flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages - (use-package org :ensure org-plus-contrib :init @@ -265,51 +242,116 @@ display-line-numbers-widen t)) (set (make-local-variable 'company-backends) '(company-beancount))) -(use-package beancount - :load-path "user-local/elisp" +(use-package magit + :ensure t :defer t - :mode - ("\\.beancount$" . beancount-mode) :init - (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) - (setenv "PATH" - (concat "/opt/beancount/bin:" - (getenv "PATH"))) - :config - (setq beancount-filename-main "/home/marc/Archiv/Finanzen/Transaktionen/transactions.beancount")) + ; set git-path in work environment + (if (string-equal user-login-name "POH") + (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe") + ) + :bind (("C-x g" . magit-status)) +) (use-package lsp-mode - :ensure t - :init - (add-to-list 'exec-path "/home/marc/.local/bin") - :config - (setq lsp-prefer-flymake nil) ;; prefer lsp-ui (flycheck) over flymake - (add-hook 'python-mode-hook #'lsp)) + :defer t + :commands lsp + :custom + (lsp-auto-guess-root nil) + (lsp-prefer-flymake nil) ; use flycheck instead + (lsp-file-watch-threshold 2000) + :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer)) + :hook ((python-mode + js-mode + js2-mode + typescript-mode + web-mode) . lsp)) (use-package lsp-ui - :requires lsp-mode flycheck - :ensure t + :after lsp-mode + :diminish + :commands lsp-ui-mode :config (setq lsp-ui-doc-enable t - lsp-ui-doc-use-childframe t - lsp-ui-doc-position 'top + lsp-ui-doc-header t lsp-ui-doc-include-signature t + lsp-ui-doc-position 'top + lsp-ui-doc-border (face-foreground 'default) lsp-ui-sideline-enable nil - lsp-ui-flycheck-enable t - lsp-ui-flycheck-list-position 'right - lsp-ui-flycheck-live-reporting t - lsp-ui-peek-enable t - lsp-ui-peek-list-width 60 - lsp-ui-peek-list-height 25) - (add-hook 'lsp-mode-hook 'lsp-ui-mode)) + lsp-ui-sideline-ignore-duplicate t + lsp-ui-sideline-show-code-actions nil) + (when (display-graphic-p) + (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) + (setq mode-line-format nil))) (use-package company-lsp :requires company + :defer t :ensure t :config - (push 'company-lsp company-backends) - ;;disable client-side cache because lsp server does a better job (setq company-transformers nil company-lsp-async t company-lsp-cache-candidates nil)) + +(use-package flycheck + ;;:ensure t + :hook + ((css-mode . flycheck-mode) + (emacs-lisp-mode . flycheck-mode) + (python-mode . flycheck-mode)) + :init + (setq flycheck-emacs-lisp-load-path 'inherit) + :config + (setq-default + flycheck-check-synta-automatically '(save mode-enabled) + flycheck-disable-checkers '(emacs-lisp-checkdoc) + eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck + flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages + +(add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook) + +(use-package web-mode + :ensure t + :defer t + :mode + ("\\.phtml\\'" + "\\.tpl\\.php\\'" + "\\.djhtml\\'" + "\\.[t]?html?\\'")) + +(use-package pyvenv + :ensure t + :config + (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")) + (add-hook 'pyvenv-post-activate-hooks #'my/postactivatehook)) + +(defun my/postactivatehook () + (setq lsp-python-ms-extra-paths pyvenv-virtual-env)) + +(use-package virtualenvwrapper + :ensure t + :hook (venv-postmkvirtualenv . (lambda() (shell-command "pip3 install importmagic epc"))) + :config + (setq venv-location (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))) + +(use-package lsp-python-ms + :ensure t + :after lsp-mode python) +; :custom (lsp-python-executable-cmd "python3")) + +(use-package beancount + :load-path "user-local/elisp" + :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")) diff --git a/init.org b/init.org index 6de24bc..3f2582e 100644 --- a/init.org +++ b/init.org @@ -130,33 +130,12 @@ display-line-numbers-widen t)) ; (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode) #+END_SRC -* Git -** Magit -Little crash course in magit: -- magit-init to init a git project -- magit-status (C-x g) to call the status window - -In status buffer: -- s stage files -- u unstage files -- U unstage all files -- a apply changes to staging -- c c commit (type commit message, then C-c C-c to commit) -- b b switch to another branch -- P u git push -- F u git pull - +** misc #+BEGIN_SRC emacs-lisp -(use-package magit - :ensure t - :defer t - :init - ; set git-path in work environment - (if (string-equal user-login-name "POH") - (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe") - ) - :bind (("C-x g" . magit-status)) -) + (use-package rainbow-mode + :diminish + :hook ((org-mode + emacs-lisp-mode) . rainbow-mode)) #+END_SRC * undo #+BEGIN_SRC emacs-lisp @@ -197,29 +176,8 @@ In status buffer: (setq which-key-idle-delay 0.5)) #+END_SRC -* lisp -#+BEGIN_SRC emacs-lisp - (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook) -#+END_SRC -* flycheck -#+BEGIN_SRC emacs-lisp - (use-package flycheck - ;;:ensure t - :hook - ((css-mode . flycheck-mode) - (emacs-lisp-mode . flycheck-mode) - (python-mode . flycheck-mode)) - :init - (setq flycheck-emacs-lisp-load-path 'inherit) - :config - (setq-default - flycheck-check-synta-automatically '(save mode-enabled) - flycheck-disable-checkers '(emacs-lisp-checkdoc) - eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck - flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages -#+END_SRC - -* org +* orgmode +** org #+BEGIN_SRC emacs-lisp (use-package org :ensure org-plus-contrib @@ -235,7 +193,7 @@ In status buffer: org-log-into-drawer "LOGBOOK")) (org-id-update-id-locations) #+END_SRC -* habits +** habits #+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") @@ -244,10 +202,10 @@ In status buffer: org-habit-following-days 7 org-habit-show-habits-only-for-today nil) #+END_SRC -* *TODO* +** *TODO* org-super-agenda -* org-caldav +** org-caldav Vorerst deaktiviert, Nutzen evtl. nicht vorhanden BEGIN_SRC emacs-lisp (use-package org-caldav @@ -258,7 +216,7 @@ BEGIN_SRC emacs-lisp org-caldav-inbox (expand-file-name "~/Archiv/Organisieren/caldav-inbox") org-caldav-files (concat MY--PATH_ORG_FILES "tasks"))) END_SRC -* journal +** journal [[https://github.com/bastibe/org-journal][Source]] #+BEGIN_SRC emacs-lisp @@ -370,6 +328,156 @@ END_SRC '(company-beancount))) #+END_SRC +* Programming +** Magit / Git +Little crash course in magit: +- magit-init to init a git project +- magit-status (C-x g) to call the status window + +In status buffer: +- s stage files +- u unstage files +- U unstage all files +- a apply changes to staging +- c c commit (type commit message, then C-c C-c to commit) +- b b switch to another branch +- P u git push +- F u git pull + +#+BEGIN_SRC emacs-lisp + (use-package magit + :ensure t + :defer t + :init + ; set git-path in work environment + (if (string-equal user-login-name "POH") + (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe") + ) + :bind (("C-x g" . magit-status)) + ) +#+END_SRC + +** LSP +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. +Getestet wurde die funktionierende Datei selbst und neu erstellte Dateien im selben Pfad. +TODO Unterverzeichnisse wurden noch nicht getestet + +#+BEGIN_SRC emacs-lisp + (use-package lsp-mode + :defer t + :commands lsp + :custom + (lsp-auto-guess-root nil) + (lsp-prefer-flymake nil) ; use flycheck instead + (lsp-file-watch-threshold 2000) + :bind (:map lsp-mode-map ("C-c C-f" . lsp-format-buffer)) + :hook ((python-mode + js-mode + js2-mode + typescript-mode + web-mode) . lsp)) + + (use-package lsp-ui + :after lsp-mode + :diminish + :commands lsp-ui-mode + :config + (setq lsp-ui-doc-enable t + lsp-ui-doc-header t + lsp-ui-doc-include-signature t + lsp-ui-doc-position 'top + lsp-ui-doc-border (face-foreground 'default) + lsp-ui-sideline-enable nil + lsp-ui-sideline-ignore-duplicate t + lsp-ui-sideline-show-code-actions nil) + (when (display-graphic-p) + (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) + (setq mode-line-format nil))) + + (use-package company-lsp + :requires company + :defer t + :ensure t + :config + ;;disable client-side cache because lsp server does a better job + (setq company-transformers nil + company-lsp-async t + company-lsp-cache-candidates nil)) +#+END_SRC + +** flycheck +#+BEGIN_SRC emacs-lisp + (use-package flycheck + ;;:ensure t + :hook + ((css-mode . flycheck-mode) + (emacs-lisp-mode . flycheck-mode) + (python-mode . flycheck-mode)) + :init + (setq flycheck-emacs-lisp-load-path 'inherit) + :config + (setq-default + flycheck-check-synta-automatically '(save mode-enabled) + flycheck-disable-checkers '(emacs-lisp-checkdoc) + eldoc-idle-delay .1 ;; let eldoc echo faster than flycheck + flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages +#+END_SRC + +** lisp +#+BEGIN_SRC emacs-lisp + (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook) +#+END_SRC +** web + + apt install npm + sudo npm install -g vscode-html-languageserver-bin + evtl alternativ typescript-language-server? + + #+BEGIN_SRC emacs-lisp + (use-package web-mode + :ensure t + :defer t + :mode + ("\\.phtml\\'" + "\\.tpl\\.php\\'" + "\\.djhtml\\'" + "\\.[t]?html?\\'")) + #+END_SRC + +** Python + Systemseitig muss python-language-server installiert sein: + pip3 install 'python-language-server[all]' + + für andere language servers + https://github.com/emacs-lsp/lsp-mode#install-language-server + + #+BEGIN_SRC emacs-lisp + (use-package pyvenv + :ensure t + :config + (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")) + (add-hook 'pyvenv-post-activate-hooks #'my/postactivatehook)) + + (defun my/postactivatehook () + (setq lsp-python-ms-extra-paths pyvenv-virtual-env)) + + (use-package virtualenvwrapper + :ensure t + :hook (venv-postmkvirtualenv . (lambda() (shell-command "pip3 install importmagic epc"))) + :config + (setq venv-location (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))) + + (use-package lsp-python-ms + :ensure t + :after lsp-mode python) + ; :custom (lsp-python-executable-cmd "python3")) + + + #+END_SRC * beancount ** Installation #+BEGIN_SRC shell @@ -392,9 +500,10 @@ deactivate ("\\.beancount$" . beancount-mode) :init (add-hook 'beancount-mode-hook 'company/beancount-mode-hook) - (setenv "PATH" - (concat "/opt/beancount/bin:" - (getenv "PATH"))) +; (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")) #+END_SRC @@ -433,44 +542,3 @@ Start fava with fava my_file.beancount It is accessable on this URL: [[http://127.0.0.1:5000][Fava]] Beancount-mode can start fava and open the URL right away. -* Python -Systemseitig muss python-language-server installiert sein: -pip3 install 'python-language-server[all]' - -#+BEGIN_SRC emacs-lisp - (use-package lsp-mode - :ensure t - :init - (add-to-list 'exec-path "/home/marc/.local/bin") - :config - (setq lsp-prefer-flymake nil) ;; prefer lsp-ui (flycheck) over flymake - (add-hook 'python-mode-hook #'lsp)) - - (use-package lsp-ui - :requires lsp-mode flycheck - :ensure t - :config - (setq lsp-ui-doc-enable t - lsp-ui-doc-use-childframe t - lsp-ui-doc-position 'top - lsp-ui-doc-include-signature t - lsp-ui-sideline-enable nil - lsp-ui-flycheck-enable t - lsp-ui-flycheck-list-position 'right - lsp-ui-flycheck-live-reporting t - lsp-ui-peek-enable t - lsp-ui-peek-list-width 60 - lsp-ui-peek-list-height 25) - (add-hook 'lsp-mode-hook 'lsp-ui-mode)) - - (use-package company-lsp - :requires company - :ensure t - :config - (push 'company-lsp company-backends) - - ;;disable client-side cache because lsp server does a better job - (setq company-transformers nil - company-lsp-async t - company-lsp-cache-candidates nil)) -#+END_SRC