rescript-lang / rescript-vscode

Official VSCode plugin for ReScript
MIT License
329 stars 56 forks source link

No hover type hint for variables #550

Closed sym233 closed 1 year ago

sym233 commented 2 years ago

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": "yarn@3.2.2",
  "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

cristianoc commented 2 years ago

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.

sym233 commented 2 years ago

The file was saved.

I did other trials

Then the hover hint appears.

3rd round:

Maybe the extension is not compatible with yarn 2?

cristianoc commented 2 years ago

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.

zth commented 2 years ago

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

sym233 commented 2 years ago

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

nothing changes

sym233 commented 2 years ago

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.
fhammerschmidt commented 2 years ago

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

sym233 commented 2 years ago

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

fhammerschmidt commented 2 years ago

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.

sym233 commented 2 years ago

@fhammerschmidt ah, that works

fhammerschmidt commented 2 years ago

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.

zth commented 1 year ago

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