-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy-python.el
131 lines (111 loc) · 4.56 KB
/
my-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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
;; Python settings ------------------------------------------------------------
(setq conda-base (expand-file-name "~/opt/plus/anaconda3/envs/plus"))
(defun plus-conda-path (subpath)
"Get a subpath in the Conda env."
(interactive)
(concat conda-base "/" subpath)
)
(setq conda-python (plus-conda-path "bin/python"))
(setq conda-mypy (plus-conda-path "bin/mypy"))
(require 'flymake)
(remove-hook 'flymake-diagnostic-functions 'flymake-proc-legacy-flymake)
(unless (package-installed-p 'yapfify)
(package-refresh-contents)
(package-install 'yapfify))
(unless (package-installed-p 'elpy)
(package-refresh-contents)
(package-install 'elpy))
(use-package elpy
:ensure t
:config
(unbind-key "M-<left>" elpy-mode-map)
(unbind-key "M-<right>" elpy-mode-map)
(unbind-key "M-<up>" elpy-mode-map)
(unbind-key "M-<down>" elpy-mode-map)
(local-set-key (kbd "C-x C-e") 'elpy-shell-send-buffer)
(local-set-key (kbd "C-x C-d") 'elpy-pdb-break-at-point)
(bind-keys :map elpy-mode-map
("M-<left>" . windmove-left)
("M-<right>" . windmove-right)
("M-<up>" . windmove-up)
("M-<down>" . windmove-down)
("s-<left>" . elpy-nav-indent-shift-left)
("s-<right>" . elpy-nav-indent-shift-right)))
(setq comint-process-echoes t)
(setq my-venv conda-base)
(setq my-vpy (expand-file-name conda-python))
(pyvenv-activate my-venv)
(pyvenv-workon my-venv)
(custom-set-variables
'(elpy-modules
(quote
(elpy-module-company elpy-module-eldoc elpy-module-flymake elpy-module-pyvenv elpy-module-highlight-indentation elpy-module-yasnippet elpy-module-sane-defaults)))
'(python-shell-interpreter conda-python)
'(elpy-rpc-python-command conda-python)
'(elpy-rpc-virtualenv-path conda-python)
'(elpy-rpc-python-command conda-python)
'(elpy-syntax-check-command conda-mypy)
'(elpy-rpc-virtualenv-path conda-python)
'(elpy-test-discover-runner-command (quote ("python-shell-interpreter" "-m" "pytest")))
'(elpy-test-pytest-runner-command (plus-conda-path "bin/pytest"))
'(python-check-command conda-mypy)
'(elpy-test-runner (quote elpy-test-pytest-runner))
'(elpy-rpc-python-command conda-python)
'(elpy-rpc-virtualenv-path conda-python)
'(elpy-syntax-check-command conda-mypy)
'(elpy-test-discover-runner-command (quote ("python-shell-interpreter" "-m" "pytest")))
'(elpy-test-pytest-runner-command (plus-conda-path "bin/pytest"))
'(python-check-command conda-mypy)
'(python-shell-interpreter conda-python)
)
(defun my-mypy ()
"Docstring for my-mypy."
(interactive)
(run-python)
(flycheck-mode)
(flycheck-compile 'python-mypy)
)
(add-hook 'python-mode-hook
'(lambda ()
(interactive)
(setenv "MYPYPATH"
(concat
(expand-file-name "~/src/mine/skunkworks/python/stubs")
":"
(expand-file-name "~/src/ext/python/typeshed/")
":"
(expand-file-name "~/src/oss/kingston/")
":"
(expand-file-name "~/src/oss/ormsnack/")
":"
(expand-file-name "~/src/oss/plus/")
)
)
(setq outline-regexp "[^ \t\n]\\|[ \t]*\\(if[ \t]+\\|elif[ \t]+\\|else[ \t]+\\|for[ \t]+\\|while[ \t]+\\|with[ \t]+\\|def[ \t]+\\|class[ \t]+\\)")
(outline-minor-mode t)
(persistent-overlays-minor-mode 1)
(persistent-overlays-load-overlays)
(setq python-shell-interpreter conda-python)
(add-hook 'before-save-hook 'persistent-overlays-save-overlays nil 'local)
(require 'yapfify)
(highlight-lines-matching-regexp ".set_trace" 'hi-red-b)
(define-key python-mode-map (kbd "C-x C-m") 'outline-toggle-children)
(define-key python-mode-map (kbd "C-x C-c") 'my-mypy)
(define-key python-mode-map (kbd "") 'outline-toggle-children)
(define-key python-mode-map (kbd "") 'outline-toggle-children)
(elpy-enable)
(setq company-idle-delay 0.2)
)
)
(setq auto-mode-alist
(append '(("\\.wsgi$" . python-mode)
("\\.pyx$" . python-mode)) auto-mode-alist))
(setq auto-mode-alist
(append '(("Pipfile*" . conf-mode)) auto-mode-alist))
;; EIN settings ------------------------------------------------------------
(unless (package-installed-p 'ein)
(package-install 'ein)
(package-install 'ein-subpackages))
(require 'ein)
;; (require 'ein-subpackages)
(provide 'my-python)