<commit_before>;;; packages.el --- Python Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2016 <NAME> & Contributors
;;
;; Author: <NAME> <<EMAIL>>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(setq python-packages
  '(
    anaconda-mode
    company
    company-anaconda
    cython-mode
    eldoc
    evil-matchit
    flycheck
    helm-cscope
    helm-pydoc
    hy-mode
    (nose :location local)
    live-py-mode
    pip-requirements
    pyenv-mode
    (pylookup :location local)
    pytest
    python
    pyvenv
    (py-yapf :location local)
    semantic
    smartparens
    stickyfunc-enhance
    xcscope
    ))

(defun python/init-anaconda-mode ()
  (use-package anaconda-mode
    :defer t
    :init
    (progn
      (setq anaconda-mode-installation-directory
            (concat spacemacs-cache-directory "anaconda-mode"))
      (add-hook 'python-mode-hook 'anaconda-mode))
    :config
    (progn
      (spacemacs/set-leader-keys-for-major-mode 'python-mode
        "hh" 'anaconda-mode-show-doc
        "gg" 'anaconda-mode-find-definitions
        "ga" 'anaconda-mode-find-assignments
        "gb" 'anaconda-mode-go-back
        "gu" 'anaconda-mode-find-references)
      (evilified-state-evilify anaconda-mode-view-mode anaconda-mode-view-mode-map
        (kbd "q") 'quit-window)
      (spacemacs|hide-lighter anaconda-mode)

      (defadvice anaconda-mode-goto (before python/anaconda-mode-goto activate)
        (evil--jumps-push)))))

(when (configuration-layer/layer-usedp 'auto-completion)
  (defun python/post-init-company ()
    (spacemacs|add-company-hook python-mode)
    (spacemacs|add-company-hook inferior-python-mode)
    (push '(company-files company-capf) company-backends-inferior-python-mode)
    (add-hook 'inferior-python-mode-hook (lambda ()
                                           (setq-local company-minimum-prefix-length 0)
                                           (setq-local company-idle-delay 0.5))))

  (defun python/init-company-anaconda ()
    (use-package company-anaconda
      :if (configuration-layer/package-usedp 'company)
      :defer t
      :init
      (push 'company-anaconda company-backends-python-mode))))


(defun python/init-cython-mode ()
  (use-package cython-mode
    :defer t
    :init
    (progn
      (spacemacs/set-leader-keys-for-major-mode 'cython-mode
        "hh" 'anaconda-mode-view-doc
        "gg" 'anaconda-mode-goto
        "gu" 'anaconda-mode-usages))))

(defun python/post-init-eldoc ()
  (defun spacemacs//init-eldoc-python-mode ()
    (eldoc-mode)
    (when (configuration-layer/package-usedp 'anaconda-mode)
      (anaconda-eldoc-mode)))
  (add-hook 'python-mode-hook 'spacemacs//init-eldoc-python-mode))

(defun python/post-init-evil-matchit ()
  (add-hook `python-mode-hook `turn-on-evil-matchit-mode))

(defun python/post-init-flycheck ()
  (spacemacs/add-flycheck-hook 'python-mode))

(when (configuration-layer/layer-usedp 'spacemacs-helm)
  (defun python/pre-init-helm-cscope ()
    (spacemacs|use-package-add-hook xcscope
      :post-init
      (spacemacs/setup-helm-cscope 'python-mode))))

(when (configuration-layer/layer-usedp 'spacemacs-helm)
  (defun python/init-helm-pydoc ()
    (use-package helm-pydoc
      :defer t
      :init
      (spacemacs/set-leader-keys-for-major-mode 'python-mode "hd" 'helm-pydoc))))

(defun python/init-hy-mode ()
  (use-package hy-mode
    :defer t))

(defun python/init-live-py-mode ()
  (use-package live-py-mode
    :defer t
    :commands live-py-mode
    :init
    (spacemacs/set-leader-keys-for-major-mode 'python-mode
      "l" 'live-py-mode)))

(defun python/init-nose ()
  (use-package nose
    :if (eq 'nose python-test-runner)
    :commands (nosetests-one
               nosetests-pdb-one
               nosetests-all
               nosetests-pdb-all
               nosetests-module
               nosetests-pdb-module
               nosetests-suite
               nosetests-pdb-suite)
    :init
    (spacemacs/set-leader-keys-for-major-mode 'python-mode
      "tA" 'nosetests-pdb-all
      "ta" 'nosetests-all
      "tB" 'nosetests-pdb-module
      "tb" 'nosetests-module
      "tT" 'nosetests-pdb-one
      "tt" 'nosetests-one
      "tM" 'nosetests-pdb-module
      "tm" 'nosetests-module
      "tS" 'nosetests-pdb-suite
      "ts" 'nosetests-suite)
    :config
    (progn
      (add-to-list 'nose-project-root-files "setup.cfg")
      (setq nose-use-verbose nil))))

(defun python/init-pip-requirements ()
  (use-package pip-requirements
    :defer t
    :init
    (progn
      ;; company support
      (push 'company-capf company-backends-pip-requirements-mode)
      (spacemacs|add-company-hook pip-requirements-mode))))

(defun python/init-pyenv-mode ()
  (use-package pyenv-mode
    :if (executable-find "pyenv")
    :commands (pyenv-mode-versions)
    :init
    (progn
      (pcase python-auto-set-local-pyenv-version
       (`on-visit
        (add-hook 'python-mode-hook 'pyenv-mode-set-local-version))
       (`on-project-switch
        (add-hook 'projectile-after-switch-project-hook 'pyenv-mode-set-local-version)))
      (spacemacs/set-leader-keys-for-major-mode 'python-mode
        "vu" 'pyenv-mode-unset
        "vs" 'pyenv-mode-set))))


(defun python/init-pyvenv ()
  (use-package pyvenv
    :defer t
    :init
    (spacemacs/set-leader-keys-for-major-mode 'python-mode
      "Va" 'pyvenv-activate
      "Vd" 'pyvenv-deactivate
      "Vw" 'pyvenv-workon)))

(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
        "mhH" 'pylookup-lookup))
    :config
    (progn
      (let ((dir (configuration-layer/get-layer-local-dir 'python)))
        (setq pylookup-dir (concat dir "pylookup/")
              pylookup-program (concat pylookup-dir "pylookup.py")
              pylookup-db-file (concat pylookup-dir "pylookup.db"))))))

(defun python/init-pytest ()
  (use-package pytest
    :if (eq 'pytest python-test-runner)
    :defer t
    :commands (pytest-one
               pytest-pdb-one
               pytest-all
               pytest-pdb-all
               pytest-module
               pytest-pdb-module)
    :init (spacemacs/set-leader-keys-for-major-mode 'python-mode<commit_msg>Fix pylookup binding<commit_after>;;; packages.el --- Python Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2016 <NAME> & Contributors
;;
;; Author: <NAME> <<EMAIL>>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(setq python-packages
  '(
    anaconda-mode
    company
    company-anaconda
    cython-mode
    eldoc
    evil-matchit
    flycheck
    helm-cscope
    helm-pydoc
    hy-mode
    (nose :location local)
    live-py-mode
    pip-requirements
    pyenv-mode
    (pylookup :location local)
    pytest
    python
    pyvenv
    (py-yapf :location local)
    semantic
    smartparens
    stickyfunc-enhance
    xcscope
    ))

(defun python/init-anaconda-mode ()
  (use-package anaconda-mode
    :defer t
    :init
    (progn
      (setq anaconda-mode-installation-directory
            (concat spacemacs-cache-directory "anaconda-mode"))
      (add-hook 'python-mode-hook 'anaconda-mode))
    :config
    (progn
      (spacemacs/set-leader-keys-for-major-mode 'python-mode
        "hh" 'anaconda-mode-show-doc
        "gg" 'anaconda-mode-find-definitions
        "ga" 'anaconda-mode-find-assignments
        "gb" 'anaconda-mode-go-back
        "gu" 'anaconda-mode-find-references)
      (evilified-state-evilify anaconda-mode-view-mode anaconda-mode-view-mode-map
        (kbd "q") 'quit-window)
      (spacemacs|hide-lighter anaconda-mode)

      (defadvice anaconda-mode-goto (before python/anaconda-mode-goto activate)
        (evil--jumps-push)))))

(when (configuration-layer/layer-usedp 'auto-completion)
  (defun python/post-init-company ()
    (spacemacs|add-company-hook python-mode)
    (spacemacs|add-company-hook inferior-python-mode)
    (push '(company-files company-capf) company-backends-inferior-python-mode)
    (add-hook 'inferior-python-mode-hook (lambda ()
                                           (setq-local company-minimum-prefix-length 0)
                                           (setq-local company-idle-delay 0.5))))

  (defun python/init-company-anaconda ()
    (use-package company-anaconda
      :if (configuration-layer/package-usedp 'company)
      :defer t
      :init
      (push 'company-anaconda company-backends-python-mode))))


(defun python/init-cython-mode ()
  (use-package cython-mode
    :defer t
    :init
    (progn
      (spacemacs/set-leader-keys-for-major-mode 'cython-mode
        "hh" 'anaconda-mode-view-doc
        "gg" 'anaconda-mode-goto
        "gu" 'anaconda-mode-usages))))

(defun python/post-init-eldoc ()
  (defun spacemacs//init-eldoc-python-mode ()
    (eldoc-mode)
    (when (configuration-layer/package-usedp 'anaconda-mode)
      (anaconda-eldoc-mode)))
  (add-hook 'python-mode-hook 'spacemacs//init-eldoc-python-mode))

(defun python/post-init-evil-matchit ()
  (add-hook `python-mode-hook `turn-on-evil-matchit-mode))

(defun python/post-init-flycheck ()
  (spacemacs/add-flycheck-hook 'python-mode))

(when (configuration-layer/layer-usedp 'spacemacs-helm)
  (defun python/pre-init-helm-cscope ()
    (spacemacs|use-package-add-hook xcscope
      :post-init
      (spacemacs/setup-helm-cscope 'python-mode))))

(when (configuration-layer/layer-usedp 'spacemacs-helm)
  (defun python/init-helm-pydoc ()
    (use-package helm-pydoc
      :defer t
      :init
      (spacemacs/set-leader-keys-for-major-mode 'python-mode "hd" 'helm-pydoc))))

(defun python/init-hy-mode ()
  (use-package hy-mode
    :defer t))

(defun python/init-live-py-mode ()
  (use-package live-py-mode
    :defer t
    :commands live-py-mode
    :init
    (spacemacs/set-leader-keys-for-major-mode 'python-mode
      "l" 'live-py-mode)))

(defun python/init-nose ()
  (use-package nose
    :if (eq 'nose python-test-runner)
    :commands (nosetests-one
               nosetests-pdb-one
               nosetests-all
               nosetests-pdb-all
               nosetests-module
               nosetests-pdb-module
               nosetests-suite
               nosetests-pdb-suite)
    :init
    (spacemacs/set-leader-keys-for-major-mode 'python-mode
      "tA" 'nosetests-pdb-all
      "ta" 'nosetests-all
      "tB" 'nosetests-pdb-module
      "tb" 'nosetests-module
      "tT" 'nosetests-pdb-one
      "tt" 'nosetests-one
      "tM" 'nosetests-pdb-module
      "tm" 'nosetests-module
      "tS" 'nosetests-pdb-suite
      "ts" 'nosetests-suite)
    :config
    (progn
      (add-to-list 'nose-project-root-files "setup.cfg")
      (setq nose-use-verbose nil))))

(defun python/init-pip-requirements ()
  (use-package pip-requirements
    :defer t
    :init
    (progn
      ;; company support
      (push 'company-capf company-backends-pip-requirements-mode)
      (spacemacs|add-company-hook pip-requirements-mode))))

(defun python/init-pyenv-mode ()
  (use-package pyenv-mode
    :if (executable-find "pyenv")
    :commands (pyenv-mode-versions)
    :init
    (progn
      (pcase python-auto-set-local-pyenv-version
       (`on-visit
        (add-hook 'python-mode-hook 'pyenv-mode-set-local-version))
       (`on-project-switch
        (add-hook 'projectile-after-switch-project-hook 'pyenv-mode-set-local-version)))
      (spacemacs/set-leader-keys-for-major-mode 'python-mode
        "vu" 'pyenv-mode-unset
        "vs" 'pyenv-mode-set))))


(defun python/init-pyvenv ()
  (use-package pyvenv
    :defer t
    :init
    (spacemacs/set-leader-keys-for-major-mode 'python-mode
      "Va" 'pyvenv-activate
      "Vd" 'pyvenv-deactivate
      "Vw" 'pyvenv-workon)))

(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
        "hH" 'pylookup-lookup))
    :config
    (progn
      (let ((dir (configuration-layer/get-layer-local-dir 'python)))
        (setq pylookup-dir (concat dir "pylookup/")
              pylookup-program (concat pylookup-dir "pylookup.py")
              pylookup-db-file (concat pylookup-dir "pylookup.db"))))))

(defun python/init-pytest ()
  (use-package pytest
    :if (eq 'pytest python-test-runner)
    :defer t
    :commands (pytest-one
               pytest-pdb-one
               pytest-all
               pytest-pdb-all
               pytest-module
               pytest-pdb-module)
    :init (spacemacs/set-leader-keys-for-major-mode 'python-mode
{'fraction_non_alphanumeric': 0.1375233354075918, 'fraction_numerical': 0.0021779713752333543, 'mean_word_length': 2.4496914408371344, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1662184', 'n_tokens_mistral': 4723, 'n_tokens_neox': 4646, 'n_words': 759}