gencay / vscode-chatgpt

An unofficial Visual Studio Code - OpenAI ChatGPT integration
ISC License
3.5k stars 760 forks source link

[Feature Request]: Smart code formatting based on context #231

Closed martinszeltins closed 1 year ago

martinszeltins commented 1 year ago

Describe the feature

It would be super nice if there was a smart AI code formatting option where the AI looks at your codebase and understands your formatting style and then formats the current file based on the style of the rest of the code base. I do not like to use formatters like prettier since they are too opinionated but if the AI could analyze my style and apply the same formatting that would be so 🔥 😍

gencay commented 1 year ago

Can you give me a prompt example where gpt model would style the code? That's ideally the job of formatting utilities or linters like prettier, eslint etc. On the other hand the extension currently doesn't support embeddings of full projects due to token limitations. Perhaps you could give some examples of current capability of these models where you see it'd be helpful in styling your code

Christopher-Hayes commented 1 year ago

For this use-case it might more efficient to use AI to generate a config that matches the formatting you like to use. I'm a big fan of VSCode's "Format document" action which works flexibly with different formatters with different rules. Your original feature may be possible with the GPT-4 32k model, but will be pricey if you're doing this on a lot of files.