copilot-emacs / copilot.el

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

Warning with `copilot-max-char` #175

Closed maikol-solis closed 10 months ago

maikol-solis commented 10 months ago

Every time I start doom-emacs I receive this message

Warning (emacs):  *temp* size exceeds ’copilot-max-char’ (100000), copilot completions may not work [3 times]

It seems to be a minor issue because after closing the warning, I can use copilot correctly.

Please let me know what I can do to further debug this.

Best.

emil-vdw commented 10 months ago

@maikol-solis there is a default limit (copilot-max-char) of 100'000 characters that is sent to the copilot agent to prevent sending super large buffers. This means that if a buffer has a size of 500'000 characters, only 1/5th of the buffer will be sent to the agent. Predictions won't work reliably in these buffers but other buffers will work just fine.

You can increase the limit (or disable it by setting it to -1) if the buffers you're working on are large.

In your case it looks like it's some temporary buffer *temp* that's exceeding the limit. I don't know if this is a doom emacs thing or just part of your setup.

Are you using global-copilot-mode?

maikol-solis commented 10 months ago

Hi, No, I am not using globlal-copilot-mode.

This is my whole config for the package

(use-package! copilot
  :config
  (add-hook! '(org-mode-hook TeX-mode-hook LaTeX-mode-hook latex-mode-hook markdown-mode-hook prog-mode-hook )
             'copilot-mode)
  (setq copilot-max-char 1000000)
  (map! (:map copilot-completion-map
              "<tab>"    #'copilot-accept-completion
              "TAB"    #'copilot-accept-completion
              "C-<tab>"  #'copilot-accept-completion-by-word
              "C-TAB"  #'copilot-accept-completion-by-word
              "M-n"      #'copilot-next-completion
              "M-p"      #'copilot-prev-completion
              "C-g"      #'copilot-clear-overlay)
        (:map copilot-mode-map
              "C-x C-a"    #'copilot-complete)))

Setting (setq copilot-max-char -1) disappear the message, but with some time penalty due to my agenda files (which are a little large).

A less drastic measure is (setq copilot-max-char 1000000). All the warning messages disappeared.

Thanks.

emil-vdw commented 10 months ago

Awesome. You could also write a more sophisticated hook function that doesn't activate the mode for certain buffer names (like *temp* and your agenda files).

Closing as resolved.

forgoty commented 2 months ago

@emil-vdw any suggestions how to disable copilot-mode at this large buffers with (global-copilot-mode)?