From 07cdad1b56ea44a53843a1fcf969fe151178cc67 Mon Sep 17 00:00:00 2001 From: fnussbaum Date: Fri, 27 Dec 2024 19:52:06 +0100 Subject: [PATCH] [github-copilot] Fix activation for holy-mode Completions were disabled by default due to `holy-mode` permanently activating `evil-emacs-state`. --- layers/+web-services/github-copilot/funcs.el | 29 +++++++++++++++++++ .../+web-services/github-copilot/packages.el | 3 ++ 2 files changed, 32 insertions(+) create mode 100644 layers/+web-services/github-copilot/funcs.el diff --git a/layers/+web-services/github-copilot/funcs.el b/layers/+web-services/github-copilot/funcs.el new file mode 100644 index 000000000000..bb9d6349ea80 --- /dev/null +++ b/layers/+web-services/github-copilot/funcs.el @@ -0,0 +1,29 @@ +;;; funcs.el --- GitHub Copilot Layer functions file for Spacemacs -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2024 Sylvain Benner & Contributors +;; +;; Author: Ferdinand Nussbaum +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +(defun spacemacs//copilot-enable-predicate () + "Copilot is by default only enabled in `evil-insert-state', not in `evil-emacs-state', +see the default value of `copilot-enable-predicates'. +In `holy-mode', we enable `evil-emacs-state' permanently, hence this workaround." + (or (not (bound-and-true-p evil-local-mode)) + (bound-and-true-p holy-mode) + (evil-insert-state-p))) diff --git a/layers/+web-services/github-copilot/packages.el b/layers/+web-services/github-copilot/packages.el index 5e4d5471c366..20982439868a 100644 --- a/layers/+web-services/github-copilot/packages.el +++ b/layers/+web-services/github-copilot/packages.el @@ -29,4 +29,7 @@ (defun github-copilot/init-copilot () (use-package copilot + :custom + (copilot-enable-predicates '(spacemacs//copilot-enable-predicate + copilot--buffer-changed)) :defer t))