rescript-vscode icon indicating copy to clipboard operation
rescript-vscode copied to clipboard

No hover type hint for variables

Open sym233 opened this issue 3 years ago • 11 comments
trafficstars

image I think there should be a hint, e.g. greeting is string, but nothing poped up.

It can auto-complete external keyword as expected. image

Rescript compiler works properly. image

I'm new to rescript and not sure I installed the extension properly. I use yarn 2 thus no node_modules in the working directory, and find executables in .yarn subdirectory.

vscode setting.json:

{
    "rescript.settings.binaryPath": "[proj_name]\\.yarn\\unplugged\\rescript-npm-9.1.4-75c65d01e7\\node_modules\\rescript",
    "rescript.settings.autoRunCodeAnalysis": true
}

bsconfig.json:

{
  "name": "proj_name",
  "sources": [
    {
      "dir": "src",
      "subdirs": true
    }
  ],
  "package-specs": [
    {
      "module": "es6",
      "in-source": true
    }
  ],
  "suffix": ".bs.js",
  "bs-dependencies": []
}

package.json:

{
  "name": "proj_name",
  "packageManager": "[email protected]",
  "devDependencies": {
    "rescript": "^9.1.4"
  },
  "scripts": {
    "re:build": "rescript",
    "re:start": "rescript build -w"
  }
}

System info: 版本: 1.70.1 (user setup) 提交: 6d9b74a70ca9c7733b29f0456fd8195364076dda 日期: 2022-08-10T06:08:33.642Z Electron: 18.3.5 Chromium: 100.0.4896.160 Node.js: 16.13.2 V8: 10.0.139.17-electron.0 OS: Windows_NT x64 10.0.19044

extension version: v1.4.2

sym233 avatar Aug 12 '22 04:08 sym233

Make sure the file was saved before trying to hover. If it was saved, start with an empty project that only contains those 2 lines, se if the issue is still there.

cristianoc avatar Aug 12 '22 05:08 cristianoc

The file was saved.

I did other trials

  • clone https://github.com/rescript-lang/rescript-project-template
  • yarn # install, using yarn 1 here, with node_modules
  • leave "rescript.settings.binaryPath" empty

Then the hover hint appears.

  • clone template again
  • yarn set version berry # swap to yarn 2, plug'n'play
  • yarn -v # 3.2.2
  • yarn # install without node_modules
  • set "rescript.settings.binaryPath" to "D:\Github\rescript-project-template\.yarn\unplugged\rescript-npm-9.1.4-75c65d01e7\node_modules\rescript"
  • click 'start build' in the popup Then no hover hint.

3rd round:

  • clone template again
  • yarn # install deps using yarn 1 with node_modules
  • set "rescript.settings.binaryPath" to "D:\Github\rescript-project-template\node_modules\.bin" Then hover hint work for the template, but NOT for other projects managed by yarn 2

Maybe the extension is not compatible with yarn 2?

sym233 avatar Aug 12 '22 05:08 sym233

We have no windows devs, so these are always tricky. It would be good to at some point have someone who can build the extension from source on Windows and begin debugging these very basic cases.

cristianoc avatar Aug 12 '22 06:08 cristianoc

Can you try the pre-release version of the extension?

zth avatar Aug 12 '22 06:08 zth

Can you try the pre-release version of the extension?

nothing changes

sym233 avatar Aug 12 '22 06:08 sym233

I tested it in wsl with yarn 2. NO hover hint still.

  • clone template again
  • yarn set version berry # swap to yarn 2, plug'n'play
  • yarn -v # 3.2.2
  • yarn # install without node_modules
  • set "rescript.settings.binaryPath" to "D:\Github\rescript-project-template.yarn\unplugged\rescript-npm-9.1.4-75c65d01e7\node_modules\rescript"
  • click 'start build' in the popup Then no hover hint.

sym233 avatar Aug 12 '22 07:08 sym233

Before we have a fix, can you try https://github.com/reason-seoul/yarn-plugin-rescript and check if the extension works with that?

fhammerschmidt avatar Aug 12 '22 07:08 fhammerschmidt

@fhammerschmidt it seems to have issue, too. https://github.com/reason-seoul/yarn-plugin-rescript/issues/14

sym233 avatar Aug 12 '22 10:08 sym233

Ok, I guess the plugin is not compatible with Windows (or your setup).

Alternatively: Can you set nodeLinker to node-modules in your .yarnrc.yml? See: https://yarnpkg.com/configuration/yarnrc#nodeLinker

Then the extension should work without setting the binary path manually. However it disables pnp.

fhammerschmidt avatar Aug 12 '22 10:08 fhammerschmidt

@fhammerschmidt ah, that works

sym233 avatar Aug 12 '22 10:08 sym233

Just to clarify: It does not make sense for the extension to support yarn PnP yet, when even the compiler does not: https://github.com/rescript-lang/rescript-compiler/issues/3276

As soon as you add some dependencies, you will have all kinds of issues.

fhammerschmidt avatar Aug 12 '22 12:08 fhammerschmidt

Closing this since there's nothing actionable for us here for now.

zth avatar Feb 01 '23 06:02 zth