Welcome to the Forge Format VSC extension! Streamline the formatting of your Solidity files with ease using Forge, a powerful tool from Foundry. This Visual Studio Code (VSCode) extension seamlessly integrates Forge into the VSCode formatter API, allowing efficient formatting of Solidity code directly within the editor.
-
Forge Formatting Integration: Harness the capabilities of Forge from Foundry for quick and efficient Solidity file formatting.
- Integrated seamlessly into VSCode's powerful formatter API, seamlessly working with default VSCode commands.
- Utilize shortcuts like alt+shift+f for entire file formatting and cmd+k + cmd+f (or ctrl+k + ctrl+f) for formatting specific code ranges or snippets.
- Right-click inside a document for "format document" support.
-
Context Menu Integration: (Coming soon™) Easily format individual files or entire folders directly from the VSCode context menu.
- Foundry: Ensure that Foundry is installed on your machine. Download it from getfoundry.sh.
Tailor the extension to your preferences with the following configuration options:
- Include and Exclude Globs: Define globs for files to include or exclude from formatting.
- Auto-Save and Auto-Close: Choose whether formatted files are automatically saved and closed after formatting.
- Workspace Configuration: Customize workspace settings for automatic detection or specify a root override.
Adjust these settings in the VSCode settings menu.
Forge Format VSC respects your editor configuration. Control automatic formatting on save and set the default formatter to "rmcmk.forge-format-vsc" in your VSCode settings.
- Formatting a range with "invalid" Solidity, such as a snippet missing a closing bracket, may fail if Forge cannot construct a valid Parse Tree.
If you encounter any issues, please refer to the GitHub issues page or report a new issue.
- Fix occasional inconsistencies when formatting ranges.
- Format code ranges/snippets within a document using VSCode's built-in range formatter.
- Ability to pipe code into Forge from the editor's buffer, enabling formatting of dirty files with pending changes.
- Shifted from parsing diffs directly from Forge to generating custom diffs using the
jsdiff
library and raw formatted output from Forge. This change enhances integration with Visual Studio Code's TextEdit API, offering improved control over text edits within the editor. - New Settings:
- Implementation of
includeGlobs
andexcludeGlobs
. - Options for saving and closing files after formatting.
- Implementation of
- Improved parsing of Forge's diff output.
- Correct handling of unmodified lines.
- Enhanced tokenization of the diff for more reliable output across OS.
- Fail-fast mechanism for impossible formatting.
- Proper implementation of
editor.formatOnSave
. - Improved default settings for a consistent out-of-the-box experience.
- Settings UI implementation for user-friendly configuration.
- Initial release of "Forge Format VSC."
Enjoy effortless Solidity formatting with Forge in VSCode!