i've been trying to get this to work for days now
Hi guys and guylettes!
im using vscode on windows 11: i setup foundry and added hardhat to it and for the life of me i cannot get this thing to work properly. i want codehinting to work as expected, linting, remappings, prettier and hardhat to simply just work.
i get lost in millions of config files, but i think im almost there?
i went to do the following:
- i got git
- i installed foundryup to get foundry working on windows.
- created a project in a folder using gitbash: forge init
- then i ran: npm install --save-dev @nomicfoundation/hardhat-toolbox @nomicfoundation/hardhat-foundry
- i added the two require lines in the hardhatconfig
- i got the openzeppelin contracts using forge install
- i installed the hardhat extension for vscode (i had the prettier formatter extension earlier)
- i npm'd the solidity prettier plugin
i could not figure out how to properly setup Prettier to work with this setup. my .vscode settings file looks like this rn:
{
"editor.formatOnSave": true,
"[solidity]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.configPath": ".prettierrc"
}
i'm assuming this might not be correct since it seems to format solidity files but won't any other file. (settings.json for example)
my .prettierrc file is like this now:
{
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.sol",
"options": {
"parser": "solidity-parse",
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false
}
}
]
}
Whats working now:
- forge seems to be working now
- Prettier seems to at least recognize solidity files
- codehinting looks alright now
Whats NOT working:
- remapping is SO totally not working (Without errors shown in vscode [since no linting works], only on compile using forge)
- clicking on any file in the import list using go to definition (will land me on an empty page saying "The file is not displayed in the text editor because it is a directory."
- clicking on any go to definition in code
What am i missing? Thank you guys!
oh i forgot to mention: i cannot just start vscode to have this working.
I get the following error:
Hardhat project "v1" was not able to initialize correctly: Couldn't run forge. Please check that your foundry installation is correct.
for now i have to got to the project folder and use gitbash to start vscode. which is also less than desirable.
How are you setting up your remappings for forge? Could you paste the remappings?
Hi @WynonaEngine, I'm closing this for bookkeeping reasons, but I'll be happy to reopen it if this issue persists and you can provide more information. Thanks!