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
886 stars 190 forks source link

Support for truffle v5 #120

Open PaulRBerg opened 5 years ago

PaulRBerg commented 5 years ago

Truffle v5 allows you to bring your own compiler, but this extension doesn't seem to be aware of that.

Source files requires different compiler version

Whereas my truffle-config.js file specifies a version which is compatible with the current smart contract code (compiling with truffle works fine):

compilers: {
    solc: {
        version: '0.4.24',
        ...
    },
}
juanfranblanco commented 5 years ago

Hi @PaulRBerg,

You will need to use the vscode extension configuration to match the truffle compiler. Check the readme for that.

Edit.. (For the time being). I guess it could be added as a configuration option to put "truffle" and truffle file.

PaulRBerg commented 5 years ago

What I'm doing now is to have this in my "Workspace Settings":

{
  "solidity.compileUsingRemoteVersion": "v0.4.24+commit.e67f0147"
}

But indeed, my suggestion was to have the vscode extension automatically detect the use of truffle.

juanfranblanco commented 5 years ago

I guess the remote version could be set as "truffle-version", this way the order of preference local, node-modules, etc will be preserved. "solidity.compileUsingRemoteVersion": "truffle-version"

Also something that can be set only for the workspace.

davidcozsmith commented 5 years ago

In the meantime, are there any known workarounds like aliasing or symlinking the "truffle" folder?

Copied From: https://ethereum.stackexchange.com/questions/39213/smart-way-to-link-to-truffle-library-files-using-visual-code-on-ubuntu-14-04?rq=1

> ...
> pragma solidity ^0.4.18;
> import "truffle/Assert.sol"; // This import statement shows an error.

Below is the path to my current Truffle installation under NVM (Node Version Manager's) control: > ~/.nvm/versions/node/v6.7.0/lib/node_modules/truffle/build/Assert.sol My question is, what is the smart way to tell Visual Code where to find the library files so that if I change > Node or Truffle versions, I don't break my smart contract projects? Symlink? Something else?

Related: https://github.com/juanfranblanco/vscode-solidity/issues/76 https://github.com/truffle-box/pet-shop-box/issues/32 https://github.com/trufflesuite/truffle/issues/787 https://github.com/trufflesuite/truffle/issues/968 https://github.com/trufflesuite/truffle/issues/756