summaryrefslogtreecommitdiffhomepage
path: root/init.org
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-03-26 22:40:24 +0000
committerjao <jao@gnu.org>2021-03-26 22:40:24 +0000
commit2efe63605a87df5537ec07d931bd5ae0e395a42a (patch)
tree95b31b66cd7641c9690959841385bc5a95adf3f8 /init.org
parent558919d4dd63eb0efe604caeaac4bbfe9aff5404 (diff)
downloadelibs-2efe63605a87df5537ec07d931bd5ae0e395a42a.tar.gz
elibs-2efe63605a87df5537ec07d931bd5ae0e395a42a.tar.bz2
company mode tweaks
Diffstat (limited to 'init.org')
-rw-r--r--init.org74
1 files changed, 63 insertions, 11 deletions
diff --git a/init.org b/init.org
index dc0148d..9cda877 100644
--- a/init.org
+++ b/init.org
@@ -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)