Search code examples
bootstrap-4emacs

Emacs company-bootstrap (how to make it auto active in web-mode)?


When in web-mode while editing a html file, I've to hit M-x company-bootstrap to see a list of possible value for a class in a html tag.

<p class="M-X company-bootstrap here ..">

Is it possible to make it auto active while opening a html file. I'm faced the same issue with company-web-html.

I defined in my configuration file that :

(add-hook 'web-mode-hook (
 lambda()
   (set (make-local-variable 'company-backends) '(company-css company-web-html company-yasnippet company-files company-bootstrap))
   (company-mode t)))

But not working.

Thk for help


Solution

  • Update company-backends before using:

    (require 'company)     ; Import company-backends variable
    (require 'company-web) ; Import required backends
    (add-to-list 'company-backends 'company-css)
    (add-to-list 'company-backends 'company-web-html)
    
    

    Activate company-mode globally or only for web-mode:

    (global-company-mode 1) ; Global company-mode.
    (add-hook 'web-mode-hook 'company-mode) ; Run only for web-mode.