From 1fa1eba5ac38d654a0763282f3ddd631e873c273 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 5 Sep 2024 05:25:40 -0400 Subject: [PATCH 1/5] bump: :lang python emacs-lsp/lsp-pyright@cc6df06aeaee -> emacs-lsp/lsp-pyright@0c0d72aedd18 necaris/conda.el@60e14d1e9793 -> necaris/conda.el@ce748a53f9c7 pythonic-emacs/anaconda-mode@79fa9b4d2bda -> pythonic-emacs/anaconda-mode@f900bd7656a0 pythonic-emacs/company-anaconda@1fe526163c26 -> pythonic-emacs/company-anaconda@169252fca79a pythonic-emacs/pyenv-mode@de0d750b9c30 -> pythonic-emacs/pyenv-mode@76787ea44f63 wbolster/emacs-python-pytest@9f850e22df93 -> wbolster/emacs-python-pytest@dcdaec6fe203 - Adds basedpyright support to lsp-pyright; and will prioritize it above pyright, if found on your system. Ref: emacs-lsp/lsp-pyright#101 --- modules/lang/python/README.org | 5 +++-- modules/lang/python/config.el | 5 ++++- modules/lang/python/packages.el | 12 ++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/modules/lang/python/README.org b/modules/lang/python/README.org index 977365736..a0ef69f5b 100644 --- a/modules/lang/python/README.org +++ b/modules/lang/python/README.org @@ -10,7 +10,7 @@ This module adds [[https://www.python.org/][Python]] support to Doom Emacs. - Snippets - Run tests ([[doom-package:nose]], [[doom-package:pytest]]) - Auto-format (with ~black~, requires [[doom-module::editor format]]) -- LSP integration (=pyls=, =jedi=, =ruff=, or =pyright=) +- LSP integration (=pyls=, =jedi=, =ruff=, =pyright=, or =basedpyright=) ** Maintainers - [[doom-user:][@hlissner]] @@ -86,9 +86,10 @@ For LSP support the [[doom-module::tools lsp]] module must be enabled, along wit An alternative LSP server can be used by installing them through the [[cmd:][lsp-install-server]] command, or an external package manager. For example: +- To install *basedpyright*: ~$ pip install basedpyright~ +- To install *pyright*: ~$ pip install pyright~ or ~$ npm i -g pyright~. - To install [[https://pypi.org/project/python-language-server/][*pyls*]]: ~$ pip install python-language-server[all]~. - To install *mspyls*: ~M-x lsp-install-server RET mspyls~. -- To install *pyright*: ~$ pip install pyright~ or ~$ npm i -g pyright~. ** Formatter diff --git a/modules/lang/python/config.el b/modules/lang/python/config.el index 3fbc0345c..7d3f57281 100644 --- a/modules/lang/python/config.el +++ b/modules/lang/python/config.el @@ -353,4 +353,7 @@ :when (modulep! +lsp) :when (modulep! +pyright) :when (not (modulep! :tools lsp +eglot)) - :after lsp-mode) + :after lsp-mode + :init + (when-let ((exe (executable-find "basedpyright"))) + (setq lsp-pyright-langserver-command exe))) diff --git a/modules/lang/python/packages.el b/modules/lang/python/packages.el index 5fefb1d85..75928863e 100644 --- a/modules/lang/python/packages.el +++ b/modules/lang/python/packages.el @@ -12,26 +12,26 @@ (when (modulep! +lsp) (unless (modulep! :tools lsp +eglot) (when (modulep! +pyright) - (package! lsp-pyright :pin "cc6df06aeaee3053eb800a24193483387b7b545b")))) + (package! lsp-pyright :pin "0c0d72aedd18b16f48379b7d2f9ecb9c068713b0")))) ;; Programming environment -(package! anaconda-mode :pin "79fa9b4d2bda9f69857aeffb30c75276848a2810") +(package! anaconda-mode :pin "f900bd7656a03aa24ef3295251f266736f7756eb") (when (modulep! :completion company) - (package! company-anaconda :pin "1fe526163c265891cc20d971dc58b661ad8bcf23")) + (package! company-anaconda :pin "169252fca79a79da41ef22f2ec0eab0cf1313966")) ;; Environment management (package! pipenv :pin "3af159749824c03f59176aff7f66ddd6a5785a10") (package! pyvenv :pin "31ea715f2164dd611e7fc77b26390ef3ca93509b") (when (modulep! +pyenv) - (package! pyenv-mode :pin "de0d750b9c3057fd7cecc72e6a290902a0475afe")) + (package! pyenv-mode :pin "76787ea44f633426df402341663784db3a9e9639")) (when (modulep! +conda) - (package! conda :pin "60e14d1e9793431b91913a5688e278bd91d56224")) + (package! conda :pin "ce748a53f9c7d7a7d112632d32c848d6e5482e18")) (when (modulep! +poetry) (package! poetry :pin "1dff0d4a51ea8aff5f6ce97b154ea799902639ad")) ;; Testing frameworks (package! nose :pin "f8528297519eba911696c4e68fa88892de9a7b72") -(package! python-pytest :pin "9f850e22df93812a5b109968c549f9b3dd828ed1") +(package! python-pytest :pin "dcdaec6fe203f08bda0f5ee1931370dfd075a4ff") ;; Import managements (package! pyimport :pin "4398ce8dd64fa0f685f4bf8683a35087649346d3") From 03e5f1333ccd183939a62cf9b7999030553d67aa Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 5 Sep 2024 14:45:16 -0400 Subject: [PATCH 2/5] fix(latex): reorder viewers wrt +latex-viewers If a viewer already exists in `TeX-view-program-selection`, loading `+viewer.el` does not change its order because `add-to-list` does nothing when the item is already in the list. Close: #8046 Fix: #5275 Co-authored-by: cartoonist --- modules/lang/latex/+viewers.el | 75 ++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/modules/lang/latex/+viewers.el b/modules/lang/latex/+viewers.el index f1d439c4b..228f60e4f 100644 --- a/modules/lang/latex/+viewers.el +++ b/modules/lang/latex/+viewers.el @@ -4,47 +4,50 @@ (add-to-list 'TeX-view-program-selection '(output-pdf "preview-pane") 'append) (add-to-list 'TeX-view-program-list '("preview-pane" latex-preview-pane-mode)) -(dolist (viewer (reverse +latex-viewers)) - (pcase viewer - (`skim - (when-let - (app-path - (and (featurep :system 'macos) - (file-exists-p! (or "/Applications/Skim.app" - "~/Applications/Skim.app")))) - (add-to-list 'TeX-view-program-selection '(output-pdf "Skim")) - (add-to-list 'TeX-view-program-list - (list "Skim" (format "%s/Contents/SharedSupport/displayline -r -b %%n %%o %%b" - app-path))))) +(letf! (defun prepend-to-list (list-var value &optional append) + (set list-var (delete value (symbol-value list-var))) + (add-to-list list-var value append)) + (dolist (viewer (reverse +latex-viewers)) + (pcase viewer + (`skim + (when-let + (app-path + (and (featurep :system 'macos) + (file-exists-p! (or "/Applications/Skim.app" + "~/Applications/Skim.app")))) + (prepend-to-list 'TeX-view-program-selection '(output-pdf "Skim")) + (add-to-list 'TeX-view-program-list + (list "Skim" (format "%s/Contents/SharedSupport/displayline -r -b %%n %%o %%b" + app-path))))) - (`sumatrapdf - (when (and (featurep :system 'windows) - (executable-find "SumatraPDF")) - (add-to-list 'TeX-view-program-selection '(output-pdf "SumatraPDF")))) + (`sumatrapdf + (when (and (featurep :system 'windows) + (executable-find "SumatraPDF")) + (prepend-to-list 'TeX-view-program-selection '(output-pdf "SumatraPDF")))) - (`okular - (when (executable-find "okular") - ;; Configure Okular as viewer. Including a bug fix - ;; (https://bugs.kde.org/show_bug.cgi?id=373855). - (add-to-list 'TeX-view-program-list '("Okular" ("okular --noraise --unique file:%o" (mode-io-correlate "#src:%n%a")))) - (add-to-list 'TeX-view-program-selection '(output-pdf "Okular")))) + (`okular + (when (executable-find "okular") + ;; Configure Okular as viewer. Including a bug fix + ;; (https://bugs.kde.org/show_bug.cgi?id=373855). + (add-to-list 'TeX-view-program-list '("Okular" ("okular --noraise --unique file:%o" (mode-io-correlate "#src:%n%a")))) + (prepend-to-list 'TeX-view-program-selection '(output-pdf "Okular")))) - (`zathura - (when (executable-find "zathura") - (add-to-list 'TeX-view-program-selection '(output-pdf "Zathura")))) + (`zathura + (when (executable-find "zathura") + (prepend-to-list 'TeX-view-program-selection '(output-pdf "Zathura")))) - (`evince - (when (executable-find "evince") - (add-to-list 'TeX-view-program-selection '(output-pdf "Evince")))) + (`evince + (when (executable-find "evince") + (prepend-to-list 'TeX-view-program-selection '(output-pdf "Evince")))) - (`pdf-tools - (when (modulep! :tools pdf) - (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools")) - (when (featurep :system 'macos) - ;; PDF Tools isn't in `TeX-view-program-list-builtin' on macs. - (add-to-list 'TeX-view-program-list '("PDF Tools" TeX-pdf-tools-sync-view))) - ;; Update PDF buffers after successful LaTeX runs. - (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))))) + (`pdf-tools + (when (modulep! :tools pdf) + (prepend-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools")) + (when (featurep :system 'macos) + ;; PDF Tools isn't in `TeX-view-program-list-builtin' on macs. + (add-to-list 'TeX-view-program-list '("PDF Tools" TeX-pdf-tools-sync-view))) + ;; Update PDF buffers after successful LaTeX runs. + (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)))))) (after! latex-preview-pane From 45310f1c3ecbd8a652312bf950e6f43149afcee1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 5 Sep 2024 14:50:17 -0400 Subject: [PATCH 3/5] fix(mu4e): "no such file or directory: ~/.mbsyncrc" In c647957 "~/.mbsyncrc" was passed to mbsync quoted, preventing ~ from being expanded into $HOME. Now, I've chosen to omit the whole --config option if $XDG_CONFIG_HOME/isyncrc isn't present, since mbsync will fall back to ~/.mbsyncrc on its own. Amend: c6479574e6d3 Fix: #8048 --- modules/email/mu4e/config.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/email/mu4e/config.el b/modules/email/mu4e/config.el index 4f91e1486..d679ba26b 100644 --- a/modules/email/mu4e/config.el +++ b/modules/email/mu4e/config.el @@ -36,11 +36,11 @@ (cond ((or (modulep! +mbsync) (eq +mu4e-backend 'mbsync)) (setq mu4e-get-mail-command - (format "mbsync --all --config %S" + (concat "mbsync --all" ;; XDG support was added to isync 1.5, but this lets ;; users on older benefit from it sooner. - (or (file-exists-p! "isyncrc" (or (getenv "XDG_CONFIG_HOME") "~/.config")) - "~/.mbsyncrc")) + (when-let (file (file-exists-p! "isyncrc" (or (getenv "XDG_CONFIG_HOME") "~/.config"))) + (format " --config %S" file))) mu4e-change-filenames-when-moving t)) ((or (modulep! +offlineimap) (eq +mu4e-backend 'offlineimap)) From 6d9a7e9a8fa061634f6a3008a999f2b2d1172287 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 5 Sep 2024 15:03:39 -0400 Subject: [PATCH 4/5] fix: over-aggressive deactivation of hl-line-mode `(de?)activate-mark-hook` is triggered a little too often in too many edge cases where the user isn't interactively selecting a region. One annoying edge case has non-evil motions used on evil operators activating but not deactivating the mark (e.g. #8047). This leaves non-evil users without the nicety of hl-line auto-disabling itself when the region is active, but I'll revisit that in v3.0, when most of these package defaults are moved out to modules. Fix: #8047 --- lisp/doom-ui.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/doom-ui.el b/lisp/doom-ui.el index 4ca274457..847f5301f 100644 --- a/lisp/doom-ui.el +++ b/lisp/doom-ui.el @@ -388,13 +388,14 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original (unless hl-line-mode (setq-local doom--hl-line-mode nil)))) - (add-hook! '(evil-visual-state-entry-hook activate-mark-hook) + ;; TODO: Use (de)activate-mark-hook in the absence of evil + (add-hook! 'evil-visual-state-entry-hook (defun doom-disable-hl-line-h () (when hl-line-mode (hl-line-mode -1) (setq-local doom--hl-line-mode t)))) - (add-hook! '(evil-visual-state-exit-hook deactivate-mark-hook) + (add-hook! 'evil-visual-state-exit-hook (defun doom-enable-hl-line-maybe-h () (when doom--hl-line-mode (hl-line-mode +1))))) From fe54aa436c39f0e6f948791b8956b7b93fdf36ed Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 5 Sep 2024 15:59:14 -0400 Subject: [PATCH 5/5] fix(latex): modes not remapped to auctex modes Deduced from a comment in 21a252d (where `TeX-after-compilation-finished-functions` wasn't being triggered because the user was in latex-mode, instead of LaTeX-mode). Fix: 21a252d994d3 --- modules/lang/latex/config.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/lang/latex/config.el b/modules/lang/latex/config.el index 066be1492..ff31b6196 100644 --- a/modules/lang/latex/config.el +++ b/modules/lang/latex/config.el @@ -42,7 +42,15 @@ If no viewer is found, `latex-preview-pane-mode' is used.") ;; ;; Packages -(add-to-list 'auto-mode-alist '("\\.tex\\'" . LaTeX-mode)) +;; HACK: Doom sets `custom-dont-initialize' during the early parts of its +;; startup process. This stops tex-site's setter on `TeX-modes' from +;; activating in `tex-site', which auctex loads *very early* from its +;; autoloads file. `tex-site's existence is hacky (more a historical artifact +;; and necessary evil, given its conflicts with the built in latex modes), so +;; I fix it as a one-off problem rather than a systemic one. +(after! tex-site + (TeX-modes-set 'TeX-modes TeX-modes)) + (setq TeX-parse-self t ; parse on load TeX-auto-save t ; parse on save