ellie-complete: use /complete endpoint via 9p rdwr
This commit is contained in:
parent
d97f4c4f42
commit
09d86f7a99
30
ellie.el
30
ellie.el
|
|
@ -699,24 +699,26 @@ Calling again while a suggestion is showing requests a new one."
|
|||
(cur-point (point))
|
||||
(region-cons (and has-region (cons reg-beg reg-end)))
|
||||
(buf (current-buffer))
|
||||
(ucomplete (expand-file-name "u/complete" ellie-mount-directory)))
|
||||
(complete-path (concat (file-name-as-directory
|
||||
(or (getenv "NAMESPACE")
|
||||
(expand-file-name "ns" (or (getenv "TMPDIR") "/tmp"))))
|
||||
"ollie/complete")))
|
||||
(when has-region (deactivate-mark))
|
||||
(message "ellie: completing...")
|
||||
(let* ((process-environment
|
||||
(append (list (concat "OLLIE=" ellie-mount-directory))
|
||||
process-environment))
|
||||
(cmd (format "%s -file %s -suffix %s -model %s -backend %s"
|
||||
(shell-quote-argument ucomplete)
|
||||
(shell-quote-argument (file-name-nondirectory filename))
|
||||
(shell-quote-argument suffix)
|
||||
(shell-quote-argument ellie-complete-model)
|
||||
(shell-quote-argument ellie-complete-backend)))
|
||||
(let* ((json-payload (json-encode
|
||||
`((cwd . ,(expand-file-name default-directory))
|
||||
(file . ,(file-name-nondirectory filename))
|
||||
(prefix . ,prefix)
|
||||
(suffix . ,suffix)
|
||||
(context . ""))))
|
||||
(proc-buf (generate-new-buffer " *ellie-complete*")))
|
||||
(when ellie--complete-timer (cancel-timer ellie--complete-timer))
|
||||
(set-process-sentinel
|
||||
(start-process-shell-command "ellie-complete" proc-buf
|
||||
(format "printf '%%s' %s | %s"
|
||||
(shell-quote-argument prefix) cmd))
|
||||
(start-process-shell-command
|
||||
"ellie-complete" proc-buf
|
||||
(format "printf '%%s' %s | 9p rdwr %s"
|
||||
(shell-quote-argument json-payload)
|
||||
(shell-quote-argument complete-path)))
|
||||
(lambda (proc _event)
|
||||
(when (eq (process-status proc) 'exit)
|
||||
(let ((result (string-trim-right
|
||||
|
|
@ -728,7 +730,7 @@ Calling again while a suggestion is showing requests a new one."
|
|||
(string-empty-p (string-trim result)))
|
||||
(message "ellie: empty completion")
|
||||
(ellie--ghost-show result cur-point buf region-cons)
|
||||
(message "ellie: TAB/RET accept · M-/ retry · any key dismiss"))))))))))
|
||||
(message "ellie: TAB/RET accept · M-/ retry · any key dismiss")))))))))))
|
||||
|
||||
;;;###autoload
|
||||
(define-key global-map (kbd "M-/") #'ellie-complete)
|
||||
|
|
|
|||
Reference in New Issue