doomemacs/modules/lang/python/config.el

90 lines
2.9 KiB
EmacsLisp
Raw Normal View History

2017-02-20 07:57:16 +08:00
;;; lang/python/config.el
2015-06-15 15:06:10 +08:00
(def-package! python
:commands python-mode
2015-06-15 15:06:10 +08:00
:init
2017-02-20 07:57:16 +08:00
(setq python-environment-directory doom-cache-dir
python-indent-guess-indent-offset-verbose nil
2017-04-23 05:08:26 +08:00
python-shell-interpreter "python")
(add-hook! 'python-mode-hook
#'(flycheck-mode +evil|simple-matchit))
:config
(set! :repl 'python-mode #'+python/repl)
2017-04-10 03:02:31 +08:00
(set! :electric 'python-mode :chars '(?:))
(define-key python-mode-map (kbd "DEL") nil) ; interferes with smartparens
2017-04-23 05:08:26 +08:00
(when (executable-find "ipython")
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args "-i --simple-prompt --no-color-info"
python-shell-prompt-regexp "In \\[[0-9]+\\]: "
python-shell-prompt-block-regexp "\\.\\.\\.\\.: "
python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
python-shell-completion-setup-code
"from IPython.core.completerlib import module_completion"
python-shell-completion-string-code
"';'.join(get_ipython().Completer.all_completions('''%s'''))\n"))
(sp-with-modes 'python-mode
(sp-local-pair "'" nil :unless '(sp-point-before-word-p sp-point-after-word-p sp-point-before-same-p))))
2015-06-15 15:06:10 +08:00
2017-02-20 07:57:16 +08:00
(def-package! anaconda-mode
:after python
:init
(add-hook 'python-mode-hook #'anaconda-mode)
(add-hook 'anaconda-mode-hook #'anaconda-eldoc-mode)
(setq anaconda-mode-installation-directory (concat doom-etc-dir "anaconda/")
anaconda-mode-eldoc-as-single-line t)
2016-03-05 11:34:14 +08:00
:config
(set! :popup "*anaconda-mode*" :size 10 :noselect t :autoclose t :autokill t)
2017-02-20 07:57:16 +08:00
(map! :map anaconda-mode-map :m "gd" #'anaconda-mode-find-definitions)
2015-06-15 15:06:10 +08:00
(advice-add #'anaconda-mode-doc-buffer :after #'doom*anaconda-mode-doc-buffer))
2015-06-15 15:06:10 +08:00
(def-package! company-anaconda
:when (featurep! :completion company)
:after anaconda-mode
:config
(set! :company-backend 'python-mode '(company-anaconda))
(map! :map python-mode-map
:m "gd" #'anaconda-mode-find-definitions
:m "gD" #'anaconda-mode-find-references
:localleader
:prefix "f"
:nv "d" #'anaconda-mode-find-definitions
:nv "h" #'anaconda-mode-show-doc
:nv "a" #'anaconda-mode-find-assignments
:nv "f" #'anaconda-mode-find-file
:nv "u" #'anaconda-mode-find-references))
2017-02-20 07:57:16 +08:00
2015-06-15 15:06:10 +08:00
(def-package! pip-requirements
2017-02-20 07:57:16 +08:00
:mode ("/requirements.txt$" . pip-requirements-mode))
2016-04-19 14:38:58 +08:00
2017-02-20 07:57:16 +08:00
(def-package! nose
2016-04-05 00:06:47 +08:00
:commands nose-mode
2017-02-20 07:57:16 +08:00
:preface
(defvar nose-mode-map (make-sparse-keymap))
:init
(associate! nose-mode :match "/test_.+\\.py$" :modes (python-mode))
2016-04-05 00:06:47 +08:00
:config
(set! :popup "*nosetests*" :size 0.4 :noselect t)
(set! :yas-minor-mode 'nose-mode)
(map! :map nose-mode-map
2017-02-20 07:57:16 +08:00
:localleader
:prefix "t"
:n "r" #'nosetests-again
:n "a" #'nosetests-all
:n "s" #'nosetests-one
:n "v" #'nosetests-module
:n "A" #'nosetests-pdb-all
:n "O" #'nosetests-pdb-one
:n "V" #'nosetests-pdb-module))
2016-04-05 00:06:47 +08:00