Skip to content

Instantly share code, notes, and snippets.

@Kalinovcic
Last active May 22, 2021 13:59
Show Gist options
  • Save Kalinovcic/4e06b20c27c97cc62dc09fdf9320d879 to your computer and use it in GitHub Desktop.
Save Kalinovcic/4e06b20c27c97cc62dc09fdf9320d879 to your computer and use it in GitHub Desktop.
Sublime Text files: C++ syntax and theme. The $ characters in filenames represent subdirectories.
#!/bin/bash
ok="1"
staged=$(git diff --name-only --cached)
for file in ${staged}; do
if grep -q -E 'nocheckin' ${file}; then
git reset ${file}
echo "nocheckin: ${file}"
ok="0"
fi
done
if [ $ok == "0" ]; then
echo "not committing"
exit 1
fi
exit 0
rem Configure cmd shortcut with /k %HOMEDRIVE%%HOMEPATH%\init.bat
@echo off
chcp 65001
prompt $E[33m$p$_$E[0m$g$s
w:
doskey edit="d:\work\echo\run_tree\edit" $*
cls
{
"extensions": ["c","h","christ"],
"tab_size": 4,
"translate_tabs_to_spaces": true,
"detect_indentation": false,
// Helps consistency
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": true,
"shift_tab_unindent": true,
// I mean... This is just common sense...
// I don't know if this forces you to save files in UTF-8, but I sure hope it does.
"default_line_ending": "LF",
"default_encoding": "UTF-8",
"fallback_encoding": "UTF-8",
}
%YAML 1.2
---
name: C++
scope: source.cpp
file_extensions:
- cpp
- cc
- c
- cp
- cxx
- c++
- C
- h
- hh
- hpp
- hxx
- h++
- inl
- ipp
- christ
uuid: bb8767c3-e54f-403d-998c-0fa1dad73ddd
contexts:
main:
- include: comments
- include: preprocessor
- include: keywords
- include: string_literal
- include: numeric_literal
- include: other_literals
preprocessor:
- match: \s*(\#\s*include)\b\s*(\<.*\>)
captures:
1: meta.preprocessor.c++ keyword.c++
2: string.quoted.double.c++
- match: \s*(\#\s*(pragma|include|define|undef|error|if|ifdef|ifndef|elif|else|endif))\b
captures:
1: meta.preprocessor.c++ keyword.c++
keywords:
# Control flow stuff
- match: \b(goto|if|else|while|do|for|switch|case|default|break|continue|return|throw|try|catch|asm)\b
scope: keyword.c++
# Type-related stuff
- match: \b(struct|enum|union|class|private|protected|public|virtual|friend|typedef|sizeof|offsetof|alignof|alignas|typeid|auto|template|typename|static_cast|const_cast|reinterpret_cast|dynamic_cast|this)\b
scope: keyword.c++
# Types
- match: \b(int|short|long|signed|unsigned|char|float|double|void|bool)\b
scope: storage.type.c++
# Other stuff
- match: \b(using|namespace|static|inline|volatile|const|constexpr|thread_local|register|operator|mutable|new|delete|extern|export|explicit)\b
scope: keyword.c++
# Reserved
- match: \b(and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq)\b
scope: keyword.c++
# Personal - Asserts
- match: \b(Unreachable|NotImplemented|IllegalDefaultCase|Assert|AssertMessage|DebugAssert|DebugAssertMessage|CompileTimeAssert)\b
scope: keyword.c++
# Personal - Utility
- match: \b(ArrayCount|ElementSize|ZeroStruct|ZeroStaticArray|Defer|BeginFunction|EndFunction|Function|For|Loop|BreakLoop|ContinueLoop)\b
scope: keyword.c++
# Personal - lk_region
- match: \b(PushValue|PushArray|PushValueA|PushArrayA|PushString)\b
scope: keyword.c++
- match: \b(LK_RegionValue|LK_RegionArray|LK_RegionValueAligned|LK_RegionArrayAligned)\b
scope: keyword.c++
- match: \b(LK_Region|Region)\b
scope: storage.type.c++
# Personal - Basic types
- match: \b(s8|s16|s32|s64|smm|u8|u16|u32|u64|umm|byte|flags8|flags16|flags32|flags64|String)\b
scope: storage.type.c++
# Personal - Vector types
- match: \b(Vector2|Vector3|Vector4|Vector2i|Vector3i|Vector4i|)\b
scope: storage.type.c++
# Personal - SIMD types
- match: \b(Floats|Ints|Vector2s|Vector3s|Vector4s|Vector2is|Vector3is|Vector4is)\b
scope: storage.type.c++
string_literal:
- match: '\bR"([^()]*)\('
push:
- meta_scope: string.quoted.double.c++
- match: '\)(\1)"'
pop: true
- match: \'
push:
- meta_scope: string.quoted.double.c++
- match: \\(\\|n|r|t|b|\'|0|x)
scope: constant.character.escape.c++
- match: \'
pop: true
- match: '"'
push:
- meta_scope: string.quoted.double.c++
- match: \\(\\|n|r|t|b|\"|0|x)
scope: constant.character.escape.c++
- match: '"'
pop: true
# This thing was copied from the original C++ sublime-syntax.
numeric_literal:
- match: |-
(?x)
(?:
# floats
(?:
(?:\b\d(?:[\d']*\d)?\.\d(?:[\d']*\d)?|\B\.\d(?:[\d']*\d)?)(?:[Ee][+-]?\d(?:[\d']*\d)?)?(?:[fFlL]|(?:i[fl]?|h|min|[mun]?s|_\w*))?\b |
(?:\b\d(?:[\d']*\d)?\.)(?:\B|(?:[fFlL]|(?:i[fl]?|h|min|[mun]?s|_\w*))\b|(?:[Ee][+-]?\d(?:[\d']*\d)?)(?:[fFlL]|(?:i[fl]?|h|min|[mun]?s|_\w*))?\b) |
\b\d(?:[\d']*\d)?(?:[Ee][+-]?\d(?:[\d']*\d)?)(?:[fFlL]|(?:i[fl]?|h|min|[mun]?s|_\w*))?\b
)
|
# integers
\b(?:
(?:
[1-9](?:[\d']*\d)? | # decimal integer
0(?:[0-7']*[0-7])? | # octal integer
0[Xx][\da-fA-F](?:[\da-fA-F']*[\da-fA-F])? | # hexadecimal integer
0[Bb][01](?:[01']*[01])? # binary integer
)
(?:(?:l{1,2}|L{1,2})[uU]?|[uU](?:l{0,2}|L{0,2})|(?:i[fl]?|h|min|[mun]?s|_\w*))?)\b # suffixes
)
(?!\.) # Number must not be followed by a decimal point
scope: constant.numeric.c++
other_literals:
- match: \b(NULL|TRUE|FALSE|true|false)\b
scope: constant.language.c++
if_zero_deep:
- meta_scope: comment.block.c++
- match: \#\s*\bif\b
push: if_zero_deep
- match: \#\s*\bendif\b
pop: true
if_zero:
- meta_scope: comment.block.c++
- match: \#\s*\bif\b
push: if_zero_deep
- match: \#\s*\b(else|elif)\b
set:
- clear_scopes: true
- match: \#\s*\bendif\b
pop: true
- include: main
- match: \#\s*\bendif\b
pop: true
comments:
- match: \s*\#\s*\bif\b\s*0
push: if_zero
- match: \s*\#\s*\bif\b\s*1
push:
- match: \#\s*\belse\b
set: if_zero_deep
- match: \#\s*\bendif\b
pop: true
- include: main
- match: /\*
scope: punctuation.definition.comment.c++
push:
- meta_scope: comment.block.c++
- include: comment_mark
- include: comment_nocheckin
- match: \*/
scope: punctuation.definition.comment.c++
pop: true
- match: //
scope: punctuation.definition.comment.c++
push:
- meta_scope: comment.line.double-slash.c++
- include: comment_mark
- include: comment_nocheckin
- match: '(\\)$\n'
captures:
1: punctuation.separator.continuation.c++
- match: \n
pop: true
comment_nocheckin:
- match: '\snocheckin\b'
scope: comment.personal.nocheckin
comment_mark:
- match: '\s[:@]\b[[:alpha:]_][[:alnum:]_]*\b'
scope: comment.personal.mark
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Kalinovcic1</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#052329</string>
<key>caret</key>
<string>#89DF8D</string>
<key>foreground</key>
<string>#C1C3AE</string>
<key>invisibles</key>
<string>#4e9bad</string>
<key>lineHighlight</key>
<string>#094B59</string>
<key>selection</key>
<string>#0E7085</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment</string>
<key>scope</key>
<string>comment</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#59C653</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment Personal Mark</string>
<key>scope</key>
<string>comment.personal.mark</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold italic</string>
<key>foreground</key>
<string>#8def81</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment Personal Scream</string>
<key>scope</key>
<string>comment.personal.scream</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold italic</string>
<key>foreground</key>
<string>#8def81</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment Personal Nocheckin</string>
<key>scope</key>
<string>comment.personal.nocheckin</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#f56258</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>String</string>
<key>scope</key>
<string>string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#55c2b8</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Number</string>
<key>scope</key>
<string>constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#90E8E6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keyword</string>
<key>scope</key>
<string>keyword</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FFFFFF</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keyword Operator</string>
<key>scope</key>
<string>keyword.operator</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#C1C3AE</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage</string>
<key>scope</key>
<string>storage</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#FFFFFF</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage type</string>
<key>scope</key>
<string>storage.type</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#a1e8c0</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Invalid</string>
<key>scope</key>
<string>invalid</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#F92672</string>
<key>foreground</key>
<string>#F8F8F0</string>
</dict>
</dict>
</array>
<key>semanticClass</key>
<string>theme.dark.kalinovcic1</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Kalinovcic2</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#242424</string>
<key>caret</key>
<string>#89C7E0</string>
<key>foreground</key>
<string>#D0D0D0</string>
<key>invisibles</key>
<string>#6D7E82</string>
<key>lineHighlight</key>
<string>#333333</string>
<key>selection</key>
<string>#374D4F</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment</string>
<key>scope</key>
<string>comment</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#6FED68</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment Personal Mark</string>
<key>scope</key>
<string>comment.personal.mark</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold italic</string>
<key>foreground</key>
<string>#B1FCA7</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment Personal Nocheckin</string>
<key>scope</key>
<string>comment.personal.nocheckin</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#F5938C</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Invalid</string>
<key>scope</key>
<string>invalid</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#F92672</string>
<key>foreground</key>
<string>#F8F8F0</string>
</dict>
</dict>
</array>
<key>semanticClass</key>
<string>theme.dark.kalinovcic2</string>
</dict>
</plist>
%YAML 1.2
---
name: Kuna
scope: source.kuna
file_extensions:
- kuna
uuid: 3cb8df5e-6da9-42d2-8ce1-18e858a04d9b
variables:
keyword: '\b(fn|debug|table|struct|typeof|if|else|for|in|while|continue|break|return|not|and|or)\b|#if\b'
name: '\b[a-zA-Z_][a-zA-Z_0-9]*\b'
type: '{{name}}(\[\]|\{\})*'
contexts:
block_comment:
- meta_scope: comment.block.kuna
- match: '/\*'
push: block_comment
- match: '\*/'
scope: punctuation.definition.comment.kuna
pop: true
main:
- match: '\b(struct)\b\s*({{name}})?'
captures:
1: keyword.kuna
2: storage.type
- match: '\b(failure)\b\s*\(\s*(?!{{keyword}})({{type}})\s*\)'
captures:
1: constant.language.kuna
3: storage.type
- match: '{{keyword}}'
scope: keyword.kuna
- match: '\b(true|false|failure)\b'
scope: constant.language.kuna
- match: '({{name}}|\]|\})\s*(?!{{keyword}})({{type}})'
captures:
3: storage.type
- match: '"'
push:
- meta_scope: string.quoted.double.kuna
- match: '\\(\\|n|r|t|\")'
scope: constant.character.escape.kuna
- match: '"'
pop: true
- match: '`'
push:
- meta_scope: string.quoted.backtick.kuna
- match: '`'
pop: true
- match: '\b([0-9]+(\.[0-9]+)?)\b'
scope: constant.numeric.kuna
- match: '/\*'
scope: punctuation.definition.comment.kuna
push: block_comment
- match: '//'
scope: punctuation.definition.comment.kuna
push:
- meta_scope: comment.line.double-slash.kuna
- match: '\n'
pop: true
{
"auto_complete": false,
"color_scheme": "Packages/User/Kalinovcic2.tmTheme",
"font_face": "Consolas",
"font_size": 12,
"ignored_packages":
[
"Diff",
"Vintage"
],
"mini_diff": false,
"rulers":
[
100
],
"show_panel_on_build": false,
"theme": "Adaptive.sublime-theme"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment