Add support for company-statistics.
This commit is contained in:
parent
91e560d415
commit
866f59e41f
|
@ -9,6 +9,7 @@
|
|||
- [Configuration](#configuration)
|
||||
- [Key bindings](#key-bindings)
|
||||
- [Tooltips](#tooltips)
|
||||
- [Sort results by usage](#sort-results-by-usage)
|
||||
- [Enable company or auto-complete globally](#enable-company-or-auto-complete-globally)
|
||||
- [Replacing company by auto-complete](#replacing-company-by-auto-complete)
|
||||
- [Add auto-completion in a layer](#add-auto-completion-in-a-layer)
|
||||
|
@ -85,6 +86,18 @@ To enable docstring tooltips set `auto-completion-enable-help-tooltip` to `t`
|
|||
auto-completion-enable-help-tooltip t))
|
||||
```
|
||||
|
||||
### Sort results by usage
|
||||
|
||||
To enable sorting auto-completion results by their usage frequency set
|
||||
`auto-completion-sort-by-usage` to `t`. This feature uses the
|
||||
[company-statistics][] package.
|
||||
|
||||
```elisp
|
||||
(setq-default dotspacemacs-configuration-layers
|
||||
'(auto-completion :variables
|
||||
auto-completion-sort-by-usage t))
|
||||
```
|
||||
|
||||
### Enable company or auto-complete globally
|
||||
|
||||
By default Spacemacs enables auto-completion explicitly for each supported
|
||||
|
@ -154,7 +167,7 @@ In `packages.el`:
|
|||
<kbd>C-d</kbd> | open minibuffer with documentation of thing at point in company dropdown
|
||||
|
||||
### Auto-complete
|
||||
|
||||
|
||||
Key Binding | Description
|
||||
-------------------|------------------------------------------------------------
|
||||
<kbd>C-j</kbd> | select next candidate
|
||||
|
@ -166,3 +179,4 @@ In `packages.el`:
|
|||
[company]: http://company-mode.github.io/
|
||||
[auto-complete]: http://auto-complete.org/
|
||||
[yasnippet]: https://github.com/capitaomorte/yasnippet
|
||||
[company-statistics]: https://github.com/company-mode/company-statistics
|
||||
|
|
|
@ -24,6 +24,9 @@ Possible values are `complete', `cycle' or `nil'.")
|
|||
"Provide a key sequence (string) to complete the current
|
||||
selection.")
|
||||
|
||||
(defvar auto-completion-sort-by-usage nil
|
||||
"If non nil suggestions are sorted by how often they are used.")
|
||||
|
||||
(defvar auto-completion-enable-help-tooltip nil
|
||||
"If non nil the docstring appears in a tooltip.")
|
||||
|
||||
|
|
|
@ -11,14 +11,15 @@
|
|||
;;; License: GPLv3
|
||||
|
||||
(setq auto-completion-packages
|
||||
'(
|
||||
auto-complete
|
||||
ac-ispell
|
||||
company
|
||||
helm-c-yasnippet
|
||||
hippie-exp
|
||||
yasnippet
|
||||
))
|
||||
'(
|
||||
auto-complete
|
||||
ac-ispell
|
||||
company
|
||||
company-statistics
|
||||
helm-c-yasnippet
|
||||
hippie-exp
|
||||
yasnippet
|
||||
))
|
||||
|
||||
;; company-quickhelp from MELPA is not compatible with 24.3 anymore
|
||||
(unless (version< emacs-version "24.4")
|
||||
|
@ -109,6 +110,15 @@
|
|||
(setq company-transformers '(spacemacs//company-transformer-cancel
|
||||
company-sort-by-occurrence)))))
|
||||
|
||||
(defun auto-completion/init-company-statistics ()
|
||||
(use-package company-statistics
|
||||
:if auto-completion-sort-by-usage
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(setq company-statistics-file (concat spacemacs-cache-directory "company-statistics-cache.el"))
|
||||
(add-hook 'company-mode-hook 'company-statistics-mode))))
|
||||
|
||||
(defun auto-completion/init-company-quickhelp ()
|
||||
(use-package company-quickhelp
|
||||
:if (and auto-completion-enable-help-tooltip (display-graphic-p))
|
||||
|
@ -130,7 +140,7 @@
|
|||
(setq helm-c-yas-space-match-any-greedy t))))
|
||||
|
||||
(defun auto-completion/init-hippie-exp ()
|
||||
;; replace dabbrev-expand
|
||||
;; replace dabbrev-expand
|
||||
(global-set-key (kbd "M-/") 'hippie-expand)
|
||||
(define-key evil-insert-state-map (kbd "C-p") 'hippie-expand)
|
||||
(setq hippie-expand-try-functions-list
|
||||
|
|
Loading…
Reference in a new issue