summary refs log tree commit diff stats
path: root/user
diff options
context:
space:
mode:
authorAlan Pearce2021-03-28 20:01:45 +0200
committerAlan Pearce2021-03-28 20:01:45 +0200
commit637c2437f01775fa0f10b5bac451e3b949d47077 (patch)
treee21e18da8d99e158622bb6a144fb04259f0fc4ff /user
parent113c154ed21e88dab5d28fe51c5d9c3f07c2842b (diff)
downloadnixfiles-637c2437f01775fa0f10b5bac451e3b949d47077.tar.lz
nixfiles-637c2437f01775fa0f10b5bac451e3b949d47077.tar.zst
nixfiles-637c2437f01775fa0f10b5bac451e3b949d47077.zip
Emacs: enable company-tide as secondary backend for typescript
use a macro to set up secondary company backend s by mode
Diffstat (limited to 'user')
-rw-r--r--user/emacs/init.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/user/emacs/init.el b/user/emacs/init.el
index 680bfead..e5b2f9f5 100644
--- a/user/emacs/init.el
+++ b/user/emacs/init.el
@@ -516,6 +516,18 @@ _p_rev       _u_pper              _=_: upper/lower       _r_esolve
 (use-package all-the-icons
   :config (setq all-the-icons-color-icons nil))
 
+(defmacro company-set-secondary-backend-for-mode (mode backend)
+  (let ((hook-fn-name (intern (concat "ap/set-local-backend-" (symbol-name mode)))))
+    `(progn
+       (defun ,hook-fn-name ()
+         (make-local-variable 'company-backends)
+         (setq company-backends (append
+                                 (list
+                                  'company-tabnine
+                                  ,backend)
+                                 (copy-tree (remq 'company-tabnine company-backends)))))
+       (add-hook ',(derived-mode-hook-name mode) #',hook-fn-name))))
+
 (use-package company-tabnine
   :commands (company-tabnine)
   :after (company)
@@ -945,6 +957,9 @@ _p_rev       _u_pper              _=_: upper/lower       _r_esolve
 (use-package tide
   :after (typescript-mode company flycheck)
   :ghook ('typescript-mode-hook #'tide-setup)
+  :init (progn
+          (setq tide-completion-setup-company-backend nil)
+          (company-set-secondary-backend-for-mode typescript-mode 'company-tide))
   :config (progn
             ;; loading this package has the annoying effect of breaking my company configuration
             ;; upstream fix: https://github.com/ananthakumaran/tide/pull/384