forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-python.el
34 lines (24 loc) · 1.03 KB
/
init-python.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;;; init-python.el --- Python editing -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; I use nix + direnv instead of virtualenv/pyenv/pyvenv, and it is an
;; approach which extends to other languages too. I recorded a
;; screencast about this: https://www.youtube.com/watch?v=TbIHRHy7_JM
(setq auto-mode-alist
(append '(("SConstruct\\'" . python-mode)
("SConscript\\'" . python-mode))
auto-mode-alist))
(setq python-shell-interpreter "python3")
(require-package 'pip-requirements)
(when (maybe-require-package 'flymake-ruff)
(defun sanityinc/flymake-ruff-maybe-enable ()
(when (executable-find "ruff")
(flymake-ruff-load)))
(add-hook 'python-mode-hook 'sanityinc/flymake-ruff-maybe-enable))
(maybe-require-package 'ruff-format)
(when (maybe-require-package 'toml-mode)
(add-to-list 'auto-mode-alist '("poetry\\.lock\\'" . toml-mode)))
(when (maybe-require-package 'reformatter)
(reformatter-define black :program "black" :args '("-")))
(provide 'init-python)
;;; init-python.el ends here