From 77aab3adfbdaa2c09db575a9cc78aa1f3a8b8bd5 Mon Sep 17 00:00:00 2001 From: Marc Date: Sun, 4 Feb 2024 07:25:03 +0100 Subject: [PATCH] a lot --- config.org | 315 +++++++++++++++++++++++------------------------------ 1 file changed, 135 insertions(+), 180 deletions(-) diff --git a/config.org b/config.org index d6d3235..3d9c6ac 100644 --- a/config.org +++ b/config.org @@ -8,18 +8,12 @@ - Paket exec-path-from-shell, um PATH aus Linux auch in emacs zu haben - Smart mode line? - Theme -- evil-collection or custom in init file? -- meow instead of evil? Testing - flymake instead of flycheck? -- eglot instead of lsp? -- project.el instead of projectile - Hydra - General - (defalias 'list-buffers 'ibuffer) ;; change default to ibuffer - ido? - treemacs (for linux) -- treemacs-evil? -- treemacs-projectile windmove? - tramp (in linux) - visual-regexp @@ -527,7 +521,7 @@ Exclude some dirs from spamming recentf (org-imenu-depth 4)) #+END_SRC -* Evil +* COMMENT Evil See also https://github.com/noctuid/evil-guide @@ -548,7 +542,7 @@ in case evil is messing something up. (evil-mode 1)) #+END_SRC -* COMMENT Meow +* Meow #+begin_src emacs-lisp (use-package meow :ensure t @@ -685,20 +679,24 @@ Completion ui, replaces company. (corfu-popupinfo-delay t) (corfu-auto t) (corfu-cycle t) - (corfu-auto-delay 0.0) + (corfu-auto-delay 0.3) (corfu-preselect-first nil) + (corfu-popupinfo-delay '(1.0 . 0.0)) ;1s for first popup, instant for subsequent popups + (corfu-popupinfo-max-width 70) + (corfu-popupinfo-max-height 20) :init (global-corfu-mode) ; (corfu-popupinfo-mode) ; causes corfu window to stay (corfu-history-mode) ;; belongs to emacs (add-to-list 'savehist-additional-variables 'corfu-history) - :general - (:states 'insert - :definer 'minor-mode - :predicate 'corfu-map - :keymaps 'completion-in-region-mode - "C-d" 'corfu-info-documentation)) + :hook + (corfu-mode . corfu-popupinfo-mode)) +; :bind +; (:map corfu-map +; ("TAB" . corfu-next) +; ("" . corfu-insert) +; ("C-TAB" . corfu-popupinfo-toggle))) ;; (general-define-key ;; :states 'insert @@ -1520,10 +1518,15 @@ If nil it defaults to `split-string-default-separators', normally :requires emacsql-sqlite3 :init :config + (add-to-list 'org-roam-capture-templates + '("ß""telephone call" plain + "*** [%<%Y-%m-%d %H:%M>] ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n" + :target (file+olp "p:/Eigene Dateien/Notizen/phone_calls.org" + ("2023" "11")))) (add-to-list 'org-roam-capture-templates - '("t" "telephone call" plain + '("x" "telephone call" plain "%?" - :target (file+head "telephone/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: CALL %<%Y-%m-%d %H:%M> ${title}\n") + :target (file+head "telephone/%<%Y%m%d%H%M>-${slug}.org" "#+title: CALL %<%Y-%m-%d %H:%M> ${title}\n") :unnarrowed t) t) (add-to-list 'org-roam-capture-templates '("p" "project" plain @@ -1535,7 +1538,7 @@ If nil it defaults to `split-string-default-separators', normally "*** TODO [#A] Sicherheitenmeldung ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" :target (file+olp "tasks.org" ("Todos" "Sicherheitenmeldungen"))) t) (add-to-list 'org-roam-capture-templates - '("m" "Monatsbericht" plain' + '("m" "Monatsbericht" plain "*** TODO [#A] Monatsbericht ${title}\n :PROPERTIES:\n :ID: %(org-id-uuid)\n:END:\n%u\n" :target (file+olp "tasks.org" ("Todos" "Monatsberichte"))) t) :custom @@ -1577,81 +1580,87 @@ In status buffer: ) :bind (("C-x g" . magit-status))) #+END_SRC -** COMMENT Eglot (can't do dap-mode) +** COMMENT Eglot (can't do dap-mode, maybe dape?) for python pyls (in env: pip install python-language-server) seems to work better than pyright (npm install -g pyright), at least pandas couldnt be resolved in pyright #+begin_src emacs-lisp (use-package eglot :ensure t :init - (setq completion-category-overrides '((eglot (styles orderless))))) - -#+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 + (setq completion-category-overrides '((eglot (styles orderless)))) + :config + (add-to-list 'eglot-server-programs '(python-mode . ("pyright-langserver" "--stdio"))) + (with-eval-after-load 'eglot + (load-library "project")) + :hook + (python-mode . eglot-ensure) + :custom + (eglot-ignored-server-capabilities '(:documentHighlightProvider)) + (eglot-autoshutdown t) + (eglot-events-buffer-size 0) + ) -#+BEGIN_SRC emacs-lisp -(setq read-process-output-max (* 1024 1024)) ;; support reading large blobs of data for LSP's sake +;; performance stuff if necessary +;(fset #'jsonrpc--log-event #'ignore) + +#+end_src +** LSP-Mode +#+begin_src emacs-lisp +(defun corfu-lsp-setup () + (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) + '(orderless))) (use-package lsp-mode - :defer t - :commands (lsp lsp-execute-code-action) + :ensure t +; :hook +; ((python-mode . lsp)) :custom - (lsp-auto-guess-root nil) - (lsp-prefer-flymake nil) ; use flycheck instead - (lsp-prefer-capf t) - (lsp-file-watch-threshold 5000) - (lsp-print-performance t) - (lsp-log-io nil) ; enable log only for debug - (lsp-enable-folding t) ; default, maybe evil-matchit instead for performance? - (lsp-diagnostics-modeline-scope :project) - (lsp-enable-file-watchers nil) - (lsp-keymap-prefix "C-c l") - (lsp-session-file (concat MY--PATH_USER_LOCAL "lsp-session")) - (lsp-eslint-library-choices-file (concat MY--PATH_USER_LOCAL "lsp-eslint-choices")) - (lsp-completion-provider :none) ;; use corfu - :bind - (:map lsp-mode-map - ("C-c C-f" . lsp-format-buffer)) + (lsp-completion-provider :none) + (lsp-enable-suggest-server-download nil) :hook - (lsp-mode . lsp-enable-which-key-integration) - (lsp-mode . lsp-diagnostics-modeline-mode) - (web-mode . #'lsp-flycheck-enable) ;; enable flycheck-lsp for web-mode locally - (lsp-completion-mode . my/lsp-mode-setup-completion) - :init - (defun my/lsp-mode-setup-completion () - "Setup orderless for lsp" - (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) - '(orderless))) ;; configure orderless - :config - (setq lsp-diagnostic-package :none)) ; disable flycheck-lsp for most modes + (lsp-completion-mode #'corfu-lsp-setup)) + +;(use-package lsp-ui +; :ensure t +; :commands lsp-ui-mode) -(use-package lsp-ui - :after lsp-mode +(use-package lsp-pyright :ensure t - :defer t - :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 t - lsp-ui-sideline-ignore-duplicate t -; lsp-ui-sideline-show-symbol t ; show symbol definition in sideline - lsp-ui-sideline-show-code-actions nil) - (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) - (setq mode-line-format nil))) -#+END_SRC + :after (python lsp-mode) + :custom + (lsp-pyright-multi-root nil) + :hook + (python-mode-hook . (lambda () + (require 'lsp-pyright) (lsp)))) +#+end_src +** flymake +python in venv: pip install pyflake (or ruff?) +TODO: if ruff active, sideline stops working +#+begin_src emacs-lisp +(setq python-flymake-command '("ruff" "--quiet" "--stdin-filename=stdin" "-")) +#+end_src +** Eldoc Box +Currently corfu-popupinfo displays eldoc in highlighted completion candidate. Maybe that's good enough. +#+begin_src emacs-lisp +(use-package eldoc-box + :ensure t) +#+end_src +** sideline +show flymake errors on the right of code window +#+begin_src emacs-lisp +(use-package sideline + :ensure t) + +(use-package sideline-flymake + :ensure t + :requires sideline + :hook + (flymake-mode . sideline-mode) + :init + (setq sideline-flymake-display-mode 'line ; 'point or 'line +; sideline-backends-left '(sideline-lsp) + sideline-backends-right '(sideline-flymake))) +#+end_src ** yasnippet For useful snippet either install yasnippet-snippets or get them from here @@ -1682,7 +1691,7 @@ With hippie expand I am able to use yasnippet and emmet at the same time with th '(yas-hippie-try-expand emmet-expand-line))) #+end_src -** flycheck +** COMMENT flycheck (now flymake) #+BEGIN_SRC emacs-lisp (use-package flycheck :ensure t @@ -1701,37 +1710,6 @@ With hippie expand I am able to use yasnippet and emmet at the same time with th flycheck-display-errors-delay .3)) ;; this way any errors will override eldoc messages #+END_SRC -** COMMENT Projectile (now project.el, if any) -Manage projects and jump quickly between its files -#+BEGIN_SRC emacs-lisp -(use-package projectile - :ensure t -; :defer 1.0 - :diminish - :bind - (("C-c p" . projectile-command-map)) - ;:preface - :init - (setq-default projectile-cache-file (concat MY--PATH_USER_LOCAL "projectile-cache") - projectile-known-projects-file (concat MY--PATH_USER_LOCAL "projectile-bookmarks")) - :config - (projectile-mode) -; (add-hook 'projectile-after-switch-project-hook #'set-workon_home) - (setq-default projectile-completion-system 'ivy - projectile-enable-caching t - projectile-mode-line '(:eval (projectile-project-name)))) - -;; requires ripgrep on system for rg functions -;(use-package counsel-projectile -; :ensure t -; :config (counsel-projectile-mode) (setq ivy-use-virtual-buffers t ;; recent files and bookmarks in ivy-switch-buffer) - -;(use-package helm-projectile -; :ensure t -; :hook -; (projectile-mode . helm-projectile)) -#+END_SRC - ** smartparens #+BEGIN_SRC emacs-lisp (use-package smartparens @@ -1771,7 +1749,7 @@ Hier runterladen: https://nodejs.org/dist/latest/ und in ein Verzeichnis entpacken. Optional: PATH erweitern unter Windows (so kann exec-path-from-shell den Pfad ermitteln): PATH=P:\path\to\node;%path% - +*** web-mode #+BEGIN_SRC emacs-lisp (use-package web-mode :ensure t @@ -1867,90 +1845,67 @@ npm install -g prettier org-babel-R-command "P:/Tools/R/bin/x64/R --slave --no-save"))) #+END_SRC -** Python - Systemseitig muss python-language-server installiert sein: -apt install python3-pip python3-setuptools python3-wheel -apt install build-essential python3-dev - pip3 install 'python-language-server[all]' +** project.el +#+begin_src emacs-lisp +(use-package project + :custom + (project-vc-extra-root-markers '(".project.el" ".project" ))) - Statt obiges: npm install -g pyright +#+end_src +** Python +Preparations: +- Install language server in *each* projects venv + source ./bin/activate + pip install pyright +- in project root: + touch .project.el + echo "((nil . (pyvenv-activate . "/path/to/project/.env")))" >> .dir-locals.el für andere language servers https://github.com/emacs-lsp/lsp-mode#install-language-server - #+BEGIN_SRC emacs-lisp -;(use-package lsp-python-ms -; :if *sys/linux* -; :ensure t -; :defer t -; :custom (lsp-python-ms-auto-install-server t)) - -(use-package lsp-pyright - :ensure t - :after lsp-mode - :defer t - :hook - (python-mode . (lambda () - (require 'lsp-pyright) - (lsp-deferred))) -; :custom -; (lsp-pyright-auto-import-completions nil) -; (lsp-pyright-typechecking-mode "off") - ) + TODO if in a project, set venv automatically + (when-let ((project (project-current))) (project-root project)) + returns project path from project.el + to recognize a project, either have git or + place a .project.el file in project root and + (setq project-vc-extra-root-markers '(".project.el" "..." )) + #+begin_src emacs-lisp (use-package python :if *sys/linux* :delight "π " :defer t :bind (("M-[" . python-nav-backward-block) - ("M-]" . python-nav-forward-block))) - + ("M-]" . python-nav-forward-block)) + :mode + (("\\.py\\'" . python-mode))) + (use-package pyvenv - :if *sys/linux* +; :if *sys/linux* :ensure t :defer t :after python - :hook ((python-mode . pyvenv-mode) - (python-mode . (lambda () - (if-let ((pyvenv-directory (find-pyvenv-directory (buffer-file-name)))) - (pyvenv-activate pyvenv-directory)) - (lsp)))) + :hook + (python-mode . pyvenv-mode) :custom - (pyvenv-default-virtual-env-name "env") - (pyvenv-mode-line-indicator '(pyvenv-virtual-env-name ("[venv:" pyvenv-virtual-env-name "]"))) - :preface - (defun find-pyvenv-directory (path) - "Check if a pyvenv directory exists." - (cond - ((not path) nil) - ((file-regular-p path) (find-pyvenv-directory (file-name-directory path))) - ((file-directory-p path) - (or - (seq-find - (lambda (path) (file-regular-p (expand-file-name "pyvenv.cfg" path))) - (directory-files path t)) - (let ((parent (file-name-directory (directory-file-name path)))) - (unless (equal parent path) (find-pyvenv-directory parent)))))))) - - ;; manage multiple python version - ;; needs to be installed on system -; (use-package pyenv-mode -; :ensure t -; :after python -; :hook ((python-mode . pyenv-mode) -; (projectile-switch-project . projectile-pyenv-mode-set)) -; :custom (pyenv-mode-set "3.8.5") -; :preface -; (defun projectile-pyenv-mode-set () -; "Set pyenv version matching project name." -; (let ((project (projectile-project-name))) -; (if (member project (pyenv-mode-versions)) -; (pyenv-mode-set project) -; (pyenv-mode-unset))))) - - ;) + (pyvenv-default-virtual-env-name ".env") + (pyvenv-mode-line-indicator '(pyvenv-virtual-env-name ("[venv:" pyvenv-virtual-env-name "]")))) - #+END_SRC +;; formatting to pep8 +;; requires pip install black +;(use-package blacken +; :ensure t) + + #+end_src + + + TODO python mode hook: + - activate venv + - activate eglot with proper ls + - activate tree-sitter? + - have some fallback if activations fail + * beancount ** Installation #+BEGIN_SRC shell :tangle no