2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/python/config.el -*- lexical-binding: t; -*-
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2020-08-25 21:22:56 -04:00
|
|
|
(defvar +python-ipython-command '("ipython" "-i" "--simple-prompt" "--no-color-info")
|
|
|
|
"Command to initialize the ipython REPL for `+python/open-ipython-repl'.")
|
2018-12-05 14:31:02 -05:00
|
|
|
|
2020-08-25 21:22:56 -04:00
|
|
|
(defvar +python-jupyter-command '("jupyter" "console" "--simple-prompt")
|
|
|
|
"Command to initialize the jupyter REPL for `+python/open-jupyter-repl'.")
|
2018-12-05 14:31:02 -05:00
|
|
|
|
2019-10-19 15:25:29 -04:00
|
|
|
(after! projectile
|
2022-02-23 15:05:00 +01:00
|
|
|
(pushnew! projectile-project-root-files "pyproject.toml" "requirements.txt" "setup.py"))
|
2019-10-19 15:25:29 -04:00
|
|
|
|
2017-09-26 01:02:42 +02:00
|
|
|
|
|
|
|
;;
|
2020-07-27 01:20:12 -04:00
|
|
|
;;; Packages
|
2017-09-26 01:02:42 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! python
|
2020-06-01 15:54:12 +03:00
|
|
|
:mode ("[./]flake8\\'" . conf-mode)
|
|
|
|
:mode ("/Pipfile\\'" . conf-mode)
|
2015-06-15 09:06:10 +02:00
|
|
|
:init
|
2017-02-19 18:57:16 -05:00
|
|
|
(setq python-environment-directory doom-cache-dir
|
2018-10-06 00:25:50 -04:00
|
|
|
python-indent-guess-indent-offset-verbose nil)
|
2019-11-17 16:45:50 -05:00
|
|
|
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! +lsp)
|
2022-03-24 02:19:52 +01:00
|
|
|
(add-hook 'python-mode-local-vars-hook #'lsp! 'append)
|
2020-05-01 11:01:11 +02:00
|
|
|
;; Use "mspyls" in eglot if in PATH
|
|
|
|
(when (executable-find "Microsoft.Python.LanguageServer")
|
|
|
|
(set-eglot-client! 'python-mode '("Microsoft.Python.LanguageServer"))))
|
2022-07-25 17:34:44 +02:00
|
|
|
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! +tree-sitter)
|
2022-07-25 17:34:44 +02:00
|
|
|
(add-hook 'python-mode-local-vars-hook #'tree-sitter! 'append))
|
2016-05-01 01:10:30 -04:00
|
|
|
:config
|
2021-12-18 10:39:14 -05:00
|
|
|
(set-repl-handler! 'python-mode #'+python/open-repl
|
|
|
|
:persist t
|
|
|
|
:send-region #'python-shell-send-region
|
|
|
|
:send-buffer #'python-shell-send-buffer)
|
2021-03-19 20:41:20 +07:00
|
|
|
(set-docsets! '(python-mode inferior-python-mode) "Python 3" "NumPy" "SciPy" "Pandas")
|
2017-03-04 20:51:35 -05:00
|
|
|
|
2020-08-12 18:52:14 -04:00
|
|
|
(set-ligatures! 'python-mode
|
2018-06-16 19:32:25 +02:00
|
|
|
;; Functional
|
|
|
|
:def "def"
|
|
|
|
:lambda "lambda"
|
|
|
|
;; Types
|
|
|
|
:null "None"
|
|
|
|
:true "True" :false "False"
|
|
|
|
:int "int" :str "str"
|
|
|
|
:float "float"
|
|
|
|
:bool "bool"
|
|
|
|
:tuple "tuple"
|
|
|
|
;; Flow
|
|
|
|
:not "not"
|
|
|
|
:in "in" :not-in "not in"
|
|
|
|
:and "and" :or "or"
|
|
|
|
:for "for"
|
|
|
|
:return "return" :yield "yield")
|
|
|
|
|
2019-07-22 00:38:23 +02:00
|
|
|
;; Stop the spam!
|
|
|
|
(setq python-indent-guess-indent-offset-verbose nil)
|
|
|
|
|
2019-07-22 00:38:33 +02:00
|
|
|
;; Default to Python 3. Prefer the versioned Python binaries since some
|
2022-08-10 23:06:45 +02:00
|
|
|
;; systems link the unversioned one to Python 2.
|
2019-07-22 00:38:33 +02:00
|
|
|
(when (and (executable-find "python3")
|
|
|
|
(string= python-shell-interpreter "python"))
|
|
|
|
(setq python-shell-interpreter "python3"))
|
|
|
|
|
2019-07-28 02:16:58 +02:00
|
|
|
(add-hook! 'python-mode-hook
|
2019-07-22 00:37:34 +02:00
|
|
|
(defun +python-use-correct-flycheck-executables-h ()
|
|
|
|
"Use the correct Python executables for Flycheck."
|
|
|
|
(let ((executable python-shell-interpreter))
|
|
|
|
(save-excursion
|
2019-08-06 14:50:42 -04:00
|
|
|
(goto-char (point-min))
|
2019-07-22 00:37:34 +02:00
|
|
|
(save-match-data
|
|
|
|
(when (or (looking-at "#!/usr/bin/env \\(python[^ \n]+\\)")
|
|
|
|
(looking-at "#!\\([^ \n]+/python[^ \n]+\\)"))
|
|
|
|
(setq executable (substring-no-properties (match-string 1))))))
|
|
|
|
;; Try to compile using the appropriate version of Python for
|
|
|
|
;; the file.
|
|
|
|
(setq-local flycheck-python-pycompile-executable executable)
|
|
|
|
;; We might be running inside a virtualenv, in which case the
|
|
|
|
;; modules won't be available. But calling the executables
|
|
|
|
;; directly will work.
|
|
|
|
(setq-local flycheck-python-pylint-executable "pylint")
|
|
|
|
(setq-local flycheck-python-flake8-executable "flake8"))))
|
|
|
|
|
2019-03-07 00:11:45 -05:00
|
|
|
;; Affects pyenv and conda
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! :ui modeline)
|
2019-10-07 15:34:12 -04:00
|
|
|
(advice-add #'pythonic-activate :after-while #'+modeline-update-env-in-all-windows-h)
|
|
|
|
(advice-add #'pythonic-deactivate :after #'+modeline-clear-env-in-all-windows-h))
|
2019-03-04 20:48:52 -05:00
|
|
|
|
2022-09-12 12:40:42 +02:00
|
|
|
(setq-hook! 'python-mode-hook tab-width python-indent-offset))
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! anaconda-mode
|
2019-11-17 16:45:50 -05:00
|
|
|
:defer t
|
2016-04-23 22:08:46 -04:00
|
|
|
:init
|
2022-08-14 18:10:01 +02:00
|
|
|
(setq anaconda-mode-installation-directory (concat doom-data-dir "anaconda/")
|
2016-04-23 22:08:46 -04:00
|
|
|
anaconda-mode-eldoc-as-single-line t)
|
2019-11-17 16:45:50 -05:00
|
|
|
|
2020-01-18 22:02:17 -05:00
|
|
|
(add-hook! 'python-mode-local-vars-hook :append
|
2019-11-17 16:45:50 -05:00
|
|
|
(defun +python-init-anaconda-mode-maybe-h ()
|
2019-12-22 23:00:26 -05:00
|
|
|
"Enable `anaconda-mode' if `lsp-mode' is absent and
|
|
|
|
`python-shell-interpreter' is present."
|
2019-11-17 16:45:50 -05:00
|
|
|
(unless (or (bound-and-true-p lsp-mode)
|
2020-05-01 11:01:11 +02:00
|
|
|
(bound-and-true-p eglot--managed-mode)
|
2019-12-22 23:00:26 -05:00
|
|
|
(bound-and-true-p lsp--buffer-deferred)
|
2021-01-08 17:45:33 -05:00
|
|
|
(not (executable-find python-shell-interpreter t)))
|
2019-11-17 16:45:50 -05:00
|
|
|
(anaconda-mode +1))))
|
2024-06-30 13:02:27 -04:00
|
|
|
|
|
|
|
(add-hook! 'eglot-server-initialized-hook
|
2024-07-01 03:34:23 -04:00
|
|
|
(defun +python-disable-anaconda-mode-h (&rest _)
|
2024-06-30 13:02:27 -04:00
|
|
|
"Ensure `anaconda-mode' doesn't interfere with `eglot'."
|
|
|
|
(when (bound-and-true-p anaconda-mode)
|
|
|
|
(anaconda-mode -1))))
|
2016-04-23 22:08:46 -04:00
|
|
|
:config
|
2018-07-31 19:20:58 +02:00
|
|
|
(set-company-backend! 'anaconda-mode '(company-anaconda))
|
|
|
|
(set-lookup-handlers! 'anaconda-mode
|
2018-01-24 03:16:36 -05:00
|
|
|
:definition #'anaconda-mode-find-definitions
|
|
|
|
:references #'anaconda-mode-find-references
|
|
|
|
:documentation #'anaconda-mode-show-doc)
|
2018-07-31 19:20:58 +02:00
|
|
|
(set-popup-rule! "^\\*anaconda-mode" :select nil)
|
2018-01-31 05:32:05 -05:00
|
|
|
|
2019-12-22 23:00:26 -05:00
|
|
|
(add-hook 'anaconda-mode-hook #'anaconda-eldoc-mode)
|
|
|
|
|
2019-07-26 19:57:13 +02:00
|
|
|
(defun +python-auto-kill-anaconda-processes-h ()
|
2018-01-31 05:32:05 -05:00
|
|
|
"Kill anaconda processes if this buffer is the last python buffer."
|
|
|
|
(when (and (eq major-mode 'python-mode)
|
|
|
|
(not (delq (current-buffer)
|
|
|
|
(doom-buffers-in-mode 'python-mode (buffer-list)))))
|
|
|
|
(anaconda-mode-stop)))
|
|
|
|
(add-hook! 'python-mode-hook
|
2019-11-17 16:45:50 -05:00
|
|
|
(add-hook 'kill-buffer-hook #'+python-auto-kill-anaconda-processes-h
|
|
|
|
nil 'local))
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2018-07-31 14:02:34 +02:00
|
|
|
(when (featurep 'evil)
|
|
|
|
(add-hook 'anaconda-mode-hook #'evil-normalize-keymaps))
|
2018-12-23 23:54:27 -05:00
|
|
|
(map! :localleader
|
|
|
|
:map anaconda-mode-map
|
2019-10-04 17:49:28 -04:00
|
|
|
:prefix "g"
|
2018-12-23 23:54:27 -05:00
|
|
|
"d" #'anaconda-mode-find-definitions
|
|
|
|
"h" #'anaconda-mode-show-doc
|
|
|
|
"a" #'anaconda-mode-find-assignments
|
|
|
|
"f" #'anaconda-mode-find-file
|
|
|
|
"u" #'anaconda-mode-find-references))
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! pyimport
|
2019-11-17 16:45:50 -05:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(map! :after python
|
|
|
|
:map python-mode-map
|
2019-05-28 17:02:10 -04:00
|
|
|
:localleader
|
2019-08-09 20:09:18 -03:00
|
|
|
(:prefix ("i" . "imports")
|
|
|
|
:desc "Insert missing imports" "i" #'pyimport-insert-missing
|
2022-07-23 15:00:40 +01:00
|
|
|
:desc "Remove unused imports" "R" #'pyimport-remove-unused
|
2019-10-04 17:49:28 -04:00
|
|
|
:desc "Optimize imports" "o" #'+python/optimize-imports)))
|
2019-05-28 17:02:10 -04:00
|
|
|
|
|
|
|
|
2019-12-11 11:27:50 +01:00
|
|
|
(use-package! py-isort
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(map! :after python
|
|
|
|
:map python-mode-map
|
|
|
|
:localleader
|
|
|
|
(:prefix ("i" . "imports")
|
|
|
|
:desc "Sort imports" "s" #'py-isort-buffer
|
|
|
|
:desc "Sort region" "r" #'py-isort-region)))
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! nose
|
2016-04-04 12:06:47 -04:00
|
|
|
:commands nose-mode
|
2018-07-31 14:02:34 +02:00
|
|
|
:preface (defvar nose-mode-map (make-sparse-keymap))
|
2019-07-22 04:30:04 +02:00
|
|
|
:minor ("/test_.+\\.py$" . nose-mode)
|
2016-04-04 12:06:47 -04:00
|
|
|
:config
|
2018-06-18 02:26:05 +02:00
|
|
|
(set-popup-rule! "^\\*nosetests" :size 0.4 :select nil)
|
2018-06-15 18:03:11 +02:00
|
|
|
(set-yas-minor-mode! 'nose-mode)
|
2018-07-31 14:02:34 +02:00
|
|
|
(when (featurep 'evil)
|
|
|
|
(add-hook 'nose-mode-hook #'evil-normalize-keymaps))
|
|
|
|
|
2018-12-23 23:54:27 -05:00
|
|
|
(map! :localleader
|
|
|
|
:map nose-mode-map
|
2017-02-28 12:11:18 -05:00
|
|
|
:prefix "t"
|
2018-12-23 23:54:27 -05:00
|
|
|
"r" #'nosetests-again
|
|
|
|
"a" #'nosetests-all
|
|
|
|
"s" #'nosetests-one
|
|
|
|
"v" #'nosetests-module
|
|
|
|
"A" #'nosetests-pdb-all
|
|
|
|
"O" #'nosetests-pdb-one
|
|
|
|
"V" #'nosetests-pdb-module))
|
2016-04-04 12:06:47 -04:00
|
|
|
|
2018-12-05 21:45:40 -05:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! python-pytest
|
2020-08-26 09:24:22 +02:00
|
|
|
:commands python-pytest-dispatch
|
2018-12-03 23:15:40 -05:00
|
|
|
:init
|
|
|
|
(map! :after python
|
2018-11-22 12:53:08 -06:00
|
|
|
:localleader
|
2018-12-23 23:54:27 -05:00
|
|
|
:map python-mode-map
|
2019-10-04 17:49:28 -04:00
|
|
|
:prefix ("t" . "test")
|
2020-10-24 01:29:44 +02:00
|
|
|
"a" #'python-pytest
|
2019-10-04 17:49:28 -04:00
|
|
|
"f" #'python-pytest-file-dwim
|
|
|
|
"F" #'python-pytest-file
|
|
|
|
"t" #'python-pytest-function-dwim
|
|
|
|
"T" #'python-pytest-function
|
2019-05-25 21:01:31 -03:00
|
|
|
"r" #'python-pytest-repeat
|
2020-08-10 15:05:54 +02:00
|
|
|
"p" #'python-pytest-dispatch))
|
2018-05-31 11:32:26 +02:00
|
|
|
|
2018-12-05 21:45:40 -05:00
|
|
|
|
2018-05-31 11:32:26 +02:00
|
|
|
;;
|
2020-07-27 01:20:12 -04:00
|
|
|
;;; Environment management
|
2018-05-31 11:32:26 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! pipenv
|
2018-07-31 14:02:34 +02:00
|
|
|
:commands pipenv-project-p
|
2018-08-11 21:18:21 +02:00
|
|
|
:hook (python-mode . pipenv-mode)
|
|
|
|
:init (setq pipenv-with-projectile nil)
|
|
|
|
:config
|
2018-09-26 12:28:32 -04:00
|
|
|
(set-eval-handler! 'python-mode
|
2018-10-06 00:25:50 -04:00
|
|
|
'((:command . (lambda () python-shell-interpreter))
|
2018-09-26 12:28:32 -04:00
|
|
|
(:exec (lambda ()
|
2021-01-08 17:45:33 -05:00
|
|
|
(if-let* ((bin (executable-find "pipenv" t))
|
2018-09-26 20:38:02 -04:00
|
|
|
(_ (pipenv-project-p)))
|
|
|
|
(format "PIPENV_MAX_DEPTH=9999 %s run %%c %%o %%s %%a" bin)
|
2018-09-26 12:28:32 -04:00
|
|
|
"%c %o %s %a")))
|
2019-11-12 20:35:14 -05:00
|
|
|
(:description . "Run Python script")))
|
|
|
|
(map! :map python-mode-map
|
|
|
|
:localleader
|
|
|
|
:prefix "e"
|
|
|
|
:desc "activate" "a" #'pipenv-activate
|
|
|
|
:desc "deactivate" "d" #'pipenv-deactivate
|
|
|
|
:desc "install" "i" #'pipenv-install
|
|
|
|
:desc "lock" "l" #'pipenv-lock
|
|
|
|
:desc "open module" "o" #'pipenv-open
|
|
|
|
:desc "run" "r" #'pipenv-run
|
|
|
|
:desc "shell" "s" #'pipenv-shell
|
|
|
|
:desc "uninstall" "u" #'pipenv-uninstall))
|
2018-07-31 14:02:34 +02:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! pyvenv
|
2019-03-04 20:46:20 -05:00
|
|
|
:after python
|
2019-03-07 00:11:45 -05:00
|
|
|
:init
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! :ui modeline)
|
2019-07-18 15:27:20 +02:00
|
|
|
(add-hook 'pyvenv-post-activate-hooks #'+modeline-update-env-in-all-windows-h)
|
|
|
|
(add-hook 'pyvenv-pre-deactivate-hooks #'+modeline-clear-env-in-all-windows-h))
|
2019-03-07 00:11:45 -05:00
|
|
|
:config
|
2019-11-02 13:41:55 -04:00
|
|
|
(add-hook 'python-mode-local-vars-hook #'pyvenv-track-virtualenv)
|
2019-03-04 20:46:20 -05:00
|
|
|
(add-to-list 'global-mode-string
|
2019-03-07 00:11:45 -05:00
|
|
|
'(pyvenv-virtual-env-name (" venv:" pyvenv-virtual-env-name " "))
|
2019-11-12 20:35:14 -05:00
|
|
|
'append))
|
2019-07-25 10:18:03 +05:30
|
|
|
|
2019-03-04 20:46:20 -05:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! pyenv-mode
|
2022-08-12 20:29:19 +02:00
|
|
|
:when (modulep! +pyenv)
|
2018-07-31 14:02:34 +02:00
|
|
|
:after python
|
|
|
|
:config
|
2018-09-25 22:17:41 -04:00
|
|
|
(when (executable-find "pyenv")
|
2021-03-27 16:24:40 +07:00
|
|
|
(pyenv-mode +1)
|
2019-09-23 10:14:19 +02:00
|
|
|
(add-to-list 'exec-path (expand-file-name "shims" (or (getenv "PYENV_ROOT") "~/.pyenv"))))
|
2020-08-20 01:48:49 -04:00
|
|
|
(add-hook 'python-mode-local-vars-hook #'+python-pyenv-mode-set-auto-h)
|
2019-09-23 10:14:19 +02:00
|
|
|
(add-hook 'doom-switch-buffer-hook #'+python-pyenv-mode-set-auto-h))
|
2018-07-31 14:02:34 +02:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! conda
|
2022-08-12 20:29:19 +02:00
|
|
|
:when (modulep! +conda)
|
2018-07-31 14:02:34 +02:00
|
|
|
:after python
|
|
|
|
:config
|
2019-09-22 14:05:03 -04:00
|
|
|
;; The location of your anaconda home will be guessed from a list of common
|
|
|
|
;; possibilities, starting with `conda-anaconda-home''s default value (which
|
|
|
|
;; will consult a ANACONDA_HOME envvar, if it exists).
|
2018-07-31 14:02:34 +02:00
|
|
|
;;
|
2019-09-22 14:05:03 -04:00
|
|
|
;; If none of these work for you, `conda-anaconda-home' must be set
|
|
|
|
;; explicitly. Afterwards, run M-x `conda-env-activate' to switch between
|
2018-07-31 23:07:22 +02:00
|
|
|
;; environments
|
2019-11-17 16:45:50 -05:00
|
|
|
(or (cl-loop for dir in (list conda-anaconda-home
|
|
|
|
"~/.anaconda"
|
|
|
|
"~/.miniconda"
|
|
|
|
"~/.miniconda3"
|
2021-12-13 07:13:41 +09:00
|
|
|
"~/.miniforge3"
|
2020-06-17 13:03:08 -07:00
|
|
|
"~/anaconda3"
|
2019-11-17 16:45:50 -05:00
|
|
|
"~/miniconda3"
|
2021-12-13 07:13:41 +09:00
|
|
|
"~/miniforge3"
|
2020-10-13 22:52:10 -04:00
|
|
|
"~/opt/miniconda3"
|
2019-11-17 16:45:50 -05:00
|
|
|
"/usr/bin/anaconda3"
|
|
|
|
"/usr/local/anaconda3"
|
|
|
|
"/usr/local/miniconda3"
|
2022-02-01 17:06:54 +01:00
|
|
|
"/usr/local/Caskroom/miniconda/base"
|
|
|
|
"~/.conda")
|
2019-11-17 16:45:50 -05:00
|
|
|
if (file-directory-p dir)
|
2020-06-17 13:03:08 -07:00
|
|
|
return (setq conda-anaconda-home (expand-file-name dir)
|
|
|
|
conda-env-home-directory (expand-file-name dir)))
|
2019-11-17 16:45:50 -05:00
|
|
|
(message "Cannot find Anaconda installation"))
|
2018-07-31 14:02:34 +02:00
|
|
|
|
|
|
|
;; integration with term/eshell
|
|
|
|
(conda-env-initialize-interactive-shells)
|
|
|
|
(after! eshell (conda-env-initialize-eshell))
|
2019-07-27 13:53:38 +02:00
|
|
|
|
2019-03-01 15:12:27 -05:00
|
|
|
(add-to-list 'global-mode-string
|
2019-03-07 00:11:45 -05:00
|
|
|
'(conda-env-current-name (" conda:" conda-env-current-name " "))
|
2018-08-01 22:29:51 +02:00
|
|
|
'append))
|
2019-07-26 22:32:17 -04:00
|
|
|
|
2019-07-27 13:53:38 +02:00
|
|
|
|
2020-04-22 20:48:00 +03:00
|
|
|
(use-package! poetry
|
2022-08-12 20:29:19 +02:00
|
|
|
:when (modulep! +poetry)
|
2020-10-24 20:16:20 +09:00
|
|
|
:after python
|
|
|
|
:init
|
2021-03-30 17:00:00 +07:00
|
|
|
(setq poetry-tracking-strategy 'switch-buffer)
|
2020-10-31 16:18:15 +09:00
|
|
|
(add-hook 'python-mode-hook #'poetry-tracking-mode))
|
2020-04-22 20:48:00 +03:00
|
|
|
|
|
|
|
|
2019-10-15 09:09:24 +02:00
|
|
|
(use-package! cython-mode
|
2022-08-12 20:29:19 +02:00
|
|
|
:when (modulep! +cython)
|
2019-10-17 08:51:18 +02:00
|
|
|
:mode "\\.p\\(yx\\|x[di]\\)\\'"
|
2019-10-15 09:09:24 +02:00
|
|
|
:config
|
|
|
|
(setq cython-default-compile-format "cython -a %s")
|
|
|
|
(map! :map cython-mode-map
|
|
|
|
:localleader
|
|
|
|
:prefix "c"
|
2019-10-17 08:51:18 +02:00
|
|
|
:desc "Cython compile buffer" "c" #'cython-compile))
|
|
|
|
|
2019-10-15 09:09:24 +02:00
|
|
|
|
|
|
|
(use-package! flycheck-cython
|
2022-08-12 20:29:19 +02:00
|
|
|
:when (modulep! +cython)
|
2022-08-17 01:16:08 +01:00
|
|
|
:when (and (modulep! :checkers syntax)
|
|
|
|
(not (modulep! :checkers syntax +flymake)))
|
2019-10-15 09:09:24 +02:00
|
|
|
:after cython-mode)
|
2020-07-27 01:20:12 -04:00
|
|
|
|
|
|
|
|
2022-04-16 02:57:21 +02:00
|
|
|
(use-package! pip-requirements
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
;; HACK `pip-requirements-mode' performs a sudden HTTP request to
|
|
|
|
;; https://pypi.org/simple, which causes unexpected hangs (see #5998). This
|
|
|
|
;; advice defers this behavior until the first time completion is invoked.
|
|
|
|
;; REVIEW More sensible behavior should be PRed upstream.
|
|
|
|
(defadvice! +python--init-completion-a (&rest args)
|
|
|
|
"Call `pip-requirements-fetch-packages' first time completion is invoked."
|
|
|
|
:before #'pip-requirements-complete-at-point
|
|
|
|
(unless pip-packages (pip-requirements-fetch-packages)))
|
|
|
|
(defadvice! +python--inhibit-pip-requirements-fetch-packages-a (fn &rest args)
|
|
|
|
"No-op `pip-requirements-fetch-packages', which can be expensive."
|
|
|
|
:around #'pip-requirements-mode
|
2022-04-18 18:14:16 +02:00
|
|
|
(letf! ((#'pip-requirements-fetch-packages #'ignore))
|
2022-04-16 02:57:21 +02:00
|
|
|
(apply fn args))))
|
|
|
|
|
|
|
|
|
2020-07-27 01:20:12 -04:00
|
|
|
;;
|
|
|
|
;;; LSP
|
|
|
|
|
2024-07-05 16:54:24 -04:00
|
|
|
(use-package! lsp-pyright
|
|
|
|
:when (modulep! +lsp)
|
|
|
|
:when (modulep! +pyright)
|
|
|
|
:when (not (modulep! :tools lsp +eglot))
|
|
|
|
:after lsp-mode)
|