3

How can I stop company-mode from autocompleting dictionary words? I only want it to autocomplete commands.

This is my config:

(use-package company
  :ensure
  :defer 4
  :init (progn
          (global-company-mode)
          (setq company-global-modes '(not python-mode cython-mode sage-mode))
          )
  :config (progn
            (setq company-tooltip-limit 20
                  company-idle-delay .1
                  company-echo-delay 0
                  company-begin-commands '(self-insert-command)
                  company-transformers '(company-sort-by-occurrence)
                  company-selection-wrap-around t
                  company-idle-delay .1
                  company-minimum-prefix-length 1
                  company-selection-wrap-around t
                  company-dabbrev-downcase nil
                  )
            (bind-keys :map company-active-map
                       ("C-n" . company-select-next)
                       ("C-p" . company-select-previous)
                       ("C-d" . company-show-doc-buffer)
                       ("<tab>" . company-complete)
                       ("<escape>" . company-abort)
                       )
            )
  )

UPDATE: I just noticed that it autocompletes not from the dictionary (ispell) but from all words already existing in the current buffer. How can I stop it from doing so?

3
  • 1
    Check the value of the variable company-backends, do you see company-dabbrev in the list of backends for the major mode you are using ? If so, try to remove company-dabbrev from company-backends and let me know if it works for you Commented Oct 2, 2016 at 7:13
  • 1
    company-keywords is the backend which complete default keywords from dictionary file. Commented Oct 3, 2016 at 11:27
  • I had the same problem, company keeps on automatically committing the 1st candidate word as soon as I typed enough number of characters according to company-minimum-prefix-length. I ended up removing the company from the melpa channel and installing that from the gnu channel instead, and that fixed the issue.
    – Jason
    Commented Jan 16, 2021 at 9:03

1 Answer 1

3

You have to take a look at the variable company-backends.

If you append the backends you want to use manually, the preconfigured backends will be ignored.

So if you want to only complete python commands, you'd have to use (add-to-list 'company-backends '(company-jedi))

You should configure your backends for every mode that uses company.

Of course you have to install jedi first.

5
  • Thanks. I had to do: (delete 'company-dabbrev company-backends) (delete '(company-dabbrev-code company-gtags company-etags company-keywords) company-backends) (add-to-list 'company-backends '(company-auctex)
    – NVaughan
    Commented Oct 3, 2016 at 14:14
  • This is weird. It shouldn't be necessary to delete those backends.
    – bertfred
    Commented Oct 3, 2016 at 14:37
  • Yeap, I tried only with the add-to-list command, but the other backends were still there...
    – NVaughan
    Commented Oct 3, 2016 at 16:21
  • did you only check the value of the variable or have you really tested the functionality?
    – bertfred
    Commented Oct 3, 2016 at 18:26
  • I checked the value, before and after.
    – NVaughan
    Commented Oct 4, 2016 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.