ananthakumaran / tide

Tide - TypeScript Interactive Development Environment for Emacs
GNU General Public License v3.0
1.45k stars 109 forks source link

Error message in Vue buffers #400

Open FredrikMeyer opened 3 years ago

FredrikMeyer commented 3 years ago

Hi,

I have a problem with vue-mode + tide.

Every time I open a .vue file, I get the following error in the *Messages* tab:

Error processing request. No Project.
Error: No Project.
    at Object.ThrowNoProject (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:137981:23)
    at ScriptInfo.getDefaultProject (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:138751:46)
    at ProjectService.doEnsureDefaultProjectForFile (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:141451:48)
    at ProjectService.ensureDefaultProjectForFile (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:141446:75)
    at IOSession.Session.getFileAndProjectWorker (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:145272:87)
    at IOSession.Session.getProjectInfoWorker (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:145124:36)
    at IOSession.Session.getProjectInfo (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:145121:29)
    at Session.handlers.ts.createMapFromTemplate._a.<computed> (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:144500:61)
    at /Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:146003:88
    at IOSession.Session.executeWithRequestId (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:145994:28)
    at IOSession.Session.executeCommand (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:146003:33)
    at IOSession.Session.onMessage (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:146027:35)
    at Interface.<anonymous> (/Users/fredrikmeyer/code/work/Cloud/frontend/node_modules/typescript/lib/tsserver.js:147342:27)
    at Interface.emit (events.js:314:20)
    at Interface._onLine (readline.js:337:10)
    at Interface._normalWrite (readline.js:482:12)
    at Socket.ondata (readline.js:194:10)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:303:12)
    at readableAddChunk (_stream_readable.js:279:9)
    at Socket.Readable.push (_stream_readable.js:218:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

But if I just manually run M-x tide-setup, everything works fine. The problem is that I have to do this for every new .vue buffer.

I'm guessing this has something to do with vue-mode being derived from mmm-mode.

Here is my configuration:

(use-package typescript
  :ensure t
  :config
  (add-hook 'vue-mode-hook #'setup-vue-with-ts))

(use-package tide
  :ensure t
  :config))

(defun setup-vue-with-ts ()
  (interactive)
  "Setup vue"
  (tide-setup)
  (eldoc-mode +1)
  (flycheck-mode 0)
  (tide-hl-identifier-mode t))

(use-package vue-mode
  :ensure t
  :mode "\\.vue\\'"
  :config
  (set-face-background 'mmm-default-submode-face nil))

Tide works perfect in non-Vue buffers.

I get the same error message when I do M-x tide-verify-setup.

Relevant Version Numbers

(The list above is minimal. Make sure to include any other version numbers relevant to your report.)

Steps to Reproduce the Bug

Open any Vue buffer with the above configuration and try to do anything tide-related, like M-..

Expected Behavior

No errors.

Actual Behavior

The error message.

ananthakumaran commented 3 years ago

I am not sure when the vue-mode-hook gets executed. You could try to use

(setq mmm-typescript-mode-submode-hook #'setup-vue-with-ts)

There seem to be a lot of issues though, as tsserver tries to parse the whole file instead of the snippet. There was a fix https://github.com/ananthakumaran/tide/pull/203 submitted earlier, but it doesn't seem to work anymore. Not sure it's a regression in tide or mmm mode.

FredrikMeyer commented 3 years ago

Thank you for the quick answer!

Your suggestion seem work! Thanks.

Thank you for the best JS minor mode out there :)