Skip to content

@tank/sublime-package-dev

0.1.0

Create, develop, test, and publish Sublime Text packages. Full lifecycle: Python plugin API (commands, events, views), package structure, syntax definitions (.sublime-syntax), color schemes, themes, snippets, completions, build systems, publishing to Package Control. Triggers: "sublime package", "sublime plugin", "sublime-syntax", "color scheme", "sublime theme", "package control", "TextCommand", "WindowCommand", "EventListener", "sublime API", "sublime snippet", "scope naming"


name: "@tank/sublime-package-dev" description: | Create, develop, test, and publish Sublime Text packages. Covers the full lifecycle: Python plugin API (commands, events, views, settings), package structure (all file formats), syntax definitions (.sublime-syntax YAML), color schemes, UI themes, snippets, completions, build systems, local development workflow, debugging, and publishing to Package Control. Synthesizes official Sublime Text documentation, Package Control docs, sublimehq/Packages repository patterns, and popular package analysis (SublimeLinter, GitGutter, BracketHighlighter).

Trigger phrases: "sublime text package", "sublime plugin", "sublime text plugin", "create sublime package", "sublime-syntax", "sublime syntax definition", "color scheme", "sublime theme", "sublime snippet", "sublime completions", "sublime build system", "package control", "submit to package control", "sublime text command", "TextCommand", "WindowCommand", "EventListener", "ViewEventListener", "sublime API", ".sublime-settings", ".sublime-keymap", ".sublime-commands", ".sublime-menu", ".sublime-color-scheme", ".sublime-theme", ".sublime-build", "tmLanguage", "scope naming"

Sublime Text Package Development

Core Principles

  1. Start with the right package type — command plugins, syntax definitions, color schemes, and themes are fundamentally different artifacts with different file formats.
  2. Use Python 3.8+ — create .python-version with 3.8. Python 3.3 is being phased out (removed after Q1 2026). Python 3.13 is next.
  3. Use .sublime-syntax version 2 — always set version: 2 for new syntax definitions. Fixes scope-stacking bugs from version 1.
  4. Avoid default key bindings — provide Example.sublime-keymap with commented suggestions. Let users choose their own shortcuts.
  5. Test before publishing — use syntax_test_ files for syntaxes and UnitTesting package for plugin logic. Set up GitHub Actions CI.

Quick-Start: Package Type Selection

"I want to add a command/feature"

  1. Create Packages/MyPackage/ with .python-version (3.8)
  2. Write plugin .py with TextCommand/WindowCommand/EventListener
  3. Add Default.sublime-commands for Command Palette
  4. Add settings, menus, key bindings as needed
  5. See references/plugin-api.md and references/package-structure.md

"I want to add syntax highlighting for a language"

  1. Create MyLang.sublime-syntax (YAML, version 2)
  2. Define main context with match patterns and scopes
  3. Add Comments.tmPreferences for Toggle Comment
  4. Add snippets, completions, build system
  5. Write syntax_test_ files to verify scopes
  6. See references/syntax-definitions.md

"I want to create a color scheme or theme"

  1. Color scheme: .sublime-color-scheme (JSON with variables, globals, rules)
  2. UI theme: .sublime-theme (JSON with rules targeting UI classes)
  3. Syntax packages should NOT bundle a color scheme
  4. See references/visual-resources.md

"I want to publish to Package Control"

  1. Host on GitHub (one package per repo, root = package root)
  2. Create semver git tags (e.g., 1.0.0)
  3. Fork sublimehq/package_control_channel
  4. Add JSON entry to repository/ alphabetical file
  5. Submit PR with completed checklist
  6. See references/publishing.md

Decision Trees

Command Type Selection

NeedClassHas
Modify buffer textTextCommandself.view, edit param
Window operations (open files, panels)WindowCommandself.window
App-wide settings/actionsApplicationCommandNeither
React to editor eventsEventListenerAll views
React to specific view eventsViewEventListenerself.view, filterable
Track text changes preciselyTextChangeListenerBuffer-level

Resource File Selection

ContentFile TypeFormat
Command Palette entries.sublime-commandsJSON array
Key bindings.sublime-keymapJSON array (per-platform)
Menu items.sublime-menuJSON array (by location)
Package settings.sublime-settingsJSON object
Syntax highlighting.sublime-syntaxYAML
Color scheme.sublime-color-schemeJSON
UI theme.sublime-themeJSON
Code snippets.sublime-snippetXML
Completions.sublime-completionsJSON
Build system.sublime-buildJSON
Comment tokens.tmPreferencesXML plist
Recorded macro.sublime-macroJSON array

Event Listener Selection

ScenarioUse
Need events from ALL viewsEventListener
Need events from specific file typesViewEventListener with is_applicable()
Need precise text change detailsTextChangeListener (ST4)
Heavy processing on eventsUse _async method variants
Rarely: completion provideron_query_completions on either listener

Threading Decision

TaskApproach
Quick UI updateDirect call (main thread)
Network/disk I/Othreading.Thread or set_timeout_async
Update UI after background workset_timeout(fn, 0) from worker thread
Periodic background checkset_timeout_async with self-rescheduling

Common Mistakes

MistakeFix
No .python-version fileAdd file with content 3.8
Syntax version 1 (or missing)Set version: 2 in header
Default key bindings in packageUse Example.sublime-keymap with comments
on_modified without _asyncUse on_modified_async for non-trivial work
Committing .pyc filesAdd *.pyc to .gitignore
Committing package-metadata.jsonDelete it; auto-generated by Package Control
Buffer edit outside TextCommandAll insert/erase/replace need edit param
Missing meta_include_prototype: falseAdd to string/regex contexts to prevent comment injection
Syntax package bundles color schemeSeparate them; Package Control rejects this
Branch-based releasesUse semver git tags instead

Reference Files

FileContents
references/plugin-api.mdPython API: commands, events, View, Window, Region, Settings, input handlers, threading, ST4 enums
references/package-structure.mdDirectory layout, all resource file formats (.sublime-commands, .sublime-keymap, .sublime-menu, .sublime-settings, .sublime-build, .tmPreferences, messages.json)
references/syntax-definitions.md.sublime-syntax YAML format, contexts, match patterns, meta patterns, push/pop/set/embed/branch, variables, inheritance, scope naming, syntax testing
references/visual-resources.mdColor schemes (.sublime-color-scheme), UI themes (.sublime-theme), snippets (.sublime-snippet), completions (.sublime-completions), legacy .tmTheme
references/publishing.mdPackage Control submission process, channel JSON format, naming rules, versioning, PR checklist, UnitTesting, GitHub Actions CI
references/development-workflow.mdLocal dev setup, auto-reload, console debugging, threading patterns, common plugin architectures, scaffolding checklists

Command Palette

Search skills, docs, and navigate Tank