typescript: avoid 0 char autocomplete

This commit is contained in:
Andrea Moretti 2018-03-31 09:50:23 +02:00 committed by syl20bnr
parent 5a92c43951
commit 8081d51560
2 changed files with 14 additions and 2 deletions

View file

@ -45,7 +45,9 @@
"Setup tide auto-completion."
(spacemacs|add-company-backends
:backends company-tide
:modes typescript-mode typescript-tsx-mode)
:modes typescript-mode typescript-tsx-mode
:variables
company-minimum-prefix-length 2)
(company-mode))
@ -78,7 +80,9 @@
(spacemacs|add-company-backends
:backends company-lsp
:modes typescript-mode typescript-tsx-mode)
:modes typescript-mode typescript-tsx-mode
:variables
company-minimum-prefix-length 2)
(company-mode))
(message "`lsp' layer is not installed, please add `lsp' layer to your dofile.")))
@ -141,3 +145,6 @@
(list (point-min) (point-max))))
(browse-url (concat "http://www.typescriptlang.org/Playground#src="
(url-hexify-string (buffer-substring-no-properties start end)))))
(defun spacemacs/typescript-yasnippet-setup ()
(yas-activate-extra-mode 'js-mode))

View file

@ -18,6 +18,7 @@
tide
typescript-mode
web-mode
yasnippet
))
(defun typescript/post-init-add-node-modules-path ()
@ -78,6 +79,10 @@
(define-derived-mode typescript-tsx-mode web-mode "TypeScript-tsx")
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-tsx-mode)))
(defun typescript/post-init-yasnippet ()
(add-hook 'typescript-mode-hook #'spacemacs/typescript-yasnippet-setup)
(add-hook 'typescript-tsx-mode-hook #'spacemacs/typescript-yasnippet-setup))
(defun typescript/init-typescript-mode ()
(use-package typescript-mode
:defer t