2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- Python Layer packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq python-packages
|
2014-11-10 04:54:10 +00:00
|
|
|
'(
|
2015-04-09 03:57:22 +00:00
|
|
|
company
|
2018-02-28 03:31:32 +00:00
|
|
|
counsel-gtags
|
2015-04-09 03:57:22 +00:00
|
|
|
cython-mode
|
2014-11-10 04:54:10 +00:00
|
|
|
eldoc
|
2015-09-21 00:56:37 +00:00
|
|
|
evil-matchit
|
2014-11-10 04:54:10 +00:00
|
|
|
flycheck
|
2016-04-05 04:08:34 +00:00
|
|
|
ggtags
|
2015-07-24 02:20:25 +00:00
|
|
|
helm-cscope
|
2016-04-05 04:08:34 +00:00
|
|
|
helm-gtags
|
2017-07-03 07:52:54 +00:00
|
|
|
(helm-pydoc :requires helm)
|
2014-12-14 05:19:20 +00:00
|
|
|
hy-mode
|
2018-01-06 02:45:57 +00:00
|
|
|
importmagic
|
2015-10-29 08:42:37 +00:00
|
|
|
live-py-mode
|
2016-04-05 20:41:05 +00:00
|
|
|
(nose :location local)
|
|
|
|
org
|
2015-04-25 03:54:39 +00:00
|
|
|
pip-requirements
|
2018-02-28 03:31:32 +00:00
|
|
|
pipenv
|
2017-03-19 03:45:08 +00:00
|
|
|
pippel
|
2015-11-07 08:28:26 +00:00
|
|
|
py-isort
|
2015-01-30 15:30:10 +00:00
|
|
|
pyenv-mode
|
2016-01-18 03:06:04 +00:00
|
|
|
(pylookup :location local)
|
2015-06-08 03:59:23 +00:00
|
|
|
pytest
|
2016-03-26 07:24:35 +00:00
|
|
|
(python :location built-in)
|
2015-06-08 03:59:23 +00:00
|
|
|
pyvenv
|
2014-12-09 17:08:30 +00:00
|
|
|
semantic
|
2014-12-12 03:16:09 +00:00
|
|
|
smartparens
|
2015-04-15 22:57:31 +00:00
|
|
|
stickyfunc-enhance
|
2015-07-24 02:20:25 +00:00
|
|
|
xcscope
|
2016-07-10 20:00:38 +00:00
|
|
|
yapfify
|
2018-02-28 03:31:32 +00:00
|
|
|
;; packages for anaconda backend
|
|
|
|
anaconda-mode
|
|
|
|
(company-anaconda :requires company)
|
|
|
|
;; packages for lsp backend
|
|
|
|
(lsp-python :requires lsp-mode)
|
2015-04-19 03:40:24 +00:00
|
|
|
))
|
2014-11-10 04:54:10 +00:00
|
|
|
|
2014-12-09 03:19:55 +00:00
|
|
|
(defun python/init-anaconda-mode ()
|
|
|
|
(use-package anaconda-mode
|
2018-02-19 05:08:27 +00:00
|
|
|
:init (setq anaconda-mode-installation-directory
|
|
|
|
(concat spacemacs-cache-directory "anaconda-mode"))
|
2014-12-09 03:19:55 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode
|
2015-11-22 17:45:12 +00:00
|
|
|
"hh" 'anaconda-mode-show-doc
|
|
|
|
"ga" 'anaconda-mode-find-assignments
|
2015-11-25 09:21:44 +00:00
|
|
|
"gb" 'anaconda-mode-go-back
|
2015-11-22 17:45:12 +00:00
|
|
|
"gu" 'anaconda-mode-find-references)
|
2016-11-28 11:08:20 +00:00
|
|
|
|
2017-12-30 08:45:05 +00:00
|
|
|
(evilified-state-evilify-map anaconda-view-mode-map
|
|
|
|
:mode anaconda-view-mode
|
2016-11-28 11:08:20 +00:00
|
|
|
:bindings
|
|
|
|
(kbd "q") 'quit-window
|
|
|
|
(kbd "C-j") 'next-error-no-select
|
|
|
|
(kbd "C-k") 'previous-error-no-select
|
|
|
|
(kbd "RET") 'spacemacs/anaconda-view-forward-and-push)
|
|
|
|
|
2016-02-15 19:15:29 +00:00
|
|
|
(spacemacs|hide-lighter anaconda-mode)
|
|
|
|
|
|
|
|
(defadvice anaconda-mode-goto (before python/anaconda-mode-goto activate)
|
2016-02-17 14:46:51 +00:00
|
|
|
(evil--jumps-push)))))
|
2014-12-09 03:19:55 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun python/post-init-company ()
|
2018-02-19 05:08:27 +00:00
|
|
|
;; backend specific
|
|
|
|
(add-hook 'python-mode-local-vars-hook #'spacemacs//python-setup-company)
|
2017-01-02 05:39:04 +00:00
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends (company-files company-capf)
|
|
|
|
:modes inferior-python-mode
|
|
|
|
:variables
|
|
|
|
company-minimum-prefix-length 0
|
|
|
|
company-idle-delay 0.5)
|
2017-07-02 13:48:06 +00:00
|
|
|
(when (configuration-layer/package-used-p 'pip-requirements)
|
2017-01-02 05:39:04 +00:00
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends company-capf
|
|
|
|
:modes pip-requirements-mode)))
|
2016-01-18 03:06:04 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun python/init-company-anaconda ()
|
|
|
|
(use-package company-anaconda
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2018-02-19 05:08:27 +00:00
|
|
|
;; see `spacemacs//python-setup-anaconda-company'
|
|
|
|
))
|
2016-01-18 03:06:04 +00:00
|
|
|
|
2015-01-22 16:22:19 +00:00
|
|
|
(defun python/init-cython-mode ()
|
|
|
|
(use-package cython-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-01-22 16:22:19 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'cython-mode
|
2017-12-30 08:52:46 +00:00
|
|
|
"hh" 'anaconda-mode-show-doc
|
|
|
|
"gu" 'anaconda-mode-find-references))))
|
2015-01-22 16:22:19 +00:00
|
|
|
|
2015-08-09 03:35:16 +00:00
|
|
|
(defun python/post-init-eldoc ()
|
2018-02-19 05:08:27 +00:00
|
|
|
(add-hook 'python-mode-local-vars-hook #'spacemacs//python-setup-eldoc))
|
2014-12-09 03:19:55 +00:00
|
|
|
|
2016-01-18 03:06:04 +00:00
|
|
|
(defun python/post-init-evil-matchit ()
|
|
|
|
(add-hook `python-mode-hook `turn-on-evil-matchit-mode))
|
|
|
|
|
|
|
|
(defun python/post-init-flycheck ()
|
2017-02-14 03:27:29 +00:00
|
|
|
(spacemacs/enable-flycheck 'python-mode))
|
2016-01-18 03:06:04 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun python/pre-init-helm-cscope ()
|
|
|
|
(spacemacs|use-package-add-hook xcscope
|
|
|
|
:post-init
|
|
|
|
(spacemacs/setup-helm-cscope 'python-mode)))
|
2016-01-18 03:06:04 +00:00
|
|
|
|
2017-08-26 21:18:09 +00:00
|
|
|
(defun python/post-init-counsel-gtags ()
|
|
|
|
(spacemacs/counsel-gtags-define-keys-for-mode 'python-mode))
|
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun python/post-init-helm-gtags ()
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'python-mode))
|
|
|
|
|
|
|
|
(defun python/post-init-ggtags ()
|
2016-08-15 19:24:44 +00:00
|
|
|
(add-hook 'python-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun python/init-helm-pydoc ()
|
|
|
|
(use-package helm-pydoc
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-05-30 02:39:21 +00:00
|
|
|
:init
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode "hd" 'helm-pydoc)))
|
2016-01-18 03:06:04 +00:00
|
|
|
|
|
|
|
(defun python/init-hy-mode ()
|
|
|
|
(use-package hy-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-06-17 23:40:49 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2017-06-04 20:00:08 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'hy-mode
|
|
|
|
"si" 'inferior-lisp
|
|
|
|
"sb" 'lisp-load-file
|
|
|
|
"sB" 'switch-to-lisp
|
2017-06-08 00:57:29 +00:00
|
|
|
"ee" 'lisp-eval-last-sexp
|
|
|
|
"ef" 'lisp-eval-defun
|
|
|
|
"eF" 'lisp-eval-defun-and-go
|
|
|
|
"er" 'lisp-eval-region
|
|
|
|
"eR" 'lisp-eval-region-and-go)
|
2017-06-07 10:43:58 +00:00
|
|
|
;; call `spacemacs//python-setup-hy' once, don't put it in a hook (see issue #5988)
|
|
|
|
(spacemacs//python-setup-hy))))
|
2016-01-18 03:06:04 +00:00
|
|
|
|
2018-01-06 02:45:57 +00:00
|
|
|
(defun python/init-importmagic ()
|
|
|
|
(use-package importmagic
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(add-hook 'python-mode-hook 'importmagic-mode)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode
|
|
|
|
"rf" 'importmagic-fix-symbol-at-point))))
|
|
|
|
|
2015-10-29 08:42:37 +00:00
|
|
|
(defun python/init-live-py-mode ()
|
|
|
|
(use-package live-py-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-10-29 08:42:37 +00:00
|
|
|
:commands live-py-mode
|
|
|
|
:init
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode
|
2016-01-31 20:47:32 +00:00
|
|
|
"l" 'live-py-mode)))
|
2015-10-29 08:42:37 +00:00
|
|
|
|
2018-02-19 05:08:27 +00:00
|
|
|
(defun python/init-lsp-python ()
|
|
|
|
(use-package lsp-python
|
|
|
|
:commands lsp-python-enable))
|
|
|
|
|
2016-01-18 03:06:04 +00:00
|
|
|
(defun python/init-nose ()
|
|
|
|
(use-package nose
|
|
|
|
:commands (nosetests-one
|
|
|
|
nosetests-pdb-one
|
|
|
|
nosetests-all
|
|
|
|
nosetests-pdb-all
|
|
|
|
nosetests-module
|
|
|
|
nosetests-pdb-module
|
|
|
|
nosetests-suite
|
|
|
|
nosetests-pdb-suite)
|
2016-10-20 11:18:05 +00:00
|
|
|
:init (spacemacs//bind-python-testing-keys)
|
2016-01-18 03:06:04 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(add-to-list 'nose-project-root-files "setup.cfg")
|
|
|
|
(setq nose-use-verbose nil))))
|
|
|
|
|
2016-04-05 20:41:05 +00:00
|
|
|
(defun python/pre-init-org ()
|
|
|
|
(spacemacs|use-package-add-hook org
|
|
|
|
:post-config (add-to-list 'org-babel-load-languages '(python . t))))
|
|
|
|
|
2018-02-06 11:08:45 +00:00
|
|
|
(defun python/init-pipenv ()
|
|
|
|
(use-package pipenv
|
|
|
|
:commands (pipenv-activate
|
|
|
|
pipenv-deactivate
|
|
|
|
pipenv-shell
|
|
|
|
pipenv-open
|
|
|
|
pipenv-install
|
|
|
|
pipenv-uninstall)
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode
|
|
|
|
"vpa" 'pipenv-activate
|
|
|
|
"vpd" 'pipenv-deactivate
|
|
|
|
"vpi" 'pipenv-install
|
2018-02-24 22:57:06 +00:00
|
|
|
"vpo" 'pipenv-open
|
|
|
|
"vps" 'pipenv-shell
|
2018-02-06 11:08:45 +00:00
|
|
|
"vpu" 'pipenv-uninstall))))
|
|
|
|
|
2015-04-25 03:54:39 +00:00
|
|
|
(defun python/init-pip-requirements ()
|
|
|
|
(use-package pip-requirements
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t))
|
2015-04-25 03:54:39 +00:00
|
|
|
|
2017-03-19 03:45:08 +00:00
|
|
|
(defun python/init-pippel ()
|
|
|
|
(use-package pippel
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2018-01-06 03:15:50 +00:00
|
|
|
:init (spacemacs/set-leader-keys-for-major-mode 'python-mode
|
|
|
|
"P" 'pippel-list-packages)
|
2017-03-19 03:45:08 +00:00
|
|
|
:config
|
|
|
|
(evilified-state-evilify-map pippel-package-menu-mode-map
|
|
|
|
:mode pippel-package-menu-mode)))
|
|
|
|
|
2015-11-07 08:28:26 +00:00
|
|
|
(defun python/init-py-isort ()
|
|
|
|
(use-package py-isort
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-08-21 15:49:20 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(add-hook 'before-save-hook 'spacemacs//python-sort-imports)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode
|
|
|
|
"rI" 'py-isort-buffer))))
|
2015-11-07 08:28:26 +00:00
|
|
|
|
2015-01-30 15:30:10 +00:00
|
|
|
(defun python/init-pyenv-mode ()
|
|
|
|
(use-package pyenv-mode
|
2016-01-24 13:42:59 +00:00
|
|
|
:if (executable-find "pyenv")
|
2015-12-07 12:58:36 +00:00
|
|
|
:commands (pyenv-mode-versions)
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(pcase python-auto-set-local-pyenv-version
|
|
|
|
(`on-visit
|
2016-07-05 04:07:54 +00:00
|
|
|
(spacemacs/add-to-hooks 'spacemacs//pyenv-mode-set-local-version
|
|
|
|
'(python-mode-hook
|
|
|
|
hy-mode-hook)))
|
2015-12-07 12:58:36 +00:00
|
|
|
(`on-project-switch
|
2016-06-06 01:53:14 +00:00
|
|
|
(add-hook 'projectile-after-switch-project-hook
|
|
|
|
'spacemacs//pyenv-mode-set-local-version)))
|
2016-07-18 19:40:40 +00:00
|
|
|
;; setup shell correctly on environment switch
|
|
|
|
(dolist (func '(pyenv-mode-set pyenv-mode-unset))
|
2017-06-07 10:35:52 +00:00
|
|
|
(advice-add func :after 'spacemacs/python-setup-everything))
|
2015-12-07 12:58:36 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode
|
2016-01-09 03:37:35 +00:00
|
|
|
"vu" 'pyenv-mode-unset
|
|
|
|
"vs" 'pyenv-mode-set))))
|
2015-01-30 15:30:10 +00:00
|
|
|
|
2014-12-10 16:30:48 +00:00
|
|
|
(defun python/init-pyvenv ()
|
|
|
|
(use-package pyvenv
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2014-12-09 03:19:55 +00:00
|
|
|
:init
|
2016-06-17 23:40:49 +00:00
|
|
|
(progn
|
2016-10-25 17:25:57 +00:00
|
|
|
(pcase python-auto-set-local-pyvenv-virtualenv
|
|
|
|
(`on-visit
|
|
|
|
(spacemacs/add-to-hooks 'spacemacs//pyvenv-mode-set-local-virtualenv
|
|
|
|
'(python-mode-hook
|
|
|
|
hy-mode-hook)))
|
|
|
|
(`on-project-switch
|
|
|
|
(add-hook 'projectile-after-switch-project-hook
|
|
|
|
'spacemacs//pyvenv-mode-set-local-virtualenv)))
|
2016-07-05 04:07:54 +00:00
|
|
|
(dolist (mode '(python-mode hy-mode))
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
2018-02-06 11:08:45 +00:00
|
|
|
"va" 'pyvenv-activate
|
|
|
|
"vd" 'pyvenv-deactivate
|
|
|
|
"vw" 'pyvenv-workon))
|
2016-07-18 19:40:40 +00:00
|
|
|
;; setup shell correctly on environment switch
|
|
|
|
(dolist (func '(pyvenv-activate pyvenv-deactivate pyvenv-workon))
|
2017-06-07 10:35:52 +00:00
|
|
|
(advice-add func :after 'spacemacs/python-setup-everything)))))
|
2014-12-09 03:19:55 +00:00
|
|
|
|
2016-01-18 03:06:04 +00:00
|
|
|
(defun python/init-pylookup ()
|
|
|
|
(use-package pylookup
|
|
|
|
:commands (pylookup-lookup pylookup-update pylookup-update-all)
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(evilified-state-evilify pylookup-mode pylookup-mode-map)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode
|
2016-02-25 05:17:48 +00:00
|
|
|
"hH" 'pylookup-lookup))
|
2016-01-18 03:06:04 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(let ((dir (configuration-layer/get-layer-local-dir 'python)))
|
|
|
|
(setq pylookup-dir (concat dir "pylookup/")
|
|
|
|
pylookup-program (concat pylookup-dir "pylookup.py")
|
2016-03-01 06:34:34 +00:00
|
|
|
pylookup-db-file (concat pylookup-dir "pylookup.db")))
|
|
|
|
(setq pylookup-completing-read 'completing-read))))
|
2016-01-18 03:06:04 +00:00
|
|
|
|
2015-06-04 09:09:56 +00:00
|
|
|
(defun python/init-pytest ()
|
|
|
|
(use-package pytest
|
|
|
|
:commands (pytest-one
|
|
|
|
pytest-pdb-one
|
|
|
|
pytest-all
|
|
|
|
pytest-pdb-all
|
|
|
|
pytest-module
|
|
|
|
pytest-pdb-module)
|
2016-06-06 01:53:14 +00:00
|
|
|
:init (spacemacs//bind-python-testing-keys)
|
2015-06-08 03:59:23 +00:00
|
|
|
:config (add-to-list 'pytest-project-root-files "setup.cfg")))
|
2015-06-04 09:09:56 +00:00
|
|
|
|
2014-11-10 04:54:10 +00:00
|
|
|
(defun python/init-python ()
|
|
|
|
(use-package python
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-11-13 01:48:32 +00:00
|
|
|
:mode (("SConstruct\\'" . python-mode) ("SConscript\\'" . python-mode))
|
2014-11-10 04:54:10 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2018-02-19 05:08:27 +00:00
|
|
|
(spacemacs/register-repl 'python
|
|
|
|
'spacemacs/python-start-or-switch-repl "python")
|
2017-08-28 14:41:12 +00:00
|
|
|
(add-hook 'inferior-python-mode-hook
|
2018-02-19 05:08:27 +00:00
|
|
|
'spacemacs//inferior-python-setup-hook)
|
|
|
|
(spacemacs/add-to-hook 'python-mode-hook
|
|
|
|
'(spacemacs//python-setup-backend
|
|
|
|
spacemacs//python-default))
|
2017-08-28 14:41:12 +00:00
|
|
|
;; call `spacemacs//python-setup-shell' once, don't put it in a hook
|
|
|
|
;; (see issue #5988)
|
2017-06-07 10:43:58 +00:00
|
|
|
(spacemacs//python-setup-shell))
|
2014-11-10 04:54:10 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; add support for `ahs-range-beginning-of-defun' for python-mode
|
2015-09-29 05:07:57 +00:00
|
|
|
(with-eval-after-load 'auto-highlight-symbol
|
|
|
|
(add-to-list 'ahs-plugin-bod-modes 'python-mode))
|
2014-12-09 03:19:55 +00:00
|
|
|
|
2015-10-26 19:45:28 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'python-mode "mc" "execute")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'python-mode "md" "debug")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'python-mode "mh" "help")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'python-mode "mg" "goto")
|
2017-08-28 14:41:12 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'python-mode "ms" "REPL")
|
2015-10-26 19:45:28 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'python-mode "mr" "refactor")
|
2018-02-06 11:08:45 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'python-mode "mv" "virtualenv")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'python-mode "mvp" "pipenv")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode
|
2017-08-28 14:41:12 +00:00
|
|
|
"'" 'spacemacs/python-start-or-switch-repl
|
2015-11-18 00:38:05 +00:00
|
|
|
"cc" 'spacemacs/python-execute-file
|
|
|
|
"cC" 'spacemacs/python-execute-file-focus
|
2016-06-06 01:53:14 +00:00
|
|
|
"db" 'spacemacs/python-toggle-breakpoint
|
|
|
|
"ri" 'spacemacs/python-remove-unused-imports
|
2017-08-28 14:41:12 +00:00
|
|
|
"sB" 'spacemacs/python-shell-send-buffer-switch
|
2015-11-18 00:38:05 +00:00
|
|
|
"sb" 'python-shell-send-buffer
|
2017-08-28 14:41:12 +00:00
|
|
|
"sF" 'spacemacs/python-shell-send-defun-switch
|
2015-11-18 00:38:05 +00:00
|
|
|
"sf" 'python-shell-send-defun
|
2017-08-28 14:41:12 +00:00
|
|
|
"si" 'spacemacs/python-start-or-switch-repl
|
|
|
|
"sR" 'spacemacs/python-shell-send-region-switch
|
2015-11-18 00:38:05 +00:00
|
|
|
"sr" 'python-shell-send-region)
|
2014-11-10 04:54:10 +00:00
|
|
|
|
2015-05-23 17:19:48 +00:00
|
|
|
;; Emacs users won't need these key bindings
|
2015-05-28 03:49:19 +00:00
|
|
|
;; TODO: make these key bindings dynamic given the current style
|
|
|
|
;; Doing it only at init time won't update it if the user switches style
|
|
|
|
;; Also find a way to generalize these bindings.
|
2015-05-23 17:19:48 +00:00
|
|
|
(when (eq dotspacemacs-editing-style 'vim)
|
|
|
|
;; the default in Emacs is M-n
|
|
|
|
(define-key inferior-python-mode-map (kbd "C-j") 'comint-next-input)
|
2016-04-03 04:35:52 +00:00
|
|
|
;; the default in Emacs is M-p and this key binding overrides
|
|
|
|
;; default C-k which prevents Emacs users to kill line
|
2015-05-23 17:19:48 +00:00
|
|
|
(define-key inferior-python-mode-map (kbd "C-k") 'comint-previous-input)
|
|
|
|
;; the default in Emacs is M-r; C-r to search backward old output
|
|
|
|
;; and should not be changed
|
2016-04-03 04:35:52 +00:00
|
|
|
(define-key inferior-python-mode-map
|
|
|
|
(kbd "C-r") 'comint-history-isearch-backward)
|
2015-05-23 17:19:48 +00:00
|
|
|
;; this key binding is for recentering buffer in Emacs
|
|
|
|
;; it would be troublesome if Emacs user
|
|
|
|
;; Vim users can use this key since they have other key
|
2016-04-03 04:35:52 +00:00
|
|
|
(define-key inferior-python-mode-map
|
|
|
|
(kbd "C-l") 'spacemacs/comint-clear-buffer))
|
2015-05-23 17:19:48 +00:00
|
|
|
|
|
|
|
;; add this optional key binding for Emacs user, since it is unbound
|
2016-04-03 04:35:52 +00:00
|
|
|
(define-key inferior-python-mode-map
|
2016-04-16 02:08:35 +00:00
|
|
|
(kbd "C-c M-l") 'spacemacs/comint-clear-buffer))))
|
2014-11-10 04:54:10 +00:00
|
|
|
|
2015-04-23 14:35:04 +00:00
|
|
|
(defun python/post-init-semantic ()
|
2017-07-02 13:48:06 +00:00
|
|
|
(when (configuration-layer/package-used-p 'anaconda-mode)
|
2016-04-18 18:45:40 +00:00
|
|
|
(add-hook 'python-mode-hook
|
|
|
|
'spacemacs//disable-semantic-idle-summary-mode t))
|
2016-07-05 04:07:54 +00:00
|
|
|
(spacemacs/add-to-hook 'python-mode-hook
|
|
|
|
'(semantic-mode
|
2016-10-15 08:34:11 +00:00
|
|
|
spacemacs//python-imenu-create-index-use-semantic-maybe))
|
2016-04-03 04:35:52 +00:00
|
|
|
(defadvice semantic-python-get-system-include-path
|
|
|
|
(around semantic-python-skip-error-advice activate)
|
2015-05-21 14:18:02 +00:00
|
|
|
"Don't cause error when Semantic cannot retrieve include
|
|
|
|
paths for Python then prevent the buffer to be switched. This
|
|
|
|
issue might be fixed in Emacs 25. Until then, we need it here to
|
|
|
|
fix this issue."
|
2016-02-24 15:32:45 +00:00
|
|
|
(condition-case-unless-debug nil
|
2015-05-21 14:18:02 +00:00
|
|
|
ad-do-it
|
|
|
|
(error nil))))
|
2015-04-23 14:35:04 +00:00
|
|
|
|
2016-01-18 03:06:04 +00:00
|
|
|
(defun python/post-init-smartparens ()
|
2016-07-05 04:07:54 +00:00
|
|
|
(spacemacs/add-to-hooks 'smartparens-mode '(inferior-python-mode-hook
|
|
|
|
hy-mode-hook))
|
2016-01-18 03:06:04 +00:00
|
|
|
(defadvice python-indent-dedent-line-backspace
|
|
|
|
(around python/sp-backward-delete-char activate)
|
|
|
|
(let ((pythonp (or (not smartparens-strict-mode)
|
|
|
|
(char-equal (char-before) ?\s))))
|
|
|
|
(if pythonp
|
|
|
|
ad-do-it
|
|
|
|
(call-interactively 'sp-backward-delete-char)))))
|
|
|
|
|
2015-04-16 10:43:10 +00:00
|
|
|
(defun python/post-init-stickyfunc-enhance ()
|
2018-01-18 04:03:00 +00:00
|
|
|
(add-hook 'python-mode-hook 'spacemacs/load-stickyfunc-enhance))
|
2015-07-24 02:20:25 +00:00
|
|
|
|
|
|
|
(defun python/pre-init-xcscope ()
|
|
|
|
(spacemacs|use-package-add-hook xcscope
|
|
|
|
:post-init
|
2016-07-05 04:07:54 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode
|
|
|
|
"gi" 'cscope/run-pycscope)))
|
2016-08-07 14:33:12 +00:00
|
|
|
|
|
|
|
(defun python/init-yapfify ()
|
|
|
|
(use-package yapfify
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-11-21 23:32:00 +00:00
|
|
|
:init
|
2016-11-22 05:02:08 +00:00
|
|
|
(progn
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'python-mode
|
|
|
|
"=" 'yapfify-buffer)
|
|
|
|
(when python-enable-yapf-format-on-save
|
2017-04-13 03:18:42 +00:00
|
|
|
(add-hook 'python-mode-hook 'yapf-mode)))
|
|
|
|
:config (spacemacs|hide-lighter yapf-mode)))
|