vknabel / vscode-swiftformat

SwiftFormat for VS Code
https://marketplace.visualstudio.com/items?itemName=vknabel.vscode-swiftformat
MIT License
43 stars 8 forks source link

Headers with variables don't work #18

Closed adam-fowler closed 2 years ago

adam-fowler commented 2 years ago

I have a comment header defined in my .swiftformat file which includes the {created} variable. The swift format extension fails to run while this is included. It returns with the error

Failed to apply {created} template in file header as file info is unavailable

Add this to your .swiftformat to replicate

--header "// Created {created}"
vknabel commented 2 years ago

Thanks for the report! Didn't know about the feature!

I'll have a look on the swiftformat docs and work on a fix soon.


Update: according to the SwiftFormat docs, we need to pass the path of the file --stdinpath /path/to/file.swift. Should be relatively easy.

$ cat /path/to/file.swift | swiftformat stdin --stdinpath /path/to/file.swift
vknabel commented 2 years ago

Fix has been released in 1.3.8