diff --git a/modules/completion/siren-copilot.el b/modules/completion/siren-copilot.el index e8822fe..7894069 100644 --- a/modules/completion/siren-copilot.el +++ b/modules/completion/siren-copilot.el @@ -13,8 +13,8 @@ (prog-mode . copilot-mode) :general - ("C-" 'siren-copilot-accept-completion-dwim) - ("" 'siren-copilot-accept-completion-dwim) + ("C-" 'siren-copilot-accept-completion-without-trailing-opening-curly-bracket-dwim) + ("" 'siren-copilot-accept-completion-without-trailing-opening-curly-bracket-dwim) ("M-F" 'siren-copilot-accept-completion-by-word-dwim) ("M-E" 'siren-copilot-accept-completion-by-line-dwim) (:keymaps 'copilot-completion-map @@ -43,6 +43,20 @@ (apply f args) (copilot-complete))) + (defun siren-copilot-accept-completion-without-trailing-opening-curly-bracket-dwim () + "Accept the current completion or trigger copilot-compilot." + (interactive) + (siren-copilot-complete-or-call 'siren-copilot-accept-completion-without-trailing-opening-curly-bracket)) + + (defun siren-copilot-accept-completion-without-trailing-opening-curly-bracket () + "Accept completion removing ` {' or `{' from the end of the completion." + (interactive) + (copilot-accept-completion (lambda (completion) + (let ((index (string-match-p "\s*{\\'" completion))) + (if (and index (> index 0)) + (substring completion 0 index) + completion))))) + :config (with-eval-after-load 'company ;; Use company popup even when there's only one result