diff --git a/modules/lang/haskell/+dante.el b/modules/lang/haskell/+dante.el index 510bd7373..ee876fc80 100644 --- a/modules/lang/haskell/+dante.el +++ b/modules/lang/haskell/+dante.el @@ -1,6 +1,9 @@ ;;; lang/haskell/+dante.el -*- lexical-binding: t; -*- ;;;###if (featurep! +dante) +(def-package! attrap + :commands (attrap-attrap)) + (def-package! dante :init (setq dante-load-flags '(;; defaults: @@ -12,7 +15,7 @@ ;; necessary to make company completion useful: "-fdefer-typed-holes" "-fdefer-type-errors")) - :hook (haskell-mode . dante-mode)) - -(def-package! attrap - :commands (attrap-attrap)) + :hook (haskell-mode . dante-mode) + :config + (when (featurep! :feature syntax-checker) + (flycheck-add-next-checker 'haskell-dante '(warning . haskell-hlint)))) diff --git a/modules/lang/haskell/+intero.el b/modules/lang/haskell/+intero.el index 5dc501743..87d9ab65c 100644 --- a/modules/lang/haskell/+intero.el +++ b/modules/lang/haskell/+intero.el @@ -13,4 +13,6 @@ This is necessary because `intero-mode' doesn't do its own error checks." (message "Couldn't find stack. Refusing to enable intero-mode.")))) (add-hook 'haskell-mode-hook #'+haskell|init-intero) :config - (set-lookup-handlers! 'intero-mode :definition #'intero-goto-definition)) + (set-lookup-handlers! 'intero-mode :definition #'intero-goto-definition) + (when (featurep! :feature syntax-checker) + (flycheck-add-next-checker 'intero '(warning . haskell-hlint)))) diff --git a/modules/lang/haskell/config.el b/modules/lang/haskell/config.el index 581c03f84..3068602db 100644 --- a/modules/lang/haskell/config.el +++ b/modules/lang/haskell/config.el @@ -15,7 +15,6 @@ (set-lookup-handlers! 'haskell-mode :definition #'haskell-mode-jump-to-def-or-tag) (set-file-template! 'haskell-mode :trigger #'haskell-auto-insert-module-template :project t) (set-repl-handler! '(haskell-mode haskell-cabal-mode literate-haskell-mode) #'+haskell-repl-buffer) - (add-to-list 'completion-ignored-extensions ".hi") (map! :map haskell-mode-map :localleader @@ -35,11 +34,7 @@ :desc "info" :n "i" #'dante-info :desc "load" :n "l" #'haskell-process-load-or-reload :desc "eval command block >>>" :n "e" #'dante-eval-block - :desc "repair at point" :n "a" #'attrap-attrap) + :desc "repair at point" :n "a" #'attrap-attrap)) - (when (featurep! :feature syntax-checker) - (after! flycheck - (dolist (checker (delq nil (list (if (featurep! +intero) 'intero) - (if (featurep! +dante) 'haskell-dante)))) - (flycheck-add-next-checker checker '(warning . haskell-hlint)))))) + (add-to-list 'completion-ignored-extensions ".hi")) diff --git a/modules/lang/python/+conda.el b/modules/lang/python/+conda.el index 78f373b8a..50d5486f0 100644 --- a/modules/lang/python/+conda.el +++ b/modules/lang/python/+conda.el @@ -1,21 +1,33 @@ ;;; lang/python/+conda.el -*- lexical-binding: t; -*- ;;;###if (featurep! +conda) -;; This file add conda support to doom-emacs. To get started, try `M-x' -;; `+python/set-conda-home' and then `M-x' `conda-env-activate'. +;; Adds conda support to Doom Emacs. `conda-anaconda-home' should be the path to +;; your anaconda installation, and will be guessed from the following: +;; +;; + ~/.anaconda3 +;; + ~/.anaconda +;; + ~/usr/bin/anaconda3 +;; +;; If none of these work, you'll need to set `conda-anaconda-home' yourself. +;; +;; Once set, run M-x `conda-env-activate' to switch between environments OR turn +;; on `conda-env-autoactivate-mode' if you want it done automatically. (def-package! conda :when (featurep! +conda) - :after (python) - :init - (defvar +python-conda-home '("~/.anaconda3" "/usr/bin/anaconda3" "~/.anaconda") - "A list of host pattern and corresponding anaconda home.") + :after python :config - (advice-add 'anaconda-mode-bootstrap :override #'+python*anaconda-mode-bootstrap) - (conda-env-autoactivate-mode -1) - ;; (add-hook 'python-mode-hook #'conda-env-activate-for-buffer) + (unless (cl-loop for dir in (list conda-anaconda-home "/usr/bin/anaconda3" "~/.anaconda") + if (file-directory-p dir) + return (setq conda-anaconda-home dir + conda-env-home-directory dir)) + (message "Cannot find Anaconda installation")) + + ;; integration with term/eshell (conda-env-initialize-interactive-shells) - (conda-env-initialize-eshell) - ;; Version management with conda - (add-hook 'conda-postactivate-hook #'+python|add-conda-env-to-modeline) - (add-hook 'conda-postdeactivate-hook #'+python|add-conda-env-to-modeline)) + (after! eshell (conda-env-initialize-eshell)) + + (add-hook! '(conda-postactivate-hook conda-postdeactivate-hook) + #'+python|add-conda-env-to-modeline) + + (advice-add 'anaconda-mode-bootstrap :override #'+python*anaconda-mode-bootstrap-in-remote-environments)) diff --git a/modules/lang/python/autoload/conda.el b/modules/lang/python/autoload/conda.el index 62778c27d..1d0a25f96 100644 --- a/modules/lang/python/autoload/conda.el +++ b/modules/lang/python/autoload/conda.el @@ -3,25 +3,28 @@ ;;;###autoload (defun +python/set-conda-home () - "Set the CONDA HOME. -Usually it's `~/.anaconda3' on local machine, but you can also set it to a -remote directory using TRAMP syntax such as `/ssh:host:/usr/bin/anaconda3'. In -that way you can use the remote conda environment as well as the corresponding -remote python executable and packages." + "Set `conda-anaconda-home' (ANACONDA_HOME). + +Usually it's `~/.anaconda3' on local machine, but it can be set to a remote +directory using TRAMP syntax, e.g. `/ssh:host:/usr/bin/anaconda3'. This way, you +can use a remote conda environment, including the corresponding remote python +executable and packages." (interactive) - (ivy-read "Set conda home:" +python-conda-home - :history +python/set-conda-home--history - :action (lambda (cand) (setq conda-anaconda-home cand)))) + (require 'conda) + (when-let* ((home (read-directory-name "Set conda home: " "~" nil nil conda-anaconda-home))) + (setq conda-anaconda-home home) + (message "Successfully changed conda home to: %s" (abbreviate-file-name home)))) ;;;###autoload (defun +python|add-conda-env-to-modeline () - "Add conda environment string to the major mode in the modeline." - (setq mode-name - (if conda-env-current-name - (format "Py:conda:%s" conda-env-current-name) - "Python"))) + "Add conda environment string to the major mode modeline segment." + (setq mode-name + (if conda-env-current-name + (format "Py:conda:%s" conda-env-current-name) + "Python"))) + ;;;###autoload -(defun +python*anaconda-mode-bootstrap (&optional callback) +(defun +python*anaconda-mode-bootstrap-in-remote-environments (&optional callback) "Advice to set up the anaconda-mode even in remote environment. Original doc: Run `anaconda-mode' server. diff --git a/modules/lang/python/autoload.el b/modules/lang/python/autoload/python.el similarity index 65% rename from modules/lang/python/autoload.el rename to modules/lang/python/autoload/python.el index 122ef045a..c6ae3b17c 100644 --- a/modules/lang/python/autoload.el +++ b/modules/lang/python/autoload/python.el @@ -1,4 +1,4 @@ -;;; lang/python/autoload.el -*- lexical-binding: t; -*- +;;; lang/python/autoload/python.el -*- lexical-binding: t; -*- ;;;###autoload (defun +python/repl ()