A company-mode script for auto-parenthesis
Most of completion systems for Emacs do not support automatic parentheses. For example, by default, when typing add-ho
, the completion list will show add-hook
instead of (add-hook)
. This is sometimes annoying. The company-yasnippet-autoparens solves the problem, it can make add-hook - > (add-hook)
appear in the completion list.
- Any text input, a parentheses version will be added to the completion list.
- It can combine various backends, e.g. dabbrev.
- Some other examples that combine with yasnippet.
Note that company-yasnippet-autoparens supports any s-exp languages, not just Elisp. It even can support non s-exp languages, if using company-yasnippet-autoparens-2.el
.
- Non s-exp languages.
- If you have installed
company
andyasnippet
, uninstall them. - Clone this repository and unzip it to your emacs configuration path.
- Add the following code to your configuration file.
(require 'yasnippet)
(yas-global-mode 1)
(require 'company)
(global-company-mode 1)
(setq company-idle-delay 0.1)
(setq company-minimum-prefix-length 1)
(setq company-dabbrev-char-regexp "\\sw\\|_\\|-\\|!\\|\\?\\|*\\|+\\|=\\|>\\|<")
(setq company-backends '((company-capf
company-dabbrev
company-yasnippet-autoparens
company-yasnippet)))