Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions copilot.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

(require 'cl-lib)
(require 'compile)
(require 'files)
(require 'json)
(require 'jsonrpc)
(require 'subr-x)
Expand Down Expand Up @@ -316,14 +317,14 @@ Incremented after each change.")
((and (file-name-absolute-p copilot-server-executable)
(file-exists-p copilot-server-executable))
copilot-server-executable)
((executable-find copilot-server-executable t))
((executable-find copilot-server-executable nil))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just remove this param - it's optional.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

(t
(let ((path (executable-find
(f-join copilot-install-dir
(cond ((eq system-type 'windows-nt) "")
(t "bin"))
copilot-server-executable)
t)))
nil)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

(unless (and path (file-exists-p path))
(error "The package %s is not installed. Unable to find %s"
copilot-server-package-name path))
Expand Down Expand Up @@ -360,7 +361,10 @@ Incremented after each change.")
(defun copilot-install-server ()
"Interactively install server."
(interactive)
(if-let* ((npm-binary (executable-find "npm")))
(if-let* ((default-directory (if (file-remote-p default-directory)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this is trying to solve - I don't think it will have any effect on the executable-find call.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you want it to search only the local filesystem. As noted in another remark - I have some doubts about this approach as I think this might be quite surprising to some people.

"~/"
default-directory))
(npm-binary (executable-find "npm")))
(progn
(make-directory copilot-install-dir 'parents)
(copilot-async-start-process
Expand Down Expand Up @@ -462,10 +466,9 @@ SUCCESS-FN is the CALLBACK."

(defun copilot--start-server ()
"Start the copilot server process in local."
(cond
((not (file-exists-p (copilot-server-executable)))
(user-error "Server is not installed, please install via `M-x copilot-install-server`"))
(t
(let ((default-directory (if (file-remote-p default-directory)
"~/"
default-directory)))
(let ((installed-version (copilot-installed-version)))
(when (and copilot-version (not (equal installed-version copilot-version)))
(warn "This package has been tested for Copilot server version %s but version %s has been detected.
Expand All @@ -481,7 +484,7 @@ You can change the installed version with `M-x copilot-reinstall-server` or remo
`( :editorInfo (:name "Emacs" :version ,emacs-version)
:editorPluginInfo (:name "copilot.el" :version ,(or (copilot-installed-version) "unknown"))
,@(when copilot-network-proxy
`(:networkProxy ,copilot-network-proxy)))))))
`(:networkProxy ,copilot-network-proxy))))))

;;
;; login / logout
Expand Down