juanfranblanco / vscode-solidity

Visual Studio Code language support extension for Solidity smart contracts in Ethereum https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity
MIT License
902 stars 193 forks source link

Introspect compiler from pragma directive #270

Open ghost opened 3 years ago

ghost commented 3 years ago

I am having a hard time getting a project with multiple solidity versions to work well with this extension. There should be better support for having contracts in the same workspace use different solc compilers.

Configuring the compiler version has always been a bit of a headache for this extension. I would prefer a fix which avoids the need to do any configuration.

juanfranblanco commented 3 years ago

@eranralf you can simply do the following, it should not be a pain for you: image

A setting could be put to enable this, as once all the versions are downloaded it may not affect much the switching. I was talking about it anyway.

Why a setting?

Introspecting might be an issue with your preferred version, also it will slow down things (download the version, load it in memory, compile on the fly, show errors).

Also we do also have different compilers now, for example the OVM one, hence you can easily switch between a local and remote version.

ghost commented 3 years ago

A setting could be put to enable this, as once all the versions are downloaded it may not affect much the switching. I was talking about it anyway.

I think this is a good idea, it is cumbersome to manually switch the compiler version every time I switch working files.

mtomassoli commented 2 years ago

In hardhat I simply list the versions I need and then they're automatically selected. For instance my hardhat.config.ts contains

const config: HardhatUserConfig = {
  solidity: {
    compilers: [
      {
        version: "0.5.3",
        settings: {
          optimizer: {
            enabled: true,
            runs: 1000,
          },
        }
      },
      {
        version: "0.6.12",
        settings: {
          optimizer: {
            enabled: true,
            runs: 1000,
          },
        }
      },
      {
        version: "0.8.12",
        settings: {
          optimizer: {
            enabled: true,
            runs: 1000,
          },
        }
      }
    ]
  }

Something similar would be useful for vscode-solidity as well.