complete-computing-environment/company_code_completion.org

2.7 KiB

Company Mode Code Completion

(provide 'cce/company)

Code Completion is an incredible tool to have at your disposal when done nicely. When done nicely, I should be able to hit <TAB> to get a dropdown under my cursor with a list of options. Those options are popuplated by programming language tooling or by matching against a list of entries. Completion should be ubiquitous and useful, and should provide as much context as possible. In particular, programming language auto-completion should provide as much data about the completion target, what module it is, or what its type signature is, or the inline documentation if it's short enough. Given a language with a strong enough type system like Rust, it should be possible to intuit even templated types.

My current completion system is far from this, and so I am going back to the first-party recommended configuration for much of this, designed to integrate with Evil Mode and the Company completion framework. By default, company supports auto-completion for Emacs Lisp, etags and gtags, Clang, etc, and it can also be extended by languages, and the Emacs Modes themselves using Completion at Point Functions.

But what I care about is this:

These require no work so I include them by default.

  • Completion at Point Functions
  • Keyword Matching
  • Ispell
  • Emacs Lisp

These four combined give me basic completion in all buffers, based on words in those buffers (and the dictionary in text-mode), as well as Emacs Lisp. Everything else is defined in those files linked above.

(use-package company
  :diminish
  :config
  (setq company-backends '(company-capf company-files company-ispell company-elisp company-keywords))
  (setq-default completion-at-point-functions nil)
  (global-company-mode)
  :bind (:map prog-mode-map ("<tab>" . company-complete))
  :bind ("C-<tab>" . company-complete))
(use-package company-prescient :init (company-prescient-mode +1))