diff options
-rw-r--r-- | init.org | 74 |
1 files changed, 63 insertions, 11 deletions
@@ -856,23 +856,75 @@ message-mode org-mode scheme-mode)) - (company-idle-delay 0.5) + (company-idle-delay 0.15) (company-lighter "") (company-lighter-base "") (company-show-numbers nil) - (company-tooltip-limit 15)) + (company-tooltip-limit 15) + (company-tooltip-align-annotations t) + (company-transformers '(company-sort-by-occurrence))) + :config - (add-hook 'company-mode-hook - (lambda () (setq company-lighter-base ""))) - :bind (("C-c ." . company-complete) - ;; ("C-c C-." . company-complete) - ;; ("C-c s s" . company-yasnippet) + (add-hook 'company-mode-hook (lambda () (setq company-lighter-base ""))) + + ;; Prevent non-matching input (which will dismiss the completions + ;; menu), but only if the user interacts explicitly with Company. + (setq company-require-match #'company-explicit-action-p) + + (defun jao-complete-at-point () + (interactive) + (if (window-minibuffer-p) (completion-at-point) (company-manual-begin))) + + :bind (;; Remap the standard Emacs keybindings for invoking + ;; completion to instead use Company. You might think this + ;; could be put in the `:bind*' declaration below, but it + ;; seems that `bind-key*' does not work with remappings. + ([remap completion-at-point] . #'jao-complete-at-point) + ([remap complete-symbol] . #'jao-complete-at-point) + + ("C-c ." . company-complete) + + ;; The following are keybindings that take effect whenever + ;; the completions menu is visible, even if the user has not + ;; explicitly interacted with Company. :map company-active-map - ;; ("C-n" . company-select-next) - ;; ("C-p" . company-select-previous) + + ;; Make TAB always complete the current selection, instead of + ;; only completing a common prefix. + ("<tab>" . #'company-complete-selection) + ("TAB" . #'company-complete-selection) + + ;; When was the last time you used the C-s binding for + ;; searching candidates? It conflicts with buffer search, + ;; anyway. Same for the scroll commands. + ("C-s" . nil) + ([remap scroll-down-command] . nil) + ([remap scroll-up-command] . nil) + ("C-h" . company-show-doc-buffer) - ("M-." . company-show-location)) - :diminish) + ("M-." . company-show-location) + + ;; The following are keybindings that only take effect if the + ;; user has explicitly interacted with Company. Note that + ;; `:map' from above is "sticky", and applies also below: see + ;; https://github.com/jwiegley/use-package/issues/334#issuecomment-349473819. + + :filter (company-explicit-action-p) + + ;; Make RET trigger a completion if and only if the user has + ;; explicitly interacted with Company, instead of always + ;; doing so. + ("<return>" . #'company-complete-selection) + ("RET" . #'company-complete-selection)) + :bind* (;; The default keybinding for `completion-at-point' and + ;; `complete-symbol' is M-TAB or equivalently C-M-i. We + ;; already remapped those bindings to `company-manual-begin' + ;; above. Here we make sure that they definitely invoke + ;; `company-manual-begin' even if a minor mode binds M-TAB + ;; directly. + ("M-TAB" . #'jao-complete-at-point)) + + :diminish) (use-package company-math :ensure t :after company) |