copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.74k stars 124 forks source link

Suggest setting `copilot-enable-predicates` to nil for spacemacs #124

Closed james-ennis closed 1 year ago

james-ennis commented 1 year ago

In order for this plugin to work with spacemacs we need to set copilot-enable-predicates to nil. This closes #123

zerolfx commented 1 year ago

The copilot-enable-predicates contains two functions by default. Can you please confirm which one is causing the plugin to not work with Spacemacs?

james-ennis commented 1 year ago

I tried setting it to both copilot--buffer-changed and evil-insert-state-p individually, neither worked.

These were the two functions I found when I did M-x describe-varable copilot-enable-predicates

zerolfx commented 1 year ago

(setq copilot-enable-predicates '(evil-insert-state-p)) (setq copilot-enable-predicates '(copilot--buffer-changed))

In case you forgot to make it a list.

It's strange if both of them are preventing the plugin from working.

james-ennis commented 1 year ago

Ah yes, I didn't make them a list. Thanks, so it's:

(setq copilot-enable-predicates '(evil-insert-state-p))

that is preventing the plugin from working. I wonder if this is because I use spacemacs with emacs keybindings rather than vim ones. That setting sounds very vim-like

zerolfx commented 1 year ago

Yes, evil-insert-state-p will prevent the plugin from triggering completions if the current VIM state is not insert. However, copilot.el will ignore this function if it's not available, so it should work for users using Emacs keybindings.

I'm curious why (functionp evil-insert-state-p) returns t, even when you're using Emacs keybindings.

james-ennis commented 1 year ago

I'm not actually able to see functionp when I run M-x, not to sure why. I can describe it though:

evil-insert-state-p is a native-compiled Lisp function in ‘hybrid-mode.el’.

(evil-insert-state-p &optional STATE)

Whether the current state is insert.

So what shall we do with this PR? It sounds to me as though you're suggesting it could be an issue with Spacemacs?

zerolfx commented 1 year ago

Spacemacs offers three editing styles: Vim, Emacs, and Hybrid. However, hybrid-mode is beyond the scope of consideration due to the small number of users.

I recommend that you switch your editing style from hybrid to emacs, or alternatively customize copilot-enable-predicates.