1

Autocompletion doesn't work with tide or Tern, I have to M-x company-complete-common. I would like for it to keep suggesting with a dropdown menu as I type, but I can't manage to. It works just fine with elpy and go-mode.
I am using emacs 25.3.1 and I have these init lines regarding to js2-mode with tern:

(require 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
;; Better imenu
(add-hook 'js2-mode-hook #'js2-imenu-extras-mode)
(require 'js2-refactor)
(require 'xref-js2)

(add-hook 'js2-mode-hook #'js2-refactor-mode)
(js2r-add-keybindings-with-prefix "C-c C-r")
(define-key js2-mode-map (kbd "C-k") #'js2r-kill)

;; js-mode (which js2 is based on) binds "M-." which conflicts with xref, so
;; unbind it.
(define-key js-mode-map (kbd "M-.") nil)

(add-hook 'js2-mode-hook (lambda ()
 (add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t)))

(require 'company)
(require 'company-tern)

(add-to-list 'company-backends 'company-tern)
(add-hook 'js2-mode-hook (lambda ()
                           (tern-mode)
                           (company-mode)))

;; Disable completion keybindings, as we use xref-js2 instead
(define-key tern-mode-keymap (kbd "M-.") nil)
(define-key tern-mode-keymap (kbd "M-,") nil)

regarding tide:

;; tide
(defun setup-tide-mode ()
 (interactive)
 (tide-setup)
 (flycheck-mode +1)
 (setq flycheck-check-syntax-automatically '(save mode-enabled))
 (eldoc-mode +1)
 (company-mode +1))

;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)

;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)

(add-hook 'typescript-mode-hook #'setup-tide-mode)

There is no error on init, and company-mode is enabled on these modes as expected, it just doesn't start suggesting as typing goes, instead only works for manual completion.

  • Do you have company-mode installed? – DoMiNeLa10 Nov 25 '17 at 13:53
  • Did you install tern and added a .tern-config or .tern-project file? – caisah Nov 25 '17 at 16:38
  • @DoMiNeLa10 yes, and it works if I initiate completion manually, it shows a list of suggestion or if only one is possible it completes. It also works with other major modes such as go-mode and elpy. – Pedro Queiroga Nov 25 '17 at 17:23
  • @caisah I have tern installed tern and I do have a .tern-project file, nothing changes if I have this file or not, though. Same goes for a .tern-config file. – Pedro Queiroga Nov 25 '17 at 17:29
  • 1
    for tide, change " (add-hook 'typescript-mode-hook #'setup-tide-mode)" to " (add-hook 'js2-mode-hook #'setup-tide-mode)" and put a "jsconfig.json" file in your project path(code.visualstudio.com/docs/languages/jsconfig). – Pedro Nov 26 '17 at 0:41
0

I asked around and what solved it for me was setting company-idle-delay to 0!
Previously it was nil, since it still worked on other modes I believe they don't follow a standard in processing this variable. I will add this to my init.el.

edit: I went through my init file with a fine comb and I found why company-idle-delay was set to nil, it was a line that I put there a year or so ago.

  • What value did company-idle-delay have before? – Dmitry Nov 26 '17 at 21:19
  • @Dmitry It had nil. – Pedro Queiroga Nov 26 '17 at 22:08
  • That's not its default value. You should find where your init script set it to nil in the first place. – Dmitry Nov 27 '17 at 0:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.