Add conda
This commit is contained in:
parent
6da8e5b3ab
commit
686d102ee7
3 changed files with 56 additions and 0 deletions
18
modules/lang/python/+conda.el
Normal file
18
modules/lang/python/+conda.el
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
;;; lang/python/+conda.el -*- lexical-binding: t; -*-
|
||||||
|
;;;###if (featurep! +conda)
|
||||||
|
|
||||||
|
(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.")
|
||||||
|
:config
|
||||||
|
(advice-add 'anaconda-mode-bootstrap :override #'*anaconda-mode-bootstrap)
|
||||||
|
(conda-env-autoactivate-mode -1)
|
||||||
|
;; (add-hook 'python-mode-hook #'conda-env-activate-for-buffer)
|
||||||
|
(conda-env-initialize-interactive-shells)
|
||||||
|
(conda-env-initialize-eshell)
|
||||||
|
;; Version management with conda
|
||||||
|
(add-hook 'conda-postactivate-hook #'+python|add-version-to-modeline)
|
||||||
|
(add-hook 'conda-postdeactivate-hook #'+python|add-version-to-modeline))
|
36
modules/lang/python/autoload/conda.el
Normal file
36
modules/lang/python/autoload/conda.el
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
;;; lang/python/autoload/conda.el -*- lexical-binding: t; -*-
|
||||||
|
;;;###if (featurep! +conda)
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +python/set-conda-home ()
|
||||||
|
(interactive)
|
||||||
|
(ivy-read "Set conda home:" +python-conda-home
|
||||||
|
:history +python/set-conda-home--history
|
||||||
|
:action (lambda (cand) (setq conda-anaconda-home cand))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +python|add-version-to-modeline ()
|
||||||
|
"Add version 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")))
|
||||||
|
;;;###autoload
|
||||||
|
(defun *anaconda-mode-bootstrap (&optional callback)
|
||||||
|
"Run `anaconda-mode' server.
|
||||||
|
CALLBACK function will be called when `anaconda-mode-port' will
|
||||||
|
be bound."
|
||||||
|
(setq anaconda-mode-process
|
||||||
|
(start-pythonic :process anaconda-mode-process-name
|
||||||
|
:buffer anaconda-mode-process-buffer
|
||||||
|
:cwd (anaconda-mode-server-directory)
|
||||||
|
:filter (lambda (process output) (anaconda-mode-bootstrap-filter process output))
|
||||||
|
:sentinel 'anaconda-mode-bootstrap-sentinel
|
||||||
|
:query-on-exit nil
|
||||||
|
:args (list "-c"
|
||||||
|
anaconda-mode-server-command
|
||||||
|
(if (pythonic-remote-p)
|
||||||
|
"0.0.0.0" "127.0.0.1")
|
||||||
|
(or (pythonic-file-name pythonic-environment) ""))))
|
||||||
|
(process-put anaconda-mode-process 'server-directory (anaconda-mode-server-directory)))
|
||||||
|
|
|
@ -8,3 +8,5 @@
|
||||||
(when (package! anaconda-mode)
|
(when (package! anaconda-mode)
|
||||||
(when (featurep! :completion company)
|
(when (featurep! :completion company)
|
||||||
(package! company-anaconda)))
|
(package! company-anaconda)))
|
||||||
|
(when (featurep! +conda)
|
||||||
|
(package! conda))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue