Skip to content

Instantly share code, notes, and snippets.

@rastersize
Last active May 22, 2019 21:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rastersize/fb73b1b46a18fb3dc5fe6c67ec04c080 to your computer and use it in GitHub Desktop.
Save rastersize/fb73b1b46a18fb3dc5fe6c67ec04c080 to your computer and use it in GitHub Desktop.
Syntax highlighting of xcconfig files for Sublime Text 3

Syntax highlighting of xcconfig files for Sublime Text 3

A syntax highlighter configuration for .xcconfig (Xcode configuration) files for Sublime Text 3. Based on work by @dflems.

Screenshot of an xcconfig file being highligthed

Fig 1: Screenshot of an xcconfig file being highligthed. Shown with the “Tomorrow - Night” theme.

Installation

Copy the files *.sublime-* files into an xcconfig directory in your Packages directory.

E.g. by default for macOS this would looks something like:

mkdir -p "$HOME/Library/Application Support/Sublime Text 3/Packages/xcconfig"
cp Downloads/*.sublime-* "$HOME/Library/Application Support/Sublime Text 3/Packages/xcconfig"

Enjoy!

Changelog

v0.2

  • Add support for the VAR[conditional=something] = some_value syntax (by @rastersize)

v0.1

{
"extensions": ["xcconfig"]
}
%YAML 1.2
---
name: xcconfig
file_extensions: [xcconfig]
scope: source.xcconfig
contexts:
main:
# comments
- match: ^//.*
scope: comment.source.xcconfig
# semi-colons at EOL are ignored
- match: ;$
scope: comment.source.xcconfig
# include statement
- match: ^#include[^\S\n]*
scope: keyword.control.import.xcconfig
push:
- match: '".*?"\s*'
scope: string.quoted.double.xcconfig
pop: true
- match: \n
scope: invalid.illegal.unexpected-end-of-line.xcconfig
pop: true
- match: .*
scope: invalid.illegal.unexpected-character.xcconfig
pop: true
# var assignment
- match: ^([_A-Za-z][_A-Za-z0-9]*)(\[[_A-Za-z][_A-Za-z0-9]*\s*=.*\])?\s*(=)\s*
captures:
1: variable.source.xcconfig
2: keyword.control.xcconfig
3: keyword.operator.xcconfig
push:
- match: (.*?)(;?)$
pop: true
captures:
1: string.quoted.double.xcconfig
2: comment.source.xcconfig
# blank line
- match: ^\s*$
# otherwise invalid
- match: .*
scope: invalid.illegal.unexpected-character.xcconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment