refactor!(python): remove anaconda-mode

BREAKING CHANGE: This removes company and non-LSP integration from the
Python module, in order to reduce the complexity of the module, reduce
dependencies on Company, and lean more on LSP, which provides these
features with more reliability and consistency. Switch to :tools lsp and
install a Python LSP client to get these features back.
This commit is contained in:
Henrik Lissner
2025-04-01 17:42:34 -04:00
parent 417f3bc892
commit 52c385c033
2 changed files with 0 additions and 60 deletions

View File

@ -89,61 +89,6 @@
(setq-hook! 'python-mode-hook tab-width python-indent-offset))
(use-package! anaconda-mode
:defer t
:init
(setq anaconda-mode-installation-directory (concat doom-data-dir "anaconda/")
anaconda-mode-eldoc-as-single-line t)
(add-hook! 'python-mode-local-vars-hook :append
(defun +python-init-anaconda-mode-maybe-h ()
"Enable `anaconda-mode' if `lsp-mode' is absent and
`python-shell-interpreter' is present."
(unless (or (bound-and-true-p lsp-mode)
(bound-and-true-p eglot--managed-mode)
(bound-and-true-p lsp--buffer-deferred)
(not (executable-find python-shell-interpreter t)))
(anaconda-mode +1))))
(add-hook! 'eglot-server-initialized-hook
(defun +python-disable-anaconda-mode-h (&rest _)
"When `eglot' started, disable `anaconda-mode' so they don't interfere."
(when (bound-and-true-p anaconda-mode)
(anaconda-eldoc-mode -1)
(anaconda-mode -1))))
:config
(set-company-backend! 'anaconda-mode '(company-anaconda))
(set-lookup-handlers! 'anaconda-mode
:definition #'anaconda-mode-find-definitions
:references #'anaconda-mode-find-references
:documentation #'anaconda-mode-show-doc)
(set-popup-rule! "^\\*anaconda-mode" :select nil)
(add-hook 'anaconda-mode-hook #'anaconda-eldoc-mode)
(defun +python-auto-kill-anaconda-processes-h ()
"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
(add-hook 'kill-buffer-hook #'+python-auto-kill-anaconda-processes-h
nil 'local))
(when (featurep 'evil)
(add-hook 'anaconda-mode-hook #'evil-normalize-keymaps))
(map! :localleader
:map anaconda-mode-map
:prefix ("g" . "conda")
"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))
(use-package! pyimport
:defer t
:init

View File

@ -14,11 +14,6 @@
(when (modulep! +pyright)
(package! lsp-pyright :pin "b4cee81af46274303f2cb9b75de9fc8ddcba04d9"))))
;; Programming environment
(package! anaconda-mode :pin "28b3e0088ac7113390aa006bf277c8aa14e561a2")
(when (modulep! :completion company)
(package! company-anaconda :pin "fe6a5290441f713945956adf74c45e369f3cbefa"))
;; Environment management
(package! pipenv :pin "3af159749824c03f59176aff7f66ddd6a5785a10")
(package! pyvenv :pin "31ea715f2164dd611e7fc77b26390ef3ca93509b")