mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 01:21:38 -05:00
EIN, Company, Jedi, and connected buffers
Not sure if it is really doing anything, but ein:use-company-jedi-backend is now a valid setting for ein:completion-backends. More useful is that connected buffers now use ein's company completeion backend, so completion should now work across all backends all across ein. Now let's get something working in org!
This commit is contained in:
parent
c65c21403e
commit
91d78370d3
3 changed files with 33 additions and 12 deletions
|
@ -33,6 +33,8 @@
|
|||
(require 'deferred)
|
||||
(require 'ein-core)
|
||||
|
||||
;; Duplicates ein:jedi--completer-complete in ein-jedi.
|
||||
;; Let's refactor and enhance our calm!
|
||||
(defun ein:company--deferred-complete ()
|
||||
(let ((d (deferred:new #'identity))
|
||||
(kernel (ein:get-kernel)))
|
||||
|
@ -47,7 +49,7 @@
|
|||
(deferred:callback-post d (list nil nil)))
|
||||
d))
|
||||
|
||||
(defun ein:company--complete (fetcher-callback &optional use-jedi)
|
||||
(defun ein:company--complete (fetcher-callback)
|
||||
(deferred:$
|
||||
(deferred:next
|
||||
(lambda ()
|
||||
|
@ -56,6 +58,22 @@
|
|||
(lambda (replies)
|
||||
(ein:completions--prepare-matches fetcher-callback replies)))))
|
||||
|
||||
(defun ein:company--complete-jedi (fetcher-callback)
|
||||
(deferred:$
|
||||
(deferred:parallel
|
||||
(jedi:complete-request)
|
||||
(ein:company--deferred-complete))
|
||||
(deferred:nextc it
|
||||
(lambda (replies)
|
||||
(ein:completions--prepare-matches-jedi fetcher-callback replies)))))
|
||||
|
||||
(defun ein:completions--prepare-matches-jedi (cb replies)
|
||||
(destructuring-bind
|
||||
(_ ((&key matches &allow-other-keys) ; :complete_reply
|
||||
_))
|
||||
replies
|
||||
(funcall cb matches)))
|
||||
|
||||
(defun ein:completions--prepare-matches (cb replies)
|
||||
(destructuring-bind
|
||||
((&key matched_text matches &allow-other-keys) ; :complete_reply
|
||||
|
@ -102,14 +120,13 @@
|
|||
(funcall callback pdef))
|
||||
(error (funcall callback ""))))))))
|
||||
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun ein:company-backend (command &optional arg &rest _)
|
||||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'ein:company-backend) )
|
||||
(prefix (and (--filter (and (boundp it) (symbol-value it) (eql it 'ein:notebook-minor-mode))
|
||||
(prefix (and (--filter (and (boundp it) (symbol-value it) (or (eql it 'ein:notebook-minor-mode)
|
||||
(eql it 'ein:connect-mode)))
|
||||
minor-mode-list)
|
||||
(ein:object-at-point)))
|
||||
(annotation (if ein:allow-company-annotations
|
||||
|
@ -129,9 +146,13 @@
|
|||
(candidates () (lexical-let ((kernel (ein:get-kernel-or-error))
|
||||
(col (current-column)))
|
||||
(unless (ein:company-backend--punctuation-check (thing-at-point 'line) col)
|
||||
(cons :async
|
||||
(lambda (cb)
|
||||
(ein:company--complete cb))))))))
|
||||
(case ein:completion-backend
|
||||
(ein:use-company-jedi-backend
|
||||
(cons :async (lambda (cb)
|
||||
(ein:company--complete-jedi cb))))
|
||||
(t (cons :async
|
||||
(lambda (cb)
|
||||
(ein:company--complete cb))))))))))
|
||||
|
||||
;; (ein:kernel-complete kernel
|
||||
;; (thing-at-point 'line)
|
||||
|
|
|
@ -403,9 +403,10 @@ notebook."
|
|||
(auto-complete-mode +1))
|
||||
(ein:use-ac-jedi-backend (ein:jedi-complete-on-dot-install ein:connect-mode-map)
|
||||
(auto-complete-mode +1))
|
||||
(ein:use-company-backend (company-mode +1))
|
||||
(ein:use-company-jedi-backend (warn "Support for jedi+company currently not implemented. Defaulting to just company-mode")
|
||||
(company-mode +1))
|
||||
(ein:use-company-backend (company-mode +1)
|
||||
(add-to-list 'company-backends 'ein:company-backend))
|
||||
(ein:use-company-jedi-backend (company-mode +1)
|
||||
(add-to-list 'company-backends 'ein:company-backend))
|
||||
|
||||
(t (warn "No autocompletion backend has been selected - see `ein:completion-backend'."))))
|
||||
|
||||
|
|
|
@ -101,8 +101,7 @@ When this option is enabled, cached omni completion is available."
|
|||
(ein:ac-config-once ein:use-auto-complete-superpack))
|
||||
(ein:use-company-backend (require 'ein-company)
|
||||
(add-to-list 'company-backends 'ein:company-backend))
|
||||
(ein:use-company-jedi-backend (warn "Support for jedi+company currently not implemented. Defaulting to just company-mode")
|
||||
(require 'ein-company)
|
||||
(ein:use-company-jedi-backend (require 'ein-company)
|
||||
(add-to-list 'company-backends 'ein:company-backend))
|
||||
(ein:use-custom-backend (warn "Automatic configuration of autocompletiong for EIN is disabled."))
|
||||
(t (if (and (boundp 'ein:use-auto-complete)
|
||||
|
|
Loading…
Add table
Reference in a new issue