copilot.el icon indicating copy to clipboard operation
copilot.el copied to clipboard

Warning (copilot): copilot--infer-indentation-offset found no mode-specific indentation offset.

Open tiny911 opened this issue 1 year ago • 6 comments

This warning is always reported in go-mode recently. How to set the indentation-offset or ignore the warning? I'm using doom emacs

tiny911 avatar Jun 02 '24 00:06 tiny911

You want something like this:

(use-package! copilot
  :hook (prog-mode . copilot-mode)
  :bind (: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)
              ("C-n" . 'copilot-next-completion)
              ("C-p" . 'copilot-previous-completion))

  :config
  (add-to-list 'copilot-indentation-alist '(prog-mode . 2))
  (add-to-list 'copilot-indentation-alist '(org-mode . 2))
  (add-to-list 'copilot-indentation-alist '(text-mode . 2))
  (add-to-list 'copilot-indentation-alist '(closure-mode . 2))
  (add-to-list 'copilot-indentation-alist '(emacs-lisp-mode . 2)))

Just tune your indentation settings so they are not 2 spaces. I wish copilot could use tab-width by default if it cannot found mode specific indentation offset.

iamkarlson avatar Jun 05 '24 07:06 iamkarlson

But actually, what you want is not dots before the indentation size:

(use-package! copilot
  :hook (prog-mode . copilot-mode)
  :bind (: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)
              ("C-n" . 'copilot-next-completion)
              ("C-p" . 'copilot-previous-completion))

  :config
  (add-to-list 'copilot-indentation-alist '(prog-mode 2))
  (add-to-list 'copilot-indentation-alist '(org-mode 2))
  (add-to-list 'copilot-indentation-alist '(text-mode 2))
  (add-to-list 'copilot-indentation-alist '(closure-mode 2))
  (add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2)))

I just noticed this works, while with dots - doesn't

iamkarlson avatar Jul 16 '24 08:07 iamkarlson

Is there a way to somehow inherit the indentation by default without having to specify it for every mode?

threddast avatar Oct 03 '24 09:10 threddast

How to config this for spacemacs? I encounter the same issue in orgmode.

bebound avatar Oct 27 '24 10:10 bebound

@bebound In case you still have that issue, in spacemacs you can configure it like this

;; config example from README.md
(with-eval-after-load 'copilot
  (define-key copilot-completion-map (kbd "<tab>") 'copilot-accept-completion)
  (define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion)
  (define-key copilot-completion-map (kbd "C-TAB") 'copilot-accept-completion-by-word)
  (define-key copilot-completion-map (kbd "C-<tab>") 'copilot-accept-completion-by-word)
  ;; add it here
  (add-to-list 'copilot-indentation-alist '(org-mode 2)))

rasom avatar Nov 23 '24 20:11 rasom

I just decided to ignore it

(use-package copilot
  :vc (:url "https://github.com/copilot-emacs/copilot.el"
            :rev :newest
            :branch "main")
  :init
  (setq copilot-indent-offset-warning-disable t)
  :bind (:map copilot-completion-map
              ("<tab>" . copilot-accept-completion))
  :hook (prog-mode . copilot-mode))

AlecsFerra avatar Mar 17 '25 10:03 AlecsFerra