python: replace anaconda (completion) with jedi
This commit is contained in:
parent
1d16d33981
commit
6edf8e2821
2 changed files with 23 additions and 15 deletions
1
Cask
1
Cask
|
@ -169,6 +169,7 @@
|
||||||
;; Python -- modules/module-python.el
|
;; Python -- modules/module-python.el
|
||||||
(depends-on "anaconda-mode")
|
(depends-on "anaconda-mode")
|
||||||
(depends-on "nose")
|
(depends-on "nose")
|
||||||
|
(depends-on "company-jedi")
|
||||||
|
|
||||||
;; Ruby -- modules/module-regex.el
|
;; Ruby -- modules/module-regex.el
|
||||||
(depends-on "pcre2el")
|
(depends-on "pcre2el")
|
||||||
|
|
|
@ -1,22 +1,32 @@
|
||||||
;;; module-python.el
|
;;; module-python.el
|
||||||
|
|
||||||
(use-package python
|
(use-package python
|
||||||
:mode ("\\.py\\'" . python-mode)
|
:mode ("\\.py\\'" . python-mode)
|
||||||
:interpreter ("python" . python-mode)
|
:interpreter ("python" . python-mode)
|
||||||
:commands python-mode
|
:commands python-mode
|
||||||
:init
|
:init
|
||||||
(add-hook! python-mode '(narf|enable-tab-width-4 emr-initialize flycheck-mode))
|
(add-hook! python-mode '(narf|enable-tab-width-4 emr-initialize flycheck-mode))
|
||||||
(setq python-indent-offset 4
|
(setq-default
|
||||||
python-environment-directory narf-temp-dir
|
python-indent-offset 4
|
||||||
python-shell-interpreter "ipython")
|
python-environment-directory narf-temp-dir
|
||||||
|
python-shell-interpreter "ipython")
|
||||||
:config
|
:config
|
||||||
(define-env-command! python-mode "python --version | cut -d' ' -f2")
|
(define-env-command! python-mode "python --version | cut -d' ' -f2")
|
||||||
(define-key python-mode-map (kbd "DEL") nil)) ; interferes with smartparens
|
|
||||||
|
;; interferes with smartparens
|
||||||
|
(define-key python-mode-map (kbd "DEL") nil)
|
||||||
|
|
||||||
|
(after! company
|
||||||
|
(require 'company-jedi)
|
||||||
|
(unless (file-exists-p (concat python-environment-directory python-environment-default-root-name))
|
||||||
|
(jedi:install-server))
|
||||||
|
(define-company-backend! python-mode (jedi))))
|
||||||
|
|
||||||
(use-package nose
|
(use-package nose
|
||||||
:commands nose-mode
|
:commands nose-mode
|
||||||
:preface (defvar nose-mode-map (make-sparse-keymap))
|
:preface (defvar nose-mode-map (make-sparse-keymap))
|
||||||
:init (associate! nose-mode :pattern "/test_.+\\.py\\'")
|
:init
|
||||||
|
(associate! nose-mode :pattern "/test_.+\\.py\\'")
|
||||||
:config
|
:config
|
||||||
(bind! :map nose-mode-map
|
(bind! :map nose-mode-map
|
||||||
(:prefix ","
|
(:prefix ","
|
||||||
|
@ -32,17 +42,14 @@
|
||||||
:diminish anaconda-mode
|
:diminish anaconda-mode
|
||||||
:defines (anaconda-mode-map anaconda-nav-mode-map)
|
:defines (anaconda-mode-map anaconda-nav-mode-map)
|
||||||
:functions (anaconda-mode-running-p)
|
:functions (anaconda-mode-running-p)
|
||||||
:init (add-hook! python-mode '(anaconda-mode eldoc-mode))
|
:init
|
||||||
|
(add-hook! python-mode '(anaconda-mode eldoc-mode))
|
||||||
:config
|
:config
|
||||||
(bind! :map anaconda-mode-map :m "gd" 'anaconda-mode-goto-definitions)
|
(bind! :map anaconda-mode-map :m "gd" 'anaconda-mode-goto-definitions)
|
||||||
(bind! :map anaconda-nav-mode-map :n [escape] 'anaconda-nav-quit)
|
(bind! :map anaconda-nav-mode-map :n [escape] 'anaconda-nav-quit)
|
||||||
|
|
||||||
(advice-add 'anaconda-mode-doc-buffer :after 'narf*anaconda-mode-doc-buffer)
|
(advice-add 'anaconda-mode-doc-buffer :after 'narf*anaconda-mode-doc-buffer)
|
||||||
|
|
||||||
(after! company
|
|
||||||
(require 'company-anaconda)
|
|
||||||
(define-company-backend! python-mode (anaconda)))
|
|
||||||
|
|
||||||
(after! emr
|
(after! emr
|
||||||
(mapc (lambda (x)
|
(mapc (lambda (x)
|
||||||
(let ((command-name (car x))
|
(let ((command-name (car x))
|
||||||
|
@ -50,8 +57,8 @@
|
||||||
(region-p (caddr x))
|
(region-p (caddr x))
|
||||||
predicate)
|
predicate)
|
||||||
(setq predicate (lambda () (and (anaconda-mode-running-p)
|
(setq predicate (lambda () (and (anaconda-mode-running-p)
|
||||||
(not (use-region-p))
|
(not (use-region-p))
|
||||||
(not (sp-point-in-string-or-comment)))))
|
(not (sp-point-in-string-or-comment)))))
|
||||||
(emr-declare-command (intern (format "anaconda-mode-%s" (symbol-name command-name)))
|
(emr-declare-command (intern (format "anaconda-mode-%s" (symbol-name command-name)))
|
||||||
:title title :modes 'python-mode :predicate predicate)))
|
:title title :modes 'python-mode :predicate predicate)))
|
||||||
'((view-doc "view documentation" t)
|
'((view-doc "view documentation" t)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue