Exploring my Emacs packages - company-mode

What is company-mode?

Project homepage : https://github.com/company-mode/company-mode

company-mode adds auto-completion to the current buffer in Emacs. It's similar to ac-mode and supports some more modern features, such as lsp (language server protocol).

It works well out of the box, but with some additional packages and per-language configuration it can really shine.

Example packages for web development

Adds completion for web-mode, and can be used with HTML and HTM templates, although I prefer using emmet-mode for creating elements.
JavaScript completion. Requires flow to be installed.
Auto-completion for Ruby which uses a Ruby REPL to get code information. Requires the file (or project in Rails) to be reloaded when code changes.
Adds auto-completion for common PHP extensions, as well as user defined classes and functions. It also supports annotations and type hints. It requires a special tags file to be created in order to get the most out of it, and this file should be regenerated when code changes.

Using lsp


lsp is a common protocol for language servers. lsp-mode is a package that allows Emacs to communicate with lsp servers, and it supports a bunch of different languages.

Using lsp requires some extra setup as each language has its own server implementation which may need to be installed and configured. However, once it's up and running it's a fairly smooth experience.

company-lsp integrates with lsp-mode and allows company-mode to use information from running lsp servers.

Although it takes a while to configure, using lsp removes the need to regenerate tag files or reload projects when code changes.

This post is part of the "Exploring my Emacs packages" series.

Posted in: Emacs | Comments (0)

Post a comment

org-mode tags allowed: /italic/, *bold* and =code=