NomicFoundation / hardhat-vscode

Solidity and Hardhat support for Visual Studio Code
https://hardhat.org
MIT License
169 stars 39 forks source link

Autocomplete triggers within comments #61

Open kanej opened 2 years ago

kanej commented 2 years ago

This is feedback from @fvictorio's notes.

We trigger auto completes on on the . key. This is currently working inside of comments which is a pain if you use a fullstop:

image

We configure completions for the . key, our ideal would be not to attempt completion in a comment rather than an empty list, though that is clearly better than suggesting the generic keyword options.

Some exploration of how other language extensions deal with this is probably the best place to start.

kanej commented 1 year ago

I think we want to add a check here as to whether we are in a comment. But this probably requires the slang parser.

fvictorio commented 1 year ago

Couldn't you use solidity-comments-extractor and then check if the cursor is within a comment? Prettier Solidity uses that under the hood, so it's battle tested.

Alternatively, we could modify solidity-analyzer to return information about comments too.

kanej commented 1 year ago

Will solidity-comments-extractor give us the ranges of every comment in the file?

Could we do the extract as part of analysis and keep the ranges for instance?

kanej commented 1 year ago

I wouldn't add it in to fix this bug, but this + documents on hover supports might be worth it as a stop gap.

fvictorio commented 1 year ago

Will solidity-comments-extractor give us the ranges of every comment in the file?

Yes

Could we do the extract as part of analysis and keep the ranges for instance?

Also yes?