mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-23 19:40:24 +10:00
Updating dotfiles.
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
;;; lang/python/autoload/python.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +python-executable-find (exe)
|
||||
"Resolve the path to the EXE executable.
|
||||
Tries to be aware of your active conda/pipenv/virtualenv environment, before
|
||||
falling back on searching your PATH."
|
||||
(if (file-name-absolute-p exe)
|
||||
(and (file-executable-p exe)
|
||||
exe)
|
||||
(let ((exe-root (format "bin/%s" exe)))
|
||||
(cond ((when python-shell-virtualenv-root
|
||||
(let ((bin (expand-file-name exe-root python-shell-virtualenv-root)))
|
||||
(if (file-exists-p bin) bin))))
|
||||
((when (require 'conda nil t)
|
||||
(let ((bin (expand-file-name (concat conda-env-current-name "/" exe-root)
|
||||
(conda-env-default-location))))
|
||||
(if (file-executable-p bin) bin))))
|
||||
((when-let (bin (projectile-locate-dominating-file default-directory "bin/python"))
|
||||
(setq-local doom-modeline-python-executable (expand-file-name "bin/python" bin))))
|
||||
((executable-find exe))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +python/open-repl ()
|
||||
"Open the Python REPL."
|
||||
@@ -25,8 +45,11 @@
|
||||
"Open an IPython REPL."
|
||||
(interactive)
|
||||
(require 'python)
|
||||
(let ((python-shell-interpreter (or (+python-executable-find "ipython") "ipython"))
|
||||
(python-shell-interpreter-args (string-join +python-ipython-repl-args " ")))
|
||||
(let ((python-shell-interpreter
|
||||
(or (+python-executable-find (car +python-ipython-command))
|
||||
"ipython"))
|
||||
(python-shell-interpreter-args
|
||||
(string-join (cdr +python-ipython-command) " ")))
|
||||
(+python/open-repl)))
|
||||
|
||||
;;;###autoload
|
||||
@@ -35,28 +58,13 @@
|
||||
(interactive)
|
||||
(require 'python)
|
||||
(add-to-list 'python-shell-completion-native-disabled-interpreters "jupyter")
|
||||
(let ((python-shell-interpreter (or (+python-executable-find "jupyter") "jupyter"))
|
||||
(python-shell-interpreter-args (format "console %s" (string-join +python-jupyter-repl-args " "))))
|
||||
(let ((python-shell-interpreter
|
||||
(or (+python-executable-find (car +python-jupyter-command))
|
||||
"jupyter"))
|
||||
(python-shell-interpreter-args
|
||||
(string-join (cdr +python-jupyter-command) " ")))
|
||||
(+python/open-repl)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +python-executable-find (exe)
|
||||
"TODO"
|
||||
(if (file-name-absolute-p exe)
|
||||
(and (file-executable-p exe)
|
||||
exe)
|
||||
(let ((exe-root (format "bin/%s" exe)))
|
||||
(cond ((when python-shell-virtualenv-root
|
||||
(let ((bin (expand-file-name exe-root python-shell-virtualenv-root)))
|
||||
(if (file-exists-p bin) bin))))
|
||||
((when (require 'conda nil t)
|
||||
(let ((bin (expand-file-name (concat conda-env-current-name "/" exe-root)
|
||||
(conda-env-default-location))))
|
||||
(if (file-executable-p bin) bin))))
|
||||
((when-let (bin (projectile-locate-dominating-file default-directory "bin/python"))
|
||||
(setq-local doom-modeline-python-executable (expand-file-name "bin/python" bin))))
|
||||
((executable-find exe))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +python/optimize-imports ()
|
||||
"organize imports"
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
;;; lang/python/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +python-ipython-repl-args '("-i" "--simple-prompt" "--no-color-info")
|
||||
"CLI arguments to initialize ipython with when `+python/open-ipython-repl' is
|
||||
called.")
|
||||
(defvar +python-ipython-command '("ipython" "-i" "--simple-prompt" "--no-color-info")
|
||||
"Command to initialize the ipython REPL for `+python/open-ipython-repl'.")
|
||||
|
||||
(defvar +python-jupyter-repl-args '("--simple-prompt")
|
||||
"CLI arguments to initialize 'jupiter console %s' with when
|
||||
`+python/open-ipython-repl' is called.")
|
||||
(defvar +python-jupyter-command '("jupyter" "console" "--simple-prompt")
|
||||
"Command to initialize the jupyter REPL for `+python/open-jupyter-repl'.")
|
||||
|
||||
(after! projectile
|
||||
(pushnew! projectile-project-root-files "setup.py" "requirements.txt"))
|
||||
@@ -31,7 +29,7 @@ called.")
|
||||
(set-repl-handler! 'python-mode #'+python/open-repl :persist t)
|
||||
(set-docsets! 'python-mode "Python 3" "NumPy" "SciPy")
|
||||
|
||||
(set-pretty-symbols! 'python-mode
|
||||
(set-ligatures! 'python-mode
|
||||
;; Functional
|
||||
:def "def"
|
||||
:lambda "lambda"
|
||||
@@ -247,7 +245,7 @@ called.")
|
||||
(pyenv-mode +1)
|
||||
(when (executable-find "pyenv")
|
||||
(add-to-list 'exec-path (expand-file-name "shims" (or (getenv "PYENV_ROOT") "~/.pyenv"))))
|
||||
(add-hook 'python-mode-hook #'+python-pyenv-mode-set-auto-h)
|
||||
(add-hook 'python-mode-local-vars-hook #'+python-pyenv-mode-set-auto-h)
|
||||
(add-hook 'doom-switch-buffer-hook #'+python-pyenv-mode-set-auto-h))
|
||||
|
||||
|
||||
@@ -311,16 +309,16 @@ called.")
|
||||
;;
|
||||
;;; LSP
|
||||
|
||||
(when! (and (featurep! +lsp)
|
||||
(not (featurep! :tools lsp +eglot)))
|
||||
(eval-when! (and (featurep! +lsp)
|
||||
(not (featurep! :tools lsp +eglot)))
|
||||
|
||||
(use-package! lsp-python-ms
|
||||
:unless (featurep! +pyright)
|
||||
:after lsp-clients
|
||||
:after lsp-mode
|
||||
:preface
|
||||
(after! python
|
||||
(setq lsp-python-ms-python-executable-cmd python-shell-interpreter)))
|
||||
|
||||
(use-package! lsp-pyright
|
||||
:when (featurep! +pyright)
|
||||
:after lsp-clients))
|
||||
:after lsp-mode))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
;; Major modes
|
||||
(package! pip-requirements :pin "216cd1690f80cc965d4ae47b8753fc185f778ff6")
|
||||
(when (featurep! +cython)
|
||||
(package! cython-mode :pin "0208bf2b71f478779491bf4a63a6b61de3d7269e")
|
||||
(package! cython-mode :pin "fcfd16c7467c31f255287a73f36cf66b32bc096c")
|
||||
(when (featurep! :checkers syntax)
|
||||
(package! flycheck-cython :pin "ecc4454d35ab5317ab66a04406f36f0c1dbc0b76")))
|
||||
|
||||
@@ -12,11 +12,8 @@
|
||||
(when (featurep! +lsp)
|
||||
(unless (featurep! :tools lsp +eglot)
|
||||
(if (featurep! +pyright)
|
||||
(package! lsp-pyright
|
||||
;; REVIEW Remove this when added to melpa
|
||||
:recipe (:host github :repo "emacs-lsp/lsp-pyright")
|
||||
:pin "3cf2e8fc652e35270b1b39aeecc990d4a97de91f")
|
||||
(package! lsp-python-ms :pin "7a502e6c09456cbe8b5f6c64883c79f5ce08e5a9"))))
|
||||
(package! lsp-pyright :pin "9603dda12afaae9c82608c7d3762f98b24b8563f")
|
||||
(package! lsp-python-ms :pin "a884a9a4eb1a3acd3d70c776aec5e968bbdc1731"))))
|
||||
|
||||
;; Programming environment
|
||||
(package! anaconda-mode :pin "73266a48fa964d44268c3f3478597e553b9843f1")
|
||||
@@ -29,7 +26,7 @@
|
||||
(when (featurep! +pyenv)
|
||||
(package! pyenv-mode :pin "d191037fe62ed8d4fee5888845da3e2c386d8e89"))
|
||||
(when (featurep! +conda)
|
||||
(package! conda :pin "9d0213020ff170b17e11b35cad40ac9a8bf30f4c"))
|
||||
(package! conda :pin "9f7eea16e9ad3eb34fe3d1cbd9d6162b8046c2f8"))
|
||||
(when (featurep! +poetry)
|
||||
(package! poetry :pin "22a76cdcba180b4689a6b45c97669e3c76cd36ed"))
|
||||
|
||||
@@ -38,7 +35,7 @@
|
||||
;; REVIEW Remove this when emacsmirror/epkgs updates its emacsattic index
|
||||
:recipe (:host github :repo "emacsattic/nose")
|
||||
:pin "f8528297519eba911696c4e68fa88892de9a7b72")
|
||||
(package! python-pytest :pin "6a3b4e560f26b5b8c9dca5699a3573f554592ac9")
|
||||
(package! python-pytest :pin "fc056faf2757c42641ed94d36a090e56eb13572f")
|
||||
|
||||
;; Import managements
|
||||
(package! pyimport :pin "a6f63cf7ed93f0c0f7c207e6595813966f8852b9")
|
||||
|
||||
Reference in New Issue
Block a user