Syntax Highlighting
GitHub doesn’t recognize .bara.sky files by default, so they appear without syntax highlighting. Use .gitattributes to fix this.
The Problem
Section titled “The Problem”When you view copy.bara.sky on GitHub, it appears as plain text:
# No highlighting - hard to readcore.workflow( name = "default", origin = git.origin(url = "..."),)The Solution
Section titled “The Solution”Add a .gitattributes file to your repository root:
*.bara.sky linguist-language=StarlarkThis tells GitHub’s Linguist to treat .bara.sky files as Starlark, enabling Python-like syntax highlighting.
After Adding .gitattributes
Section titled “After Adding .gitattributes”Your Copybara config now renders with proper highlighting:
# Highlighted - much easier to readcore.workflow( name = "default", origin = git.origin(url = "https://github.com/example/source"), destination = git.destination(url = "https://github.com/example/dest"), origin_files = glob(["src/**"]), authoring = authoring.pass_thru("Bot <bot@example.com>"),)Important Notes
Section titled “Important Notes”Caching Behavior
Section titled “Caching Behavior”GitHub caches syntax highlighting per file blob. If highlighting doesn’t appear immediately:
- Make a small change to the
.bara.skyfile - Commit both files together
- The cache will refresh with the new blob
Other Useful Overrides
Section titled “Other Useful Overrides”You can add multiple rules to .gitattributes:
# Copybara configs*.bara.sky linguist-language=Starlark
# Bazel files (if not auto-detected)BUILD linguist-language=Starlark*.bzl linguist-language=StarlarkWORKSPACE linguist-language=Starlark
# Mark generated files (excluded from stats)generated/** linguist-generated=true
# Mark vendor files (excluded from stats)vendor/** linguist-vendored=trueEditor Support
Section titled “Editor Support”VS Code
Section titled “VS Code”Install the Starlark extension and add to your settings:
{ "files.associations": { "*.bara.sky": "starlark", "copy.bara.sky": "starlark" }}JetBrains IDEs
Section titled “JetBrains IDEs”The Bazel plugin includes Starlark support. Associate the file pattern:
- Go to Settings → Editor → File Types
- Find Starlark or Bazel BUILD
- Add
*.bara.skypattern
Vim/Neovim
Section titled “Vim/Neovim”Add to your config:
" .vimrc or init.vimautocmd BufRead,BufNewFile *.bara.sky set filetype=pythonOr for proper Starlark support, use vim-starlark.
;; init.el(add-to-list 'auto-mode-alist '("\\.bara\\.sky\\'" . python-mode))Language Stats
Section titled “Language Stats”The linguist-language override also affects your repository’s language statistics bar. If you have many .bara.sky files, they’ll now count as Starlark instead of being unrecognized.