2025-12-14 23:46:29 +11:00
|
|
|
;; -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
|
|
;; Python Mode
|
|
|
|
|
;; Install: pip install pyflakes autopep8
|
|
|
|
|
(use-package python
|
2026-04-02 19:21:30 +11:00
|
|
|
:ensure nil
|
2025-12-14 23:46:29 +11:00
|
|
|
:functions exec-path-from-shell-copy-env
|
|
|
|
|
:hook (inferior-python-mode . (lambda ()
|
|
|
|
|
(process-query-on-exit-flag
|
|
|
|
|
(get-process "Python"))))
|
|
|
|
|
:init
|
|
|
|
|
;; Disable readline based native completion
|
|
|
|
|
(setq python-shell-completion-native-enable nil)
|
|
|
|
|
:config
|
|
|
|
|
(add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode))
|
|
|
|
|
;; Default to Python 3. Prefer the versioned Python binaries since some
|
|
|
|
|
;; systems stupidly make the unversioned one point at Python 2.
|
|
|
|
|
(when (and (executable-find "python3")
|
|
|
|
|
(string= python-shell-interpreter "python"))
|
|
|
|
|
(setq python-shell-interpreter "python3"))
|
|
|
|
|
|
|
|
|
|
;; Env vars
|
|
|
|
|
(with-eval-after-load 'exec-path-from-shell
|
|
|
|
|
(exec-path-from-shell-copy-env "PYTHONPATH")))
|
|
|
|
|
|
2026-03-30 11:49:18 +11:00
|
|
|
;; (with-eval-after-load 'eglot
|
|
|
|
|
;; (add-hook 'python-ts-mode-hook #'eglot-ensure)
|
|
|
|
|
;; (add-to-list 'eglot-server-programs '((python-mode python-ts-mode) . ("pyright-langserver" "--stdio"))))
|
2025-12-14 23:46:29 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
(provide 'init-python)
|