2015-04-25 03:25:04 +00:00
|
|
|
;;; config.el --- Python Layer Configuration File for Spacemacs
|
2015-01-30 15:30:10 +00:00
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-01-30 15:30:10 +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-01 02:24:01 +00:00
|
|
|
;; variables
|
|
|
|
|
2015-04-09 03:57:22 +00:00
|
|
|
(spacemacs|defvar-company-backends python-mode)
|
Enable company in Python REPL for code completion
- Company should be enabled in Python REPL for displaying completion
candidates. Note that in Python REPL, we must use company-capf to
display the candidates from Python REPL, since in the REPL it uses
completion-at-point to display candidates from the REPL. Also, we
locally set company-minimum-prefix-length to 0, so that completion
starts immediately after the first character. We also need to set the
idle delay a bit higher (0.5) compared with Spacemacs default (0.2),
since setting it too low may cause company unable to retrieve completion
candidates.
- Anaconda should NOT be enabled in Python REPL for retrieving proper
completion candidates. This can be tested in Python REPL: when
anaconda-mode is enabled and without any prefix string before point, run
the command completion-at-point (bound to C-M-i by default), completion
candidates from Anaconda are displayed but NOT the ones from the real
REPL. So, when you import a module i.e. os and try to access the
functions in the module with "os." prefix, nothing inside the module is
displayed because Anaconda does not work in Python REPL. When
anaconda-mode is disabled, candidates in "os." are displayed properly
with company-capf. company-anaconda backend cannot be used in Python
REPL since it is buggy: it cannot retrieve any prefix before point and
narrow properly.
2015-05-21 05:39:57 +00:00
|
|
|
(spacemacs|defvar-company-backends inferior-python-mode)
|
2015-04-25 03:54:39 +00:00
|
|
|
(spacemacs|defvar-company-backends pip-requirements-mode)
|
2015-04-09 03:57:22 +00:00
|
|
|
|
2016-09-05 02:29:41 +00:00
|
|
|
(spacemacs|define-jump-handlers python-mode)
|
|
|
|
(spacemacs|define-jump-handlers cython-mode anaconda-mode-goto)
|
|
|
|
|
2015-04-22 04:02:23 +00:00
|
|
|
(defvar python-enable-yapf-format-on-save nil
|
|
|
|
"If non-nil, automatically format code with YAPF on save.")
|
|
|
|
|
2015-06-08 03:59:23 +00:00
|
|
|
(defvar python-test-runner 'nose
|
|
|
|
"Test runner to use. Possible values are `nose' or `pytest'.")
|
2015-09-21 23:29:23 +00:00
|
|
|
|
|
|
|
(defvar python-fill-column 79
|
|
|
|
"Fill column value for python buffers")
|
2015-12-07 12:58:36 +00:00
|
|
|
|
2016-10-11 18:01:01 +00:00
|
|
|
(defvar python-tab-width 4
|
|
|
|
"Tab width value for python buffers")
|
|
|
|
|
2015-12-07 12:58:36 +00:00
|
|
|
(defvar python-auto-set-local-pyenv-version 'on-visit
|
|
|
|
"Automatically set pyenv version from \".python-version\".
|
|
|
|
|
|
|
|
Possible values are `on-visit', `on-project-switch' or `nil'.")
|
2015-11-07 08:28:26 +00:00
|
|
|
|
2016-10-25 17:25:57 +00:00
|
|
|
(defvar python-auto-set-local-pyvenv-virtualenv 'on-visit
|
|
|
|
"Automatically set pyvenv virtualenv from \".venv\".
|
|
|
|
|
|
|
|
Possible values are `on-visit', `on-project-switch' or `nil'.")
|
|
|
|
|
2016-08-21 15:49:20 +00:00
|
|
|
(defvar python-sort-imports-on-save nil
|
2015-11-07 08:28:26 +00:00
|
|
|
"If non-nil, automatically sort imports on save.")
|