Apple Swift Format for VS Code:让您的Swift代码焕然一新
Apple Swift Format for VS Code是一款非官方扩展,旨在通过apple/swift-format自动美化您的Swift代码。无论您选择全局安装还是通过Swift包管理器使用,我们都为您提供了详细的安装指南和配置选项。
全局安装指南:
您可以使用Homebrew、Mint或手动方式全局安装apple/swift-format:
# 使用Mint
$ mint install apple/swift-format@release/5.8
# 使用Homebrew
$ brew install swift-format
# 手动安装
$ git clone -b release/5.8 https://github.com/apple/swift-format.git
$ swift build -c release
注意: 请选择与您的Swift版本相匹配的分支名称进行安装!例如,Swift 5.5使用swift-5.5-branch,Swift 5.6使用release/5.6。有关完整且最新的映射,请参考apple/swift-format#Matching Swift Format to your Swift version。
本地安装指南:
在您的Package.swift中添加apple/swift-format作为依赖项:
// swift-tools-version:5.8
import PackageDescription
let package = Package(
name: "Komondor",
products: [ ... ],
dependencies: [
// 我的依赖项
.package(url: "https://github.com/orta/PackageConfig.git", from: "0.0.1"),
// 开发依赖项
.package(url: "https://github.com/orta/Komondor.git", from: "0.0.1"),
.package(url: "https://github.com/apple/swift-format.git", branch:("release/5.8")),
],
targets: [...]
)
注意: 请选择与您的Swift版本相匹配的分支名称进行安装!例如,Swift 5.5使用swift-5.5-branch,Swift 5.6使用release/5.6。有关完整且最新的映射,请参考apple/swift-format#Matching Swift Format to your Swift version。
配置选项:
配置项 | 类型 | 默认值 | 描述 |
---|---|---|---|
apple-swift-format.enable | Bool | true | 是否启用apple/swift-format功能。 |
apple-swift-format.onlyEnableOnSwiftPMProjects | Bool | false | 仅在SwiftPM项目中启用并使用apple/swift-format作为依赖项。 |
apple-swift-format.onlyEnableWithConfig | Bool | false | 仅在存在配置文件时启用格式化。 |
apple-swift-format.path | [String] | String | swift-format | 全局安装的SwiftFormat的位置(如果仅为文件名,则与当前路径解析)。 |
apple-swift-format.configSearchPaths | [String] | [".swift-format"] | apple/swift-format配置文件的可能路径。 |
贡献者:
许可证:
vscode-apple-swift-format在MIT许可证下可用。
通过Apple Swift Format for VS Code,您可以轻松保持Swift代码的整洁和一致性,提升开发效率和代码质量。
本站所有资源都是由网友投稿发布,或转载各大下载站, 请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则 产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:study_golang@163.com