copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.72k stars 122 forks source link

Mode map isn't always active when the overlay is open #184

Open richsmith opened 9 months ago

richsmith commented 9 months ago

I've split this off from the issue mentioned in #103 for visibility / tracking.

I fairly often find that copilot makes a suggestion, but I can't accept the completion from the keys I've set up in copilot-completion-map.

I'm not very knowledgeable about how Emacs works around this, but as far as I can tell the map isn't always active even though the overlay is open. I've tried to figure out what the problem is but have so far failed.

This is generally using python mode with eglot. I can't remember if I've experienced it in other modes.

This is quite intermittent so hard to reproduce - seems completely random, but gets into a state where it won't complete for a while, then happily works well for a period.

I don't see any issues in copilot events after enabling logging (how do I view copilot stderr?)

I'm using the latest version from main in this repo.

raymond-w-ko commented 9 months ago

Wow, I have experienced this when I was working on a Python project and using eglot. I thought it was something with my setup and would come back to it later, since Python isn't my primary work language.

But it's re-assuring to know it's not my setup, but some common issue others have also experienced.

raymond-w-ko commented 9 months ago

I think eglot has integration with yasnippet, so maybe if the LSP server is returning a snippet, it overrides the copilot.el one. Eventually I will test below when I get back to Python projects, but does the following line fix the issue? copilot.el is using an overlay priority of 100.

(setq yas-overlay-priority 99)

richsmith commented 9 months ago

(setq yas-overlay-priority 99)

Thanks, have tried.

Unfortunately doesn't solve the problem for me (or setting the copilot overlay priority to 10000 either).

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

emil-vdw commented 6 months ago

@richsmith can you share your copilot config?

I don't see any issues in copilot events after enabling logging (how do I view copilot stderr?)

How did you enable logging?

richsmith commented 6 months ago

@richsmith can you share your copilot config?

Sorry for the delay @emil-vdw ! This is my current config:

(use-package copilot
  :straight (:host github :repo "zerolfx/copilot.el" :files ("dist" "*.el"))
  :ensure t
  :hook (prog-mode . copilot-mode)
  :bind (("C-c M-f" . copilot-accept-completion-by-word)
         ("C-c <tab>" . copilot-accept-completion)
         :map copilot-completion-map
         ("C-g" . 'copilot-clear-overlay)
         ("M-P" . 'copilot-previous-completion)
         ("M-N" . 'copilot-next-completion)
         ("<tab>" . 'copilot-accept-completion)
         ("M-f" . 'copilot-accept-completion-by-word)
         ("M-e" . copilot-accept-completion-by-line)
         ("M-n" . copilot-accept-completion-by-line))
  :custom-face (copilot-overlay-face ((t :foreground "silver" :underline t)))
  :config
  (setq copilot-log-max 10000)
  (setq copilot-node-executable
        (executable-find "node")))

I don't see any issues in copilot events after enabling logging (how do I view copilot stderr?)

How did you enable logging?

(setq copilot-log-max 10000) as above.

emil-vdw commented 3 months ago

Has this been resolved by 581cadd6f4229223fd5c57984f9595aeb86c84f7?

richsmith commented 3 months ago

@emil-vdw it does seem to be fixed :tada:

(Sorry, I haven't updated for a while so can't say for sure it was that commit that actually fixed it, but it seems likely!)

Big thanks for your work on this. It now works very well.