Skip to content

Commit

Permalink
Merge pull request #20 from alsolovyev/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
alsolovyev authored Jan 17, 2021
2 parents 3d77b38 + e274746 commit 4ee0ad8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 25 deletions.
40 changes: 26 additions & 14 deletions Preferences/Indents.tmPreferences
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,35 @@
<dict>
<key>increaseIndentPattern</key>
<string><![CDATA[(?x)
^\s*+
{%-?
\s*+
\b(if|elif|else|for|asyncEach|asyncAll|macro|block|raw|verbatim|filter|call)\b
.*
-?%}
\s*$
(
^.*\{\s*$
)
|
(
^\s*+
{%-?
\s*+
\b(if|elif|else|for|asyncEach|asyncAll|macro|block|raw|verbatim|filter|call)\b
.*
-?%}
\s*$
)
]]></string>
<key>decreaseIndentPattern</key>
<string><![CDATA[(?x)
^\s*+
{%-?
\s*+
\b(endif|endfor|endeach|endall|endmacro|endblock|endraw|endverbatim|endfilter|endcall)\b
.*
-?%}
\s*$
(
^.*\}\s*$
)
|
(
^\s*+
{%-?
\s*+
\b(endif|endfor|endeach|endall|endmacro|endblock|endraw|endverbatim|endfilter|endcall)\b
.*
-?%}
\s*$
)
]]></string>
</dict>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ _* to update the package `Package Control: Upgrade Package` select `Nunjucks`_

**Manually download sublime-package file:**

- download sublime-package file: [Nunjucks.sublime-package](https://github.com/alsolovyev/Nunjucks/releases/download/v2.0.0/Nunjucks.sublime-package)
- download sublime-package file: [Nunjucks.sublime-package](https://github.com/alsolovyev/Nunjucks/releases/download/v2.0.1/Nunjucks.sublime-package)
- move it into your Sublime Text **Installed Packages** directory
- Windows: `%APPDATA%\Sublime Text 3\Installed Packages`
- OS X: `~/Library/Application\ Support/Sublime\ Text\ 3/Installed\ Packages`
Expand Down
47 changes: 37 additions & 10 deletions Syntaxes/Nunjucks.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ contexts:
- include: nunjucks-commas
- include: nunjucks-colons
- include: nunjucks-semicolons
- include: nunjucks-pipe

nunjucks-dots:
- match: '\.'
Expand All @@ -112,6 +113,10 @@ contexts:
- match: ';'
scope: punctuation.terminator.njk

nunjucks-pipe:
- match: '\|'
scope: punctuation.accessor.njk

## Operators
nunjucks-operators:
- include: nunjucks-bitwise-operators
Expand Down Expand Up @@ -158,6 +163,8 @@ contexts:
- match: \}
scope: punctuation.section.braces.end.njk
pop: true
- include: nunjucks-keywords-boolean
- include: nunjucks-keywords-other
- include: nunjucks-strings
- include: nunjucks-punctuation
- include: nunjucks-parentheses
Expand All @@ -173,6 +180,8 @@ contexts:
- match: \]
scope: punctuation.section.brackets.end.njk
pop: true
- include: nunjucks-keywords-boolean
- include: nunjucks-keywords-other
- include: nunjucks-strings
- include: nunjucks-punctuation
- include: nunjucks-parentheses
Expand Down Expand Up @@ -244,22 +253,23 @@ contexts:
- include: nunjucks-block-filter

nunjucks-inline-filter:
- match: '(\|)(\s+)?({{names}})(\()?'
captures:
1: punctuation.accessor.njk
3: support.class.njk
4: support.class.njk
# With parentheses
- match: '(?<=\|)((\s+)?{{names}}\()'
scope: support.class.begin.njk
push:
- match: '(\))?(\s+)?(?=(%\}|\}\}))'
scope: support.class.njk
- match: '\)'
scope: support.class.end.njk
pop: true
- include: nunjucks-punctuation
- include: nunjucks-operators
- include: nunjucks-strings
- include: nunjucks-numeric
- include: nunjucks-keywords-boolean
- include: nunjucks-keywords-other
- include: nunjucks-keywordss-other
- include: nunjucks-variables
# Wuthout parentheses
- match: '(?<=\|)((\s+)?{{names}})'
scope: support.class.njk

nunjucks-block-filter:
- match: (?<=filter)(\s+)({{names}})(\()?
Expand Down Expand Up @@ -295,11 +305,11 @@ contexts:

nunjucks-macro-invocation:
- match: '({{names}})(\()'
scope: meta.function-call.begin.njk
scope: entity.name.function.njk meta.function-call.begin.njk
push:
- meta_content_scope: meta.function.parameters.njk
- match: (\))
scope: meta.function-call.end.njk
scope: entity.name.function.njk meta.function-call.end.njk
pop: true
- include: nunjucks-strings
- include: nunjucks-punctuation
Expand All @@ -312,8 +322,25 @@ contexts:

## Variables
nunjucks-variables:
# Object methods
- match: '(?<=[\]\w\.])({{names}})(\()'
scope: entity.name.function.njk meta.function-call.begin.njk
push:
- match: (\))
scope: entity.name.function.njk meta.function-call.end.njk
pop: true
- include: nunjucks-strings
- include: nunjucks-punctuation
- include: nunjucks-parentheses
- include: nunjucks-numeric
- include: nunjucks-operators
- include: nunjucks-keywords-boolean
- include: nunjucks-keywords-other
- include: nunjucks-variables
# Object properties
- match: '(?<=[\]\w\.])({{names}})'
# scope: variable.other.member.njk
scope: variable.function.njk
# Variables
- match: '{{names}}'
scope: variable.other.readwrite.njk

0 comments on commit 4ee0ad8

Please sign in to comment.