summary refs log tree commit diff
path: root/emacs/custom/my-lang-python.el
blob: 10c1cd9f55cfc38c17acb3216dbc86f05895855b (plain) (blame)
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
;;; my-lang-python.el --- Configures emacs for python -*- lexical-binding: t -*-
;; Author: Franck Cuny <franck@fcuny.net>

;;; Commentary:

;;; Code:

(require 'python)

(setq python-interpreter "ipython3")
(setq python-shell-interpreter "python3")
(setq python-shell-interpreter-args "-i")

;;; bindings
(define-key python-mode-map (kbd "C-h f") 'python-eldoc-at-point)

;;; hooks
;; if black is present, enable it
(when (executable-find "black")
  (require 'blacken)
  (add-hook 'python-mode-hook 'blacken-mode))

(when (executable-find "pylsp")
  (add-hook 'python-mode-hook 'eglot-ensure)
  ;; https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
  (setq-default eglot-workspace-configuration
                '((pylsp (plugins (flake8      (enabled . :json-false))
                                  (pycodestyle (enabled . :json-false)))))))

(provide 'my-lang-python)

;;; my-lang-python.el ends here