ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Swift

by hanguokai ALL

Modern, lightweight Swift 6 syntax highlighting and symbol navigation for Sublime Text 4.

Details

Installs

  • Total 98K
  • Win 18K
  • Mac 71K
  • Linux 8K
Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26
Windows 1 0 0 2 2 1 2 2 2 0 1 1 0 0 0 1 0 1 1 0 1 0 2 1 0 1 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 1 3 0 0 0
Mac 6 3 8 6 4 8 12 10 6 8 8 3 5 6 2 3 5 2 3 4 6 4 6 7 5 4 4 2 5 3 2 2 6 3 6 3 1 2 4 2 5 5 8 5 2 6
Linux 0 1 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 2 0 0 0 0 1 0 0 0 0 0 0 0 2 1 1 2 0 0 0 0 0 1 0

Readme

Source
raw.​githubusercontent.​com

Swift for Sublime Text

Swift syntax highlighting and editor integration for Sublime Text (Sublime Text 3 >=3092 and Sublime Text 4).

Built from the ground up against the official Swift language grammar and lexical specification, this package targets modern Swift (Swift 5.x – 6.4), follows Sublime Text's official Scope Naming Guidelines, and runs 100% natively on Sublime Text 4's high-performance sregex engine.


Features

  • Syntax Highlighting: Comprehensive, specification-aligned highlighting for Swift 5.x – 6.4—covering structured concurrency (async/await, actor, sending, nonisolated, #isolation), macros (macro, @freestanding, @attached, #expect, #Preview), typed throws, ownership and noncopyable types (~Copyable, ~Escapable, ~Sendable, borrowing, consuming, borrow/mutate), parameter packs (each/repeat), inline arrays ([N of Type]), regex literals (/.../, #/.../#), raw strings (#"..."#), and documentation comments (///, /** ... */).
  • Comment Toggling: Single-line (//) and block (/* ... */) comment toggling via Cmd+/ / Ctrl+/ and Cmd+Opt+/ / Ctrl+Shift+/.
  • Smart Indentation: Automatic indentation rules for braces, brackets, parentheses, and switch case / default blocks.
  • Symbol Navigation: Goto Symbol (Cmd+R / Ctrl+R) and Goto Symbol in Project (Cmd+Shift+R / Ctrl+Shift+R) for types, protocols, extensions, functions, macros, initializers, subscripts, and Xcode-style // MARK:, // TODO:, and // FIXME: section headers.

Installation

  1. Open the Command Palette (Cmd+Shift+P on macOS, Ctrl+Shift+P on Windows/Linux).
  2. Select Package Control: Install Package.
  3. Search for Swift and press Enter.

LSP (SourceKit-LSP) Integration

Pair this package with Sublime Text's LSP and LSP-SourceKit packages to enable Apple's official sourcekit-lsp language server for Semantic Highlighting, code completion, hover documentation, and jump-to-definition.

See Using SourceKit-LSP with Swift for Sublime Text for the complete setup guide.


Local Development & Testing

1. Clone and link the repository into Sublime Text (macOS)

git clone https://github.com/hanguokai/sublime-swift.git
cd sublime-swift
./scripts/install_macos.sh

(If Swift is already installed via Package Control, linking Packages/Swift overrides the packaged version during development.)

2. Run the command-line verification suite

./scripts/verify.sh

3. Run Sublime Text's built-in syntax tests

Open the target file via the Packages/Swift symlink path (required by Sublime Text's test runner when the repository folder is not named Swift) and run the corresponding build target from the Command Palette (Cmd+Shift+P):

Scope Assertions (Build With: Syntax Tests) — open tests/syntax_test_swift.swift to verify all scope assertions in the test suite:

subl "$HOME/Library/Application Support/Sublime Text/Packages/Swift/tests/syntax_test_swift.swift"

Regex Engine Compatibility (Build With: Syntax Tests - Regex Compatibility) — open Swift.sublime-syntax to verify 100% native sregex engine compatibility:

subl "$HOME/Library/Application Support/Sublime Text/Packages/Swift/Swift.sublime-syntax"

History & Legacy Releases

This package succeeds the original Swift package created by @quiqueg.

  • Sublime Text 3 (>=3092) & Sublime Text 4: Track the main branch (1.x releases).
  • Sublime Text 2 (<3092): The original 2014–2016 .tmLanguage snapshot is preserved on the st2 branch under tag st2-0.0.9.

License

MIT