Auto-complete with go-mode

I try to turn on auto-full mode whenever a .go file is loaded via go-mode. It works if I automatically start automatic full mode for Go source files, but when I tried to add it to .emacs as shown below, it does not work:

(add-hook 'go-mode-hook auto-complete-mode) 

I tried several options, but nobody seems to work. The following is a snippet of Go-Mode in my .emacs:

 ;; Load Go Mode (require 'go-mode-load) (add-hook 'go-mode-hook 'auto-complete-mode) 

I tried to create my own hook function as follows:

 ;; Load Go Mode (require 'go-mode-load) (defun auto-complete-for-go () (auto-complete-mode 1)) (add-hook 'go-mode-hook 'auto-complete-for-go) 

I also tried including hook in go-mode-load.el and go-mode.el , and also call auto-complete-mode as follows:

 (auto-complete-mode t) (provide 'go-mode) 

Doesn't work anyway. I also added the go-mode-hook to auto-complete-default function as follows:

 (defun ac-config-default () (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers)) (add-hook 'go-mode-hook 'ac-common-setup) ;; Other hooks (global-auto-complete-mode t)) 

This does not work either. What is the best way to run a command immediately after the main mode for a buffer?

+4
source share
2 answers

Here is a workaround:

 (add-to-list 'ac-modes 'go-mode) 

I fixed the issue in branch v1.4 with the following commits.

+5
source

What options have you tried? It should work if you add a single quote before auto-complete-mode :

 (add-hook 'go-mode-hook 'auto-complete-mode) 

Without this quote, auto-complete-mode interpreted as a variable, and the value of this variable is added to go-mode-hook . For this to make sense, such a variable must contain a reference to the function as its value. Most likely, although there will be no variable named auto-complete-mode , and Emacs will complain.

By adding a quote, you tell Emacs that this is not a variable, but the actual function that you want to call. See also here and here .

+3
source

Source: https://habr.com/ru/post/1432448/


All Articles