2017-06-08 11:47:56 +02:00
|
|
|
;;; completion/company/config.el -*- lexical-binding: t; -*-
|
2017-02-19 18:41:26 -05:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! company
|
2019-07-21 23:31:42 +02:00
|
|
|
:commands company-complete-common company-manual-begin company-grab-line
|
|
|
|
:after-call evil-insert-state-entry-hook evil-emacs-state-entry-hook
|
2018-04-18 18:22:23 -04:00
|
|
|
:init
|
2019-05-03 21:53:36 -04:00
|
|
|
(setq company-minimum-prefix-length 2
|
2018-02-02 15:57:49 -05:00
|
|
|
company-tooltip-limit 14
|
2017-02-19 18:41:26 -05:00
|
|
|
company-dabbrev-downcase nil
|
|
|
|
company-dabbrev-ignore-case nil
|
|
|
|
company-dabbrev-code-other-buffers t
|
|
|
|
company-tooltip-align-annotations t
|
|
|
|
company-require-match 'never
|
2018-04-22 23:41:20 -04:00
|
|
|
company-global-modes
|
2018-09-23 16:30:23 -04:00
|
|
|
'(not erc-mode message-mode help-mode gud-mode eshell-mode)
|
2018-10-03 11:18:58 -04:00
|
|
|
company-backends '(company-capf)
|
2018-04-22 23:41:20 -04:00
|
|
|
company-frontends
|
2018-04-23 02:37:58 -04:00
|
|
|
'(company-pseudo-tooltip-frontend
|
2018-08-08 23:34:11 +02:00
|
|
|
company-echo-metadata-frontend))
|
2019-05-03 21:53:36 -04:00
|
|
|
;; Lazy load until user starts entering text
|
|
|
|
(unless (featurep! :editor evil)
|
|
|
|
(add-transient-hook! 'post-self-insert-hook (require 'company)))
|
2018-04-18 18:22:23 -04:00
|
|
|
:config
|
2019-04-21 19:59:44 -04:00
|
|
|
(when (featurep! :editor evil)
|
2019-07-09 16:12:44 +02:00
|
|
|
(add-hook 'company-mode-hook #'evil-normalize-keymaps)
|
|
|
|
|
|
|
|
;; Allow users to switch between backends on the fly. E.g. C-x C-s followed
|
|
|
|
;; by C-x C-n, will switch from `company-yasnippet' to
|
|
|
|
;; `company-dabbrev-code'.
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +company--abort-previous-a (&rest _)
|
:boom: revise advice naming convention (1/2)
This is first of three big naming convention updates that have been a
long time coming. With 2.1 on the horizon, all the breaking updates will
batched together in preparation for the long haul.
In this commit, we do away with the asterix to communicate that a
function is an advice function, and we replace it with the '-a' suffix.
e.g.
doom*shut-up -> doom-shut-up-a
doom*recenter -> doom-recenter-a
+evil*static-reindent -> +evil--static-reindent-a
The rationale behind this change is:
1. Elisp's own formatting/indenting tools would occasionally struggle
with | and * (particularly pp and cl-prettyprint). They have no
problem with / and :, fortunately.
2. External syntax highlighters (like pygmentize, discord markdown or
github markdown) struggle with it, sometimes refusing to highlight
code beyond these symbols.
3. * and | are less expressive than - and -- in communicating the
intended visibility, versatility and stability of a function.
4. It complicated the regexps we must use to search for them.
5. They were arbitrary and over-complicated to begin with, decided
on haphazardly way back when Doom was simply "my private config".
Anyhow, like how predicate functions have the -p suffix, we'll adopt the
-a suffix for advice functions, -h for hook functions and -fn for
variable functions.
Other noteable changes:
- Replaces advice-{add,remove}! macro with new def-advice!
macro. The old pair weren't as useful. The new def-advice! saves on a
lot of space.
- Removed "stage" assertions to make sure you were using the right
macros in the right place. Turned out to not be necessary, we'll
employ better checks later.
2019-07-18 15:42:52 +02:00
|
|
|
:before #'company-begin-backend
|
|
|
|
(company-abort)))
|
2019-07-09 16:12:44 +02:00
|
|
|
|
2019-07-23 12:30:47 +02:00
|
|
|
(add-hook 'company-mode-hook #'+company-init-backends-h)
|
2017-02-20 20:43:22 -05:00
|
|
|
(global-company-mode +1))
|
2017-02-19 18:41:26 -05:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! company-tng
|
2018-08-25 19:54:11 +02:00
|
|
|
:when (featurep! +tng)
|
|
|
|
:after-call post-self-insert-hook
|
|
|
|
:config
|
|
|
|
(add-to-list 'company-frontends 'company-tng-frontend)
|
|
|
|
(define-key! company-active-map
|
2018-12-23 23:57:29 -05:00
|
|
|
"RET" nil
|
2019-04-01 12:58:23 -04:00
|
|
|
[return] nil
|
2018-12-23 23:57:29 -05:00
|
|
|
"TAB" #'company-select-next
|
2019-04-01 12:58:23 -04:00
|
|
|
[tab] #'company-select-next
|
2018-12-23 23:57:29 -05:00
|
|
|
[backtab] #'company-select-previous))
|
2018-05-14 20:45:47 +02:00
|
|
|
|
|
|
|
|
2018-09-07 19:36:16 -04:00
|
|
|
;;
|
|
|
|
;; Packages
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! company-prescient
|
2018-08-04 02:14:43 +02:00
|
|
|
:hook (company-mode . company-prescient-mode)
|
|
|
|
:config
|
2019-05-29 00:01:45 +10:00
|
|
|
;; NOTE prescient config duplicated with `ivy'
|
2018-08-04 02:14:43 +02:00
|
|
|
(setq prescient-save-file (concat doom-cache-dir "prescient-save.el"))
|
|
|
|
(prescient-persist-mode +1))
|
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! company-box
|
2018-04-22 23:41:53 -04:00
|
|
|
:when (and EMACS26+ (featurep! +childframe))
|
|
|
|
:hook (company-mode . company-box-mode)
|
2017-02-20 20:43:22 -05:00
|
|
|
:config
|
2019-01-22 16:22:07 -05:00
|
|
|
(setq company-box-show-single-candidate t
|
|
|
|
company-box-backends-colors nil
|
2018-06-27 19:13:54 +02:00
|
|
|
company-box-max-candidates 50
|
2019-03-12 23:20:28 +10:00
|
|
|
company-box-icons-alist 'company-box-icons-all-the-icons
|
|
|
|
company-box-icons-functions
|
2019-07-23 12:30:47 +02:00
|
|
|
'(+company-box-icons--yasnippet-fn
|
|
|
|
company-box-icons--lsp
|
|
|
|
+company-box-icons--elisp-fn
|
|
|
|
company-box-icons--acphp)
|
2019-03-12 23:20:28 +10:00
|
|
|
company-box-icons-all-the-icons
|
|
|
|
`((Unknown . ,(all-the-icons-material "find_in_page" :height 0.8 :face 'all-the-icons-purple))
|
|
|
|
(Text . ,(all-the-icons-material "text_fields" :height 0.8 :face 'all-the-icons-green))
|
|
|
|
(Method . ,(all-the-icons-material "functions" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Function . ,(all-the-icons-material "functions" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Constructor . ,(all-the-icons-material "functions" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Field . ,(all-the-icons-material "functions" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Variable . ,(all-the-icons-material "adjust" :height 0.8 :face 'all-the-icons-blue))
|
|
|
|
(Class . ,(all-the-icons-material "class" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Interface . ,(all-the-icons-material "settings_input_component" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Module . ,(all-the-icons-material "view_module" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Property . ,(all-the-icons-material "settings" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Unit . ,(all-the-icons-material "straighten" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Value . ,(all-the-icons-material "filter_1" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Enum . ,(all-the-icons-material "plus_one" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Keyword . ,(all-the-icons-material "filter_center_focus" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Snippet . ,(all-the-icons-material "short_text" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Color . ,(all-the-icons-material "color_lens" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(File . ,(all-the-icons-material "insert_drive_file" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Reference . ,(all-the-icons-material "collections_bookmark" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Folder . ,(all-the-icons-material "folder" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(EnumMember . ,(all-the-icons-material "people" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Constant . ,(all-the-icons-material "pause_circle_filled" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Struct . ,(all-the-icons-material "streetview" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Event . ,(all-the-icons-material "event" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(Operator . ,(all-the-icons-material "control_point" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(TypeParameter . ,(all-the-icons-material "class" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
;; (Template . ,(company-box-icons-image "Template.png"))))
|
|
|
|
(Yasnippet . ,(all-the-icons-material "short_text" :height 0.8 :face 'all-the-icons-green))
|
|
|
|
(ElispFunction . ,(all-the-icons-material "functions" :height 0.8 :face 'all-the-icons-red))
|
|
|
|
(ElispVariable . ,(all-the-icons-material "check_circle" :height 0.8 :face 'all-the-icons-blue))
|
|
|
|
(ElispFeature . ,(all-the-icons-material "stars" :height 0.8 :face 'all-the-icons-orange))
|
|
|
|
(ElispFace . ,(all-the-icons-material "format_paint" :height 0.8 :face 'all-the-icons-pink))))
|
|
|
|
|
2019-07-23 12:30:47 +02:00
|
|
|
(defun +company-box-icons--yasnippet-fn (candidate)
|
2019-03-12 23:20:28 +10:00
|
|
|
(when (get-text-property 0 'yas-annotation candidate)
|
|
|
|
'Yasnippet))
|
|
|
|
|
2019-07-23 12:30:47 +02:00
|
|
|
(defun +company-box-icons--elisp-fn (candidate)
|
2019-03-12 23:20:28 +10:00
|
|
|
(when (derived-mode-p 'emacs-lisp-mode)
|
|
|
|
(let ((sym (intern candidate)))
|
|
|
|
(cond ((fboundp sym) 'ElispFunction)
|
|
|
|
((boundp sym) 'ElispVariable)
|
|
|
|
((featurep sym) 'ElispFeature)
|
|
|
|
((facep sym) 'ElispFace))))))
|
2017-02-20 20:43:22 -05:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! company-dict
|
2018-05-25 00:46:11 +02:00
|
|
|
:defer t
|
2017-03-02 18:17:40 -05:00
|
|
|
:config
|
2019-03-02 01:38:54 -05:00
|
|
|
(setq company-dict-dir (expand-file-name "dicts" doom-private-dir))
|
2019-07-18 15:27:20 +02:00
|
|
|
(add-hook 'doom-project-hook
|
2019-07-23 12:30:47 +02:00
|
|
|
(defun +company-enable-project-dicts-h (mode &rest _)
|
2019-07-18 15:27:20 +02:00
|
|
|
"Enable per-project dictionaries."
|
|
|
|
(if (symbol-value mode)
|
|
|
|
(add-to-list 'company-dict-minor-mode-list mode nil #'eq)
|
|
|
|
(setq company-dict-minor-mode-list (delq mode company-dict-minor-mode-list))))))
|