Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only work in first opened javascript file #211

Closed
wd opened this issue Nov 19, 2017 · 3 comments
Closed

Only work in first opened javascript file #211

wd opened this issue Nov 19, 2017 · 3 comments

Comments

@wd
Copy link

wd commented Nov 19, 2017

It's so weird, every time I restart emacs and open an javascript file, tsserver will auto start and the auto completion, tide-hl-identifier and all other tide feature worked like a charm, but then if I open an other file, the completion will break, no candidate will show, tide-hl-identifier also not work too. I have set TSS_LOG, bug still no clue where am I wrong.

I'm working on a react-native project. Here is my jsconfig file.

{
    "compilerOptions": {
        "target": "es2016",
        "noEmit": true,
        "checkJs": true,
        "allowJs": true,
        "allowSyntheticDefaultImports": true,
        "jsx": "react"
    },
    "exclude": [
        "node_modules",
        "ios",
        "android",
        ".git"
    ]
}
(defun setup-tide-mode ()
  (interactive)
  (setq tide-tsserver-process-environment '("TSS_LOG=-level verbose -file /tmp/tss.log"))
  (tide-setup)
  ;;(setq flycheck-check-syntax-automatically '(save mode-enabled))
  (eldoc-mode +1)
  (tide-hl-identifier-mode +1)
  ;; company is an optional dependency. You have to
  ;; install it separately via package-install
  ;; `M-x package-install [ret] company`
  )

(use-package tide
  :ensure t
  :bind (("M-." . tide-jump-to-definition)
         ("M-," . tide-jump-back)
         )

  :config
  (setup-tide-mode)
  ;; 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)

  ;; configure javascript-tide checker to run after your default javascript checker
  (flycheck-add-next-checker 'javascript-eslint 'javascript-tide 'append)

  (add-hook 'web-mode-hook
            (lambda ()
              (when (string-equal "jsx" (file-name-extension buffer-file-name))
                (setup-tide-mode))))
  ;; configure jsx-tide checker to run after your default jsx checker
  (flycheck-add-mode 'javascript-eslint 'web-mode)
  (flycheck-add-next-checker 'javascript-eslint 'jsx-tide 'append)
  )
@josteink
Copy link
Collaborator

I would start checking your systems process list. Are the JS files all part of the same project? If they're not, you should see multiple tsserver-instances (one per project).

I don't really know how (use-package) works, so I can't tell if that's contributing to your issues.

I also don't do react, so I'm not sure if the whole JSX/TSX thing is causing additional troubles.

If you show us the log-output, we may be able to figure out what's going wrong, and how/if we can fix it.

@wd
Copy link
Author

wd commented Nov 25, 2017

Finally I have some spare time to check this. You are right, the problem is that only the first JS file enabled tide-mode. Thanks for your help to remind me check the configurations.

@wd wd closed this as completed Nov 25, 2017
@josteink
Copy link
Collaborator

Glad you worked it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants