language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

vue-language-server 2.x does not work for TS/JS on Emacs

Open maciej-szlosarczyk opened this issue 10 months ago • 1 comments

On Emacs with lsp-mode, 2.0.7 does not do anything useful for typescript or javascript - i.e hover request returns null or completion returns an empty array of candidates. Here's an example request-response for hover over the following:

import { RouterLink, RouterView } from 'vue-router'
[Trace - 09:15:27 pm] Sending request 'textDocument/hover - (50)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/maciej/Development/javascript/vue-example/src/App.vue"
  },
  "position": {
    "line": 1,
    "character": 13
  }
}


[Trace - 09:15:27 pm] Received response 'textDocument/hover - (50)' in 2ms.
Result: null

The same on 1.8.0:

[Trace - 09:18:05 pm] Sending request 'textDocument/hover - (50)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/maciej/Development/javascript/vue-example/src/App.vue"
  },
  "position": {
    "line": 1,
    "character": 13
  }
}


[Trace - 09:18:05 pm] Received response 'textDocument/hover - (50)' in 4ms.
Result: {
  "contents": {
    "kind": "markdown",
    "value": "```typescript\n(alias) const RouterLink: _RouterLinkI\nimport RouterLink\n```\n\nComponent to render a link that triggers a navigation on click."
  },
  "range": {
    "start": {
      "line": 1,
      "character": 9
    },
    "end": {
      "line": 1,
      "character": 19
    }
  }

This affects both script tags in Vue file and standalone .ts and .js files. What's interesting is that hovering over html tags in template tags or CSS directives in style works just fine - shows documentation and all.

I'm not even sure if this is a server issue or should the client definition in https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-volar.el be updated. Pointers would be appreciated 🙏

maciej-szlosarczyk avatar Mar 30 '24 19:03 maciej-szlosarczyk

This is due to structure change in version 2. Takeover mode has removed.

Basically you have to run another ts/js server with vue typescript extension to handle <script> or if you can pass option to lsp. You can give

-- This is lua for neovim. you should change to whatever emacs uses.
vue = {
      hybridMode = false,
},

RayGuo-ergou avatar Apr 02 '24 02:04 RayGuo-ergou

Closing this one due to inactivity. Feel free to create a new issue if you're still having issues with the latest version, thanks!

davidmatter avatar Aug 07 '24 07:08 davidmatter