Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 30 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,31 @@
# TcTidier

TcTidier is a VS Code extension and native TypeScript formatter for TwinCAT Structured Text.
TcTidier is a formatter for TwinCAT Structured Text in VS Code.

It formats the active document, can format all supported TwinCAT files in a workspace, and keeps its regression corpus under `tests/fixtures` so the repo root stays clean.
It formats common TwinCAT PLC source files, plain Structured Text files, and TwinCAT-oriented virtual documents so you can keep TwinCAT code readable and consistent without hand-tuning spacing and indentation.

## Features

- Full-document formatting for `.TcPOU`, `.TcGVL`, `.TcDUT`, `.TcIO`, `.st`, and `.iecst`
- Manual formatting from the command palette, editor toolbar, or status bar
- Workspace formatting command for bulk cleanup
- Config lookup via `.tctidier.json`
- Deterministic formatting with committed fixture, phase, and integration tests
- Benchmark smoke check to catch obvious performance regressions

## Repo Layout

```text
src/ Extension entrypoint and native formatter
tests/ Fixture corpus and focused phase tests
benchmarks/ Native formatter benchmark scripts and baseline
docs/ Quickstart, guide, and contribution notes
.vscode/ Launch/tasks for debugging the extension
```

## GitFlow
## What It Formats

This repo now uses `main` for production history and `develop` for ongoing integration work. Create `feature/*` branches from `develop`, cut `release/*` branches when preparing a version, and use `hotfix/*` only for urgent fixes from `main`.
- `.TcPOU`
- `.TcGVL`
- `.TcDUT`
- `.TcIO`
- `.st`
- `.iecst`
- `TcView` virtual Structured Text documents opened as `twincat` / `iec-st`

`npm run release:check` runs the full verification path and packages a local `.vsix` so release branches and tags are validated the same way in local work and CI.

## Install And Build

```bash
npm install
npm run build
```
## Features

If you are behind a corporate proxy or custom CA, configure npm on your machine or CI environment. Do not commit machine-specific npm certificate settings to this repo.
- Format the active TwinCAT / Structured Text document
- Format an entire workspace of supported TwinCAT files
- Use it from `Format Document`, the command palette, the editor toolbar, or the status bar
- Set it as the default formatter for TwinCAT Structured Text
- Configure formatting through a workspace `.tctidier.json`
- Respect ignore directives with `tctidier-ignore`, `tctidier-ignore-start`, and `tctidier-ignore-end`

## Run In VS Code
## Quick Start

1. Open the repo in VS Code.
2. Press `F5`.
3. Choose `Run TcTidier Extension` or `Run TcTidier Extension (Watch)`.
4. In the Extension Development Host, open a supported TwinCAT/ST file.
5. Run `Format Document`, `TcTidier: Format Current Document`, or `TcTidier: Format Workspace TwinCAT Files`.
Install the extension, open a supported file, and either run `Format Document` or set TcTidier as the default formatter.

Recommended VS Code settings:

Expand All @@ -57,29 +38,18 @@ Recommended VS Code settings:
}
```

## Package And Install Locally

```bash
npm run package:vsix
code --install-extension tctidier-0.1.2.vsix --force
```

After public publish, you can also install it directly with:

```bash
code --install-extension CodePiercerTechnologies.tctidier
```
If another extension opens TwinCAT Structured Text as `iec-st`, TcTidier can still format it.

## Commands

- `TcTidier: Format Current Document`
- `TcTidier: Format Workspace TwinCAT Files`

The current document command is also exposed through the editor toolbar and a status bar button when a supported file is active.

## Configuration

Create a `.tctidier.json` file in your workspace root:
Create a `.tctidier.json` file in your workspace root when you want to customize formatting behavior.

Example:

```json
{
Expand All @@ -90,63 +60,25 @@ Create a `.tctidier.json` file in your workspace root:
"alignNamedParameters": true,
"blankLineBetweenCaseBranches": true,
"normalizeOneLineIf": true,
"maxLineLength": 90,
"printWidth": 100,
"caseIndent": 4,
"multilineIndent": 4
"printWidth": 100
}
```

Default formatter options:
For the fuller option set and behavior notes, see the formatter guide below.

```json
{
"indent": 4,
"useTabs": true,
"alignDeclarations": true,
"alignAssignments": true,
"sortDeclarations": false,
"normalizeBlankLines": true,
"alignVarColumns": true,
"normalizeOneLineIf": true,
"blankLineBetweenCaseBranches": true,
"maxLineLength": 90,
"keywordsUppercase": true,
"verticalLogicalChains": true,
"costBasedBreaking": true,
"respectIgnore": true,
"balanceParentheses": true,
"alignNamedParameters": true,
"trailingWhitespace": false,
"printWidth": 100,
"alignComments": true,
"newlineBetweenMethods": true,
"caseIndent": 4,
"multilineIndent": 4
}
```

Ignore directives use `tctidier-ignore`, `tctidier-ignore-start`, and `tctidier-ignore-end`.

## Test And Verify

```bash
npm test
npm run bench
npm run bench:compare
npm run verify
```
## Notes

`npm test` runs formatter-core tests plus VS Code integration tests. The integration runner uses a local VS Code install when available and falls back to `@vscode/test-electron` downloads otherwise.
- Workspace formatting skips dirty files so unsaved work is not overwritten.
- TcTidier is designed for deterministic formatting rather than style-by-style presets.

## More Docs

- [Quickstart](docs/QUICKSTART.md)
- [Formatter Guide](docs/FORMATTER_GUIDE.md)
- [Project Quickstart](docs/QUICKSTART.md)
- [Contributing](docs/CONTRIBUTING.md)
- [GitFlow](docs/GITFLOW.md)
- [Changelog](CHANGELOG.md)

## License

MIT. See [`LICENSE`](LICENSE).
MIT. See [LICENSE](LICENSE).
2 changes: 1 addition & 1 deletion docs/QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ To keep rebuilding while you edit, use `Run TcTidier Extension (Watch)`.

```bash
npm run package:vsix
code --install-extension tctidier-0.1.2.vsix --force
code --install-extension tctidier-<version>.vsix --force
```

## Recommended VS Code Settings
Expand Down
Loading