doomemacs/modules/module-python.el

76 lines
2.9 KiB
EmacsLisp
Raw Normal View History

2015-06-15 09:06:10 +02:00
;;; module-python.el
(use-package python
:mode ("\\.py\\'" . python-mode)
:interpreter ("python" . python-mode)
:commands python-mode
2015-06-15 09:06:10 +02:00
:init
(setq-default
python-environment-directory narf-temp-dir
python-shell-interpreter "ipython"
python-shell-interpreter-args "--deep-reload"
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")
(define-docset! python-mode "py,py3,python")
NARF v0.7.0 vcs: + +git-gutter to conf-modes; -git-gutter from evil-insert-state-exit + switch github-browse-file for browse-at-remote + fix <leader>ob; add <leader>d[./sr] vc bindings + vc-annotate bindings and initial state Workgroups2 integration: + don't mess with buffers (speeds up emacs a lot!) + unicode numbers in display + single display function + remember workgroup uid instead (and smarter :tabrename) + clean up after wg update Org-mode + give highlight precedence to links in org-mode + enable encryption + config clean up + use different font for org + exclude attachments in recentf + redo latex and inline-image config + add narf/org-open-notes + update file templates for org CRM Mode-line + polish mode-line + decouple from spaceline-segments.el + refactor narf|spaceline-env-update + add macro-recording and buffer-size indicators to mode-line + python: '2>&1' in env-command + flycheck fringe indicator: change to arrow Aesthetics + update narf-dark-theme + add narf-minibuffer-active face + change writing indicator in writing-mode Misc + fix whitespace in display-startup-echo-area-message + reset fonts for more unicode characters + custom imenu entries + helm-imenu fontification + enable yascroll-bar in REPLs + reorganize my-commands.el + force quit iedit on ESC in normal mode + update snippets submodule + remove ido init (helm handles it all) [EXPERIMENTAL] + back to Terminus(TTF) font + popwin: update config for git-gutter and vc-diff windows + highlight :g[lobal] and :al[ign] matches + decouple narf/get-buffers+narf/get-all-buffers from wg-mess-with-buffer-list + fix narf/helm-buffers-dwim (add interactive form)
2015-12-11 16:51:04 -05:00
(define-env-command! python-mode "python --version 2>&1 | cut -d' ' -f2")
2016-04-04 12:06:47 -04:00
(define-repl! python-mode narf/inf-python)
(add-hook! python-mode '(emr-initialize narf|flycheck-enable-maybe))
:config
(define-key python-mode-map (kbd "DEL") nil) ; interferes with smartparens
2015-06-15 09:06:10 +02:00
2015-11-23 15:19:43 -05:00
(use-package anaconda-mode
:init
2016-03-04 22:34:14 -05:00
(add-hook! python-mode '(anaconda-mode anaconda-eldoc-mode eldoc-mode))
2016-03-27 00:49:52 -04:00
(setq anaconda-mode-installation-directory (concat narf-temp-dir "/anaconda/")
2016-03-04 22:34:14 -05:00
anaconda-mode-eldoc-as-single-line t)
2015-11-23 15:19:43 -05:00
:config
(map! :map anaconda-mode-map :m "gd" 'anaconda-mode-goto-definitions)
(map! :map anaconda-nav-mode-map :n [escape] 'anaconda-nav-quit)
2015-06-15 09:06:10 +02:00
2015-11-23 15:19:43 -05:00
(advice-add 'anaconda-mode-doc-buffer :after 'narf*anaconda-mode-doc-buffer)
2015-06-15 09:06:10 +02:00
2016-03-29 23:59:09 -04:00
(require 'company-anaconda)
(define-company-backend! python-mode (anaconda))
2015-11-23 15:19:43 -05:00
(after! emr
(mapc (lambda (x)
(let ((command-name (car x))
(title (cadr x))
(region-p (caddr x))
predicate)
(setq predicate (lambda () (and (anaconda-mode-running-p)
(not (use-region-p))
(not (sp-point-in-string-or-comment)))))
(emr-declare-command (intern (format "anaconda-mode-%s" (symbol-name command-name)))
2016-04-04 12:06:47 -04:00
:title title :modes 'python-mode :predicate predicate)))
2015-11-23 15:19:43 -05:00
'((show-doc "view documentation" t)
(find-assignments "find assignments" t)
(find-definitions "find definitions" t)
(find-file "find assignments" t)
(find-references "show usages" nil))))))
2015-06-15 09:06:10 +02:00
2016-04-04 12:06:47 -04:00
(use-package nose
:commands nose-mode
:preface (defvar nose-mode-map (make-sparse-keymap))
:init (associate! nose-mode :match "/test_.+\\.py\\'")
2016-04-04 12:06:47 -04:00
:config
(map! :map nose-mode-map
(:localleader
:n "tr" 'nosetests-again
:n "ta" 'nosetests-all
:n "ts" 'nosetests-one
:n "tv" 'nosetests-module
:n "tA" 'nosetests-pdb-all
:n "tO" 'nosetests-pdb-one
:n "tV" 'nosetests-pdb-module)))
2015-06-15 09:06:10 +02:00
(provide 'module-python)
;;; module-python.el ends here