├── .github ├── FUNDING.yml └── workflows │ └── CI.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── grammars ├── julia-console.cson ├── julia-console.json ├── julia.cson ├── julia.json ├── julia.template.json └── julia_vscode.json ├── lib └── julia.coffee ├── package-lock.json ├── package.json ├── scripts └── generate.js ├── settings └── language-julia.cson ├── snippets ├── basic.cson └── language-julia.cson └── test └── test.js /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: https://numfocus.salsalabs.org/donate-to-julia/index.html 2 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | jobs: 8 | test-oniguruma: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Install dependencies 13 | run: npm ci 14 | - name: Run tests 15 | run: npm run test 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.tags* 2 | node_modules -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the Julia grammar will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). 6 | 7 | ## [Unreleased] 8 | ### Fixed 9 | - new Julia 1.10 keyword `public` is now parsed correctly([#271](https://github.com/JuliaEditorSupport/atom-language-julia/issues/271)) 10 | 11 | ## [0.22.0] - 2021-11-07 12 | ### Fixed 13 | - Mathematial constants juxtaposed with numbers are properly highlighted now ([#251](https://github.com/JuliaEditorSupport/atom-language-julia/pull/251)) 14 | - Parentheses in string interpolation are now correctly tokenized ([#251](https://github.com/JuliaEditorSupport/atom-language-julia/pull/251)) 15 | - `'` after math constants is now correctly tokenized ([#251](https://github.com/JuliaEditorSupport/atom-language-julia/pull/251)) 16 | 17 | ### Changed 18 | - `foo"bar"` macros for foreign languages no longer inject a grammar for that language. No markdown strings are highlighted ([#252](https://github.com/JuliaEditorSupport/atom-language-julia/pull/252)) 19 | 20 | ## [0.21.2] - 2021-07-26 21 | ### Fixed 22 | - Number splatting is now correctly tokenized ([#246](https://github.com/JuliaEditorSupport/atom-language-julia/pull/246)). 23 | - Multiple `!`s at the end of an identifier are now correctly tokenized ([#248](https://github.com/JuliaEditorSupport/atom-language-julia/pull/248)). 24 | - Function calls succeded by a commented out `=` are now correctly tokenized ([#250](https://github.com/JuliaEditorSupport/atom-language-julia/pull/250)). 25 | 26 | ### Changed 27 | - String macro suffixes are now tokenized as macros ([#247](https://github.com/JuliaEditorSupport/atom-language-julia/pull/247)). 28 | - Markdown string content is no longer highlighted as markdown ([#249](https://github.com/JuliaEditorSupport/atom-language-julia/pull/249)). 29 | 30 | ## [0.21.1] - 2021-04-09 31 | ### Fixed 32 | - Interpolation of strings (e.g. `$"string"`) now works ([#243](https://github.com/JuliaEditorSupport/atom-language-julia/pull/243)). 33 | 34 | ### Changed 35 | - Type relations are now tokenized as `keyword.operator.relation.types.julia` instead of `keyword.operator.relation.julia` ([#239](https://github.com/JuliaEditorSupport/atom-language-julia/pull/239)). 36 | 37 | ## [0.21.0] - 2021-01-25 38 | ### Added 39 | - Support for embedded SQL syntax via the `sql` string macro ([#235](https://github.com/JuliaEditorSupport/atom-language-julia/pull/235)). 40 | - This repo now also contains a VSCode-compatible JSON grammar file ([#236](https://github.com/JuliaEditorSupport/atom-language-julia/pull/236)). 41 | - Added a changelog ([#237](https://github.com/JuliaEditorSupport/atom-language-julia/pull/237)). 42 | 43 | ### Changed 44 | - Update the readme ([#236](https://github.com/JuliaEditorSupport/atom-language-julia/pull/236)). 45 | 46 | ## [0.20.2] - 2021-01-13 47 | ### Fixed 48 | - `NaNxxx` is no longer erroneously tokenized like `NaN` ([#233](https://github.com/JuliaEditorSupport/atom-language-julia/pull/233)). 49 | - String macros (and `var""`) now properly bind tighter than `:` ([#234](https://github.com/JuliaEditorSupport/atom-language-julia/pull/234)). 50 | 51 | ### Added 52 | - Support for `var"..."` and `var"""..."""` ([#234](https://github.com/JuliaEditorSupport/atom-language-julia/pull/234)). 53 | - Support for triple-backtick strings ([#234](https://github.com/JuliaEditorSupport/atom-language-julia/pull/234)). 54 | - Support for command string macros in single- and triple-backtick variants both ([#234](https://github.com/JuliaEditorSupport/atom-language-julia/pull/234)). 55 | 56 | ## [0.20.1] - 2021-11-08 57 | ### Fixed 58 | - Restore PCRE compatibility to un-break GitHub rendering. 59 | 60 | ## [0.20.0] - 2021-10-26 61 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The atom-language-julia package is licensed under the MIT "Expat" License: 2 | 3 | > Copyright (c) 2015 4 | > 5 | > Permission is hereby granted, free of charge, to any person obtaining 6 | > a copy of this software and associated documentation files (the 7 | > "Software"), to deal in the Software without restriction, including 8 | > without limitation the rights to use, copy, modify, merge, publish, 9 | > distribute, sublicense, and/or sell copies of the Software, and to 10 | > permit persons to whom the Software is furnished to do so, subject to 11 | > the following conditions: 12 | > 13 | > The above copyright notice and this permission notice shall be 14 | > included in all copies or substantial portions of the Software. 15 | > 16 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | > IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | > CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Julia Grammar 2 | 3 | [![Build Status](https://github.com/JuliaEditorSupport/atom-language-julia/workflows/CI/badge.svg)](https://github.com/JuliaEditorSupport/atom-language-julia/actions?query=workflow%3ACI+branch%3Amaster) 4 | 5 | Julia grammar definition for Atom, VS Code, and GitHub. 6 | 7 | The source of truth in this repo is `grammars/julia.template.json`; `julia.json`, `julia.cson`, and `julia_vscode.json` are automatically generated in a pre-commit hook or with `npm run generate`. 8 | 9 | ## Contributing 10 | 11 | We love contributors. Here are the steps we have taken to develop on this package: 12 | 13 | 0. Install prerequisites: [Node.js](https://nodejs.org/) and `npm` (comes bundled with Node). We recommend using a [Node version manager](https://github.com/search?q=node+version+manager+archived%3Afalse&type=repositories&ref=advsearch). LTS is recommended, but any node version newer than 14 should do. 14 | 1. Clone this repo and `cd` into it 15 | 2. Run `npm ci` 16 | 3. Open `grammars/julia.template.json` in your favourite editor and fix a bug or implement additional highlighting rules 17 | 4. Add corresponding tests at the bottom of `test/test.js` 18 | 5. Run the updated tests with `npm run test` 19 | 6. Once tests pass and you're happy with your changes, commit them and open a PR against this repo. This should automatically run a pre-commit hook that generates derivative grammars for VS Code and Atom from `julia.template.json`. 20 | 21 | ### Testing the updated grammar in VS Code 22 | Follow the [julia-vscode developer instructions](https://github.com/julia-vscode/julia-vscode/blob/main/CONTRIBUTING.md) to get the extension setup. Afterwards, simply copy the updated `julia_vscode.json` from this repo into `julia-vscode/syntaxes` and you should see your changes in the debug editor after reloading it. 23 | 24 | ## Contributor list 25 | 26 | - Everyone who has helped with the [tmBundle](https://github.com/JuliaLang/Julia.tmbundle) 27 | - [See contributors](https://github.com/JuliaEditorSupport/atom-language-julia/graphs/contributors) 28 | 29 | ## Atom package 30 |
31 | Atom package (sunset end of 2022) 32 | 33 | This is also an Atom package to provide Julia syntax highlighting, snippets, and docstring folding. Originally based off of [JuliaLang/julia.tmBundle](https://github.com/JuliaLang/Julia.tmbundle), merged with new ideas from [language-julia](https://github.com/tpoisot/language-julia/blob/master/README.md). 34 | 35 | ### Features: 36 | 37 | - Syntax highlighting 38 | - Snippets for common Julia keywords and constructs (see `snippets/language-julia.cson`) 39 | - Toggle folding of docstrings 40 | 41 | ### Installation 42 | 43 | Installation happens normally either through `apm install language-julia` or through the install section of the settings tab within Atom. 44 | 45 | Note: if you already have a different version of language-julia plugin installed (e.g. [this one](https://github.com/tpoisot/language-julia)), you would need to remove it first using `apm uninstall language-julia` 46 | 47 | ### Recommended Extras 48 | 49 | * The [LaTeX Completions](https://github.com/JunoLab/atom-latex-completions) 50 | package provides support for unicode characters similarly to the Julia REPL. 51 | * The [Indent Detective](https://github.com/JunoLab/atom-indent-detective) package will help you keep to the style guidelines when working on Base or packages. 52 | * Install [language-markdown](https://atom.io/packages/language-markdown) for syntax highlighting in docstrings. 53 | * Install [atom-language-r](https://atom.io/packages/atom-language-r) for syntax highlighting of R string macros. 54 | 55 | ### Toggling docstrings 56 | 57 | Two Atom commands are provided to toggle all docstrings or the docstring under the cursor: `language-julia:toggle-docstrings` and `language-julia:toggle-all-docstrings`. These are not assigned keys. Here is one example of adding these to keymaps using org-mode style keys: 58 | 59 | ``` 60 | 'atom-text-editor[data-grammar="source julia"]:not([mini])': 61 | 'tab': 'language-julia:toggle-docstrings' 62 | 'shift-tab': 'language-julia:toggle-all-docstrings' 63 | ``` 64 | 65 |
66 | -------------------------------------------------------------------------------- /grammars/julia-console.cson: -------------------------------------------------------------------------------- 1 | scopeName: 'source.julia.console' 2 | name: 'Julia Console' 3 | comment: 'Not sure what this will be used for... Maybe if we have a REPL someday. We do now...' 4 | patterns: [ 5 | { 6 | match: '^(julia>)(\\s+.*(?:\\n\\s{6}\\s+.*)*)' 7 | captures: 8 | '1': 9 | name: 'punctuation.separator.prompt.julia.console' 10 | '2': 11 | patterns: [ 12 | { 13 | include: 'source.julia' 14 | } 15 | ] 16 | } 17 | { 18 | match: '^(shell>) (.+)$' 19 | captures: 20 | '1': 21 | name: 'punctuation.separator.prompt.shell.julia.console' 22 | '2': 23 | patterns: [ 24 | { 25 | include: 'source.shell' 26 | } 27 | ] 28 | } 29 | { 30 | match: '^(help\\?>) (.+)$' 31 | captures: 32 | '1': 33 | name: 'punctuation.separator.prompt.help.julia.console' 34 | '2': 35 | patterns: [ 36 | { 37 | include: 'source.julia' 38 | } 39 | ] 40 | } 41 | ] -------------------------------------------------------------------------------- /grammars/julia-console.json: -------------------------------------------------------------------------------- 1 | { 2 | "scopeName": "source.julia.console", 3 | "name": "Julia Console", 4 | "comment": "Not sure what this will be used for... Maybe if we have a REPL someday. We do now...", 5 | "patterns": [ 6 | { 7 | "match": "^(julia>)(\\s+.*(?:\\n\\s{6}\\s+.*)*)", 8 | "captures": { 9 | "1": { 10 | "name": "punctuation.separator.prompt.julia.console" 11 | }, 12 | "2": { 13 | "patterns": [ 14 | { 15 | "include": "source.julia" 16 | } 17 | ] 18 | } 19 | } 20 | }, 21 | { 22 | "match": "^(shell>) (.+)$", 23 | "captures": { 24 | "1": { 25 | "name": "punctuation.separator.prompt.shell.julia.console" 26 | }, 27 | "2": { 28 | "patterns": [ 29 | { 30 | "include": "source.shell" 31 | } 32 | ] 33 | } 34 | } 35 | }, 36 | { 37 | "match": "^(help\\?>) (.+)$", 38 | "captures": { 39 | "1": { 40 | "name": "punctuation.separator.prompt.help.julia.console" 41 | }, 42 | "2": { 43 | "patterns": [ 44 | { 45 | "include": "source.julia" 46 | } 47 | ] 48 | } 49 | } 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /grammars/julia.cson: -------------------------------------------------------------------------------- 1 | comment: ''' 2 | This grammar is used by Atom (Oniguruma), GitHub (PCRE), and VSCode (Oniguruma), 3 | so all regexps must be compatible with both engines. 4 | 5 | Specs: 6 | - https://github.com/kkos/oniguruma/blob/master/doc/RE 7 | - https://www.pcre.org/current/doc/html/ 8 | ''' 9 | fileTypes: [ 10 | 'jl' 11 | ] 12 | firstLineMatch: '^#!.*\\bjulia\\s*$' 13 | name: 'Julia' 14 | patterns: [ 15 | { 16 | include: '#operator' 17 | } 18 | { 19 | include: '#array' 20 | } 21 | { 22 | include: '#string' 23 | } 24 | { 25 | include: '#parentheses' 26 | } 27 | { 28 | include: '#bracket' 29 | } 30 | { 31 | include: '#function_decl' 32 | } 33 | { 34 | include: '#function_call' 35 | } 36 | { 37 | include: '#for_block' 38 | } 39 | { 40 | include: '#keyword' 41 | } 42 | { 43 | include: '#number' 44 | } 45 | { 46 | include: '#comment' 47 | } 48 | { 49 | include: '#type_decl' 50 | } 51 | { 52 | include: '#symbol' 53 | } 54 | { 55 | include: '#punctuation' 56 | } 57 | ] 58 | repository: 59 | array: 60 | patterns: [ 61 | { 62 | begin: '\\[' 63 | beginCaptures: 64 | '0': 65 | name: 'meta.bracket.julia' 66 | end: "(\\])((?:\\.)?'*)" 67 | endCaptures: 68 | '1': 69 | name: 'meta.bracket.julia' 70 | '2': 71 | name: 'keyword.operator.transpose.julia' 72 | name: 'meta.array.julia' 73 | patterns: [ 74 | { 75 | match: '\\bbegin\\b' 76 | name: 'constant.numeric.julia' 77 | } 78 | { 79 | match: '\\bend\\b' 80 | name: 'constant.numeric.julia' 81 | } 82 | { 83 | include: '#self_no_for_block' 84 | } 85 | ] 86 | } 87 | ] 88 | parentheses: 89 | patterns: [ 90 | { 91 | begin: '\\(' 92 | beginCaptures: 93 | '0': 94 | name: 'meta.bracket.julia' 95 | end: "(\\))((?:\\.)?'*)" 96 | endCaptures: 97 | '1': 98 | name: 'meta.bracket.julia' 99 | '2': 100 | name: 'keyword.operator.transpose.julia' 101 | patterns: [ 102 | { 103 | include: '#self_no_for_block' 104 | } 105 | ] 106 | } 107 | ] 108 | bracket: 109 | patterns: [ 110 | { 111 | begin: '\\{' 112 | beginCaptures: 113 | '0': 114 | name: 'meta.bracket.julia' 115 | end: "(\\})((?:\\.)?'*)" 116 | endCaptures: 117 | '1': 118 | name: 'meta.bracket.julia' 119 | '2': 120 | name: 'keyword.operator.transpose.julia' 121 | patterns: [ 122 | { 123 | include: '#self_no_for_block' 124 | } 125 | ] 126 | } 127 | ] 128 | comment_tags: 129 | patterns: [ 130 | { 131 | match: '\\bTODO\\b' 132 | name: 'keyword.other.comment-annotation.julia' 133 | } 134 | { 135 | match: '\\bFIXME\\b' 136 | name: 'keyword.other.comment-annotation.julia' 137 | } 138 | { 139 | match: '\\bCHANGED\\b' 140 | name: 'keyword.other.comment-annotation.julia' 141 | } 142 | { 143 | match: '\\bXXX\\b' 144 | name: 'keyword.other.comment-annotation.julia' 145 | } 146 | ] 147 | comment: 148 | patterns: [ 149 | { 150 | include: '#comment_block' 151 | } 152 | { 153 | begin: '#' 154 | beginCaptures: 155 | '0': 156 | name: 'punctuation.definition.comment.julia' 157 | end: '\\n' 158 | name: 'comment.line.number-sign.julia' 159 | patterns: [ 160 | { 161 | include: '#comment_tags' 162 | } 163 | ] 164 | } 165 | ] 166 | comment_block: 167 | patterns: [ 168 | { 169 | begin: '#=' 170 | beginCaptures: 171 | '0': 172 | name: 'punctuation.definition.comment.begin.julia' 173 | end: '=#' 174 | endCaptures: 175 | '0': 176 | name: 'punctuation.definition.comment.end.julia' 177 | name: 'comment.block.number-sign-equals.julia' 178 | patterns: [ 179 | { 180 | include: '#comment_tags' 181 | } 182 | { 183 | include: '#comment_block' 184 | } 185 | ] 186 | } 187 | ] 188 | function_call: 189 | patterns: [ 190 | { 191 | begin: '((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?\\.?(\\()' 192 | beginCaptures: 193 | '1': 194 | name: 'support.function.julia' 195 | '2': 196 | name: 'support.type.julia' 197 | '3': 198 | name: 'meta.bracket.julia' 199 | end: "\\)(('|(\\.'))*\\.?')?" 200 | endCaptures: 201 | '0': 202 | name: 'meta.bracket.julia' 203 | '1': 204 | name: 'keyword.operator.transposed-func.julia' 205 | patterns: [ 206 | { 207 | include: '#self_no_for_block' 208 | } 209 | ] 210 | } 211 | ] 212 | function_decl: 213 | patterns: [ 214 | { 215 | captures: 216 | '1': 217 | name: 'entity.name.function.julia' 218 | '2': 219 | name: 'support.type.julia' 220 | match: '((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?(?=\\([^#]*\\)(::[^\\s]+)?(\\s*\\bwhere\\b\\s+.+?)?\\s*?=(?![=>]))' 221 | comment: ''' 222 | first group is function name 223 | Second group is type parameters (e.g. {T<:Number, S}) 224 | Then open parens 225 | Then a lookahead ensures that we are followed by: 226 | - anything (function arguments) 227 | - 0 or more spaces 228 | - Finally an equal sign 229 | Negative lookahead ensures we don't have another equal sign (not `==`) 230 | ''' 231 | } 232 | { 233 | captures: 234 | '1': 235 | name: 'keyword.other.julia' 236 | '2': 237 | name: 'keyword.operator.dots.julia' 238 | '3': 239 | name: 'entity.name.function.julia' 240 | '4': 241 | name: 'support.type.julia' 242 | match: '\\b(function|macro)(?:\\s+(?:(?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*(\\.))?((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?|\\s*)(?=\\()' 243 | comment: 'similar regex to previous, but with keyword not 1-line syntax' 244 | } 245 | ] 246 | for_block: 247 | comment: "for blocks need to be special-cased to support tokenizing 'outer' properly" 248 | patterns: [ 249 | { 250 | begin: '\\b(for)\\b' 251 | beginCaptures: 252 | '0': 253 | name: 'keyword.control.julia' 254 | end: '(?|->|-->|<--|←|→|↔|↚|↛|↞|↠|↢|↣|↦|↤|↮|⇎|⇍|⇏|⇐|⇒|⇔|⇴|⇶|⇷|⇸|⇹|⇺|⇻|⇼|⇽|⇾|⇿|⟵|⟶|⟷|⟹|⟺|⟻|⟼|⟽|⟾|⟿|⤀|⤁|⤂|⤃|⤄|⤅|⤆|⤇|⤌|⤍|⤎|⤏|⤐|⤑|⤔|⤕|⤖|⤗|⤘|⤝|⤞|⤟|⤠|⥄|⥅|⥆|⥇|⥈|⥊|⥋|⥎|⥐|⥒|⥓|⥖|⥗|⥚|⥛|⥞|⥟|⥢|⥤|⥦|⥧|⥨|⥩|⥪|⥫|⥬|⥭|⥰|⧴|⬱|⬰|⬲|⬳|⬴|⬵|⬶|⬷|⬸|⬹|⬺|⬻|⬼|⬽|⬾|⬿|⭀|⭁|⭂|⭃|⥷|⭄|⥺|⭇|⭈|⭉|⭊|⭋|⭌|←|→|⇜|⇝|↜|↝|↩|↪|↫|↬|↼|↽|⇀|⇁|⇄|⇆|⇇|⇉|⇋|⇌|⇚|⇛|⇠|⇢|↷|↶|↺|↻|=>)' 332 | name: 'keyword.operator.arrow.julia' 333 | } 334 | { 335 | match: '(?::=|\\+=|-=|\\*=|//=|/=|\\.//=|\\./=|\\.\\*=|\\\\=|\\.\\\\=|\\^=|\\.\\^=|%=|\\.%=|÷=|\\.÷=|\\|=|&=|\\.&=|⊻=|\\.⊻=|\\$=|<<=|>>=|>>>=|=(?!=))' 336 | name: 'keyword.operator.update.julia' 337 | } 338 | { 339 | match: '(?:<<|>>>|>>|\\.>>>|\\.>>|\\.<<)' 340 | name: 'keyword.operator.shift.julia' 341 | } 342 | { 343 | match: '(?:\\s*(::|>:|<:)\\s*((?:(?:Union)?\\([^)]*\\)|[[:alpha:]_$∇][[:word:]⁺-ₜ!′\\.]*(?:(?:{(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})|(?:".+?(?)>=|>|<|≥|≤|===|==|≡|!=|≠|!==|≢|∈|∉|∋|∌|⊆|⊈|⊂|⊄|⊊|∝|∊|∍|∥|∦|∷|∺|∻|∽|∾|≁|≃|≂|≄|≅|≆|≇|≈|≉|≊|≋|≌|≍|≎|≐|≑|≒|≓|≖|≗|≘|≙|≚|≛|≜|≝|≞|≟|≣|≦|≧|≨|≩|≪|≫|≬|≭|≮|≯|≰|≱|≲|≳|≴|≵|≶|≷|≸|≹|≺|≻|≼|≽|≾|≿|⊀|⊁|⊃|⊅|⊇|⊉|⊋|⊏|⊐|⊑|⊒|⊜|⊩|⊬|⊮|⊰|⊱|⊲|⊳|⊴|⊵|⊶|⊷|⋍|⋐|⋑|⋕|⋖|⋗|⋘|⋙|⋚|⋛|⋜|⋝|⋞|⋟|⋠|⋡|⋢|⋣|⋤|⋥|⋦|⋧|⋨|⋩|⋪|⋫|⋬|⋭|⋲|⋳|⋴|⋵|⋶|⋷|⋸|⋹|⋺|⋻|⋼|⋽|⋾|⋿|⟈|⟉|⟒|⦷|⧀|⧁|⧡|⧣|⧤|⧥|⩦|⩧|⩪|⩫|⩬|⩭|⩮|⩯|⩰|⩱|⩲|⩳|⩵|⩶|⩷|⩸|⩹|⩺|⩻|⩼|⩽|⩾|⩿|⪀|⪁|⪂|⪃|⪄|⪅|⪆|⪇|⪈|⪉|⪊|⪋|⪌|⪍|⪎|⪏|⪐|⪑|⪒|⪓|⪔|⪕|⪖|⪗|⪘|⪙|⪚|⪛|⪜|⪝|⪞|⪟|⪠|⪡|⪢|⪣|⪤|⪥|⪦|⪧|⪨|⪩|⪪|⪫|⪬|⪭|⪮|⪯|⪰|⪱|⪲|⪳|⪴|⪵|⪶|⪷|⪸|⪹|⪺|⪻|⪼|⪽|⪾|⪿|⫀|⫁|⫂|⫃|⫄|⫅|⫆|⫇|⫈|⫉|⫊|⫋|⫌|⫍|⫎|⫏|⫐|⫑|⫒|⫓|⫔|⫕|⫖|⫗|⫘|⫙|⫷|⫸|⫹|⫺|⊢|⊣|⟂|⫪|⫫|<:|>:))' 354 | name: 'keyword.operator.relation.julia' 355 | } 356 | { 357 | match: '(?<=\\s)(?:\\?)(?=\\s)' 358 | name: 'keyword.operator.ternary.julia' 359 | } 360 | { 361 | match: '(?<=\\s)(?:\\:)(?=\\s)' 362 | name: 'keyword.operator.ternary.julia' 363 | } 364 | { 365 | match: '(?:\\|\\||&&|(?)' 374 | name: 'keyword.operator.applies.julia' 375 | } 376 | { 377 | match: '(?:\\||\\.\\||\\&|\\.\\&|~|¬|\\.~|⊻|\\.⊻)' 378 | name: 'keyword.operator.bitwise.julia' 379 | } 380 | { 381 | match: '\\.?(?:\\+\\+|\\-\\-|\\+|\\-|−|¦|\\||⊕|⊖|⊞|⊟|∪|∨|⊔|±|∓|∔|∸|≏|⊎|⊻|⊽|⋎|⋓|⟇|⧺|⧻|⨈|⨢|⨣|⨤|⨥|⨦|⨧|⨨|⨩|⨪|⨫|⨬|⨭|⨮|⨹|⨺|⩁|⩂|⩅|⩊|⩌|⩏|⩐|⩒|⩔|⩖|⩗|⩛|⩝|⩡|⩢|⩣|\\*|//?|⌿|÷|%|&|·|·|⋅|∘|×|\\\\|∩|∧|⊗|⊘|⊙|⊚|⊛|⊠|⊡|⊓|∗|∙|∤|⅋|≀|⊼|⋄|⋆|⋇|⋉|⋊|⋋|⋌|⋏|⋒|⟑|⦸|⦼|⦾|⦿|⧶|⧷|⨇|⨰|⨱|⨲|⨳|⨴|⨵|⨶|⨷|⨸|⨻|⨼|⨽|⩀|⩃|⩄|⩋|⩍|⩎|⩑|⩓|⩕|⩘|⩚|⩜|⩞|⩟|⩠|⫛|⊍|▷|⨝|⟕|⟖|⟗|⨟|\\^|↑|↓|⇵|⟰|⟱|⤈|⤉|⤊|⤋|⤒|⤓|⥉|⥌|⥍|⥏|⥑|⥔|⥕|⥘|⥙|⥜|⥝|⥠|⥡|⥣|⥥|⥮|⥯|↑|↓|√|∛|∜|⋆|±|∓)' 382 | name: 'keyword.operator.arithmetic.julia' 383 | } 384 | { 385 | match: '(?:∘)' 386 | name: 'keyword.operator.compose.julia' 387 | } 388 | { 389 | match: '(?:::|(?<=\\s)isa(?=\\s))' 390 | name: 'keyword.operator.isa.julia' 391 | } 392 | { 393 | match: '(?:(?<=\\s)in(?=\\s))' 394 | name: 'keyword.operator.relation.in.julia' 395 | } 396 | { 397 | match: '(?:\\.(?=(?:@|_|\\p{L}))|\\.\\.+|…|⁝|⋮|⋱|⋰|⋯)' 398 | name: 'keyword.operator.dots.julia' 399 | } 400 | { 401 | match: '(?:\\$)(?=.+)' 402 | name: 'keyword.operator.interpolation.julia' 403 | } 404 | { 405 | captures: 406 | '2': 407 | name: 'keyword.operator.transposed-variable.julia' 408 | match: "((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)(('|(\\.'))*\\.?')" 409 | } 410 | { 411 | captures: 412 | '1': 413 | name: 'bracket.end.julia' 414 | '2': 415 | name: 'keyword.operator.transposed-matrix.julia' 416 | match: "(\\])((?:'|(?:\\.'))*\\.?')" 417 | } 418 | { 419 | captures: 420 | '1': 421 | name: 'bracket.end.julia' 422 | '2': 423 | name: 'keyword.operator.transposed-parens.julia' 424 | match: "(\\))((?:'|(?:\\.'))*\\.?')" 425 | } 426 | ] 427 | string: 428 | patterns: [ 429 | { 430 | begin: '(?:(@doc)\\s((?:doc)?""")|(doc"""))' 431 | beginCaptures: 432 | '1': 433 | name: 'support.function.macro.julia' 434 | '2': 435 | name: 'punctuation.definition.string.begin.julia' 436 | end: '(""") ?(->)?' 437 | endCaptures: 438 | '1': 439 | name: 'punctuation.definition.string.end.julia' 440 | '2': 441 | name: 'keyword.operator.arrow.julia' 442 | name: 'string.docstring.julia' 443 | patterns: [ 444 | { 445 | include: '#string_escaped_char' 446 | } 447 | { 448 | include: '#string_dollar_sign_interpolate' 449 | } 450 | ] 451 | } 452 | { 453 | begin: '(i?cxx)(""")' 454 | beginCaptures: 455 | '1': 456 | name: 'support.function.macro.julia' 457 | '2': 458 | name: 'punctuation.definition.string.begin.julia' 459 | end: '"""' 460 | endCaptures: 461 | '0': 462 | name: 'punctuation.definition.string.end.julia' 463 | name: 'embed.cxx.julia' 464 | contentName: 'source.cpp' 465 | patterns: [ 466 | { 467 | include: 'source.cpp' 468 | } 469 | { 470 | include: '#string_dollar_sign_interpolate' 471 | } 472 | ] 473 | } 474 | { 475 | begin: '(py)(""")' 476 | beginCaptures: 477 | '1': 478 | name: 'support.function.macro.julia' 479 | '2': 480 | name: 'punctuation.definition.string.begin.julia' 481 | end: '([\\s\\w]*)(""")' 482 | endCaptures: 483 | '2': 484 | name: 'punctuation.definition.string.end.julia' 485 | name: 'embed.python.julia' 486 | contentName: 'source.python' 487 | patterns: [ 488 | { 489 | include: 'source.python' 490 | } 491 | { 492 | include: '#string_dollar_sign_interpolate' 493 | } 494 | ] 495 | } 496 | { 497 | begin: '(js)(""")' 498 | beginCaptures: 499 | '1': 500 | name: 'support.function.macro.julia' 501 | '2': 502 | name: 'punctuation.definition.string.begin.julia' 503 | end: '"""' 504 | endCaptures: 505 | '0': 506 | name: 'punctuation.definition.string.end.julia' 507 | name: 'embed.js.julia' 508 | contentName: 'source.js' 509 | patterns: [ 510 | { 511 | include: 'source.js' 512 | } 513 | { 514 | include: '#string_dollar_sign_interpolate' 515 | } 516 | ] 517 | } 518 | { 519 | begin: '(R)(""")' 520 | beginCaptures: 521 | '1': 522 | name: 'support.function.macro.julia' 523 | '2': 524 | name: 'punctuation.definition.string.begin.julia' 525 | end: '"""' 526 | endCaptures: 527 | '0': 528 | name: 'punctuation.definition.string.end.julia' 529 | name: 'embed.R.julia' 530 | contentName: 'source.r' 531 | patterns: [ 532 | { 533 | include: 'source.r' 534 | } 535 | { 536 | include: '#string_dollar_sign_interpolate' 537 | } 538 | ] 539 | } 540 | { 541 | begin: '(raw)(""")' 542 | beginCaptures: 543 | '1': 544 | name: 'support.function.macro.julia' 545 | '2': 546 | name: 'punctuation.definition.string.begin.julia' 547 | end: '"""' 548 | name: 'string.quoted.other.julia' 549 | endCaptures: 550 | '0': 551 | name: 'punctuation.definition.string.end.julia' 552 | patterns: [ 553 | { 554 | include: '#string_escaped_char' 555 | } 556 | ] 557 | } 558 | { 559 | begin: '(raw)(")' 560 | beginCaptures: 561 | '1': 562 | name: 'support.function.macro.julia' 563 | '2': 564 | name: 'punctuation.definition.string.begin.julia' 565 | end: '"' 566 | name: 'string.quoted.other.julia' 567 | endCaptures: 568 | '0': 569 | name: 'punctuation.definition.string.end.julia' 570 | patterns: [ 571 | { 572 | include: '#string_escaped_char' 573 | } 574 | ] 575 | } 576 | { 577 | begin: '(sql)(""")' 578 | beginCaptures: 579 | '1': 580 | name: 'support.function.macro.julia' 581 | '2': 582 | name: 'punctuation.definition.string.begin.julia' 583 | end: '"""' 584 | endCaptures: 585 | '0': 586 | name: 'punctuation.definition.string.end.julia' 587 | name: 'embed.sql.julia' 588 | contentName: 'meta.embedded.inline.sql' 589 | patterns: [ 590 | { 591 | include: 'source.sql' 592 | } 593 | { 594 | include: '#string_dollar_sign_interpolate' 595 | } 596 | ] 597 | } 598 | { 599 | begin: 'var"""' 600 | end: '"""' 601 | name: 'constant.other.symbol.julia' 602 | patterns: [ 603 | { 604 | include: '#string_escaped_char' 605 | } 606 | ] 607 | } 608 | { 609 | begin: 'var"' 610 | end: '"' 611 | name: 'constant.other.symbol.julia' 612 | patterns: [ 613 | { 614 | include: '#string_escaped_char' 615 | } 616 | ] 617 | } 618 | { 619 | begin: '^\\s?(doc)?(""")\\s?$' 620 | beginCaptures: 621 | '1': 622 | name: 'support.function.macro.julia' 623 | '2': 624 | name: 'punctuation.definition.string.begin.julia' 625 | end: '(""")' 626 | endCaptures: 627 | '1': 628 | name: 'punctuation.definition.string.end.julia' 629 | name: 'string.docstring.julia' 630 | comment: ''' 631 | This only matches docstrings that start and end with triple quotes on 632 | their own line in the void 633 | ''' 634 | patterns: [ 635 | { 636 | include: '#string_escaped_char' 637 | } 638 | { 639 | include: '#string_dollar_sign_interpolate' 640 | } 641 | ] 642 | } 643 | { 644 | begin: "'" 645 | beginCaptures: 646 | '0': 647 | name: 'punctuation.definition.string.begin.julia' 648 | end: "'(?!')" 649 | endCaptures: 650 | '0': 651 | name: 'punctuation.definition.string.end.julia' 652 | name: 'string.quoted.single.julia' 653 | patterns: [ 654 | { 655 | include: '#string_escaped_char' 656 | } 657 | ] 658 | } 659 | { 660 | begin: '"""' 661 | beginCaptures: 662 | '0': 663 | name: 'punctuation.definition.string.multiline.begin.julia' 664 | end: '"""' 665 | endCaptures: 666 | '0': 667 | name: 'punctuation.definition.string.multiline.end.julia' 668 | name: 'string.quoted.triple.double.julia' 669 | comment: 'multi-line string with triple double quotes' 670 | patterns: [ 671 | { 672 | include: '#string_escaped_char' 673 | } 674 | { 675 | include: '#string_dollar_sign_interpolate' 676 | } 677 | ] 678 | } 679 | { 680 | name: 'string.quoted.double.julia' 681 | begin: '"(?!"")' 682 | beginCaptures: 683 | '0': 684 | name: 'punctuation.definition.string.begin.julia' 685 | end: '"' 686 | endCaptures: 687 | '0': 688 | name: 'punctuation.definition.string.end.julia' 689 | comment: 'String with single pair of double quotes. Regex matches isolated double quote' 690 | patterns: [ 691 | { 692 | include: '#string_escaped_char' 693 | } 694 | { 695 | include: '#string_dollar_sign_interpolate' 696 | } 697 | ] 698 | } 699 | { 700 | begin: 'r"""' 701 | beginCaptures: 702 | '0': 703 | name: 'punctuation.definition.string.regexp.begin.julia' 704 | end: '(""")([imsx]{0,4})?' 705 | endCaptures: 706 | '1': 707 | name: 'punctuation.definition.string.regexp.end.julia' 708 | '2': 709 | comment: 'I took this scope name from python regex grammar' 710 | name: 'keyword.other.option-toggle.regexp.julia' 711 | name: 'string.regexp.julia' 712 | patterns: [ 713 | { 714 | include: '#string_escaped_char' 715 | } 716 | ] 717 | } 718 | { 719 | begin: 'r"' 720 | beginCaptures: 721 | '0': 722 | name: 'punctuation.definition.string.regexp.begin.julia' 723 | end: '(")([imsx]{0,4})?' 724 | endCaptures: 725 | '1': 726 | name: 'punctuation.definition.string.regexp.end.julia' 727 | '2': 728 | comment: 'I took this scope name from python regex grammar' 729 | name: 'keyword.other.option-toggle.regexp.julia' 730 | name: 'string.regexp.julia' 731 | patterns: [ 732 | { 733 | include: '#string_escaped_char' 734 | } 735 | ] 736 | } 737 | { 738 | begin: '(?!:_)(?:struct|mutable\\s+struct|abstract\\s+type|primitive\\s+type)\\s+((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)(\\s*(<:)\\s*(?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*(?:{.*})?)?' 878 | name: 'meta.type.julia' 879 | } 880 | ] 881 | self_no_for_block: 882 | comment: "Same as $self, but does not contain #for_block. 'outer' is not valid in some contexts (e.g. generators, comprehensions, indexing), so use this when matching those in begin/end patterns. Keep this up-to-date with $self!" 883 | patterns: [ 884 | { 885 | include: '#operator' 886 | } 887 | { 888 | include: '#array' 889 | } 890 | { 891 | include: '#string' 892 | } 893 | { 894 | include: '#parentheses' 895 | } 896 | { 897 | include: '#bracket' 898 | } 899 | { 900 | include: '#function_decl' 901 | } 902 | { 903 | include: '#function_call' 904 | } 905 | { 906 | include: '#keyword' 907 | } 908 | { 909 | include: '#number' 910 | } 911 | { 912 | include: '#comment' 913 | } 914 | { 915 | include: '#type_decl' 916 | } 917 | { 918 | include: '#symbol' 919 | } 920 | { 921 | include: '#punctuation' 922 | } 923 | ] 924 | punctuation: 925 | patterns: [ 926 | { 927 | match: ',' 928 | name: 'punctuation.separator.comma.julia' 929 | } 930 | { 931 | match: ';' 932 | name: 'punctuation.separator.semicolon.julia' 933 | } 934 | ] 935 | scopeName: 'source.julia' -------------------------------------------------------------------------------- /grammars/julia.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "This grammar is used by Atom (Oniguruma), GitHub (PCRE), and VSCode (Oniguruma),\nso all regexps must be compatible with both engines.\n\nSpecs:\n- https://github.com/kkos/oniguruma/blob/master/doc/RE\n- https://www.pcre.org/current/doc/html/", 3 | "fileTypes": [ 4 | "jl" 5 | ], 6 | "firstLineMatch": "^#!.*\\bjulia\\s*$", 7 | "name": "Julia", 8 | "patterns": [ 9 | { 10 | "include": "#operator" 11 | }, 12 | { 13 | "include": "#array" 14 | }, 15 | { 16 | "include": "#string" 17 | }, 18 | { 19 | "include": "#parentheses" 20 | }, 21 | { 22 | "include": "#bracket" 23 | }, 24 | { 25 | "include": "#function_decl" 26 | }, 27 | { 28 | "include": "#function_call" 29 | }, 30 | { 31 | "include": "#for_block" 32 | }, 33 | { 34 | "include": "#keyword" 35 | }, 36 | { 37 | "include": "#number" 38 | }, 39 | { 40 | "include": "#comment" 41 | }, 42 | { 43 | "include": "#type_decl" 44 | }, 45 | { 46 | "include": "#symbol" 47 | }, 48 | { 49 | "include": "#punctuation" 50 | } 51 | ], 52 | "repository": { 53 | "array": { 54 | "patterns": [ 55 | { 56 | "begin": "\\[", 57 | "beginCaptures": { 58 | "0": { 59 | "name": "meta.bracket.julia" 60 | } 61 | }, 62 | "end": "(\\])((?:\\.)?'*)", 63 | "endCaptures": { 64 | "1": { 65 | "name": "meta.bracket.julia" 66 | }, 67 | "2": { 68 | "name": "keyword.operator.transpose.julia" 69 | } 70 | }, 71 | "name": "meta.array.julia", 72 | "patterns": [ 73 | { 74 | "match": "\\bbegin\\b", 75 | "name": "constant.numeric.julia" 76 | }, 77 | { 78 | "match": "\\bend\\b", 79 | "name": "constant.numeric.julia" 80 | }, 81 | { 82 | "include": "#self_no_for_block" 83 | } 84 | ] 85 | } 86 | ] 87 | }, 88 | "parentheses": { 89 | "patterns": [ 90 | { 91 | "begin": "\\(", 92 | "beginCaptures": { 93 | "0": { 94 | "name": "meta.bracket.julia" 95 | } 96 | }, 97 | "end": "(\\))((?:\\.)?'*)", 98 | "endCaptures": { 99 | "1": { 100 | "name": "meta.bracket.julia" 101 | }, 102 | "2": { 103 | "name": "keyword.operator.transpose.julia" 104 | } 105 | }, 106 | "patterns": [ 107 | { 108 | "include": "#self_no_for_block" 109 | } 110 | ] 111 | } 112 | ] 113 | }, 114 | "bracket": { 115 | "patterns": [ 116 | { 117 | "begin": "\\{", 118 | "beginCaptures": { 119 | "0": { 120 | "name": "meta.bracket.julia" 121 | } 122 | }, 123 | "end": "(\\})((?:\\.)?'*)", 124 | "endCaptures": { 125 | "1": { 126 | "name": "meta.bracket.julia" 127 | }, 128 | "2": { 129 | "name": "keyword.operator.transpose.julia" 130 | } 131 | }, 132 | "patterns": [ 133 | { 134 | "include": "#self_no_for_block" 135 | } 136 | ] 137 | } 138 | ] 139 | }, 140 | "comment_tags": { 141 | "patterns": [ 142 | { 143 | "match": "\\bTODO\\b", 144 | "name": "keyword.other.comment-annotation.julia" 145 | }, 146 | { 147 | "match": "\\bFIXME\\b", 148 | "name": "keyword.other.comment-annotation.julia" 149 | }, 150 | { 151 | "match": "\\bCHANGED\\b", 152 | "name": "keyword.other.comment-annotation.julia" 153 | }, 154 | { 155 | "match": "\\bXXX\\b", 156 | "name": "keyword.other.comment-annotation.julia" 157 | } 158 | ] 159 | }, 160 | "comment": { 161 | "patterns": [ 162 | { 163 | "include": "#comment_block" 164 | }, 165 | { 166 | "begin": "#", 167 | "beginCaptures": { 168 | "0": { 169 | "name": "punctuation.definition.comment.julia" 170 | } 171 | }, 172 | "end": "\\n", 173 | "name": "comment.line.number-sign.julia", 174 | "patterns": [ 175 | { 176 | "include": "#comment_tags" 177 | } 178 | ] 179 | } 180 | ] 181 | }, 182 | "comment_block": { 183 | "patterns": [ 184 | { 185 | "begin": "#=", 186 | "beginCaptures": { 187 | "0": { 188 | "name": "punctuation.definition.comment.begin.julia" 189 | } 190 | }, 191 | "end": "=#", 192 | "endCaptures": { 193 | "0": { 194 | "name": "punctuation.definition.comment.end.julia" 195 | } 196 | }, 197 | "name": "comment.block.number-sign-equals.julia", 198 | "patterns": [ 199 | { 200 | "include": "#comment_tags" 201 | }, 202 | { 203 | "include": "#comment_block" 204 | } 205 | ] 206 | } 207 | ] 208 | }, 209 | "function_call": { 210 | "patterns": [ 211 | { 212 | "begin": "((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?\\.?(\\()", 213 | "beginCaptures": { 214 | "1": { 215 | "name": "support.function.julia" 216 | }, 217 | "2": { 218 | "name": "support.type.julia" 219 | }, 220 | "3": { 221 | "name": "meta.bracket.julia" 222 | } 223 | }, 224 | "end": "\\)(('|(\\.'))*\\.?')?", 225 | "endCaptures": { 226 | "0": { 227 | "name": "meta.bracket.julia" 228 | }, 229 | "1": { 230 | "name": "keyword.operator.transposed-func.julia" 231 | } 232 | }, 233 | "patterns": [ 234 | { 235 | "include": "#self_no_for_block" 236 | } 237 | ] 238 | } 239 | ] 240 | }, 241 | "function_decl": { 242 | "patterns": [ 243 | { 244 | "captures": { 245 | "1": { 246 | "name": "entity.name.function.julia" 247 | }, 248 | "2": { 249 | "name": "support.type.julia" 250 | } 251 | }, 252 | "match": "((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?(?=\\([^#]*\\)(::[^\\s]+)?(\\s*\\bwhere\\b\\s+.+?)?\\s*?=(?![=>]))", 253 | "comment": "first group is function name\nSecond group is type parameters (e.g. {T<:Number, S})\nThen open parens\nThen a lookahead ensures that we are followed by:\n - anything (function arguments)\n - 0 or more spaces\n - Finally an equal sign\nNegative lookahead ensures we don't have another equal sign (not `==`)" 254 | }, 255 | { 256 | "captures": { 257 | "1": { 258 | "name": "keyword.other.julia" 259 | }, 260 | "2": { 261 | "name": "keyword.operator.dots.julia" 262 | }, 263 | "3": { 264 | "name": "entity.name.function.julia" 265 | }, 266 | "4": { 267 | "name": "support.type.julia" 268 | } 269 | }, 270 | "match": "\\b(function|macro)(?:\\s+(?:(?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*(\\.))?((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?|\\s*)(?=\\()", 271 | "comment": "similar regex to previous, but with keyword not 1-line syntax" 272 | } 273 | ] 274 | }, 275 | "for_block": { 276 | "comment": "for blocks need to be special-cased to support tokenizing 'outer' properly", 277 | "patterns": [ 278 | { 279 | "begin": "\\b(for)\\b", 280 | "beginCaptures": { 281 | "0": { 282 | "name": "keyword.control.julia" 283 | } 284 | }, 285 | "end": "(?|->|-->|<--|←|→|↔|↚|↛|↞|↠|↢|↣|↦|↤|↮|⇎|⇍|⇏|⇐|⇒|⇔|⇴|⇶|⇷|⇸|⇹|⇺|⇻|⇼|⇽|⇾|⇿|⟵|⟶|⟷|⟹|⟺|⟻|⟼|⟽|⟾|⟿|⤀|⤁|⤂|⤃|⤄|⤅|⤆|⤇|⤌|⤍|⤎|⤏|⤐|⤑|⤔|⤕|⤖|⤗|⤘|⤝|⤞|⤟|⤠|⥄|⥅|⥆|⥇|⥈|⥊|⥋|⥎|⥐|⥒|⥓|⥖|⥗|⥚|⥛|⥞|⥟|⥢|⥤|⥦|⥧|⥨|⥩|⥪|⥫|⥬|⥭|⥰|⧴|⬱|⬰|⬲|⬳|⬴|⬵|⬶|⬷|⬸|⬹|⬺|⬻|⬼|⬽|⬾|⬿|⭀|⭁|⭂|⭃|⥷|⭄|⥺|⭇|⭈|⭉|⭊|⭋|⭌|←|→|⇜|⇝|↜|↝|↩|↪|↫|↬|↼|↽|⇀|⇁|⇄|⇆|⇇|⇉|⇋|⇌|⇚|⇛|⇠|⇢|↷|↶|↺|↻|=>)", 369 | "name": "keyword.operator.arrow.julia" 370 | }, 371 | { 372 | "match": "(?::=|\\+=|-=|\\*=|//=|/=|\\.//=|\\./=|\\.\\*=|\\\\=|\\.\\\\=|\\^=|\\.\\^=|%=|\\.%=|÷=|\\.÷=|\\|=|&=|\\.&=|⊻=|\\.⊻=|\\$=|<<=|>>=|>>>=|=(?!=))", 373 | "name": "keyword.operator.update.julia" 374 | }, 375 | { 376 | "match": "(?:<<|>>>|>>|\\.>>>|\\.>>|\\.<<)", 377 | "name": "keyword.operator.shift.julia" 378 | }, 379 | { 380 | "match": "(?:\\s*(::|>:|<:)\\s*((?:(?:Union)?\\([^)]*\\)|[[:alpha:]_$∇][[:word:]⁺-ₜ!′\\.]*(?:(?:{(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})|(?:\".+?(?)>=|>|<|≥|≤|===|==|≡|!=|≠|!==|≢|∈|∉|∋|∌|⊆|⊈|⊂|⊄|⊊|∝|∊|∍|∥|∦|∷|∺|∻|∽|∾|≁|≃|≂|≄|≅|≆|≇|≈|≉|≊|≋|≌|≍|≎|≐|≑|≒|≓|≖|≗|≘|≙|≚|≛|≜|≝|≞|≟|≣|≦|≧|≨|≩|≪|≫|≬|≭|≮|≯|≰|≱|≲|≳|≴|≵|≶|≷|≸|≹|≺|≻|≼|≽|≾|≿|⊀|⊁|⊃|⊅|⊇|⊉|⊋|⊏|⊐|⊑|⊒|⊜|⊩|⊬|⊮|⊰|⊱|⊲|⊳|⊴|⊵|⊶|⊷|⋍|⋐|⋑|⋕|⋖|⋗|⋘|⋙|⋚|⋛|⋜|⋝|⋞|⋟|⋠|⋡|⋢|⋣|⋤|⋥|⋦|⋧|⋨|⋩|⋪|⋫|⋬|⋭|⋲|⋳|⋴|⋵|⋶|⋷|⋸|⋹|⋺|⋻|⋼|⋽|⋾|⋿|⟈|⟉|⟒|⦷|⧀|⧁|⧡|⧣|⧤|⧥|⩦|⩧|⩪|⩫|⩬|⩭|⩮|⩯|⩰|⩱|⩲|⩳|⩵|⩶|⩷|⩸|⩹|⩺|⩻|⩼|⩽|⩾|⩿|⪀|⪁|⪂|⪃|⪄|⪅|⪆|⪇|⪈|⪉|⪊|⪋|⪌|⪍|⪎|⪏|⪐|⪑|⪒|⪓|⪔|⪕|⪖|⪗|⪘|⪙|⪚|⪛|⪜|⪝|⪞|⪟|⪠|⪡|⪢|⪣|⪤|⪥|⪦|⪧|⪨|⪩|⪪|⪫|⪬|⪭|⪮|⪯|⪰|⪱|⪲|⪳|⪴|⪵|⪶|⪷|⪸|⪹|⪺|⪻|⪼|⪽|⪾|⪿|⫀|⫁|⫂|⫃|⫄|⫅|⫆|⫇|⫈|⫉|⫊|⫋|⫌|⫍|⫎|⫏|⫐|⫑|⫒|⫓|⫔|⫕|⫖|⫗|⫘|⫙|⫷|⫸|⫹|⫺|⊢|⊣|⟂|⫪|⫫|<:|>:))", 395 | "name": "keyword.operator.relation.julia" 396 | }, 397 | { 398 | "match": "(?<=\\s)(?:\\?)(?=\\s)", 399 | "name": "keyword.operator.ternary.julia" 400 | }, 401 | { 402 | "match": "(?<=\\s)(?:\\:)(?=\\s)", 403 | "name": "keyword.operator.ternary.julia" 404 | }, 405 | { 406 | "match": "(?:\\|\\||&&|(?)", 415 | "name": "keyword.operator.applies.julia" 416 | }, 417 | { 418 | "match": "(?:\\||\\.\\||\\&|\\.\\&|~|¬|\\.~|⊻|\\.⊻)", 419 | "name": "keyword.operator.bitwise.julia" 420 | }, 421 | { 422 | "match": "\\.?(?:\\+\\+|\\-\\-|\\+|\\-|−|¦|\\||⊕|⊖|⊞|⊟|∪|∨|⊔|±|∓|∔|∸|≏|⊎|⊻|⊽|⋎|⋓|⟇|⧺|⧻|⨈|⨢|⨣|⨤|⨥|⨦|⨧|⨨|⨩|⨪|⨫|⨬|⨭|⨮|⨹|⨺|⩁|⩂|⩅|⩊|⩌|⩏|⩐|⩒|⩔|⩖|⩗|⩛|⩝|⩡|⩢|⩣|\\*|//?|⌿|÷|%|&|·|·|⋅|∘|×|\\\\|∩|∧|⊗|⊘|⊙|⊚|⊛|⊠|⊡|⊓|∗|∙|∤|⅋|≀|⊼|⋄|⋆|⋇|⋉|⋊|⋋|⋌|⋏|⋒|⟑|⦸|⦼|⦾|⦿|⧶|⧷|⨇|⨰|⨱|⨲|⨳|⨴|⨵|⨶|⨷|⨸|⨻|⨼|⨽|⩀|⩃|⩄|⩋|⩍|⩎|⩑|⩓|⩕|⩘|⩚|⩜|⩞|⩟|⩠|⫛|⊍|▷|⨝|⟕|⟖|⟗|⨟|\\^|↑|↓|⇵|⟰|⟱|⤈|⤉|⤊|⤋|⤒|⤓|⥉|⥌|⥍|⥏|⥑|⥔|⥕|⥘|⥙|⥜|⥝|⥠|⥡|⥣|⥥|⥮|⥯|↑|↓|√|∛|∜|⋆|±|∓)", 423 | "name": "keyword.operator.arithmetic.julia" 424 | }, 425 | { 426 | "match": "(?:∘)", 427 | "name": "keyword.operator.compose.julia" 428 | }, 429 | { 430 | "match": "(?:::|(?<=\\s)isa(?=\\s))", 431 | "name": "keyword.operator.isa.julia" 432 | }, 433 | { 434 | "match": "(?:(?<=\\s)in(?=\\s))", 435 | "name": "keyword.operator.relation.in.julia" 436 | }, 437 | { 438 | "match": "(?:\\.(?=(?:@|_|\\p{L}))|\\.\\.+|…|⁝|⋮|⋱|⋰|⋯)", 439 | "name": "keyword.operator.dots.julia" 440 | }, 441 | { 442 | "match": "(?:\\$)(?=.+)", 443 | "name": "keyword.operator.interpolation.julia" 444 | }, 445 | { 446 | "captures": { 447 | "2": { 448 | "name": "keyword.operator.transposed-variable.julia" 449 | } 450 | }, 451 | "match": "((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)(('|(\\.'))*\\.?')" 452 | }, 453 | { 454 | "captures": { 455 | "1": { 456 | "name": "bracket.end.julia" 457 | }, 458 | "2": { 459 | "name": "keyword.operator.transposed-matrix.julia" 460 | } 461 | }, 462 | "match": "(\\])((?:'|(?:\\.'))*\\.?')" 463 | }, 464 | { 465 | "captures": { 466 | "1": { 467 | "name": "bracket.end.julia" 468 | }, 469 | "2": { 470 | "name": "keyword.operator.transposed-parens.julia" 471 | } 472 | }, 473 | "match": "(\\))((?:'|(?:\\.'))*\\.?')" 474 | } 475 | ] 476 | }, 477 | "string": { 478 | "patterns": [ 479 | { 480 | "begin": "(?:(@doc)\\s((?:doc)?\"\"\")|(doc\"\"\"))", 481 | "beginCaptures": { 482 | "1": { 483 | "name": "support.function.macro.julia" 484 | }, 485 | "2": { 486 | "name": "punctuation.definition.string.begin.julia" 487 | } 488 | }, 489 | "end": "(\"\"\") ?(->)?", 490 | "endCaptures": { 491 | "1": { 492 | "name": "punctuation.definition.string.end.julia" 493 | }, 494 | "2": { 495 | "name": "keyword.operator.arrow.julia" 496 | } 497 | }, 498 | "name": "string.docstring.julia", 499 | "patterns": [ 500 | { 501 | "include": "#string_escaped_char" 502 | }, 503 | { 504 | "include": "#string_dollar_sign_interpolate" 505 | } 506 | ] 507 | }, 508 | { 509 | "begin": "(i?cxx)(\"\"\")", 510 | "beginCaptures": { 511 | "1": { 512 | "name": "support.function.macro.julia" 513 | }, 514 | "2": { 515 | "name": "punctuation.definition.string.begin.julia" 516 | } 517 | }, 518 | "end": "\"\"\"", 519 | "endCaptures": { 520 | "0": { 521 | "name": "punctuation.definition.string.end.julia" 522 | } 523 | }, 524 | "name": "embed.cxx.julia", 525 | "contentName": "source.cpp", 526 | "patterns": [ 527 | { 528 | "include": "source.cpp" 529 | }, 530 | { 531 | "include": "#string_dollar_sign_interpolate" 532 | } 533 | ] 534 | }, 535 | { 536 | "begin": "(py)(\"\"\")", 537 | "beginCaptures": { 538 | "1": { 539 | "name": "support.function.macro.julia" 540 | }, 541 | "2": { 542 | "name": "punctuation.definition.string.begin.julia" 543 | } 544 | }, 545 | "end": "([\\s\\w]*)(\"\"\")", 546 | "endCaptures": { 547 | "2": { 548 | "name": "punctuation.definition.string.end.julia" 549 | } 550 | }, 551 | "name": "embed.python.julia", 552 | "contentName": "source.python", 553 | "patterns": [ 554 | { 555 | "include": "source.python" 556 | }, 557 | { 558 | "include": "#string_dollar_sign_interpolate" 559 | } 560 | ] 561 | }, 562 | { 563 | "begin": "(js)(\"\"\")", 564 | "beginCaptures": { 565 | "1": { 566 | "name": "support.function.macro.julia" 567 | }, 568 | "2": { 569 | "name": "punctuation.definition.string.begin.julia" 570 | } 571 | }, 572 | "end": "\"\"\"", 573 | "endCaptures": { 574 | "0": { 575 | "name": "punctuation.definition.string.end.julia" 576 | } 577 | }, 578 | "name": "embed.js.julia", 579 | "contentName": "source.js", 580 | "patterns": [ 581 | { 582 | "include": "source.js" 583 | }, 584 | { 585 | "include": "#string_dollar_sign_interpolate" 586 | } 587 | ] 588 | }, 589 | { 590 | "begin": "(R)(\"\"\")", 591 | "beginCaptures": { 592 | "1": { 593 | "name": "support.function.macro.julia" 594 | }, 595 | "2": { 596 | "name": "punctuation.definition.string.begin.julia" 597 | } 598 | }, 599 | "end": "\"\"\"", 600 | "endCaptures": { 601 | "0": { 602 | "name": "punctuation.definition.string.end.julia" 603 | } 604 | }, 605 | "name": "embed.R.julia", 606 | "contentName": "source.r", 607 | "patterns": [ 608 | { 609 | "include": "source.r" 610 | }, 611 | { 612 | "include": "#string_dollar_sign_interpolate" 613 | } 614 | ] 615 | }, 616 | { 617 | "begin": "(raw)(\"\"\")", 618 | "beginCaptures": { 619 | "1": { 620 | "name": "support.function.macro.julia" 621 | }, 622 | "2": { 623 | "name": "punctuation.definition.string.begin.julia" 624 | } 625 | }, 626 | "end": "\"\"\"", 627 | "name": "string.quoted.other.julia", 628 | "endCaptures": { 629 | "0": { 630 | "name": "punctuation.definition.string.end.julia" 631 | } 632 | }, 633 | "patterns": [ 634 | { 635 | "include": "#string_escaped_char" 636 | } 637 | ] 638 | }, 639 | { 640 | "begin": "(raw)(\")", 641 | "beginCaptures": { 642 | "1": { 643 | "name": "support.function.macro.julia" 644 | }, 645 | "2": { 646 | "name": "punctuation.definition.string.begin.julia" 647 | } 648 | }, 649 | "end": "\"", 650 | "name": "string.quoted.other.julia", 651 | "endCaptures": { 652 | "0": { 653 | "name": "punctuation.definition.string.end.julia" 654 | } 655 | }, 656 | "patterns": [ 657 | { 658 | "include": "#string_escaped_char" 659 | } 660 | ] 661 | }, 662 | { 663 | "begin": "(sql)(\"\"\")", 664 | "beginCaptures": { 665 | "1": { 666 | "name": "support.function.macro.julia" 667 | }, 668 | "2": { 669 | "name": "punctuation.definition.string.begin.julia" 670 | } 671 | }, 672 | "end": "\"\"\"", 673 | "endCaptures": { 674 | "0": { 675 | "name": "punctuation.definition.string.end.julia" 676 | } 677 | }, 678 | "name": "embed.sql.julia", 679 | "contentName": "meta.embedded.inline.sql", 680 | "patterns": [ 681 | { 682 | "include": "source.sql" 683 | }, 684 | { 685 | "include": "#string_dollar_sign_interpolate" 686 | } 687 | ] 688 | }, 689 | { 690 | "begin": "var\"\"\"", 691 | "end": "\"\"\"", 692 | "name": "constant.other.symbol.julia", 693 | "patterns": [ 694 | { 695 | "include": "#string_escaped_char" 696 | } 697 | ] 698 | }, 699 | { 700 | "begin": "var\"", 701 | "end": "\"", 702 | "name": "constant.other.symbol.julia", 703 | "patterns": [ 704 | { 705 | "include": "#string_escaped_char" 706 | } 707 | ] 708 | }, 709 | { 710 | "begin": "^\\s?(doc)?(\"\"\")\\s?$", 711 | "beginCaptures": { 712 | "1": { 713 | "name": "support.function.macro.julia" 714 | }, 715 | "2": { 716 | "name": "punctuation.definition.string.begin.julia" 717 | } 718 | }, 719 | "end": "(\"\"\")", 720 | "endCaptures": { 721 | "1": { 722 | "name": "punctuation.definition.string.end.julia" 723 | } 724 | }, 725 | "name": "string.docstring.julia", 726 | "comment": "This only matches docstrings that start and end with triple quotes on\ntheir own line in the void", 727 | "patterns": [ 728 | { 729 | "include": "#string_escaped_char" 730 | }, 731 | { 732 | "include": "#string_dollar_sign_interpolate" 733 | } 734 | ] 735 | }, 736 | { 737 | "begin": "'", 738 | "beginCaptures": { 739 | "0": { 740 | "name": "punctuation.definition.string.begin.julia" 741 | } 742 | }, 743 | "end": "'(?!')", 744 | "endCaptures": { 745 | "0": { 746 | "name": "punctuation.definition.string.end.julia" 747 | } 748 | }, 749 | "name": "string.quoted.single.julia", 750 | "patterns": [ 751 | { 752 | "include": "#string_escaped_char" 753 | } 754 | ] 755 | }, 756 | { 757 | "begin": "\"\"\"", 758 | "beginCaptures": { 759 | "0": { 760 | "name": "punctuation.definition.string.multiline.begin.julia" 761 | } 762 | }, 763 | "end": "\"\"\"", 764 | "endCaptures": { 765 | "0": { 766 | "name": "punctuation.definition.string.multiline.end.julia" 767 | } 768 | }, 769 | "name": "string.quoted.triple.double.julia", 770 | "comment": "multi-line string with triple double quotes", 771 | "patterns": [ 772 | { 773 | "include": "#string_escaped_char" 774 | }, 775 | { 776 | "include": "#string_dollar_sign_interpolate" 777 | } 778 | ] 779 | }, 780 | { 781 | "name": "string.quoted.double.julia", 782 | "begin": "\"(?!\"\")", 783 | "beginCaptures": { 784 | "0": { 785 | "name": "punctuation.definition.string.begin.julia" 786 | } 787 | }, 788 | "end": "\"", 789 | "endCaptures": { 790 | "0": { 791 | "name": "punctuation.definition.string.end.julia" 792 | } 793 | }, 794 | "comment": "String with single pair of double quotes. Regex matches isolated double quote", 795 | "patterns": [ 796 | { 797 | "include": "#string_escaped_char" 798 | }, 799 | { 800 | "include": "#string_dollar_sign_interpolate" 801 | } 802 | ] 803 | }, 804 | { 805 | "begin": "r\"\"\"", 806 | "beginCaptures": { 807 | "0": { 808 | "name": "punctuation.definition.string.regexp.begin.julia" 809 | } 810 | }, 811 | "end": "(\"\"\")([imsx]{0,4})?", 812 | "endCaptures": { 813 | "1": { 814 | "name": "punctuation.definition.string.regexp.end.julia" 815 | }, 816 | "2": { 817 | "comment": "I took this scope name from python regex grammar", 818 | "name": "keyword.other.option-toggle.regexp.julia" 819 | } 820 | }, 821 | "name": "string.regexp.julia", 822 | "patterns": [ 823 | { 824 | "include": "#string_escaped_char" 825 | } 826 | ] 827 | }, 828 | { 829 | "begin": "r\"", 830 | "beginCaptures": { 831 | "0": { 832 | "name": "punctuation.definition.string.regexp.begin.julia" 833 | } 834 | }, 835 | "end": "(\")([imsx]{0,4})?", 836 | "endCaptures": { 837 | "1": { 838 | "name": "punctuation.definition.string.regexp.end.julia" 839 | }, 840 | "2": { 841 | "comment": "I took this scope name from python regex grammar", 842 | "name": "keyword.other.option-toggle.regexp.julia" 843 | } 844 | }, 845 | "name": "string.regexp.julia", 846 | "patterns": [ 847 | { 848 | "include": "#string_escaped_char" 849 | } 850 | ] 851 | }, 852 | { 853 | "begin": "(?!:_)(?:struct|mutable\\s+struct|abstract\\s+type|primitive\\s+type)\\s+((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)(\\s*(<:)\\s*(?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*(?:{.*})?)?", 1025 | "name": "meta.type.julia" 1026 | } 1027 | ] 1028 | }, 1029 | "self_no_for_block": { 1030 | "comment": "Same as $self, but does not contain #for_block. 'outer' is not valid in some contexts (e.g. generators, comprehensions, indexing), so use this when matching those in begin/end patterns. Keep this up-to-date with $self!", 1031 | "patterns": [ 1032 | { 1033 | "include": "#operator" 1034 | }, 1035 | { 1036 | "include": "#array" 1037 | }, 1038 | { 1039 | "include": "#string" 1040 | }, 1041 | { 1042 | "include": "#parentheses" 1043 | }, 1044 | { 1045 | "include": "#bracket" 1046 | }, 1047 | { 1048 | "include": "#function_decl" 1049 | }, 1050 | { 1051 | "include": "#function_call" 1052 | }, 1053 | { 1054 | "include": "#keyword" 1055 | }, 1056 | { 1057 | "include": "#number" 1058 | }, 1059 | { 1060 | "include": "#comment" 1061 | }, 1062 | { 1063 | "include": "#type_decl" 1064 | }, 1065 | { 1066 | "include": "#symbol" 1067 | }, 1068 | { 1069 | "include": "#punctuation" 1070 | } 1071 | ] 1072 | }, 1073 | "punctuation": { 1074 | "patterns": [ 1075 | { 1076 | "match": ",", 1077 | "name": "punctuation.separator.comma.julia" 1078 | }, 1079 | { 1080 | "match": ";", 1081 | "name": "punctuation.separator.semicolon.julia" 1082 | } 1083 | ] 1084 | } 1085 | }, 1086 | "scopeName": "source.julia" 1087 | } -------------------------------------------------------------------------------- /grammars/julia.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "This grammar is used by Atom (Oniguruma), GitHub (PCRE), and VSCode (Oniguruma),\nso all regexps must be compatible with both engines.\n\nSpecs:\n- https://github.com/kkos/oniguruma/blob/master/doc/RE\n- https://www.pcre.org/current/doc/html/", 3 | "fileTypes": [ 4 | "jl" 5 | ], 6 | "firstLineMatch": "^#!.*\\bjulia\\s*$", 7 | "name": "Julia", 8 | "patterns": [ 9 | { 10 | "include": "#operator" 11 | }, 12 | { 13 | "include": "#array" 14 | }, 15 | { 16 | "include": "#string" 17 | }, 18 | { 19 | "include": "#parentheses" 20 | }, 21 | { 22 | "include": "#bracket" 23 | }, 24 | { 25 | "include": "#function_decl" 26 | }, 27 | { 28 | "include": "#function_call" 29 | }, 30 | { 31 | "include": "#for_block" 32 | }, 33 | { 34 | "include": "#keyword" 35 | }, 36 | { 37 | "include": "#number" 38 | }, 39 | { 40 | "include": "#comment" 41 | }, 42 | { 43 | "include": "#type_decl" 44 | }, 45 | { 46 | "include": "#symbol" 47 | }, 48 | { 49 | "include": "#punctuation" 50 | } 51 | ], 52 | "repository": { 53 | "array": { 54 | "patterns": [ 55 | { 56 | "begin": "\\[", 57 | "beginCaptures": { 58 | "0": { 59 | "name": "meta.bracket.julia" 60 | } 61 | }, 62 | "end": "(\\])((?:\\.)?'*)", 63 | "endCaptures": { 64 | "1": { 65 | "name": "meta.bracket.julia" 66 | }, 67 | "2": { 68 | "name": "keyword.operator.transpose.julia" 69 | } 70 | }, 71 | "name": "meta.array.julia", 72 | "patterns": [ 73 | { 74 | "match": "\\bbegin\\b", 75 | "name": "constant.numeric.julia" 76 | }, 77 | { 78 | "match": "\\bend\\b", 79 | "name": "constant.numeric.julia" 80 | }, 81 | { 82 | "include": "#self_no_for_block" 83 | } 84 | ] 85 | } 86 | ] 87 | }, 88 | "parentheses": { 89 | "patterns": [ 90 | { 91 | "begin": "\\(", 92 | "beginCaptures": { 93 | "0": { 94 | "name": "meta.bracket.julia" 95 | } 96 | }, 97 | "end": "(\\))((?:\\.)?'*)", 98 | "endCaptures": { 99 | "1": { 100 | "name": "meta.bracket.julia" 101 | }, 102 | "2": { 103 | "name": "keyword.operator.transpose.julia" 104 | } 105 | }, 106 | "patterns": [ 107 | { 108 | "include": "#self_no_for_block" 109 | } 110 | ] 111 | } 112 | ] 113 | }, 114 | "bracket": { 115 | "patterns": [ 116 | { 117 | "begin": "\\{", 118 | "beginCaptures": { 119 | "0": { 120 | "name": "meta.bracket.julia" 121 | } 122 | }, 123 | "end": "(\\})((?:\\.)?'*)", 124 | "endCaptures": { 125 | "1": { 126 | "name": "meta.bracket.julia" 127 | }, 128 | "2": { 129 | "name": "keyword.operator.transpose.julia" 130 | } 131 | }, 132 | "patterns": [ 133 | { 134 | "include": "#self_no_for_block" 135 | } 136 | ] 137 | } 138 | ] 139 | }, 140 | "comment_tags": { 141 | "patterns": [ 142 | { 143 | "match": "\\bTODO\\b", 144 | "name": "keyword.other.comment-annotation.julia" 145 | }, 146 | { 147 | "match": "\\bFIXME\\b", 148 | "name": "keyword.other.comment-annotation.julia" 149 | }, 150 | { 151 | "match": "\\bCHANGED\\b", 152 | "name": "keyword.other.comment-annotation.julia" 153 | }, 154 | { 155 | "match": "\\bXXX\\b", 156 | "name": "keyword.other.comment-annotation.julia" 157 | } 158 | ] 159 | }, 160 | "comment": { 161 | "patterns": [ 162 | { 163 | "include": "#comment_block" 164 | }, 165 | { 166 | "begin": "#", 167 | "beginCaptures": { 168 | "0": { 169 | "name": "punctuation.definition.comment.julia" 170 | } 171 | }, 172 | "end": "\\n", 173 | "name": "comment.line.number-sign.julia", 174 | "patterns": [ 175 | { 176 | "include": "#comment_tags" 177 | } 178 | ] 179 | } 180 | ] 181 | }, 182 | "comment_block": { 183 | "patterns": [ 184 | { 185 | "begin": "#=", 186 | "beginCaptures": { 187 | "0": { 188 | "name": "punctuation.definition.comment.begin.julia" 189 | } 190 | }, 191 | "end": "=#", 192 | "endCaptures": { 193 | "0": { 194 | "name": "punctuation.definition.comment.end.julia" 195 | } 196 | }, 197 | "name": "comment.block.number-sign-equals.julia", 198 | "patterns": [ 199 | { 200 | "include": "#comment_tags" 201 | }, 202 | { 203 | "include": "#comment_block" 204 | } 205 | ] 206 | } 207 | ] 208 | }, 209 | "function_call": { 210 | "patterns": [ 211 | { 212 | "begin": "({{id}})({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?\\.?(\\()", 213 | "beginCaptures": { 214 | "1": { 215 | "name": "support.function.julia" 216 | }, 217 | "2": { 218 | "name": "support.type.julia" 219 | }, 220 | "3": { 221 | "name": "meta.bracket.julia" 222 | } 223 | }, 224 | "end": "\\)(('|(\\.'))*\\.?')?", 225 | "endCaptures": { 226 | "0": { 227 | "name": "meta.bracket.julia" 228 | }, 229 | "1": { 230 | "name": "keyword.operator.transposed-func.julia" 231 | } 232 | }, 233 | "patterns": [ 234 | { 235 | "include": "#self_no_for_block" 236 | } 237 | ] 238 | } 239 | ] 240 | }, 241 | "function_decl": { 242 | "patterns": [ 243 | { 244 | "captures": { 245 | "1": { 246 | "name": "entity.name.function.julia" 247 | }, 248 | "2": { 249 | "name": "support.type.julia" 250 | } 251 | }, 252 | "match": "({{id}})({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?(?=\\([^#]*\\)(::[^\\s]+)?(\\s*\\bwhere\\b\\s+.+?)?\\s*?=(?![=>]))", 253 | "comment": "first group is function name\nSecond group is type parameters (e.g. {T<:Number, S})\nThen open parens\nThen a lookahead ensures that we are followed by:\n - anything (function arguments)\n - 0 or more spaces\n - Finally an equal sign\nNegative lookahead ensures we don't have another equal sign (not `==`)" 254 | }, 255 | { 256 | "captures": { 257 | "1": { 258 | "name": "keyword.other.julia" 259 | }, 260 | "2": { 261 | "name": "keyword.operator.dots.julia" 262 | }, 263 | "3": { 264 | "name": "entity.name.function.julia" 265 | }, 266 | "4": { 267 | "name": "support.type.julia" 268 | } 269 | }, 270 | "match": "\\b(function|macro)(?:\\s+(?:{{id}}(\\.))?({{id}})({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?|\\s*)(?=\\()", 271 | "comment": "similar regex to previous, but with keyword not 1-line syntax" 272 | } 273 | ] 274 | }, 275 | "for_block": { 276 | "comment": "for blocks need to be special-cased to support tokenizing 'outer' properly", 277 | "patterns": [ 278 | { 279 | "begin": "\\b(for)\\b", 280 | "beginCaptures": { 281 | "0": { 282 | "name": "keyword.control.julia" 283 | } 284 | }, 285 | "end": "(?|->|-->|<--|←|→|↔|↚|↛|↞|↠|↢|↣|↦|↤|↮|⇎|⇍|⇏|⇐|⇒|⇔|⇴|⇶|⇷|⇸|⇹|⇺|⇻|⇼|⇽|⇾|⇿|⟵|⟶|⟷|⟹|⟺|⟻|⟼|⟽|⟾|⟿|⤀|⤁|⤂|⤃|⤄|⤅|⤆|⤇|⤌|⤍|⤎|⤏|⤐|⤑|⤔|⤕|⤖|⤗|⤘|⤝|⤞|⤟|⤠|⥄|⥅|⥆|⥇|⥈|⥊|⥋|⥎|⥐|⥒|⥓|⥖|⥗|⥚|⥛|⥞|⥟|⥢|⥤|⥦|⥧|⥨|⥩|⥪|⥫|⥬|⥭|⥰|⧴|⬱|⬰|⬲|⬳|⬴|⬵|⬶|⬷|⬸|⬹|⬺|⬻|⬼|⬽|⬾|⬿|⭀|⭁|⭂|⭃|⥷|⭄|⥺|⭇|⭈|⭉|⭊|⭋|⭌|←|→|⇜|⇝|↜|↝|↩|↪|↫|↬|↼|↽|⇀|⇁|⇄|⇆|⇇|⇉|⇋|⇌|⇚|⇛|⇠|⇢|↷|↶|↺|↻|=>)", 369 | "name": "keyword.operator.arrow.julia" 370 | }, 371 | { 372 | "match": "(?::=|\\+=|-=|\\*=|//=|/=|\\.//=|\\./=|\\.\\*=|\\\\=|\\.\\\\=|\\^=|\\.\\^=|%=|\\.%=|÷=|\\.÷=|\\|=|&=|\\.&=|⊻=|\\.⊻=|\\$=|<<=|>>=|>>>=|=(?!=))", 373 | "name": "keyword.operator.update.julia" 374 | }, 375 | { 376 | "match": "(?:<<|>>>|>>|\\.>>>|\\.>>|\\.<<)", 377 | "name": "keyword.operator.shift.julia" 378 | }, 379 | { 380 | "match": "(?:\\s*(::|>:|<:)\\s*((?:(?:Union)?\\([^)]*\\)|[[:alpha:]_$∇][[:word:]⁺-ₜ!′\\.]*(?:(?:{(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})|(?:\".+?(?)>=|>|<|≥|≤|===|==|≡|!=|≠|!==|≢|∈|∉|∋|∌|⊆|⊈|⊂|⊄|⊊|∝|∊|∍|∥|∦|∷|∺|∻|∽|∾|≁|≃|≂|≄|≅|≆|≇|≈|≉|≊|≋|≌|≍|≎|≐|≑|≒|≓|≖|≗|≘|≙|≚|≛|≜|≝|≞|≟|≣|≦|≧|≨|≩|≪|≫|≬|≭|≮|≯|≰|≱|≲|≳|≴|≵|≶|≷|≸|≹|≺|≻|≼|≽|≾|≿|⊀|⊁|⊃|⊅|⊇|⊉|⊋|⊏|⊐|⊑|⊒|⊜|⊩|⊬|⊮|⊰|⊱|⊲|⊳|⊴|⊵|⊶|⊷|⋍|⋐|⋑|⋕|⋖|⋗|⋘|⋙|⋚|⋛|⋜|⋝|⋞|⋟|⋠|⋡|⋢|⋣|⋤|⋥|⋦|⋧|⋨|⋩|⋪|⋫|⋬|⋭|⋲|⋳|⋴|⋵|⋶|⋷|⋸|⋹|⋺|⋻|⋼|⋽|⋾|⋿|⟈|⟉|⟒|⦷|⧀|⧁|⧡|⧣|⧤|⧥|⩦|⩧|⩪|⩫|⩬|⩭|⩮|⩯|⩰|⩱|⩲|⩳|⩵|⩶|⩷|⩸|⩹|⩺|⩻|⩼|⩽|⩾|⩿|⪀|⪁|⪂|⪃|⪄|⪅|⪆|⪇|⪈|⪉|⪊|⪋|⪌|⪍|⪎|⪏|⪐|⪑|⪒|⪓|⪔|⪕|⪖|⪗|⪘|⪙|⪚|⪛|⪜|⪝|⪞|⪟|⪠|⪡|⪢|⪣|⪤|⪥|⪦|⪧|⪨|⪩|⪪|⪫|⪬|⪭|⪮|⪯|⪰|⪱|⪲|⪳|⪴|⪵|⪶|⪷|⪸|⪹|⪺|⪻|⪼|⪽|⪾|⪿|⫀|⫁|⫂|⫃|⫄|⫅|⫆|⫇|⫈|⫉|⫊|⫋|⫌|⫍|⫎|⫏|⫐|⫑|⫒|⫓|⫔|⫕|⫖|⫗|⫘|⫙|⫷|⫸|⫹|⫺|⊢|⊣|⟂|⫪|⫫|<:|>:))", 395 | "name": "keyword.operator.relation.julia" 396 | }, 397 | { 398 | "match": "(?<=\\s)(?:\\?)(?=\\s)", 399 | "name": "keyword.operator.ternary.julia" 400 | }, 401 | { 402 | "match": "(?<=\\s)(?:\\:)(?=\\s)", 403 | "name": "keyword.operator.ternary.julia" 404 | }, 405 | { 406 | "match": "(?:\\|\\||&&|(?)", 415 | "name": "keyword.operator.applies.julia" 416 | }, 417 | { 418 | "match": "(?:\\||\\.\\||\\&|\\.\\&|~|¬|\\.~|⊻|\\.⊻)", 419 | "name": "keyword.operator.bitwise.julia" 420 | }, 421 | { 422 | "match": "\\.?(?:\\+\\+|\\-\\-|\\+|\\-|−|¦|\\||⊕|⊖|⊞|⊟|∪|∨|⊔|±|∓|∔|∸|≏|⊎|⊻|⊽|⋎|⋓|⟇|⧺|⧻|⨈|⨢|⨣|⨤|⨥|⨦|⨧|⨨|⨩|⨪|⨫|⨬|⨭|⨮|⨹|⨺|⩁|⩂|⩅|⩊|⩌|⩏|⩐|⩒|⩔|⩖|⩗|⩛|⩝|⩡|⩢|⩣|\\*|//?|⌿|÷|%|&|·|·|⋅|∘|×|\\\\|∩|∧|⊗|⊘|⊙|⊚|⊛|⊠|⊡|⊓|∗|∙|∤|⅋|≀|⊼|⋄|⋆|⋇|⋉|⋊|⋋|⋌|⋏|⋒|⟑|⦸|⦼|⦾|⦿|⧶|⧷|⨇|⨰|⨱|⨲|⨳|⨴|⨵|⨶|⨷|⨸|⨻|⨼|⨽|⩀|⩃|⩄|⩋|⩍|⩎|⩑|⩓|⩕|⩘|⩚|⩜|⩞|⩟|⩠|⫛|⊍|▷|⨝|⟕|⟖|⟗|⨟|\\^|↑|↓|⇵|⟰|⟱|⤈|⤉|⤊|⤋|⤒|⤓|⥉|⥌|⥍|⥏|⥑|⥔|⥕|⥘|⥙|⥜|⥝|⥠|⥡|⥣|⥥|⥮|⥯|↑|↓|√|∛|∜|⋆|±|∓)", 423 | "name": "keyword.operator.arithmetic.julia" 424 | }, 425 | { 426 | "match": "(?:∘)", 427 | "name": "keyword.operator.compose.julia" 428 | }, 429 | { 430 | "match": "(?:::|(?<=\\s)isa(?=\\s))", 431 | "name": "keyword.operator.isa.julia" 432 | }, 433 | { 434 | "match": "(?:(?<=\\s)in(?=\\s))", 435 | "name": "keyword.operator.relation.in.julia" 436 | }, 437 | { 438 | "match": "(?:\\.(?=(?:@|_|\\p{L}))|\\.\\.+|…|⁝|⋮|⋱|⋰|⋯)", 439 | "name": "keyword.operator.dots.julia" 440 | }, 441 | { 442 | "match": "(?:\\$)(?=.+)", 443 | "name": "keyword.operator.interpolation.julia" 444 | }, 445 | { 446 | "captures": { 447 | "2": { 448 | "name": "keyword.operator.transposed-variable.julia" 449 | } 450 | }, 451 | "match": "({{id}})(('|(\\.'))*\\.?')" 452 | }, 453 | { 454 | "captures": { 455 | "1": { 456 | "name": "bracket.end.julia" 457 | }, 458 | "2": { 459 | "name": "keyword.operator.transposed-matrix.julia" 460 | } 461 | }, 462 | "match": "(\\])((?:'|(?:\\.'))*\\.?')" 463 | }, 464 | { 465 | "captures": { 466 | "1": { 467 | "name": "bracket.end.julia" 468 | }, 469 | "2": { 470 | "name": "keyword.operator.transposed-parens.julia" 471 | } 472 | }, 473 | "match": "(\\))((?:'|(?:\\.'))*\\.?')" 474 | } 475 | ] 476 | }, 477 | "string": { 478 | "patterns": [ 479 | { 480 | "begin": "(?:(@doc)\\s((?:doc)?\"\"\")|(doc\"\"\"))", 481 | "beginCaptures": { 482 | "1": { 483 | "name": "support.function.macro.julia" 484 | }, 485 | "2": { 486 | "name": "punctuation.definition.string.begin.julia" 487 | } 488 | }, 489 | "end": "(\"\"\") ?(->)?", 490 | "endCaptures": { 491 | "1": { 492 | "name": "punctuation.definition.string.end.julia" 493 | }, 494 | "2": { 495 | "name": "keyword.operator.arrow.julia" 496 | } 497 | }, 498 | "name": "string.docstring.julia", 499 | "patterns": [ 500 | { 501 | "include": "#string_escaped_char" 502 | }, 503 | { 504 | "include": "#string_dollar_sign_interpolate" 505 | } 506 | ] 507 | }, 508 | { 509 | "begin": "(i?cxx)(\"\"\")", 510 | "beginCaptures": { 511 | "1": { 512 | "name": "support.function.macro.julia" 513 | }, 514 | "2": { 515 | "name": "punctuation.definition.string.begin.julia" 516 | } 517 | }, 518 | "end": "\"\"\"", 519 | "endCaptures": { 520 | "0": { 521 | "name": "punctuation.definition.string.end.julia" 522 | } 523 | }, 524 | "name": "embed.cxx.julia", 525 | "contentName": "source.cpp", 526 | "patterns": [ 527 | { 528 | "include": "source.cpp" 529 | }, 530 | { 531 | "include": "#string_dollar_sign_interpolate" 532 | } 533 | ] 534 | }, 535 | { 536 | "begin": "(py)(\"\"\")", 537 | "beginCaptures": { 538 | "1": { 539 | "name": "support.function.macro.julia" 540 | }, 541 | "2": { 542 | "name": "punctuation.definition.string.begin.julia" 543 | } 544 | }, 545 | "end": "([\\s\\w]*)(\"\"\")", 546 | "endCaptures": { 547 | "2": { 548 | "name": "punctuation.definition.string.end.julia" 549 | } 550 | }, 551 | "name": "embed.python.julia", 552 | "contentName": "source.python", 553 | "patterns": [ 554 | { 555 | "include": "source.python" 556 | }, 557 | { 558 | "include": "#string_dollar_sign_interpolate" 559 | } 560 | ] 561 | }, 562 | { 563 | "begin": "(js)(\"\"\")", 564 | "beginCaptures": { 565 | "1": { 566 | "name": "support.function.macro.julia" 567 | }, 568 | "2": { 569 | "name": "punctuation.definition.string.begin.julia" 570 | } 571 | }, 572 | "end": "\"\"\"", 573 | "endCaptures": { 574 | "0": { 575 | "name": "punctuation.definition.string.end.julia" 576 | } 577 | }, 578 | "name": "embed.js.julia", 579 | "contentName": "source.js", 580 | "patterns": [ 581 | { 582 | "include": "source.js" 583 | }, 584 | { 585 | "include": "#string_dollar_sign_interpolate" 586 | } 587 | ] 588 | }, 589 | { 590 | "begin": "(R)(\"\"\")", 591 | "beginCaptures": { 592 | "1": { 593 | "name": "support.function.macro.julia" 594 | }, 595 | "2": { 596 | "name": "punctuation.definition.string.begin.julia" 597 | } 598 | }, 599 | "end": "\"\"\"", 600 | "endCaptures": { 601 | "0": { 602 | "name": "punctuation.definition.string.end.julia" 603 | } 604 | }, 605 | "name": "embed.R.julia", 606 | "contentName": "source.r", 607 | "patterns": [ 608 | { 609 | "include": "source.r" 610 | }, 611 | { 612 | "include": "#string_dollar_sign_interpolate" 613 | } 614 | ] 615 | }, 616 | { 617 | "begin": "(raw)(\"\"\")", 618 | "beginCaptures": { 619 | "1": { 620 | "name": "support.function.macro.julia" 621 | }, 622 | "2": { 623 | "name": "punctuation.definition.string.begin.julia" 624 | } 625 | }, 626 | "end": "\"\"\"", 627 | "name": "string.quoted.other.julia", 628 | "endCaptures": { 629 | "0": { 630 | "name": "punctuation.definition.string.end.julia" 631 | } 632 | }, 633 | "patterns": [ 634 | { 635 | "include": "#string_escaped_char" 636 | } 637 | ] 638 | }, 639 | { 640 | "begin": "(raw)(\")", 641 | "beginCaptures": { 642 | "1": { 643 | "name": "support.function.macro.julia" 644 | }, 645 | "2": { 646 | "name": "punctuation.definition.string.begin.julia" 647 | } 648 | }, 649 | "end": "\"", 650 | "name": "string.quoted.other.julia", 651 | "endCaptures": { 652 | "0": { 653 | "name": "punctuation.definition.string.end.julia" 654 | } 655 | }, 656 | "patterns": [ 657 | { 658 | "include": "#string_escaped_char" 659 | } 660 | ] 661 | }, 662 | { 663 | "begin": "(sql)(\"\"\")", 664 | "beginCaptures": { 665 | "1": { 666 | "name": "support.function.macro.julia" 667 | }, 668 | "2": { 669 | "name": "punctuation.definition.string.begin.julia" 670 | } 671 | }, 672 | "end": "\"\"\"", 673 | "endCaptures": { 674 | "0": { 675 | "name": "punctuation.definition.string.end.julia" 676 | } 677 | }, 678 | "name": "embed.sql.julia", 679 | "contentName": "meta.embedded.inline.sql", 680 | "patterns": [ 681 | { 682 | "include": "source.sql" 683 | }, 684 | { 685 | "include": "#string_dollar_sign_interpolate" 686 | } 687 | ] 688 | }, 689 | { 690 | "begin": "var\"\"\"", 691 | "end": "\"\"\"", 692 | "name": "constant.other.symbol.julia", 693 | "patterns": [ 694 | { 695 | "include": "#string_escaped_char" 696 | } 697 | ] 698 | }, 699 | { 700 | "begin": "var\"", 701 | "end": "\"", 702 | "name": "constant.other.symbol.julia", 703 | "patterns": [ 704 | { 705 | "include": "#string_escaped_char" 706 | } 707 | ] 708 | }, 709 | { 710 | "begin": "^\\s?(doc)?(\"\"\")\\s?$", 711 | "beginCaptures": { 712 | "1": { 713 | "name": "support.function.macro.julia" 714 | }, 715 | "2": { 716 | "name": "punctuation.definition.string.begin.julia" 717 | } 718 | }, 719 | "end": "(\"\"\")", 720 | "endCaptures": { 721 | "1": { 722 | "name": "punctuation.definition.string.end.julia" 723 | } 724 | }, 725 | "name": "string.docstring.julia", 726 | "comment": "This only matches docstrings that start and end with triple quotes on\ntheir own line in the void", 727 | "patterns": [ 728 | { 729 | "include": "#string_escaped_char" 730 | }, 731 | { 732 | "include": "#string_dollar_sign_interpolate" 733 | } 734 | ] 735 | }, 736 | { 737 | "begin": "'", 738 | "beginCaptures": { 739 | "0": { 740 | "name": "punctuation.definition.string.begin.julia" 741 | } 742 | }, 743 | "end": "'(?!')", 744 | "endCaptures": { 745 | "0": { 746 | "name": "punctuation.definition.string.end.julia" 747 | } 748 | }, 749 | "name": "string.quoted.single.julia", 750 | "patterns": [ 751 | { 752 | "include": "#string_escaped_char" 753 | } 754 | ] 755 | }, 756 | { 757 | "begin": "\"\"\"", 758 | "beginCaptures": { 759 | "0": { 760 | "name": "punctuation.definition.string.multiline.begin.julia" 761 | } 762 | }, 763 | "end": "\"\"\"", 764 | "endCaptures": { 765 | "0": { 766 | "name": "punctuation.definition.string.multiline.end.julia" 767 | } 768 | }, 769 | "name": "string.quoted.triple.double.julia", 770 | "comment": "multi-line string with triple double quotes", 771 | "patterns": [ 772 | { 773 | "include": "#string_escaped_char" 774 | }, 775 | { 776 | "include": "#string_dollar_sign_interpolate" 777 | } 778 | ] 779 | }, 780 | { 781 | "name": "string.quoted.double.julia", 782 | "begin": "\"(?!\"\")", 783 | "beginCaptures": { 784 | "0": { 785 | "name": "punctuation.definition.string.begin.julia" 786 | } 787 | }, 788 | "end": "\"", 789 | "endCaptures": { 790 | "0": { 791 | "name": "punctuation.definition.string.end.julia" 792 | } 793 | }, 794 | "comment": "String with single pair of double quotes. Regex matches isolated double quote", 795 | "patterns": [ 796 | { 797 | "include": "#string_escaped_char" 798 | }, 799 | { 800 | "include": "#string_dollar_sign_interpolate" 801 | } 802 | ] 803 | }, 804 | { 805 | "begin": "r\"\"\"", 806 | "beginCaptures": { 807 | "0": { 808 | "name": "punctuation.definition.string.regexp.begin.julia" 809 | } 810 | }, 811 | "end": "(\"\"\")([imsx]{0,4})?", 812 | "endCaptures": { 813 | "1": { 814 | "name": "punctuation.definition.string.regexp.end.julia" 815 | }, 816 | "2": { 817 | "comment": "I took this scope name from python regex grammar", 818 | "name": "keyword.other.option-toggle.regexp.julia" 819 | } 820 | }, 821 | "name": "string.regexp.julia", 822 | "patterns": [ 823 | { 824 | "include": "#string_escaped_char" 825 | } 826 | ] 827 | }, 828 | { 829 | "begin": "r\"", 830 | "beginCaptures": { 831 | "0": { 832 | "name": "punctuation.definition.string.regexp.begin.julia" 833 | } 834 | }, 835 | "end": "(\")([imsx]{0,4})?", 836 | "endCaptures": { 837 | "1": { 838 | "name": "punctuation.definition.string.regexp.end.julia" 839 | }, 840 | "2": { 841 | "comment": "I took this scope name from python regex grammar", 842 | "name": "keyword.other.option-toggle.regexp.julia" 843 | } 844 | }, 845 | "name": "string.regexp.julia", 846 | "patterns": [ 847 | { 848 | "include": "#string_escaped_char" 849 | } 850 | ] 851 | }, 852 | { 853 | "begin": "(?!:_)(?:struct|mutable\\s+struct|abstract\\s+type|primitive\\s+type)\\s+({{id}})(\\s*(<:)\\s*{{id}}(?:{.*})?)?", 1025 | "name": "meta.type.julia" 1026 | } 1027 | ] 1028 | }, 1029 | "self_no_for_block": { 1030 | "comment": "Same as $self, but does not contain #for_block. 'outer' is not valid in some contexts (e.g. generators, comprehensions, indexing), so use this when matching those in begin/end patterns. Keep this up-to-date with $self!", 1031 | "patterns": [ 1032 | { 1033 | "include": "#operator" 1034 | }, 1035 | { 1036 | "include": "#array" 1037 | }, 1038 | { 1039 | "include": "#string" 1040 | }, 1041 | { 1042 | "include": "#parentheses" 1043 | }, 1044 | { 1045 | "include": "#bracket" 1046 | }, 1047 | { 1048 | "include": "#function_decl" 1049 | }, 1050 | { 1051 | "include": "#function_call" 1052 | }, 1053 | { 1054 | "include": "#keyword" 1055 | }, 1056 | { 1057 | "include": "#number" 1058 | }, 1059 | { 1060 | "include": "#comment" 1061 | }, 1062 | { 1063 | "include": "#type_decl" 1064 | }, 1065 | { 1066 | "include": "#symbol" 1067 | }, 1068 | { 1069 | "include": "#punctuation" 1070 | } 1071 | ] 1072 | }, 1073 | "punctuation": { 1074 | "patterns": [ 1075 | { 1076 | "match": ",", 1077 | "name": "punctuation.separator.comma.julia" 1078 | }, 1079 | { 1080 | "match": ";", 1081 | "name": "punctuation.separator.semicolon.julia" 1082 | } 1083 | ] 1084 | } 1085 | }, 1086 | "scopeName": "source.julia" 1087 | } -------------------------------------------------------------------------------- /grammars/julia_vscode.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "This grammar is used by Atom (Oniguruma), GitHub (PCRE), and VSCode (Oniguruma),\nso all regexps must be compatible with both engines.\n\nSpecs:\n- https://github.com/kkos/oniguruma/blob/master/doc/RE\n- https://www.pcre.org/current/doc/html/", 3 | "fileTypes": [ 4 | "jl" 5 | ], 6 | "firstLineMatch": "^#!.*\\bjulia\\s*$", 7 | "name": "Julia", 8 | "patterns": [ 9 | { 10 | "include": "#operator" 11 | }, 12 | { 13 | "include": "#array" 14 | }, 15 | { 16 | "include": "#string" 17 | }, 18 | { 19 | "include": "#parentheses" 20 | }, 21 | { 22 | "include": "#bracket" 23 | }, 24 | { 25 | "include": "#function_decl" 26 | }, 27 | { 28 | "include": "#function_call" 29 | }, 30 | { 31 | "include": "#for_block" 32 | }, 33 | { 34 | "include": "#keyword" 35 | }, 36 | { 37 | "include": "#number" 38 | }, 39 | { 40 | "include": "#comment" 41 | }, 42 | { 43 | "include": "#type_decl" 44 | }, 45 | { 46 | "include": "#symbol" 47 | }, 48 | { 49 | "include": "#punctuation" 50 | } 51 | ], 52 | "repository": { 53 | "array": { 54 | "patterns": [ 55 | { 56 | "begin": "\\[", 57 | "beginCaptures": { 58 | "0": { 59 | "name": "meta.bracket.julia" 60 | } 61 | }, 62 | "end": "(\\])((?:\\.)?'*)", 63 | "endCaptures": { 64 | "1": { 65 | "name": "meta.bracket.julia" 66 | }, 67 | "2": { 68 | "name": "keyword.operator.transpose.julia" 69 | } 70 | }, 71 | "name": "meta.array.julia", 72 | "patterns": [ 73 | { 74 | "match": "\\bbegin\\b", 75 | "name": "constant.numeric.julia" 76 | }, 77 | { 78 | "match": "\\bend\\b", 79 | "name": "constant.numeric.julia" 80 | }, 81 | { 82 | "include": "#self_no_for_block" 83 | } 84 | ] 85 | } 86 | ] 87 | }, 88 | "parentheses": { 89 | "patterns": [ 90 | { 91 | "begin": "\\(", 92 | "beginCaptures": { 93 | "0": { 94 | "name": "meta.bracket.julia" 95 | } 96 | }, 97 | "end": "(\\))((?:\\.)?'*)", 98 | "endCaptures": { 99 | "1": { 100 | "name": "meta.bracket.julia" 101 | }, 102 | "2": { 103 | "name": "keyword.operator.transpose.julia" 104 | } 105 | }, 106 | "patterns": [ 107 | { 108 | "include": "#self_no_for_block" 109 | } 110 | ] 111 | } 112 | ] 113 | }, 114 | "bracket": { 115 | "patterns": [ 116 | { 117 | "begin": "\\{", 118 | "beginCaptures": { 119 | "0": { 120 | "name": "meta.bracket.julia" 121 | } 122 | }, 123 | "end": "(\\})((?:\\.)?'*)", 124 | "endCaptures": { 125 | "1": { 126 | "name": "meta.bracket.julia" 127 | }, 128 | "2": { 129 | "name": "keyword.operator.transpose.julia" 130 | } 131 | }, 132 | "patterns": [ 133 | { 134 | "include": "#self_no_for_block" 135 | } 136 | ] 137 | } 138 | ] 139 | }, 140 | "comment_tags": { 141 | "patterns": [ 142 | { 143 | "match": "\\bTODO\\b", 144 | "name": "keyword.other.comment-annotation.julia" 145 | }, 146 | { 147 | "match": "\\bFIXME\\b", 148 | "name": "keyword.other.comment-annotation.julia" 149 | }, 150 | { 151 | "match": "\\bCHANGED\\b", 152 | "name": "keyword.other.comment-annotation.julia" 153 | }, 154 | { 155 | "match": "\\bXXX\\b", 156 | "name": "keyword.other.comment-annotation.julia" 157 | } 158 | ] 159 | }, 160 | "comment": { 161 | "patterns": [ 162 | { 163 | "include": "#comment_block" 164 | }, 165 | { 166 | "begin": "#", 167 | "beginCaptures": { 168 | "0": { 169 | "name": "punctuation.definition.comment.julia" 170 | } 171 | }, 172 | "end": "\\n", 173 | "name": "comment.line.number-sign.julia", 174 | "patterns": [ 175 | { 176 | "include": "#comment_tags" 177 | } 178 | ] 179 | } 180 | ] 181 | }, 182 | "comment_block": { 183 | "patterns": [ 184 | { 185 | "begin": "#=", 186 | "beginCaptures": { 187 | "0": { 188 | "name": "punctuation.definition.comment.begin.julia" 189 | } 190 | }, 191 | "end": "=#", 192 | "endCaptures": { 193 | "0": { 194 | "name": "punctuation.definition.comment.end.julia" 195 | } 196 | }, 197 | "name": "comment.block.number-sign-equals.julia", 198 | "patterns": [ 199 | { 200 | "include": "#comment_tags" 201 | }, 202 | { 203 | "include": "#comment_block" 204 | } 205 | ] 206 | } 207 | ] 208 | }, 209 | "function_call": { 210 | "patterns": [ 211 | { 212 | "begin": "((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?\\.?(\\()", 213 | "beginCaptures": { 214 | "1": { 215 | "name": "support.function.julia" 216 | }, 217 | "2": { 218 | "name": "support.type.julia" 219 | }, 220 | "3": { 221 | "name": "meta.bracket.julia" 222 | } 223 | }, 224 | "end": "\\)(('|(\\.'))*\\.?')?", 225 | "endCaptures": { 226 | "0": { 227 | "name": "meta.bracket.julia" 228 | }, 229 | "1": { 230 | "name": "keyword.operator.transposed-func.julia" 231 | } 232 | }, 233 | "patterns": [ 234 | { 235 | "include": "#self_no_for_block" 236 | } 237 | ] 238 | } 239 | ] 240 | }, 241 | "function_decl": { 242 | "patterns": [ 243 | { 244 | "captures": { 245 | "1": { 246 | "name": "entity.name.function.julia" 247 | }, 248 | "2": { 249 | "name": "support.type.julia" 250 | } 251 | }, 252 | "match": "((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?(?=\\([^#]*\\)(::[^\\s]+)?(\\s*\\bwhere\\b\\s+.+?)?\\s*?=(?![=>]))", 253 | "comment": "first group is function name\nSecond group is type parameters (e.g. {T<:Number, S})\nThen open parens\nThen a lookahead ensures that we are followed by:\n - anything (function arguments)\n - 0 or more spaces\n - Finally an equal sign\nNegative lookahead ensures we don't have another equal sign (not `==`)" 254 | }, 255 | { 256 | "captures": { 257 | "1": { 258 | "name": "keyword.other.julia" 259 | }, 260 | "2": { 261 | "name": "keyword.operator.dots.julia" 262 | }, 263 | "3": { 264 | "name": "entity.name.function.julia" 265 | }, 266 | "4": { 267 | "name": "support.type.julia" 268 | } 269 | }, 270 | "match": "\\b(function|macro)(?:\\s+(?:(?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*(\\.))?((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)({(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})?|\\s*)(?=\\()", 271 | "comment": "similar regex to previous, but with keyword not 1-line syntax" 272 | } 273 | ] 274 | }, 275 | "for_block": { 276 | "comment": "for blocks need to be special-cased to support tokenizing 'outer' properly", 277 | "patterns": [ 278 | { 279 | "begin": "\\b(for)\\b", 280 | "beginCaptures": { 281 | "0": { 282 | "name": "keyword.control.julia" 283 | } 284 | }, 285 | "end": "(?|->|-->|<--|←|→|↔|↚|↛|↞|↠|↢|↣|↦|↤|↮|⇎|⇍|⇏|⇐|⇒|⇔|⇴|⇶|⇷|⇸|⇹|⇺|⇻|⇼|⇽|⇾|⇿|⟵|⟶|⟷|⟹|⟺|⟻|⟼|⟽|⟾|⟿|⤀|⤁|⤂|⤃|⤄|⤅|⤆|⤇|⤌|⤍|⤎|⤏|⤐|⤑|⤔|⤕|⤖|⤗|⤘|⤝|⤞|⤟|⤠|⥄|⥅|⥆|⥇|⥈|⥊|⥋|⥎|⥐|⥒|⥓|⥖|⥗|⥚|⥛|⥞|⥟|⥢|⥤|⥦|⥧|⥨|⥩|⥪|⥫|⥬|⥭|⥰|⧴|⬱|⬰|⬲|⬳|⬴|⬵|⬶|⬷|⬸|⬹|⬺|⬻|⬼|⬽|⬾|⬿|⭀|⭁|⭂|⭃|⥷|⭄|⥺|⭇|⭈|⭉|⭊|⭋|⭌|←|→|⇜|⇝|↜|↝|↩|↪|↫|↬|↼|↽|⇀|⇁|⇄|⇆|⇇|⇉|⇋|⇌|⇚|⇛|⇠|⇢|↷|↶|↺|↻|=>)", 369 | "name": "keyword.operator.arrow.julia" 370 | }, 371 | { 372 | "match": "(?::=|\\+=|-=|\\*=|//=|/=|\\.//=|\\./=|\\.\\*=|\\\\=|\\.\\\\=|\\^=|\\.\\^=|%=|\\.%=|÷=|\\.÷=|\\|=|&=|\\.&=|⊻=|\\.⊻=|\\$=|<<=|>>=|>>>=|=(?!=))", 373 | "name": "keyword.operator.update.julia" 374 | }, 375 | { 376 | "match": "(?:<<|>>>|>>|\\.>>>|\\.>>|\\.<<)", 377 | "name": "keyword.operator.shift.julia" 378 | }, 379 | { 380 | "match": "(?:\\s*(::|>:|<:)\\s*((?:(?:Union)?\\([^)]*\\)|[[:alpha:]_$∇][[:word:]⁺-ₜ!′\\.]*(?:(?:{(?:[^{}]|{(?:[^{}]|{[^{}]*})*})*})|(?:\".+?(?)>=|>|<|≥|≤|===|==|≡|!=|≠|!==|≢|∈|∉|∋|∌|⊆|⊈|⊂|⊄|⊊|∝|∊|∍|∥|∦|∷|∺|∻|∽|∾|≁|≃|≂|≄|≅|≆|≇|≈|≉|≊|≋|≌|≍|≎|≐|≑|≒|≓|≖|≗|≘|≙|≚|≛|≜|≝|≞|≟|≣|≦|≧|≨|≩|≪|≫|≬|≭|≮|≯|≰|≱|≲|≳|≴|≵|≶|≷|≸|≹|≺|≻|≼|≽|≾|≿|⊀|⊁|⊃|⊅|⊇|⊉|⊋|⊏|⊐|⊑|⊒|⊜|⊩|⊬|⊮|⊰|⊱|⊲|⊳|⊴|⊵|⊶|⊷|⋍|⋐|⋑|⋕|⋖|⋗|⋘|⋙|⋚|⋛|⋜|⋝|⋞|⋟|⋠|⋡|⋢|⋣|⋤|⋥|⋦|⋧|⋨|⋩|⋪|⋫|⋬|⋭|⋲|⋳|⋴|⋵|⋶|⋷|⋸|⋹|⋺|⋻|⋼|⋽|⋾|⋿|⟈|⟉|⟒|⦷|⧀|⧁|⧡|⧣|⧤|⧥|⩦|⩧|⩪|⩫|⩬|⩭|⩮|⩯|⩰|⩱|⩲|⩳|⩵|⩶|⩷|⩸|⩹|⩺|⩻|⩼|⩽|⩾|⩿|⪀|⪁|⪂|⪃|⪄|⪅|⪆|⪇|⪈|⪉|⪊|⪋|⪌|⪍|⪎|⪏|⪐|⪑|⪒|⪓|⪔|⪕|⪖|⪗|⪘|⪙|⪚|⪛|⪜|⪝|⪞|⪟|⪠|⪡|⪢|⪣|⪤|⪥|⪦|⪧|⪨|⪩|⪪|⪫|⪬|⪭|⪮|⪯|⪰|⪱|⪲|⪳|⪴|⪵|⪶|⪷|⪸|⪹|⪺|⪻|⪼|⪽|⪾|⪿|⫀|⫁|⫂|⫃|⫄|⫅|⫆|⫇|⫈|⫉|⫊|⫋|⫌|⫍|⫎|⫏|⫐|⫑|⫒|⫓|⫔|⫕|⫖|⫗|⫘|⫙|⫷|⫸|⫹|⫺|⊢|⊣|⟂|⫪|⫫|<:|>:))", 395 | "name": "keyword.operator.relation.julia" 396 | }, 397 | { 398 | "match": "(?<=\\s)(?:\\?)(?=\\s)", 399 | "name": "keyword.operator.ternary.julia" 400 | }, 401 | { 402 | "match": "(?<=\\s)(?:\\:)(?=\\s)", 403 | "name": "keyword.operator.ternary.julia" 404 | }, 405 | { 406 | "match": "(?:\\|\\||&&|(?)", 415 | "name": "keyword.operator.applies.julia" 416 | }, 417 | { 418 | "match": "(?:\\||\\.\\||\\&|\\.\\&|~|¬|\\.~|⊻|\\.⊻)", 419 | "name": "keyword.operator.bitwise.julia" 420 | }, 421 | { 422 | "match": "\\.?(?:\\+\\+|\\-\\-|\\+|\\-|−|¦|\\||⊕|⊖|⊞|⊟|∪|∨|⊔|±|∓|∔|∸|≏|⊎|⊻|⊽|⋎|⋓|⟇|⧺|⧻|⨈|⨢|⨣|⨤|⨥|⨦|⨧|⨨|⨩|⨪|⨫|⨬|⨭|⨮|⨹|⨺|⩁|⩂|⩅|⩊|⩌|⩏|⩐|⩒|⩔|⩖|⩗|⩛|⩝|⩡|⩢|⩣|\\*|//?|⌿|÷|%|&|·|·|⋅|∘|×|\\\\|∩|∧|⊗|⊘|⊙|⊚|⊛|⊠|⊡|⊓|∗|∙|∤|⅋|≀|⊼|⋄|⋆|⋇|⋉|⋊|⋋|⋌|⋏|⋒|⟑|⦸|⦼|⦾|⦿|⧶|⧷|⨇|⨰|⨱|⨲|⨳|⨴|⨵|⨶|⨷|⨸|⨻|⨼|⨽|⩀|⩃|⩄|⩋|⩍|⩎|⩑|⩓|⩕|⩘|⩚|⩜|⩞|⩟|⩠|⫛|⊍|▷|⨝|⟕|⟖|⟗|⨟|\\^|↑|↓|⇵|⟰|⟱|⤈|⤉|⤊|⤋|⤒|⤓|⥉|⥌|⥍|⥏|⥑|⥔|⥕|⥘|⥙|⥜|⥝|⥠|⥡|⥣|⥥|⥮|⥯|↑|↓|√|∛|∜|⋆|±|∓)", 423 | "name": "keyword.operator.arithmetic.julia" 424 | }, 425 | { 426 | "match": "(?:∘)", 427 | "name": "keyword.operator.compose.julia" 428 | }, 429 | { 430 | "match": "(?:::|(?<=\\s)isa(?=\\s))", 431 | "name": "keyword.operator.isa.julia" 432 | }, 433 | { 434 | "match": "(?:(?<=\\s)in(?=\\s))", 435 | "name": "keyword.operator.relation.in.julia" 436 | }, 437 | { 438 | "match": "(?:\\.(?=(?:@|_|\\p{L}))|\\.\\.+|…|⁝|⋮|⋱|⋰|⋯)", 439 | "name": "keyword.operator.dots.julia" 440 | }, 441 | { 442 | "match": "(?:\\$)(?=.+)", 443 | "name": "keyword.operator.interpolation.julia" 444 | }, 445 | { 446 | "captures": { 447 | "2": { 448 | "name": "keyword.operator.transposed-variable.julia" 449 | } 450 | }, 451 | "match": "((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)(('|(\\.'))*\\.?')" 452 | }, 453 | { 454 | "captures": { 455 | "1": { 456 | "name": "bracket.end.julia" 457 | }, 458 | "2": { 459 | "name": "keyword.operator.transposed-matrix.julia" 460 | } 461 | }, 462 | "match": "(\\])((?:'|(?:\\.'))*\\.?')" 463 | }, 464 | { 465 | "captures": { 466 | "1": { 467 | "name": "bracket.end.julia" 468 | }, 469 | "2": { 470 | "name": "keyword.operator.transposed-parens.julia" 471 | } 472 | }, 473 | "match": "(\\))((?:'|(?:\\.'))*\\.?')" 474 | } 475 | ] 476 | }, 477 | "string": { 478 | "patterns": [ 479 | { 480 | "begin": "(?:(@doc)\\s((?:doc)?\"\"\")|(doc\"\"\"))", 481 | "beginCaptures": { 482 | "1": { 483 | "name": "support.function.macro.julia" 484 | }, 485 | "2": { 486 | "name": "punctuation.definition.string.begin.julia" 487 | } 488 | }, 489 | "end": "(\"\"\") ?(->)?", 490 | "endCaptures": { 491 | "1": { 492 | "name": "punctuation.definition.string.end.julia" 493 | }, 494 | "2": { 495 | "name": "keyword.operator.arrow.julia" 496 | } 497 | }, 498 | "name": "string.docstring.julia", 499 | "patterns": [ 500 | { 501 | "include": "#string_escaped_char" 502 | }, 503 | { 504 | "include": "#string_dollar_sign_interpolate" 505 | } 506 | ] 507 | }, 508 | { 509 | "begin": "(i?cxx)(\"\"\")", 510 | "beginCaptures": { 511 | "1": { 512 | "name": "support.function.macro.julia" 513 | }, 514 | "2": { 515 | "name": "punctuation.definition.string.begin.julia" 516 | } 517 | }, 518 | "end": "\"\"\"", 519 | "endCaptures": { 520 | "0": { 521 | "name": "punctuation.definition.string.end.julia" 522 | } 523 | }, 524 | "name": "embed.cxx.julia", 525 | "contentName": "meta.embedded.inline.cpp", 526 | "patterns": [ 527 | { 528 | "include": "source.cpp#root_context" 529 | }, 530 | { 531 | "include": "#string_dollar_sign_interpolate" 532 | } 533 | ] 534 | }, 535 | { 536 | "begin": "(py)(\"\"\")", 537 | "beginCaptures": { 538 | "1": { 539 | "name": "support.function.macro.julia" 540 | }, 541 | "2": { 542 | "name": "punctuation.definition.string.begin.julia" 543 | } 544 | }, 545 | "end": "([\\s\\w]*)(\"\"\")", 546 | "endCaptures": { 547 | "2": { 548 | "name": "punctuation.definition.string.end.julia" 549 | } 550 | }, 551 | "name": "embed.python.julia", 552 | "contentName": "meta.embedded.inline.python", 553 | "patterns": [ 554 | { 555 | "include": "source.python" 556 | }, 557 | { 558 | "include": "#string_dollar_sign_interpolate" 559 | } 560 | ] 561 | }, 562 | { 563 | "begin": "(js)(\"\"\")", 564 | "beginCaptures": { 565 | "1": { 566 | "name": "support.function.macro.julia" 567 | }, 568 | "2": { 569 | "name": "punctuation.definition.string.begin.julia" 570 | } 571 | }, 572 | "end": "\"\"\"", 573 | "endCaptures": { 574 | "0": { 575 | "name": "punctuation.definition.string.end.julia" 576 | } 577 | }, 578 | "name": "embed.js.julia", 579 | "contentName": "meta.embedded.inline.javascript", 580 | "patterns": [ 581 | { 582 | "include": "source.js" 583 | }, 584 | { 585 | "include": "#string_dollar_sign_interpolate" 586 | } 587 | ] 588 | }, 589 | { 590 | "begin": "(R)(\"\"\")", 591 | "beginCaptures": { 592 | "1": { 593 | "name": "support.function.macro.julia" 594 | }, 595 | "2": { 596 | "name": "punctuation.definition.string.begin.julia" 597 | } 598 | }, 599 | "end": "\"\"\"", 600 | "endCaptures": { 601 | "0": { 602 | "name": "punctuation.definition.string.end.julia" 603 | } 604 | }, 605 | "name": "embed.R.julia", 606 | "contentName": "meta.embedded.inline.r", 607 | "patterns": [ 608 | { 609 | "include": "source.r" 610 | }, 611 | { 612 | "include": "#string_dollar_sign_interpolate" 613 | } 614 | ] 615 | }, 616 | { 617 | "begin": "(raw)(\"\"\")", 618 | "beginCaptures": { 619 | "1": { 620 | "name": "support.function.macro.julia" 621 | }, 622 | "2": { 623 | "name": "punctuation.definition.string.begin.julia" 624 | } 625 | }, 626 | "end": "\"\"\"", 627 | "name": "string.quoted.other.julia", 628 | "endCaptures": { 629 | "0": { 630 | "name": "punctuation.definition.string.end.julia" 631 | } 632 | }, 633 | "patterns": [ 634 | { 635 | "include": "#string_escaped_char" 636 | } 637 | ] 638 | }, 639 | { 640 | "begin": "(raw)(\")", 641 | "beginCaptures": { 642 | "1": { 643 | "name": "support.function.macro.julia" 644 | }, 645 | "2": { 646 | "name": "punctuation.definition.string.begin.julia" 647 | } 648 | }, 649 | "end": "\"", 650 | "name": "string.quoted.other.julia", 651 | "endCaptures": { 652 | "0": { 653 | "name": "punctuation.definition.string.end.julia" 654 | } 655 | }, 656 | "patterns": [ 657 | { 658 | "include": "#string_escaped_char" 659 | } 660 | ] 661 | }, 662 | { 663 | "begin": "(sql)(\"\"\")", 664 | "beginCaptures": { 665 | "1": { 666 | "name": "support.function.macro.julia" 667 | }, 668 | "2": { 669 | "name": "punctuation.definition.string.begin.julia" 670 | } 671 | }, 672 | "end": "\"\"\"", 673 | "endCaptures": { 674 | "0": { 675 | "name": "punctuation.definition.string.end.julia" 676 | } 677 | }, 678 | "name": "embed.sql.julia", 679 | "contentName": "meta.embedded.inline.sql", 680 | "patterns": [ 681 | { 682 | "include": "source.sql" 683 | }, 684 | { 685 | "include": "#string_dollar_sign_interpolate" 686 | } 687 | ] 688 | }, 689 | { 690 | "begin": "var\"\"\"", 691 | "end": "\"\"\"", 692 | "name": "constant.other.symbol.julia", 693 | "patterns": [ 694 | { 695 | "include": "#string_escaped_char" 696 | } 697 | ] 698 | }, 699 | { 700 | "begin": "var\"", 701 | "end": "\"", 702 | "name": "constant.other.symbol.julia", 703 | "patterns": [ 704 | { 705 | "include": "#string_escaped_char" 706 | } 707 | ] 708 | }, 709 | { 710 | "begin": "^\\s?(doc)?(\"\"\")\\s?$", 711 | "beginCaptures": { 712 | "1": { 713 | "name": "support.function.macro.julia" 714 | }, 715 | "2": { 716 | "name": "punctuation.definition.string.begin.julia" 717 | } 718 | }, 719 | "end": "(\"\"\")", 720 | "endCaptures": { 721 | "1": { 722 | "name": "punctuation.definition.string.end.julia" 723 | } 724 | }, 725 | "name": "string.docstring.julia", 726 | "comment": "This only matches docstrings that start and end with triple quotes on\ntheir own line in the void", 727 | "patterns": [ 728 | { 729 | "include": "#string_escaped_char" 730 | }, 731 | { 732 | "include": "#string_dollar_sign_interpolate" 733 | } 734 | ] 735 | }, 736 | { 737 | "begin": "'", 738 | "beginCaptures": { 739 | "0": { 740 | "name": "punctuation.definition.string.begin.julia" 741 | } 742 | }, 743 | "end": "'(?!')", 744 | "endCaptures": { 745 | "0": { 746 | "name": "punctuation.definition.string.end.julia" 747 | } 748 | }, 749 | "name": "string.quoted.single.julia", 750 | "patterns": [ 751 | { 752 | "include": "#string_escaped_char" 753 | } 754 | ] 755 | }, 756 | { 757 | "begin": "\"\"\"", 758 | "beginCaptures": { 759 | "0": { 760 | "name": "punctuation.definition.string.multiline.begin.julia" 761 | } 762 | }, 763 | "end": "\"\"\"", 764 | "endCaptures": { 765 | "0": { 766 | "name": "punctuation.definition.string.multiline.end.julia" 767 | } 768 | }, 769 | "name": "string.quoted.triple.double.julia", 770 | "comment": "multi-line string with triple double quotes", 771 | "patterns": [ 772 | { 773 | "include": "#string_escaped_char" 774 | }, 775 | { 776 | "include": "#string_dollar_sign_interpolate" 777 | } 778 | ] 779 | }, 780 | { 781 | "name": "string.quoted.double.julia", 782 | "begin": "\"(?!\"\")", 783 | "beginCaptures": { 784 | "0": { 785 | "name": "punctuation.definition.string.begin.julia" 786 | } 787 | }, 788 | "end": "\"", 789 | "endCaptures": { 790 | "0": { 791 | "name": "punctuation.definition.string.end.julia" 792 | } 793 | }, 794 | "comment": "String with single pair of double quotes. Regex matches isolated double quote", 795 | "patterns": [ 796 | { 797 | "include": "#string_escaped_char" 798 | }, 799 | { 800 | "include": "#string_dollar_sign_interpolate" 801 | } 802 | ] 803 | }, 804 | { 805 | "begin": "r\"\"\"", 806 | "beginCaptures": { 807 | "0": { 808 | "name": "punctuation.definition.string.regexp.begin.julia" 809 | } 810 | }, 811 | "end": "(\"\"\")([imsx]{0,4})?", 812 | "endCaptures": { 813 | "1": { 814 | "name": "punctuation.definition.string.regexp.end.julia" 815 | }, 816 | "2": { 817 | "comment": "I took this scope name from python regex grammar", 818 | "name": "keyword.other.option-toggle.regexp.julia" 819 | } 820 | }, 821 | "name": "string.regexp.julia", 822 | "patterns": [ 823 | { 824 | "include": "#string_escaped_char" 825 | } 826 | ] 827 | }, 828 | { 829 | "begin": "r\"", 830 | "beginCaptures": { 831 | "0": { 832 | "name": "punctuation.definition.string.regexp.begin.julia" 833 | } 834 | }, 835 | "end": "(\")([imsx]{0,4})?", 836 | "endCaptures": { 837 | "1": { 838 | "name": "punctuation.definition.string.regexp.end.julia" 839 | }, 840 | "2": { 841 | "comment": "I took this scope name from python regex grammar", 842 | "name": "keyword.other.option-toggle.regexp.julia" 843 | } 844 | }, 845 | "name": "string.regexp.julia", 846 | "patterns": [ 847 | { 848 | "include": "#string_escaped_char" 849 | } 850 | ] 851 | }, 852 | { 853 | "begin": "(?!:_)(?:struct|mutable\\s+struct|abstract\\s+type|primitive\\s+type)\\s+((?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*)(\\s*(<:)\\s*(?:[[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{So}←-⇿])(?:[[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\P{Mn}\u0001-¡]|[^\\P{Mc}\u0001-¡]|[^\\P{Nd}\u0001-¡]|[^\\P{Pc}\u0001-¡]|[^\\P{Sk}\u0001-¡]|[^\\P{Me}\u0001-¡]|[^\\P{No}\u0001-¡]|[′-‷⁗]|[^\\P{So}←-⇿])*(?:{.*})?)?", 1025 | "name": "meta.type.julia" 1026 | } 1027 | ] 1028 | }, 1029 | "self_no_for_block": { 1030 | "comment": "Same as $self, but does not contain #for_block. 'outer' is not valid in some contexts (e.g. generators, comprehensions, indexing), so use this when matching those in begin/end patterns. Keep this up-to-date with $self!", 1031 | "patterns": [ 1032 | { 1033 | "include": "#operator" 1034 | }, 1035 | { 1036 | "include": "#array" 1037 | }, 1038 | { 1039 | "include": "#string" 1040 | }, 1041 | { 1042 | "include": "#parentheses" 1043 | }, 1044 | { 1045 | "include": "#bracket" 1046 | }, 1047 | { 1048 | "include": "#function_decl" 1049 | }, 1050 | { 1051 | "include": "#function_call" 1052 | }, 1053 | { 1054 | "include": "#keyword" 1055 | }, 1056 | { 1057 | "include": "#number" 1058 | }, 1059 | { 1060 | "include": "#comment" 1061 | }, 1062 | { 1063 | "include": "#type_decl" 1064 | }, 1065 | { 1066 | "include": "#symbol" 1067 | }, 1068 | { 1069 | "include": "#punctuation" 1070 | } 1071 | ] 1072 | }, 1073 | "punctuation": { 1074 | "patterns": [ 1075 | { 1076 | "match": ",", 1077 | "name": "punctuation.separator.comma.julia" 1078 | }, 1079 | { 1080 | "match": ";", 1081 | "name": "punctuation.separator.semicolon.julia" 1082 | } 1083 | ] 1084 | } 1085 | }, 1086 | "scopeName": "source.julia" 1087 | } -------------------------------------------------------------------------------- /lib/julia.coffee: -------------------------------------------------------------------------------- 1 | {CompositeDisposable, Point, Range, TextBuffer} = require 'atom' 2 | 3 | module.exports = JuliaFolding = 4 | subscriptions: null 5 | 6 | activate: (state) -> 7 | 8 | @subscriptions = new CompositeDisposable 9 | 10 | # Register command that toggles the view 11 | @subscriptions.add atom.commands.add 'atom-workspace', 'language-julia:toggle-docstrings': (event) => @toggledocstrings(event) 12 | @subscriptions.add atom.commands.add 'atom-workspace', 'language-julia:toggle-all-docstrings': => @togglealldocstrings() 13 | 14 | @foldnext = true 15 | 16 | deactivate: -> 17 | @subscriptions.dispose() 18 | 19 | isdocstring: (scopes) -> 20 | for str in scopes.getScopesArray() 21 | if str.match /string\.docstring/ 22 | return true 23 | return false 24 | 25 | toggledocstrings: (event) -> 26 | editor = atom.workspace.getActiveTextEditor() 27 | startpos = editor.getCursorBufferPosition() 28 | startrow = startpos.row 29 | isdoc = @isdocstring(editor.scopeDescriptorForBufferPosition(startpos)) 30 | if !isdoc 31 | event.abortKeyBinding() 32 | return 33 | shouldunfold = editor.isFoldedAtBufferRow(startrow + 1) 34 | if shouldunfold 35 | editor.unfoldBufferRow(startrow) 36 | return 37 | row = startrow 38 | row-- while row >= 0 && @isdocstring(editor.scopeDescriptorForBufferPosition([row, 0])) 39 | firstrow = row + 1 40 | row = startrow 41 | row++ while row < editor.getLastBufferRow() && @isdocstring(editor.scopeDescriptorForBufferPosition([row, 0])) 42 | lastrow = row - 1 43 | if lastrow > firstrow 44 | editor.setSelectedBufferRange(new Range(new Point(firstrow, 0), new Point(lastrow, 0))) 45 | editor.foldSelectedLines() 46 | editor.moveUp() 47 | 48 | togglealldocstrings: -> 49 | editor = atom.workspace.getActiveTextEditor() 50 | startpos = editor.getCursorBufferPosition() 51 | if !@foldnext 52 | editor.unfoldAll() 53 | editor.scrollToCursorPosition() 54 | else # fold 55 | lookingforfirst = true 56 | for row in [0..editor.getLastBufferRow()] 57 | isdoc = @isdocstring(editor.scopeDescriptorForBufferPosition([row, 0])) 58 | if lookingforfirst && isdoc 59 | firstrow = row 60 | lookingforfirst = false 61 | else if !lookingforfirst && !isdoc 62 | lookingforfirst = true 63 | if row > firstrow 64 | editor.setSelectedBufferRange(new Range(new Point(firstrow, 0), new Point(row-1, 0))) 65 | editor.foldSelectedLines() 66 | @foldnext = !@foldnext 67 | # return cursor to initial position 68 | editor.setCursorBufferPosition(startpos) 69 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-julia", 3 | "version": "0.23.0", 4 | "description": "Julia language support for Atom.", 5 | "keywords": [], 6 | "repository": "https://github.com/JuliaEditorSupport/atom-language-julia", 7 | "main": "./lib/julia", 8 | "license": "MIT", 9 | "engines": { 10 | "atom": ">=0.174.0 <2.0.0" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/JuliaEditorSupport/atom-language-julia/issues" 14 | }, 15 | "homepage": "https://github.com/JuliaEditorSupport/atom-language-julia", 16 | "scripts": { 17 | "generate": "node ./scripts/generate.js && git add grammars/julia.json && git add grammars/julia.cson && git add grammars/julia_vscode.json", 18 | "test": "npm run generate && mocha" 19 | }, 20 | "devDependencies": { 21 | "@fastify/pre-commit": "^2.2.0", 22 | "chai": "^4.3.7", 23 | "cson": "^7.20.0", 24 | "mocha": "^10.8.2", 25 | "vscode-oniguruma": "^1.7.0", 26 | "vscode-textmate": "^9.0.0" 27 | }, 28 | "pre-commit": [ 29 | "generate" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /scripts/generate.js: -------------------------------------------------------------------------------- 1 | const CSON = require('cson') 2 | const fs = require('fs') 3 | const path = require('path') 4 | 5 | const outdir = path.join(__dirname, '..', 'grammars') 6 | 7 | const consoleGrammar = JSON.parse(fs.readFileSync(path.join(outdir, 'julia-console.json'))) 8 | fs.writeFileSync(path.join(outdir, 'julia-console.cson'), CSON.stringify(consoleGrammar, null, 2)) 9 | 10 | let grammar = JSON.parse(fs.readFileSync(path.join(outdir, 'julia.template.json'))) 11 | 12 | const templateRules = { 13 | '{{id}}': '(?:[[:alpha:]_\\\\p{Lu}\\\\p{Ll}\\\\p{Lt}\\\\p{Lm}\\\\p{Lo}\\\\p{Nl}\\\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\\\P{So}←-⇿])(?:[[:word:]_!\\\\p{Lu}\\\\p{Ll}\\\\p{Lt}\\\\p{Lm}\\\\p{Lo}\\\\p{Nl}\\\\p{Sc}⅀-⅄∿⊾⊿⊤⊥∂∅-∇∎∏∐∑∞∟∫-∳⋀-⋃◸-◿♯⟘⟙⟀⟁⦰-⦴⨀-⨆⨉-⨖⨛⨜𝛁𝛛𝛻𝜕𝜵𝝏𝝯𝞉𝞩𝟃ⁱ-⁾₁-₎∠-∢⦛-⦯℘℮゛-゜𝟎-𝟡]|[^\\\\P{Mn}\\u0001-¡]|[^\\\\P{Mc}\\u0001-¡]|[^\\\\P{Nd}\\u0001-¡]|[^\\\\P{Pc}\\u0001-¡]|[^\\\\P{Sk}\\u0001-¡]|[^\\\\P{Me}\\u0001-¡]|[^\\\\P{No}\\u0001-¡]|[′-‷⁗]|[^\\\\P{So}←-⇿])*', 14 | } 15 | 16 | // recurse through grammar and replace values: 17 | function recurseAndReplace(obj, key, val, replacement) { 18 | for (const objKey of Object.keys(obj)) { 19 | if (objKey === key && obj[objKey] === val) { 20 | obj[objKey] = replacement 21 | } else if (obj[objKey] instanceof Array || obj[objKey] instanceof Object) { 22 | recurseAndReplace(obj[objKey], key, val, replacement) 23 | } 24 | } 25 | } 26 | 27 | // templating 28 | let grammarString = JSON.stringify(grammar) 29 | for (const [k, v] of Object.entries(templateRules)) { 30 | grammarString = grammarString.replaceAll(k, v) 31 | } 32 | grammar = JSON.parse(grammarString) 33 | 34 | // write normal JSON grammar 35 | fs.writeFileSync(path.join(outdir, 'julia.json'), JSON.stringify(grammar, null, 2)) 36 | 37 | // write normal CSON grammar 38 | fs.writeFileSync(path.join(outdir, 'julia.cson'), CSON.stringify(grammar, null, 2)) 39 | 40 | // fix markdown 41 | recurseAndReplace(grammar, 'include', 'source.gfm', 'text.html.markdown.julia') 42 | 43 | // Skip over-zealous top-level production in `source.cpp`. See offending pattern here: 44 | // https://github.com/microsoft/vscode/blob/c3fe2d8acde04e579880413ae4622a1f551efdcc/extensions/cpp/syntaxes/cpp.tmLanguage.json#L745 45 | recurseAndReplace(grammar, 'include', 'source.cpp', 'source.cpp#root_context') 46 | 47 | // Choose content names consistent with the vscode conventions for embedded code. Cf.: 48 | // https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#embedded-languages 49 | recurseAndReplace(grammar, 'contentName', 'source.cpp', 'meta.embedded.inline.cpp') 50 | recurseAndReplace(grammar, 'contentName', 'source.gfm', 'meta.embedded.inline.markdown') 51 | recurseAndReplace(grammar, 'contentName', 'source.js', 'meta.embedded.inline.javascript') 52 | recurseAndReplace(grammar, 'contentName', 'source.r', 'meta.embedded.inline.r') 53 | recurseAndReplace(grammar, 'contentName', 'source.python', 'meta.embedded.inline.python') 54 | 55 | // write VSCode compatible JSON grammar 56 | fs.writeFileSync(path.join(outdir, 'julia_vscode.json'), JSON.stringify(grammar, null, 2)) 57 | -------------------------------------------------------------------------------- /settings/language-julia.cson: -------------------------------------------------------------------------------- 1 | ".source.julia": 2 | editor: 3 | tabLength: 4 4 | commentStart: "# " 5 | increaseIndentPattern: "^(\\s*|.*=\\s*|.*@\\w*\\s*)([\\w\\s]*|\\s+\".*\"\\s+)\\b(if|while|for|function|macro|mutable\\s+struct|struct|abstract\\s+type|primitive\\s+type|let|quote|try|begin|.*\\)\\s*do|else|elseif|catch|finally)\\b(?!.*\\bend\\b[^\\]]*$).*$" 6 | decreaseIndentPattern: "^\\s*(end|else|elseif|catch|finally)\\b.*$" 7 | foldEndPattern: '^\\s*\\]|^\\s*\\)' 8 | 9 | # NOTE: foldingStartMarker/foldingStopMarker not currently implemented in 10 | # atom/first-mate, but we leave it here anyway for the potential future 11 | # day when it will be implemented 12 | # see https://github.com/atom/first-mate/issues/48 13 | -------------------------------------------------------------------------------- /snippets/basic.cson: -------------------------------------------------------------------------------- 1 | ".source.julia": 2 | "Module": 3 | prefix: 'module' 4 | body: """ 5 | module ${1:name} 6 | ${2} 7 | end # module ${1} 8 | """ 9 | "Bang": 10 | prefix: '#!' 11 | body: """#! /usr/bin/env julia 12 | $1""" 13 | 'Multi-line comment': 14 | prefix: '#=' 15 | body: """#= 16 | $1 17 | =#""" 18 | "Using": 19 | prefix: 'using' 20 | body: """using ${1:module} 21 | $2""" 22 | "Include": 23 | prefix: 'include' 24 | body: """include("${1:file}") 25 | $2""" 26 | "Typed variable": 27 | prefix: 'tv' 28 | body: '${1:var}::${2:type}' 29 | -------------------------------------------------------------------------------- /snippets/language-julia.cson: -------------------------------------------------------------------------------- 1 | ".source.julia": 2 | "Documented function": 3 | prefix: "functiond" 4 | body: ''' 5 | """ 6 | ${1:name}(${2:args}) 7 | 8 | ${3:documentation} 9 | """ 10 | function ${1:name}(${2:args}) 11 | \t${4:body} 12 | end 13 | ''' 14 | "function": 15 | prefix: "function" 16 | body: ''' 17 | function ${1:name}(${2:args}) 18 | \t${3:body} 19 | end 20 | ''' 21 | 'Else if': 22 | prefix: 'elseif' 23 | body: """ 24 | elseif ${1:condition} 25 | \t$2 26 | """ 27 | 'Else if2': 28 | prefix: 'elif' 29 | body: """ 30 | elseif ${1:condition} 31 | \t$2 32 | """ 33 | "for": 34 | prefix: "for" 35 | body: ''' 36 | for ${1:variable} 37 | \t$2 38 | end 39 | ''' 40 | "for/in": 41 | prefix: "forin" 42 | body: ''' 43 | for ${1:variable} in ${2:iterator} 44 | \t$3 45 | end 46 | ''' 47 | "return": 48 | prefix: 'return' 49 | body: 'return $1' 50 | "if": 51 | prefix: "if" 52 | body: ''' 53 | if ${1:condition} 54 | \t${2:body} 55 | end 56 | ''' 57 | "if/else": 58 | prefix: "ife" 59 | body: ''' 60 | if ${1:condition} 61 | \t${2:true_body} 62 | else 63 | \t${3:false_body} 64 | end 65 | ''' 66 | "macro": 67 | prefix: "macro" 68 | body: ''' 69 | macro ${1:name}(${2:args}) 70 | \t${3:body} 71 | end 72 | ''' 73 | "try/catch": 74 | prefix: "try" 75 | body: ''' 76 | try 77 | \t${1:try_block} 78 | catch $2 79 | \t$3 80 | end 81 | ''' 82 | "try/finally": 83 | prefix: "tryf" 84 | body: ''' 85 | try 86 | \t$1 87 | finally 88 | \t$2 89 | end 90 | ''' 91 | "try/catch/finally": 92 | prefix: "trycf" 93 | body: ''' 94 | try 95 | \t${1:try_block} 96 | catch $2 97 | \t$3 98 | finally 99 | \t$4 100 | end 101 | ''' 102 | "struct": 103 | prefix: "struct" 104 | body: ''' 105 | struct ${1:name} 106 | \t${2:fields} 107 | end 108 | ''' 109 | "mutable struct": 110 | prefix: "mutable" 111 | body: ''' 112 | mutable struct ${1:name} 113 | \t${2:fields} 114 | end 115 | ''' 116 | "abstract type": 117 | prefix: "abstract" 118 | body: 'abstract type ${1:name} end' 119 | "primtitive type": 120 | prefix: "primitive" 121 | body: 'primitive type ${1:name} ${2:bits} end' 122 | "while": 123 | prefix: "while" 124 | body: ''' 125 | while ${1:condition} 126 | \t${2:body} 127 | end 128 | ''' 129 | 'begin block': 130 | prefix: 'begin' 131 | body: """ 132 | begin 133 | \t$1 134 | end 135 | """ 136 | 'let block': 137 | prefix: 'let' 138 | body: """ 139 | let 140 | \t$1 141 | end 142 | """ 143 | 'do block': 144 | prefix: 'do' 145 | body: """ 146 | do ${1:args} 147 | \t$2 148 | end 149 | """ 150 | 151 | "Documented function with end function indicator": 152 | prefix: "functiond#" 153 | body: ''' 154 | """ 155 | ${1:name}(${2:args}) 156 | 157 | ${3:documentation} 158 | """ 159 | function ${1:name}(${2:args}) 160 | \t${4:body} 161 | end # function 162 | ''' 163 | "function with end function indicator": 164 | prefix: "function#" 165 | body: ''' 166 | function ${1:name}(${2:args}) 167 | \t${3:body} 168 | end # function 169 | ''' 170 | "for with end for indicator": 171 | prefix: "for#" 172 | body: ''' 173 | for ${1:variable} 174 | \t$2 175 | end # for 176 | ''' 177 | "for/in with end for indicator": 178 | prefix: "forin#" 179 | body: ''' 180 | for ${1:variable} in ${2:iterator} 181 | \t$3 182 | end # for 183 | ''' 184 | "if with end if indicator": 185 | prefix: "if#" 186 | body: ''' 187 | if ${1:condition} 188 | \t${2:body} 189 | end # if 190 | ''' 191 | "if/else with end if indicator": 192 | prefix: "ife#" 193 | body: ''' 194 | if ${1:condition} 195 | \t${2:true_body} 196 | else 197 | \t${3:false_body} 198 | end # if 199 | ''' 200 | "macro with end macro indicator": 201 | prefix: "macro#" 202 | body: ''' 203 | macro ${1:name}(${2:args}) 204 | \t${3:body} 205 | end # macro 206 | ''' 207 | "try/catch with end try indicator": 208 | prefix: "try#" 209 | body: ''' 210 | try 211 | \t${1:try_block} 212 | catch $2 213 | \t$3 214 | end # try 215 | ''' 216 | "try/finally with end try indicator": 217 | prefix: "tryf#" 218 | body: ''' 219 | try 220 | \t$1 221 | finally 222 | \t$2 223 | end # try 224 | ''' 225 | "try/catch/finally with end try indicator": 226 | prefix: "trycf#" 227 | body: ''' 228 | try 229 | \t${1:try_block} 230 | catch $2 231 | \t$3 232 | finally 233 | \t$4 234 | end # try 235 | ''' 236 | "struct with end struct indicator": 237 | prefix: "struct#" 238 | body: ''' 239 | struct ${1:name} 240 | \t${2:fields} 241 | end # struct 242 | ''' 243 | "mutable struct with end mutable struct indicator": 244 | prefix: "mutable#" 245 | body: ''' 246 | mutable struct ${1:name} 247 | \t${2:fields} 248 | end # mutable struct 249 | ''' 250 | "while with end while indicator": 251 | prefix: "while#" 252 | body: ''' 253 | while ${1:condition} 254 | \t${2:body} 255 | end # while 256 | ''' 257 | 'begin block with end begin indicator': 258 | prefix: 'begin#' 259 | body: """ 260 | begin 261 | \t$1 262 | end # begin 263 | """ 264 | 'let block with end let indicator': 265 | prefix: 'let#' 266 | body: """ 267 | let 268 | \t$1 269 | end # let 270 | """ 271 | 'do block with end do indicator': 272 | prefix: 'do#' 273 | body: """ 274 | do ${1:args} 275 | \t$2 276 | end # do 277 | """ 278 | --------------------------------------------------------------------------------