doomemacs/init/init-python.el

86 lines
3.3 KiB
EmacsLisp
Raw Normal View History

2014-09-05 17:08:40 -04:00
(use-package python
:mode ("\\.py\\'" . python-mode)
:interpreter ("python" . python-mode)
:init
(progn
(add-hook 'python-mode-hook 'enable-tab-width-4)
(add-hook 'python-mode-hook 'emr-initialize))
2014-09-05 17:08:40 -04:00
:config
(progn
(setq-default python-indent-offset 4)
2014-12-05 17:28:03 -05:00
(setq python-environment-directory my-tmp-dir)
2014-09-20 16:54:04 -04:00
(setq python-shell-interpreter "ipython")
2015-05-07 03:19:24 -04:00
;; interferes with smartparens
(define-key python-mode-map (kbd "DEL") nil)
(use-package anaconda-mode
:init
(progn
(add-hook 'python-mode-hook 'anaconda-mode)
(add-hook 'python-mode-hook 'eldoc-mode)
(add-hook! 'anaconda-mode-hook
(process-buffer (python-shell-get-or-create-process python-shell-interpreter t nil))))
:config
(progn
(bind 'motion anaconda-mode-map "gd" 'anaconda-mode-goto-definitions)
(bind 'normal anaconda-nav-mode-map [escape] 'anaconda-nav-quit)
;; Delete the window on escape or C-g
(defadvice anaconda-mode-doc-buffer (after anaconda-doc-buffer-escape-to-close activate)
(with-current-buffer (get-buffer "*anaconda-doc*")
(local-set-key [escape] 'anaconda-nav-quit)
(local-set-key [?\C-g] 'anaconda-nav-quit)))
(after "emr"
(emr-declare-command 'anaconda-mode-view-doc
:title "view documentation"
:modes 'python-mode
:predicate (lambda () (and (anaconda-mode-running-p)
(not (use-region-p))
(not (sp-point-in-string-or-comment)))))
(emr-declare-command 'anaconda-mode-goto-assignments
:title "go to assignments"
:modes 'python-mode
:predicate (lambda () (and (anaconda-mode-running-p)
(not (use-region-p))
(not (sp-point-in-string-or-comment)))))
(emr-declare-command 'anaconda-mode-goto-definitions
:title "go to definition"
:modes 'python-mode
:predicate (lambda () (and (anaconda-mode-running-p)
(not (use-region-p))
(not (sp-point-in-string-or-comment)))))
(emr-declare-command 'anaconda-mode-usages
:title "show usages"
:modes 'python-mode
:predicate (lambda () (and (anaconda-mode-running-p)
(not (use-region-p))
(not (sp-point-in-string-or-comment))))))
(after "company"
(use-package company-anaconda
:config (company--backend-on 'python-mode-hook 'company-anaconda)))))
2014-09-20 16:54:04 -04:00
(use-package nose
2014-12-05 17:28:03 -05:00
:commands nose-mode
2014-09-05 17:08:40 -04:00
:init
2014-09-20 16:54:04 -04:00
(progn
;; Reset nose keymap, we'll set new ones in my-keymaps.el
(defvar nose-mode-map (make-sparse-keymap))
2014-12-05 17:28:03 -05:00
(associate-minor-mode "/test_.+\\.py\\'" 'nose-mode))
:config
(bind 'normal nose-mode-map
",tr" 'nosetests-again
",ta" 'nosetests-all
",ts" 'nosetests-one
",tv" 'nosetests-module
",tA" 'nosetests-pdb-all
",tO" 'nosetests-pdb-one
",tV" 'nosetests-pdb-module))))
2014-12-12 15:35:58 -05:00
(provide 'init-python)
;;; init-python.el ends here