ktfmtter
This is a VS Code extension for running ktfmt as a Kotlin formatter. It is a fork of the vscode-ktfmt extension, with added support for selecting the formatting style.
When activated, this extension will prompt you to select a ktfmt
version, which will be downloaded and cached.
You can set ktfmt
as your default formatter for kotlin files by adding the following to your settings.json
file:
{
// The version of ktfmt to use.
// This is updated automatically when you select a version from the prompt.
// Set this to `null` to be prompted to select a version again.
"ktfmtter.ktfmtVersion": "0.47",
// Optional: Set the formatting style. Can be 'kotlinlang' or 'google'.
"ktfmtter.style": "kotlinlang",
// Optional: Specify which Java runtime to use.
// If not set, it will use the one marked as default in 'java.configuration.runtimes'.
"ktfmtter.java-runtime": "JavaSE-17",
"[kotlin]": {
"editor.defaultFormatter": "shape-app.ktfmtter"
}
}
This extension uses your Java configuration to run ktfmt
. It assumes that you have installed the Java Language Support extension, which configures an array of runtimes at java.configuration.runtimes
. If you have not configured this yet, you may need to add something like the following to your settings.json
:
{
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "/path/to/your/java/home",
"default": true
}
]
}
If you do not want to use the default
runtime to run ktfmt
, copy the name
property into ktfmtter.java-runtime
and this extension will use that path
instead.
Known Issues
Nothing right now.
Release Notes
1.1.1
- Added extension icon.
- Updated extension description.
1.1.0
- Added
ktfmtter.selectVersion
command to download and select ktfmt
version.
1.0.0
- Initial fork of
crdrost/vscode-ktfmt
- Added
ktfmtter.style
setting