Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode intellisense not working for solidity files when using hardhat-foundry #571

Open
tmigone opened this issue Mar 27, 2024 · 2 comments
Assignees
Labels
status:ready This issue is ready to be worked on type:bug Something isn't working

Comments

@tmigone
Copy link

tmigone commented Mar 27, 2024

Version of Hardhat

2.22.2

What happened?

IntelliSense in VSCode stops working when adding @nomicfoundation/hardhat-foundry plugin to a Hardhat project. Imported files wont have any definitions or types, suggestions, etc. For example the following screenshot showing import definitions not being found:

Screenshot 2024-03-27 at 10 39 49

The project will build fine though.

Minimal reproduction steps

The following repo contains a project and steps for a minimal reproduction: https://github.com/tmigone/hardhat-foundry-repro

Search terms

foundry, intellisense, vscode

@kanej kanej added type:bug Something isn't working status:ready This issue is ready to be worked on and removed status:triaging labels Mar 27, 2024
@kanej
Copy link
Member

kanej commented Mar 27, 2024

Hey @tmigone, thanks for the reproduction repo, that makes things far easier to debug.
We will investigate and get back.

@kanej kanej transferred this issue from NomicFoundation/hardhat May 16, 2024
@Reblixt
Copy link

Reblixt commented Jul 22, 2024

Has there been any progress here?
Have the same issue and no imports works at all when i have solidity_ls_nomicfoundation lsp installed.
And when i have solidity_ls installed instead i get syntax errors on all the imports.

However these issue go away when i remove the
@nomicfoundation/hardhat-foundry
Line from hardhat.config.ts file

But then other issue arises instead.
example i get syntaxerror for all the forge-std imports.

I notice when i "go to definition" to: @nomicfoundation/hardhat-foundry
that file looks like this

export { };
//# sourceMappingURL=index.d.ts.map

I imagine that this could be the issue?

Because when i try to go to definition on Neovim i get this response

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:294: bad argument #1 to 'gmatch' (string expected, got nil)
stack traceback:
	[C]: in function 'gmatch'
	/usr/share/nvim/runtime/lua/vim/lsp/util.lua:294: in function 'get_lines'
	/usr/share/nvim/runtime/lua/vim/lsp/util.lua:1908: in function 'locations_to_items'
	...nvim/lazy/telescope.nvim/lua/telescope/builtin/__lsp.lua:197: in function 'handler'
	/usr/share/nvim/runtime/lua/vim/lsp/client.lua:685: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

In summery it expects a string but gets nil/nul/undefined instead

And in VScode i get no response at all

These is the installed dependencies i have.

{
  "devDependencies": {
    "@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
    "@nomicfoundation/hardhat-ethers": "^3.0.0",
    "@nomicfoundation/hardhat-foundry": "^1.1.2",
    "@nomicfoundation/hardhat-ignition": "^0.15.0",
    "@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.0",
    "@nomicfoundation/hardhat-toolbox": "^5.0.0",
    "@nomicfoundation/hardhat-verify": "^2.0.0",
    "@typechain/ethers-v6": "^0.5.0",
    "@typechain/hardhat": "^9.0.0",
    "@types/chai": "^4.2.0",
    "@types/mocha": ">=9.1.0",
    "@types/node": ">=18.0.0",
    "chai": "^4.2.0",
    "ethers": "^6.4.0",
    "hardhat": "^2.22.5",
    "hardhat-gas-reporter": "^1.0.8",
    "husky": ">=6",
    "lint-staged": ">=10",
    "prettier": "^3.3.2",
    "solidity-coverage": "^0.8.0",
    "ts-node": ">=8.0.0",
    "typechain": "^8.3.0",
    "typescript": ">=4.5.0"
  },
  "dependencies": {
    "@openzeppelin/contracts": "^5.0.2",
    "@openzeppelin/contracts-upgradeable": "^5.0.2",
    "@openzeppelin/hardhat-upgrades": "^3.2.0",
    "dayjs": "^1.11.11",
    "dotenv": "^16.4.5",
    "zod": "^3.23.8"
  },
  "lint-staged": {
    "*.{js,css,md}": "prettier --write"
  },
  "scripts": {
    "prepare": "husky install"
  }
}

Thanks in advance! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on type:bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

3 participants