Skip to content

Syntax Highlighting

GitHub doesn’t recognize .bara.sky files by default, so they appear without syntax highlighting. Use .gitattributes to fix this.

When you view copy.bara.sky on GitHub, it appears as plain text:

# No highlighting - hard to read
core.workflow(
name = "default",
origin = git.origin(url = "..."),
)

Add a .gitattributes file to your repository root:

.gitattributes
*.bara.sky linguist-language=Starlark

This tells GitHub’s Linguist to treat .bara.sky files as Starlark, enabling Python-like syntax highlighting.

Your Copybara config now renders with proper highlighting:

# Highlighted - much easier to read
core.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>"),
)

GitHub caches syntax highlighting per file blob. If highlighting doesn’t appear immediately:

  1. Make a small change to the .bara.sky file
  2. Commit both files together
  3. The cache will refresh with the new blob

You can add multiple rules to .gitattributes:

.gitattributes
# Copybara configs
*.bara.sky linguist-language=Starlark
# Bazel files (if not auto-detected)
BUILD linguist-language=Starlark
*.bzl linguist-language=Starlark
WORKSPACE linguist-language=Starlark
# Mark generated files (excluded from stats)
generated/** linguist-generated=true
# Mark vendor files (excluded from stats)
vendor/** linguist-vendored=true

Install the Starlark extension and add to your settings:

.vscode/settings.json
{
"files.associations": {
"*.bara.sky": "starlark",
"copy.bara.sky": "starlark"
}
}

The Bazel plugin includes Starlark support. Associate the file pattern:

  1. Go to Settings → Editor → File Types
  2. Find Starlark or Bazel BUILD
  3. Add *.bara.sky pattern

Add to your config:

" .vimrc or init.vim
autocmd BufRead,BufNewFile *.bara.sky set filetype=python

Or for proper Starlark support, use vim-starlark.

;; init.el
(add-to-list 'auto-mode-alist '("\\.bara\\.sky\\'" . python-mode))

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.