I've been using typescript-mode and tide for a long time but I wanted to try out tree-sitter and lsp-mode. I've got most things working except for one problem with syntax highlighting. When I first visit a TypeScript or TSX file, the buffer has no syntax highlighting. If I call (font-lock-update) then syntax highlighting starts working correctly in that buffer.
I can confirm that the two major modes I'm using are typescript-ts-mode and tsx-ts-mode. When I first visit a file and check C-h m, I can see that "Global minor mode global-font-lock-mode" is enabled. After I call (font-lock-update) I can see that "Local minor mode font-lock-mode" is enabled.
I customise these two major modes with a hook function that looks like this:
(defun setup-typescript-mode () (interactive) (lsp) (flycheck-mode +1) (setq flycheck-check-syntax-automatically '(save mode-enabled)) (eldoc-mode +1) (company-mode +1) (prettier-js-mode) (git-gutter+-mode) (yas-minor-mode-on) (tsi-typescript-mode 1) (turn-on-font-lock)) (add-hook 'typescript-ts-mode-hook #'setup-typescript-mode) (add-hook 'tsx-ts-mode-hook #'setup-typescript-mode) I tried adding that call to (turn-on-font-lock) in response to this problem but it hasn't fixed it.
Any ideas how I can get syntax highlighting to work here when I first visit a file and without having to do M-x font-lock-update every time?