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))
|
(cur-point (point))
|
||||||
(region-cons (and has-region (cons reg-beg reg-end)))
|
(region-cons (and has-region (cons reg-beg reg-end)))
|
||||||
(buf (current-buffer))
|
(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))
|
(when has-region (deactivate-mark))
|
||||||
(message "ellie: completing...")
|
(message "ellie: completing...")
|
||||||
(let* ((process-environment
|
(let* ((json-payload (json-encode
|
||||||
(append (list (concat "OLLIE=" ellie-mount-directory))
|
`((cwd . ,(expand-file-name default-directory))
|
||||||
process-environment))
|
(file . ,(file-name-nondirectory filename))
|
||||||
(cmd (format "%s -file %s -suffix %s -model %s -backend %s"
|
(prefix . ,prefix)
|
||||||
(shell-quote-argument ucomplete)
|
(suffix . ,suffix)
|
||||||
(shell-quote-argument (file-name-nondirectory filename))
|
(context . ""))))
|
||||||
(shell-quote-argument suffix)
|
|
||||||
(shell-quote-argument ellie-complete-model)
|
|
||||||
(shell-quote-argument ellie-complete-backend)))
|
|
||||||
(proc-buf (generate-new-buffer " *ellie-complete*")))
|
(proc-buf (generate-new-buffer " *ellie-complete*")))
|
||||||
(when ellie--complete-timer (cancel-timer ellie--complete-timer))
|
(when ellie--complete-timer (cancel-timer ellie--complete-timer))
|
||||||
(set-process-sentinel
|
(set-process-sentinel
|
||||||
(start-process-shell-command "ellie-complete" proc-buf
|
(start-process-shell-command
|
||||||
(format "printf '%%s' %s | %s"
|
"ellie-complete" proc-buf
|
||||||
(shell-quote-argument prefix) cmd))
|
(format "printf '%%s' %s | 9p rdwr %s"
|
||||||
|
(shell-quote-argument json-payload)
|
||||||
|
(shell-quote-argument complete-path)))
|
||||||
(lambda (proc _event)
|
(lambda (proc _event)
|
||||||
(when (eq (process-status proc) 'exit)
|
(when (eq (process-status proc) 'exit)
|
||||||
(let ((result (string-trim-right
|
(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)))
|
(string-empty-p (string-trim result)))
|
||||||
(message "ellie: empty completion")
|
(message "ellie: empty completion")
|
||||||
(ellie--ghost-show result cur-point buf region-cons)
|
(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
|
;;;###autoload
|
||||||
(define-key global-map (kbd "M-/") #'ellie-complete)
|
(define-key global-map (kbd "M-/") #'ellie-complete)
|
||||||
|
|
|
||||||
Reference in New Issue