diff --git a/.codespellrc b/.codespellrc index ed86754..481601a 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,2 +1,2 @@ [codespell] -skip = **/package-lock.json +skip = **/package-lock.json,example/textmate/langs/** diff --git a/.flake8 b/.flake8 deleted file mode 100644 index c9cf276..0000000 --- a/.flake8 +++ /dev/null @@ -1,11 +0,0 @@ -[flake8] - -ignore = - # Black and flake8 conflict here - E203 - # Just assume black did a good job with the line lengths - E501 - -per-file-ignores = - # These directories will always contain "from ... import *" - trame/*:F401,F403 diff --git a/.github/workflows/test_and_release.yml b/.github/workflows/test_and_release.yml index bd14cf6..90fb6be 100644 --- a/.github/workflows/test_and_release.yml +++ b/.github/workflows/test_and_release.yml @@ -2,25 +2,29 @@ name: Test and Release on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: pre-commit: runs-on: ubuntu-latest + env: + UV_PYTHON: "3.12" steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-python@v2 + - uses: actions/checkout@v6 + - name: Install uv + uses: astral-sh/setup-uv@v6 with: - python-version: "3.9" + version: "0.8.12" + enable-cache: true + - name: Install the project + run: uv sync --all-extras --dev # Install and run pre-commit - run: | - pip install pre-commit - pre-commit install - pre-commit run --all-files + uv run pre-commit install + uv run pre-commit run --all-files pytest: name: Pytest ${{ matrix.config.name }} @@ -28,51 +32,45 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.9] + python-version: ["3.12"] config: - - { - name: "Linux", - os: ubuntu-latest - } - - { - name: "MacOSX", - os: macos-latest - } - - { - name: "Windows", - os: windows-latest - } + - { name: "Linux", os: ubuntu-latest } + - { name: "MacOSX", os: macos-latest } + - { name: "Windows", os: windows-latest } defaults: run: shell: bash steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Install and Run Tests - run: | - pip install . - pip install -r tests/requirements.txt - pytest -s ./tests + - name: Checkout + uses: actions/checkout@v6 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@v6 + with: + version: "0.8.12" + enable-cache: true + - name: Install and Run Tests + run: | + uv sync --dev + uv pip install -r tests/requirements.txt + uv run pytest -s ./tests test-npm-build: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v6 - name: Set Up Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v6 with: - node-version: 14 + node-version: 24 - name: Build Vue Components run: | @@ -81,24 +79,25 @@ jobs: npm run build release: - needs: [ - pre-commit, - pytest, - test-npm-build, - ] + needs: [pre-commit, pytest, test-npm-build] runs-on: ubuntu-latest + environment: release + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + contents: write # IMPORTANT: mandatory for making GitHub Releases + attestations: write # IMPORTANT: mandatory to attest build provenance if: github.event_name == 'push' steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v6 with: fetch-depth: 0 - name: Set Up Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v6 with: - node-version: 14 + node-version: 24 - name: Build Vue Components run: | @@ -107,8 +106,17 @@ jobs: npm run build - name: Python Semantic Release - uses: relekang/python-semantic-release@v7.34.6 + id: release + uses: python-semantic-release/python-semantic-release@v10.5.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - repository_username: __token__ - repository_password: ${{ secrets.PYPI_API_TOKEN }} + + - name: Generate artifact attestation for sdist and wheel + if: steps.release.outputs.released == 'true' + uses: actions/attest-build-provenance@v4.1.0 + with: + subject-path: "dist/*" + + # https://docs.pypi.org/trusted-publishers/using-a-publisher/ + - uses: pypa/gh-action-pypi-publish@release/v1 + if: steps.release.outputs.released == 'true' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 21c6c49..5c405af 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,16 +1,68 @@ +ci: + autoupdate_commit_msg: "chore: update pre-commit hooks" + autofix_commit_msg: "style: pre-commit fixes" + +exclude: ^.cruft.json|.copier-answers.yml$|uv\.lock$ + repos: - - repo: https://github.com/psf/black - rev: 22.3.0 + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v5.0.0" + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: name-tests-test + args: ["--pytest-test-first"] + - id: requirements-txt-fixer + - id: trailing-whitespace + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: "v1.10.0" + hooks: + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal + + - repo: https://github.com/rbubley/mirrors-prettier + rev: "v3.4.2" hooks: - - id: black - entry: black --check + - id: prettier + types_or: [yaml, markdown, html, css, scss, javascript, json] + args: [--prose-wrap=always] + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.15.10" + hooks: + - id: ruff + args: ["--fix", "--show-fixes"] + - id: ruff-format - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 + rev: "v2.3.0" hooks: - id: codespell - - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: "v0.10.0.1" + hooks: + - id: shellcheck + + - repo: https://github.com/abravalheri/validate-pyproject + rev: "v0.25" + hooks: + - id: validate-pyproject + additional_dependencies: + - validate-pyproject[all] + - validate-pyproject-schema-store + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: "0.31.0" hooks: - - id: flake8 + - id: check-dependabot + - id: check-github-workflows + - id: check-readthedocs diff --git a/CHANGELOG.md b/CHANGELOG.md index d982564..947d757 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,40 +6,62 @@ ### Fix -* Update vue2 example to use vue2 client type ([`34b443d`](https://github.com/Kitware/trame-code/commit/34b443d4b02328db155a4e152516d312dbfa7090)) -* Initial value for vue2 ([`b356e66`](https://github.com/Kitware/trame-code/commit/b356e66608b7b0655bffa4022c8f9815ceffcdbf)) -* Bring back vue2 support ([`d9dc6f8`](https://github.com/Kitware/trame-code/commit/d9dc6f8fe0d393e596a0eeb4a0d20d32e5aa6681)) -* Update to use modelValue for vue3 ([`4274d8f`](https://github.com/Kitware/trame-code/commit/4274d8f8221c2bc2f3052900186444ca8dab6af0)) +- Update vue2 example to use vue2 client type + ([`34b443d`](https://github.com/Kitware/trame-code/commit/34b443d4b02328db155a4e152516d312dbfa7090)) +- Initial value for vue2 + ([`b356e66`](https://github.com/Kitware/trame-code/commit/b356e66608b7b0655bffa4022c8f9815ceffcdbf)) +- Bring back vue2 support + ([`d9dc6f8`](https://github.com/Kitware/trame-code/commit/d9dc6f8fe0d393e596a0eeb4a0d20d32e5aa6681)) +- Update to use modelValue for vue3 + ([`4274d8f`](https://github.com/Kitware/trame-code/commit/4274d8f8221c2bc2f3052900186444ca8dab6af0)) ### Documentation -* Remove value from python wrapper ([`9172e3b`](https://github.com/Kitware/trame-code/commit/9172e3b87a3959dee4df5bcbbf912576a5bbd459)) -* Update README.rst ([`adc54bb`](https://github.com/Kitware/trame-code/commit/adc54bb796288d91b8b9d89c8140b24e7b372e1f)) +- Remove value from python wrapper + ([`9172e3b`](https://github.com/Kitware/trame-code/commit/9172e3b87a3959dee4df5bcbbf912576a5bbd459)) +- Update README.rst + ([`adc54bb`](https://github.com/Kitware/trame-code/commit/adc54bb796288d91b8b9d89c8140b24e7b372e1f)) ## v1.0.1 (2023-08-16) ### Fix -* **docs:** Improve API ([`e125a5b`](https://github.com/Kitware/trame-code/commit/e125a5b03ea7518329adadb082fc4f142fd6f28e)) +- **docs:** Improve API + ([`e125a5b`](https://github.com/Kitware/trame-code/commit/e125a5b03ea7518329adadb082fc4f142fd6f28e)) ### Documentation -* **layout:** Use automaticLayout option ([`c416d98`](https://github.com/Kitware/trame-code/commit/c416d98d2827e06d0a281733186016d6dbee98ca)) -* **example:** Cleanup of textmate ([`d2e3eb3`](https://github.com/Kitware/trame-code/commit/d2e3eb322bef5574b2ae5ab0971d43c4a8335cd7)) +- **layout:** Use automaticLayout option + ([`c416d98`](https://github.com/Kitware/trame-code/commit/c416d98d2827e06d0a281733186016d6dbee98ca)) +- **example:** Cleanup of textmate + ([`d2e3eb3`](https://github.com/Kitware/trame-code/commit/d2e3eb322bef5574b2ae5ab0971d43c4a8335cd7)) ## v1.0.0 (2023-04-19) + ### Feature -* **release:** Official release ([`080923c`](https://github.com/Kitware/trame-code/commit/080923c5ad7343dac65e192902947ed08f761f57)) + +- **release:** Official release + ([`080923c`](https://github.com/Kitware/trame-code/commit/080923c5ad7343dac65e192902947ed08f761f57)) ### Breaking -* Just making that library official now that it vue2/3 compatible ([`080923c`](https://github.com/Kitware/trame-code/commit/080923c5ad7343dac65e192902947ed08f761f57)) + +- Just making that library official now that it vue2/3 compatible + ([`080923c`](https://github.com/Kitware/trame-code/commit/080923c5ad7343dac65e192902947ed08f761f57)) ## v0.1.0 (2023-04-18) + ### Feature -* **textmate:** Handle textmate format ([`83cfb97`](https://github.com/Kitware/trame-code/commit/83cfb97110296afa5fbfd31a2d66a4c8dc9810d1)) -* **vue23:** Working for both vue client ([`13b5a92`](https://github.com/Kitware/trame-code/commit/13b5a92851a3f73f6020626547e63a7c4887cead)) -* Initial VS code editor ([`831f907`](https://github.com/Kitware/trame-code/commit/831f90763d6a37088a648b2948f7f4b80b6c81aa)) + +- **textmate:** Handle textmate format + ([`83cfb97`](https://github.com/Kitware/trame-code/commit/83cfb97110296afa5fbfd31a2d66a4c8dc9810d1)) +- **vue23:** Working for both vue client + ([`13b5a92`](https://github.com/Kitware/trame-code/commit/13b5a92851a3f73f6020626547e63a7c4887cead)) +- Initial VS code editor + ([`831f907`](https://github.com/Kitware/trame-code/commit/831f90763d6a37088a648b2948f7f4b80b6c81aa)) ### Fix -* **version:** Add __version__ ([`efac4ab`](https://github.com/Kitware/trame-code/commit/efac4abe7c61c0ce562e88c54461d3a19b1e553d)) -* **options:** Fix setting the language and theme ([`4ae0c42`](https://github.com/Kitware/trame-code/commit/4ae0c42055df982181453371ae76dd9e5677b451)) + +- **version:** Add **version** + ([`efac4ab`](https://github.com/Kitware/trame-code/commit/efac4abe7c61c0ce562e88c54461d3a19b1e553d)) +- **options:** Fix setting the language and theme + ([`4ae0c42`](https://github.com/Kitware/trame-code/commit/4ae0c42055df982181453371ae76dd9e5677b451)) diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 9bddec8..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -graft trame_code/module/serve diff --git a/example/language-features/app.py b/example/language-features/app.py index 41eae88..ccc37a9 100644 --- a/example/language-features/app.py +++ b/example/language-features/app.py @@ -23,6 +23,7 @@ import jedi from trame.app import TrameApp from trame.ui.vuetify3 import SinglePageLayout + from trame.widgets import code from trame.widgets import vuetify3 as v3 diff --git a/example/language-features/requirements.txt b/example/language-features/requirements.txt index 5b8dc30..7c4b1d6 100644 --- a/example/language-features/requirements.txt +++ b/example/language-features/requirements.txt @@ -1,4 +1,4 @@ +jedi trame -trame-vuetify trame-code -jedi +trame-vuetify diff --git a/example/live-state/app.py b/example/live-state/app.py index 0e119a5..f51f6bd 100644 --- a/example/live-state/app.py +++ b/example/live-state/app.py @@ -26,6 +26,7 @@ from trame.app import TrameApp from trame.ui.vuetify3 import SinglePageLayout + from trame.widgets import code from trame.widgets import vuetify3 as vuetify diff --git a/example/live-state/requirements.txt b/example/live-state/requirements.txt index 1eb2265..d1b417a 100644 --- a/example/live-state/requirements.txt +++ b/example/live-state/requirements.txt @@ -1,3 +1,3 @@ trame -trame-vuetify trame-code +trame-vuetify diff --git a/example/read-only/requirements.txt b/example/read-only/requirements.txt index e9a4f4e..fcc9c0c 100644 --- a/example/read-only/requirements.txt +++ b/example/read-only/requirements.txt @@ -1,2 +1,2 @@ trame -trame-code \ No newline at end of file +trame-code diff --git a/example/read-only/viewer.py b/example/read-only/viewer.py index 579fe9e..40e5baf 100644 --- a/example/read-only/viewer.py +++ b/example/read-only/viewer.py @@ -1,8 +1,9 @@ +from pathlib import Path + from trame.app import get_server from trame.ui.vuetify import SinglePageWithDrawerLayout -from trame.widgets import vuetify, code -from pathlib import Path +from trame.widgets import code, vuetify # ----------------------------------------------------------------------------- # Trame setup @@ -85,15 +86,14 @@ def load_file(full_paths): update_active=(load_file, "[$event]"), ) - with layout.content: - with vuetify.VContainer(fluid=True, classes="fill-height pa-0"): - editor = code.Editor( - style="width: 100%", - value=("editor_content", ""), - options=("editor_options", {}), - language=("editor_lang", "plaintext"), - theme=("editor_theme", "vs-dark"), - ) + with layout.content, vuetify.VContainer(fluid=True, classes="fill-height pa-0"): + editor = code.Editor( + style="width: 100%", + value=("editor_content", ""), + options=("editor_options", {}), + language=("editor_lang", "plaintext"), + theme=("editor_theme", "vs-dark"), + ) # ----------------------------------------------------------------------------- diff --git a/example/read-only/viewer_vue3.py b/example/read-only/viewer_vue3.py index 8eabd2c..30acfb9 100644 --- a/example/read-only/viewer_vue3.py +++ b/example/read-only/viewer_vue3.py @@ -1,8 +1,9 @@ +from pathlib import Path + from trame.app import get_server from trame.ui.vuetify3 import SinglePageWithDrawerLayout -from trame.widgets import vuetify3, code -from pathlib import Path +from trame.widgets import code, vuetify3 # ----------------------------------------------------------------------------- # Trame setup diff --git a/example/textmate/app.py b/example/textmate/app.py index 7e36bfe..e17db18 100644 --- a/example/textmate/app.py +++ b/example/textmate/app.py @@ -1,14 +1,14 @@ +import sys +from pathlib import Path + from trame.app import get_server from trame.ui.vuetify import SinglePageWithDrawerLayout -from trame.widgets import vuetify, code -from pathlib import Path - -import sys +from trame.widgets import code, vuetify sys.path.append(str(Path(__file__).parent.absolute())) -import langs # noqa: E402 +import langs # ----------------------------------------------------------------------------- # Trame setup @@ -79,25 +79,21 @@ def load_file(lang, file_path): style="max-width: 200px;", ) - with layout.drawer: - with vuetify.VCol(): - vuetify.VBtn("Python", classes="mb-2", block=True, click=load_python) - vuetify.VBtn("Moose", classes="mb-2", block=True, click=load_moose) - vuetify.VBtn( - "JavaScript", classes="mb-2", block=True, click=load_javascript - ) - vuetify.VBtn("Latex", classes="mb-2", block=True, click=load_latex) - - with layout.content: - with vuetify.VContainer(fluid=True, classes="fill-height pa-0"): - editor = code.Editor( - style="width: 100%", - value=("editor_content", ""), - options=("editor_options", {"automaticLayout": True}), - language=("editor_lang", "plaintext"), - theme=("editor_theme", "vs-dark"), - textmate=("editor_textmate", None), - ) + with layout.drawer, vuetify.VCol(): + vuetify.VBtn("Python", classes="mb-2", block=True, click=load_python) + vuetify.VBtn("Moose", classes="mb-2", block=True, click=load_moose) + vuetify.VBtn("JavaScript", classes="mb-2", block=True, click=load_javascript) + vuetify.VBtn("Latex", classes="mb-2", block=True, click=load_latex) + + with layout.content, vuetify.VContainer(fluid=True, classes="fill-height pa-0"): + editor = code.Editor( + style="width: 100%", + value=("editor_content", ""), + options=("editor_options", {"automaticLayout": True}), + language=("editor_lang", "plaintext"), + theme=("editor_theme", "vs-dark"), + textmate=("editor_textmate", None), + ) # ----------------------------------------------------------------------------- diff --git a/example/textmate/files/javascript_example.js b/example/textmate/files/javascript_example.js index db72402..d5d2b2f 100644 --- a/example/textmate/files/javascript_example.js +++ b/example/textmate/files/javascript_example.js @@ -67,7 +67,7 @@ export class SimpleLanguageInfoProvider { this.monaco.languages.getEncodedLanguageId(language); return this.tokensProviderCache.createEncodedTokensProvider( scopeName, - encodedLanguageId + encodedLanguageId, ); } @@ -114,7 +114,7 @@ class TokensProviderCache { .loadGrammarWithConfiguration( scopeName, encodedLanguageId, - grammarConfiguration + grammarConfiguration, ) .then((grammar) => { if (grammar) { @@ -154,9 +154,8 @@ export function registerLanguages(languages, fetchLanguageInfo, monaco) { // Lazy-load the tokens provider and configuration data. monaco.languages.onLanguage(languageId, async () => { - const { tokensProvider, configuration } = await fetchLanguageInfo( - languageId - ); + const { tokensProvider, configuration } = + await fetchLanguageInfo(languageId); if (tokensProvider != null) { monaco.languages.setTokensProvider(languageId, tokensProvider); diff --git a/example/textmate/files/latex_example.tex b/example/textmate/files/latex_example.tex index 3886b81..3a94802 100644 --- a/example/textmate/files/latex_example.tex +++ b/example/textmate/files/latex_example.tex @@ -6,4 +6,4 @@ Empty, i, i, i \end{quote}~Empty, The Cranberries -\end{document} \ No newline at end of file +\end{document} diff --git a/example/textmate/langs/__init__.py b/example/textmate/langs/__init__.py index d5b7134..d5f89c0 100644 --- a/example/textmate/langs/__init__.py +++ b/example/textmate/langs/__init__.py @@ -1,4 +1,4 @@ -from . import python, moose +from . import moose, python ALL_LANGS = dict(languages=[], grammars={}, configs={}) diff --git a/example/textmate/langs/moose/moose.config.json b/example/textmate/langs/moose/moose.config.json index 54752d2..b8738c0 100644 --- a/example/textmate/langs/moose/moose.config.json +++ b/example/textmate/langs/moose/moose.config.json @@ -1,67 +1,41 @@ { - "comments": { - "lineComment": "#" + "comments": { + "lineComment": "#" + }, + "indentationRules": { + "increaseIndentPattern": "^\\s*\\[.+\\]$", + "decreaseIndentPattern": "^\\s*\\[\\]$" + }, + "brackets": [ + ["{", "}"], + ["(", ")"] + ], + "autoClosingPairs": [ + { + "open": "{", + "close": "}" }, - "indentationRules": { - "increaseIndentPattern": "^\\s*\\[.+\\]$", - "decreaseIndentPattern": "^\\s*\\[\\]$" + { + "open": "(", + "close": ")" }, - "brackets": [ - [ - "{", - "}" - ], - [ - "(", - ")" - ] - ], - "autoClosingPairs": [ - { - "open": "{", - "close": "}" - }, - { - "open": "(", - "close": ")" - }, - { - "open": "'", - "close": "'", - "notIn": [ - "string", - "comment" - ] - }, - { - "open": "\"", - "close": "\"", - "notIn": [ - "string" - ] - } - ], - "autoCloseBefore": ";:.,=}])>` \n\t", - "surroundingPairs": [ - [ - "{", - "}" - ], - [ - "(", - ")" - ], - [ - "'", - "'" - ], - [ - "\"", - "\"" - ], - [ - "`", - "`" - ] - ] -} \ No newline at end of file + { + "open": "'", + "close": "'", + "notIn": ["string", "comment"] + }, + { + "open": "\"", + "close": "\"", + "notIn": ["string"] + } + ], + "autoCloseBefore": ";:.,=}])>` \n\t", + "surroundingPairs": [ + ["{", "}"], + ["(", ")"], + ["'", "'"], + ["\"", "\""], + ["`", "`"] + ] +} diff --git a/example/textmate/langs/moose/moose.grammar.json b/example/textmate/langs/moose/moose.grammar.json index e5e9159..698f1a2 100644 --- a/example/textmate/langs/moose/moose.grammar.json +++ b/example/textmate/langs/moose/moose.grammar.json @@ -1,323 +1,321 @@ { - "scopeName": "input.moose", - "fileTypes": [ - "i" - ], - "foldingStartMarker": "(^\\s*\\[[^.]+\\]\\s*$)", - "foldingStopMarker": "(^\\s*\\[\\]\\s*$)", - "name": "MOOSE Input", - "patterns": [ - { - "include": "#comments" - }, - { - "match": "(\\[)(Adaptivity|Bounds|Mesh|MeshGenerators|MeshModifiers|Kernels|AuxKernels|ScalarKernels|AuxScalarKernels|Variables|AuxVariables|Materials|Postprocessors|BCs|ICs|Executioner|Outputs|Problem|Debug|Preconditioning|UserObjects|Functions|GlobalParams|VectorPostprocessors|Dampers|DiracKernels|DGKernels|Constraints|NodalNormals|CoupledProblems|DeprecatedBlock|MultiApps|Transfers|InterfaceKernels|NodalKernels|Controls|Modules)(\\])", - "captures": { - "2": { - "name": "keyword.control.moose" - } + "scopeName": "input.moose", + "fileTypes": ["i"], + "foldingStartMarker": "(^\\s*\\[[^.]+\\]\\s*$)", + "foldingStopMarker": "(^\\s*\\[\\]\\s*$)", + "name": "MOOSE Input", + "patterns": [ + { + "include": "#comments" + }, + { + "match": "(\\[)(Adaptivity|Bounds|Mesh|MeshGenerators|MeshModifiers|Kernels|AuxKernels|ScalarKernels|AuxScalarKernels|Variables|AuxVariables|Materials|Postprocessors|BCs|ICs|Executioner|Outputs|Problem|Debug|Preconditioning|UserObjects|Functions|GlobalParams|VectorPostprocessors|Dampers|DiracKernels|DGKernels|Constraints|NodalNormals|CoupledProblems|DeprecatedBlock|MultiApps|Transfers|InterfaceKernels|NodalKernels|Controls|Modules)(\\])", + "captures": { + "2": { + "name": "keyword.control.moose" } - }, - { - "match": "\\[(\\.\\/)(TimeStepper|TimePeriods|Quadrature|Predictor|Adaptivity|Indicators|Markers|Periodic|InitialCondition|MortarInterfaces)\\]", - "captures": { - "1": { - "name": "moose" - }, - "2": { - "name": "keyword.control.moose" - } + } + }, + { + "match": "\\[(\\.\\/)(TimeStepper|TimePeriods|Quadrature|Predictor|Adaptivity|Indicators|Markers|Periodic|InitialCondition|MortarInterfaces)\\]", + "captures": { + "1": { + "name": "moose" + }, + "2": { + "name": "keyword.control.moose" } - }, - { - "match": "\\[(\\.*/*)(.*)\\]", - "captures": { - "1": { - "name": "moose" - }, - "2": { - "name": "support.function.moose" - } + } + }, + { + "match": "\\[(\\.*/*)(.*)\\]", + "captures": { + "1": { + "name": "moose" + }, + "2": { + "name": "support.function.moose" } - }, - { - "match": "\\b(type)\\s*(=)\\s*([^\\s]+)", - "captures": { - "1": { - "name": "keyword.control.moose" - }, - "2": { - "name": "keyword.operator.moose" - }, - "3": { - "name": "entity.name.function.moose" - } + } + }, + { + "match": "\\b(type)\\s*(=)\\s*([^\\s]+)", + "captures": { + "1": { + "name": "keyword.control.moose" + }, + "2": { + "name": "keyword.operator.moose" + }, + "3": { + "name": "entity.name.function.moose" + } + } + }, + { + "match": "\\[(\\.+/)\\]", + "captures": { + "1": { + "name": "moose" + } + } + }, + { + "match": "\\[\\]", + "captures": { + "1": { + "name": "moose" + } + } + }, + { + "match": "\\border\\s*(=)\\s*(CONSTANT|FIRST|SECOND|THIRD|FOURTH|FIFTH|SIXTH|SEVENTH|EIGHTH|NINTH)\\b", + "captures": { + "1": { + "name": "keyword.operator.assignment.moose" + }, + "2": { + "name": "constant.language.moose" + } + } + }, + { + "match": "\\bfamily\\s*(=)\\s*(LAGRANGE|MONOMIAL|HERMITE|SCALAR|HIERARCHIC|CLOUGH|XYZ|SZABAB|BERNSTEIN|L2_LAGRANGE|L2_HIERARCHIC)\\b", + "captures": { + "1": { + "name": "keyword.operator.assignment.moose" + }, + "2": { + "name": "constant.language.moose" + } + } + }, + { + "match": "\\belem_type\\s*(=)\\s*(EDGE|EDGE2|EDGE3|EDGE4|QUAD|QUAD4|QUAD8|QUAD9|TRI3|TRI6|HEX|HEX8|HEX20|HEX27|TET4|TET10|PRISM6|PRISM15|PRISM18)\\b", + "captures": { + "1": { + "name": "keyword.operator.assignment.moose" + }, + "2": { + "name": "constant.language.moose" + } + } + }, + { + "begin": "\\boutput_on\\s*(=)\\s*(')", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.moose" + }, + "2": { + "name": "punctuation.definition.string.begin.moose" } }, - { - "match": "\\[(\\.+/)\\]", - "captures": { - "1": { - "name": "moose" - } + "end": "'", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.moose" } }, - { - "match": "\\[\\]", - "captures": { - "1": { - "name": "moose" - } + "patterns": [ + { + "include": "#output_on" + } + ] + }, + { + "begin": "\\bexecute_on\\s*(=)\\s*(')", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.moose" + }, + "2": { + "name": "punctuation.definition.string.begin.moose" } }, - { - "match": "\\border\\s*(=)\\s*(CONSTANT|FIRST|SECOND|THIRD|FOURTH|FIFTH|SIXTH|SEVENTH|EIGHTH|NINTH)\\b", - "captures": { - "1": { - "name": "keyword.operator.assignment.moose" - }, - "2": { - "name": "constant.language.moose" - } + "end": "'", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.moose" } }, - { - "match": "\\bfamily\\s*(=)\\s*(LAGRANGE|MONOMIAL|HERMITE|SCALAR|HIERARCHIC|CLOUGH|XYZ|SZABAB|BERNSTEIN|L2_LAGRANGE|L2_HIERARCHIC)\\b", - "captures": { - "1": { - "name": "keyword.operator.assignment.moose" - }, - "2": { - "name": "constant.language.moose" - } + "patterns": [ + { + "include": "#execute_on" + } + ] + }, + { + "begin": "[a-z_A-Z0-9]+\\s*(=)\\s*(')", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.moose" + }, + "2": { + "name": "punctuation.definition.string.begin.moose" } }, - { - "match": "\\belem_type\\s*(=)\\s*(EDGE|EDGE2|EDGE3|EDGE4|QUAD|QUAD4|QUAD8|QUAD9|TRI3|TRI6|HEX|HEX8|HEX20|HEX27|TET4|TET10|PRISM6|PRISM15|PRISM18)\\b", - "captures": { - "1": { - "name": "keyword.operator.assignment.moose" - }, - "2": { - "name": "constant.language.moose" - } + "end": "'", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.moose" } }, - { - "begin": "\\boutput_on\\s*(=)\\s*(')", - "beginCaptures": { - "1": { - "name": "keyword.operator.assignment.moose" - }, - "2": { - "name": "punctuation.definition.string.begin.moose" - } + "patterns": [ + { + "include": "#numbers" }, - "end": "'", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.moose" - } + { + "include": "#operators" }, - "patterns": [ - { - "include": "#output_on" - } - ] + { + "include": "#fparser_variables" + } + ] + }, + { + "begin": "[a-z_A-Z0-9]+\\s*(=)\\s*", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.moose" + } }, - { - "begin": "\\bexecute_on\\s*(=)\\s*(')", - "beginCaptures": { - "1": { - "name": "keyword.operator.assignment.moose" - }, - "2": { - "name": "punctuation.definition.string.begin.moose" - } + "end": "\n", + "patterns": [ + { + "include": "#constants" }, - "end": "'", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.moose" - } + { + "include": "#numbers" }, - "patterns": [ - { - "include": "#execute_on" - } - ] - }, - { - "begin": "[a-z_A-Z0-9]+\\s*(=)\\s*(')", - "beginCaptures": { - "1": { - "name": "keyword.operator.assignment.moose" - }, - "2": { - "name": "punctuation.definition.string.begin.moose" + { + "include": "#comments" + } + ] + } + ], + "repository": { + "numbers": { + "patterns": [ + { + "match": "\\b(\\d*\\.\\d+)\\b", + "captures": { + "1": { + "name": "constant.numeric.moose" + } } }, - "end": "'", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.moose" + { + "match": "\\b(\\d+e[+-]{0,1}\\d+)\\b", + "captures": { + "1": { + "name": "constant.numeric.moose" + } } }, - "patterns": [ - { - "include": "#numbers" - }, - { - "include": "#operators" - }, - { - "include": "#fparser_variables" - } - ] - }, - { - "begin": "[a-z_A-Z0-9]+\\s*(=)\\s*", - "beginCaptures": { - "1": { - "name": "keyword.operator.assignment.moose" + { + "match": "\\b(\\d*\\.\\d+e[+-]{0,1}\\d+)\\b", + "captures": { + "1": { + "name": "constant.numeric.moose" + } } }, - "end": "\n", - "patterns": [ - { - "include": "#constants" - }, - { - "include": "#numbers" - }, - { - "include": "#comments" - } - ] - } - ], - "repository": { - "numbers": { - "patterns": [ - { - "match": "\\b(\\d*\\.\\d+)\\b", - "captures": { - "1": { - "name": "constant.numeric.moose" - } + { + "match": "\\b(\\d+)\\b", + "captures": { + "1": { + "name": "constant.numeric.moose" } - }, - { - "match": "\\b(\\d+e[+-]{0,1}\\d+)\\b", - "captures": { - "1": { - "name": "constant.numeric.moose" - } - } - }, - { - "match": "\\b(\\d*\\.\\d+e[+-]{0,1}\\d+)\\b", - "captures": { - "1": { - "name": "constant.numeric.moose" - } - } - }, - { - "match": "\\b(\\d+)\\b", - "captures": { - "1": { - "name": "constant.numeric.moose" - } - } - } - ] - }, - "output_on": { - "patterns": [ - { - "match": "(?i)\\b(none|initial|linear|nonlinear|timestep_end|timestep_begin|final|failed|custom)\\b", - "name": "constant.language.moose" } - ] - }, - "execute_on": { - "patterns": [ - { - "match": "(?i)\\b(initial|linear|nonlinear|timestep_end|timestep_begin|final|custom)\\b", - "name": "constant.language.moose" - } - ] - }, - "constants": { - "patterns": [ - { - "match": "(?i)\\b(false|true)\\b", - "name": "constant.language.moose" - } - ] - }, - "escaped_char": { - "patterns": [ - { - "match": "\\\\.", - "name": "constant.character.escape.moose" - } - ] - }, - "operators": { - "patterns": [ - { - "match": "[\\+\\*\\/\\^%\\-]", - "name": "keyword.operator.moose" - }, - { - "match": "(abs|acos|acosh|arg|asin|atan|atan2|atanh|cbrt|ceil|conj|cos|cosh|cot|csc|exp|exp2|floor|hypot|if|imag|int|log|log10|log2|max|min|polar|pow|real|sec|sin|sinh|sqrt|tan|tanh|trunc|plog)\\(", - "captures": { - "1": { - "name": "support.function.moose" - } + } + ] + }, + "output_on": { + "patterns": [ + { + "match": "(?i)\\b(none|initial|linear|nonlinear|timestep_end|timestep_begin|final|failed|custom)\\b", + "name": "constant.language.moose" + } + ] + }, + "execute_on": { + "patterns": [ + { + "match": "(?i)\\b(initial|linear|nonlinear|timestep_end|timestep_begin|final|custom)\\b", + "name": "constant.language.moose" + } + ] + }, + "constants": { + "patterns": [ + { + "match": "(?i)\\b(false|true)\\b", + "name": "constant.language.moose" + } + ] + }, + "escaped_char": { + "patterns": [ + { + "match": "\\\\.", + "name": "constant.character.escape.moose" + } + ] + }, + "operators": { + "patterns": [ + { + "match": "[\\+\\*\\/\\^%\\-]", + "name": "keyword.operator.moose" + }, + { + "match": "(abs|acos|acosh|arg|asin|atan|atan2|atanh|cbrt|ceil|conj|cos|cosh|cot|csc|exp|exp2|floor|hypot|if|imag|int|log|log10|log2|max|min|polar|pow|real|sec|sin|sinh|sqrt|tan|tanh|trunc|plog)\\(", + "captures": { + "1": { + "name": "support.function.moose" } } - ] - }, - "fparser_variables": { - "patterns": [ - { - "match": "\\b([a-zA-Z][a-z_A-Z0-9]*)\\b", - "captures": { - "1": { - "name": "variable.other.moose" - } + } + ] + }, + "fparser_variables": { + "patterns": [ + { + "match": "\\b([a-zA-Z][a-z_A-Z0-9]*)\\b", + "captures": { + "1": { + "name": "variable.other.moose" } } - ] - }, - "comments": { - "patterns": [ - { - "match": "^\\s*((#+).*)", - "captures": { - "1": { - "name": "punctuation.definition.comment.moose" - }, - "2": { - "name": "comment.line.number-sign.moose" - } + } + ] + }, + "comments": { + "patterns": [ + { + "match": "^\\s*((#+).*)", + "captures": { + "1": { + "name": "punctuation.definition.comment.moose" + }, + "2": { + "name": "comment.line.number-sign.moose" } - }, - { - "match": "((#+).*)", - "captures": { - "1": { - "name": "punctuation.definition.comment.moose" - }, - "2": { - "name": "comment.line.number-sign.moose" - } + } + }, + { + "match": "((#+).*)", + "captures": { + "1": { + "name": "punctuation.definition.comment.moose" + }, + "2": { + "name": "comment.line.number-sign.moose" } } - ] - } + } + ] } - } \ No newline at end of file + } +} diff --git a/example/textmate/langs/python/python.config.json b/example/textmate/langs/python/python.config.json index 9fd917a..5a2789a 100644 --- a/example/textmate/langs/python/python.config.json +++ b/example/textmate/langs/python/python.config.json @@ -1,135 +1,135 @@ { - "comments": { - "lineComment": "#", - "blockComment": ["\"\"\"", "\"\"\""] - }, - "brackets": [ - ["{", "}"], - ["[", "]"], - ["(", ")"] - ], - "autoClosingPairs": [ - { - "open": "{", - "close": "}" - }, - { - "open": "[", - "close": "]" - }, - { - "open": "(", - "close": ")" - }, - { - "open": "\"", - "close": "\"", - "notIn": ["string"] - }, - { - "open": "r\"", - "close": "\"", - "notIn": ["string", "comment"] - }, - { - "open": "R\"", - "close": "\"", - "notIn": ["string", "comment"] - }, - { - "open": "u\"", - "close": "\"", - "notIn": ["string", "comment"] - }, - { - "open": "U\"", - "close": "\"", - "notIn": ["string", "comment"] - }, - { - "open": "f\"", - "close": "\"", - "notIn": ["string", "comment"] - }, - { - "open": "F\"", - "close": "\"", - "notIn": ["string", "comment"] - }, - { - "open": "b\"", - "close": "\"", - "notIn": ["string", "comment"] - }, - { - "open": "B\"", - "close": "\"", - "notIn": ["string", "comment"] - }, - { - "open": "'", - "close": "'", - "notIn": ["string", "comment"] - }, - { - "open": "r'", - "close": "'", - "notIn": ["string", "comment"] - }, - { - "open": "R'", - "close": "'", - "notIn": ["string", "comment"] - }, - { - "open": "u'", - "close": "'", - "notIn": ["string", "comment"] - }, - { - "open": "U'", - "close": "'", - "notIn": ["string", "comment"] - }, - { - "open": "f'", - "close": "'", - "notIn": ["string", "comment"] - }, - { - "open": "F'", - "close": "'", - "notIn": ["string", "comment"] - }, - { - "open": "b'", - "close": "'", - "notIn": ["string", "comment"] - }, - { - "open": "B'", - "close": "'", - "notIn": ["string", "comment"] - }, - { - "open": "`", - "close": "`", - "notIn": ["string"] - } - ], - "surroundingPairs": [ - ["{", "}"], - ["[", "]"], - ["(", ")"], - ["\"", "\""], - ["'", "'"], - ["`", "`"] - ], - "folding": { - "offSide": true, - "markers": { - "start": "^\\s*#\\s*region\\b", - "end": "^\\s*#\\s*endregion\\b" - } + "comments": { + "lineComment": "#", + "blockComment": ["\"\"\"", "\"\"\""] + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + { + "open": "{", + "close": "}" + }, + { + "open": "[", + "close": "]" + }, + { + "open": "(", + "close": ")" + }, + { + "open": "\"", + "close": "\"", + "notIn": ["string"] + }, + { + "open": "r\"", + "close": "\"", + "notIn": ["string", "comment"] + }, + { + "open": "R\"", + "close": "\"", + "notIn": ["string", "comment"] + }, + { + "open": "u\"", + "close": "\"", + "notIn": ["string", "comment"] + }, + { + "open": "U\"", + "close": "\"", + "notIn": ["string", "comment"] + }, + { + "open": "f\"", + "close": "\"", + "notIn": ["string", "comment"] + }, + { + "open": "F\"", + "close": "\"", + "notIn": ["string", "comment"] + }, + { + "open": "b\"", + "close": "\"", + "notIn": ["string", "comment"] + }, + { + "open": "B\"", + "close": "\"", + "notIn": ["string", "comment"] + }, + { + "open": "'", + "close": "'", + "notIn": ["string", "comment"] + }, + { + "open": "r'", + "close": "'", + "notIn": ["string", "comment"] + }, + { + "open": "R'", + "close": "'", + "notIn": ["string", "comment"] + }, + { + "open": "u'", + "close": "'", + "notIn": ["string", "comment"] + }, + { + "open": "U'", + "close": "'", + "notIn": ["string", "comment"] + }, + { + "open": "f'", + "close": "'", + "notIn": ["string", "comment"] + }, + { + "open": "F'", + "close": "'", + "notIn": ["string", "comment"] + }, + { + "open": "b'", + "close": "'", + "notIn": ["string", "comment"] + }, + { + "open": "B'", + "close": "'", + "notIn": ["string", "comment"] + }, + { + "open": "`", + "close": "`", + "notIn": ["string"] + } + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"], + ["`", "`"] + ], + "folding": { + "offSide": true, + "markers": { + "start": "^\\s*#\\s*region\\b", + "end": "^\\s*#\\s*endregion\\b" } } +} diff --git a/example/textmate/langs/python/python.grammar.json b/example/textmate/langs/python/python.grammar.json index d5f1523..f2a216b 100644 --- a/example/textmate/langs/python/python.grammar.json +++ b/example/textmate/langs/python/python.grammar.json @@ -1,5335 +1,5335 @@ { - "information_for_contributors": [ - "This file has been converted from https://github.com/MagicStack/MagicPython/blob/master/grammars/MagicPython.tmLanguage", - "If you want to provide a fix or improvement, please create a pull request against the original repository.", - "Once accepted there, we are happy to receive an update request." - ], - "version": "https://github.com/MagicStack/MagicPython/commit/b4b2e6eb16fee36aea0788bf0aa1853c25f7d276", - "name": "MagicPython", - "scopeName": "source.python", - "patterns": [ - { - "include": "#statement" - }, - { - "include": "#expression" - } - ], - "repository": { - "impossible": { - "comment": "This is a special rule that should be used where no match is desired. It is not a good idea to match something like '1{0}' because in some cases that can result in infinite loops in token generation. So the rule instead matches and impossible expression to allow a match to fail and move to the next token.", - "match": "$.^" - }, - "statement": { - "patterns": [ - { - "include": "#import" - }, - { - "include": "#class-declaration" - }, - { - "include": "#function-declaration" - }, - { - "include": "#generator" - }, - { - "include": "#statement-keyword" - }, - { - "include": "#assignment-operator" + "information_for_contributors": [ + "This file has been converted from https://github.com/MagicStack/MagicPython/blob/master/grammars/MagicPython.tmLanguage", + "If you want to provide a fix or improvement, please create a pull request against the original repository.", + "Once accepted there, we are happy to receive an update request." + ], + "version": "https://github.com/MagicStack/MagicPython/commit/b4b2e6eb16fee36aea0788bf0aa1853c25f7d276", + "name": "MagicPython", + "scopeName": "source.python", + "patterns": [ + { + "include": "#statement" + }, + { + "include": "#expression" + } + ], + "repository": { + "impossible": { + "comment": "This is a special rule that should be used where no match is desired. It is not a good idea to match something like '1{0}' because in some cases that can result in infinite loops in token generation. So the rule instead matches and impossible expression to allow a match to fail and move to the next token.", + "match": "$.^" + }, + "statement": { + "patterns": [ + { + "include": "#import" + }, + { + "include": "#class-declaration" + }, + { + "include": "#function-declaration" + }, + { + "include": "#generator" + }, + { + "include": "#statement-keyword" + }, + { + "include": "#assignment-operator" + }, + { + "include": "#decorator" + }, + { + "include": "#docstring-statement" + }, + { + "include": "#semicolon" + } + ] + }, + "semicolon": { + "patterns": [ + { + "name": "invalid.deprecated.semicolon.python", + "match": "\\;$" + } + ] + }, + "comments": { + "patterns": [ + { + "name": "comment.line.number-sign.python", + "contentName": "meta.typehint.comment.python", + "begin": "(?x)\n (?:\n \\# \\s* (type:)\n \\s*+ (?# we want `\\s*+` which is possessive quantifier since\n we do not actually want to backtrack when matching\n whitespace here)\n (?! $ | \\#)\n )\n", + "end": "(?:$|(?=\\#))", + "beginCaptures": { + "0": { + "name": "meta.typehint.comment.python" + }, + "1": { + "name": "comment.typehint.directive.notation.python" + } }, - { - "include": "#decorator" + "patterns": [ + { + "name": "comment.typehint.ignore.notation.python", + "match": "(?x)\n \\G ignore\n (?= \\s* (?: $ | \\#))\n" + }, + { + "name": "comment.typehint.type.notation.python", + "match": "(?x)\n (?))" + }, + { + "name": "comment.typehint.variable.notation.python", + "match": "([[:alpha:]_]\\w*)" + } + ] + }, + { + "include": "#comments-base" + } + ] + }, + "docstring-statement": { + "begin": "^(?=\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))", + "comment": "the string either terminates correctly or by the beginning of a new line (this is for single line docstrings that aren't terminated) AND it's not followed by another docstring", + "end": "((?<=\\1)|^)(?!\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))", + "patterns": [ + { + "include": "#docstring" + } + ] + }, + "docstring": { + "patterns": [ + { + "name": "string.quoted.docstring.multi.python", + "begin": "(\\'\\'\\'|\\\"\\\"\\\")", + "end": "(\\1)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.string.begin.python" + } }, - { - "include": "#docstring-statement" + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.python" + } }, - { - "include": "#semicolon" - } - ] - }, - "semicolon": { - "patterns": [ - { - "name": "invalid.deprecated.semicolon.python", - "match": "\\;$" - } - ] - }, - "comments": { - "patterns": [ - { - "name": "comment.line.number-sign.python", - "contentName": "meta.typehint.comment.python", - "begin": "(?x)\n (?:\n \\# \\s* (type:)\n \\s*+ (?# we want `\\s*+` which is possessive quantifier since\n we do not actually want to backtrack when matching\n whitespace here)\n (?! $ | \\#)\n )\n", - "end": "(?:$|(?=\\#))", - "beginCaptures": { - "0": { - "name": "meta.typehint.comment.python" - }, - "1": { - "name": "comment.typehint.directive.notation.python" - } + "patterns": [ + { + "include": "#docstring-prompt" }, - "patterns": [ - { - "name": "comment.typehint.ignore.notation.python", - "match": "(?x)\n \\G ignore\n (?= \\s* (?: $ | \\#))\n" - }, - { - "name": "comment.typehint.type.notation.python", - "match": "(?x)\n (?))" - }, - { - "name": "comment.typehint.variable.notation.python", - "match": "([[:alpha:]_]\\w*)" - } - ] - }, - { - "include": "#comments-base" - } - ] - }, - "docstring-statement": { - "begin": "^(?=\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))", - "comment": "the string either terminates correctly or by the beginning of a new line (this is for single line docstrings that aren't terminated) AND it's not followed by another docstring", - "end": "((?<=\\1)|^)(?!\\s*[rR]?(\\'\\'\\'|\\\"\\\"\\\"|\\'|\\\"))", - "patterns": [ - { - "include": "#docstring" - } - ] - }, - "docstring": { - "patterns": [ - { - "name": "string.quoted.docstring.multi.python", - "begin": "(\\'\\'\\'|\\\"\\\"\\\")", - "end": "(\\1)", - "beginCaptures": { - "1": { - "name": "punctuation.definition.string.begin.python" - } + { + "include": "#codetags" }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end.python" - } + { + "include": "#docstring-guts-unicode" + } + ] + }, + { + "name": "string.quoted.docstring.raw.multi.python", + "begin": "([rR])(\\'\\'\\'|\\\"\\\"\\\")", + "end": "(\\2)", + "beginCaptures": { + "1": { + "name": "storage.type.string.python" }, - "patterns": [ - { - "include": "#docstring-prompt" - }, - { - "include": "#codetags" - }, - { - "include": "#docstring-guts-unicode" - } - ] + "2": { + "name": "punctuation.definition.string.begin.python" + } }, - { - "name": "string.quoted.docstring.raw.multi.python", - "begin": "([rR])(\\'\\'\\'|\\\"\\\"\\\")", - "end": "(\\2)", - "beginCaptures": { - "1": { - "name": "storage.type.string.python" - }, - "2": { - "name": "punctuation.definition.string.begin.python" - } + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.python" + } + }, + "patterns": [ + { + "include": "#string-consume-escape" }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end.python" - } + { + "include": "#docstring-prompt" }, - "patterns": [ - { - "include": "#string-consume-escape" - }, - { - "include": "#docstring-prompt" - }, - { - "include": "#codetags" - } - ] + { + "include": "#codetags" + } + ] + }, + { + "name": "string.quoted.docstring.single.python", + "begin": "(\\'|\\\")", + "end": "(\\1)|(\\n)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.string.begin.python" + } }, - { - "name": "string.quoted.docstring.single.python", - "begin": "(\\'|\\\")", - "end": "(\\1)|(\\n)", - "beginCaptures": { - "1": { - "name": "punctuation.definition.string.begin.python" - } + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.python" }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end.python" - }, - "2": { - "name": "invalid.illegal.newline.python" - } - }, - "patterns": [ - { - "include": "#codetags" - }, - { - "include": "#docstring-guts-unicode" - } - ] + "2": { + "name": "invalid.illegal.newline.python" + } }, - { - "name": "string.quoted.docstring.raw.single.python", - "begin": "([rR])(\\'|\\\")", - "end": "(\\2)|(\\n)", - "beginCaptures": { - "1": { - "name": "storage.type.string.python" - }, - "2": { - "name": "punctuation.definition.string.begin.python" - } + "patterns": [ + { + "include": "#codetags" }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end.python" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "include": "#docstring-guts-unicode" + } + ] + }, + { + "name": "string.quoted.docstring.raw.single.python", + "begin": "([rR])(\\'|\\\")", + "end": "(\\2)|(\\n)", + "beginCaptures": { + "1": { + "name": "storage.type.string.python" }, - "patterns": [ - { - "include": "#string-consume-escape" - }, - { - "include": "#codetags" - } - ] - } - ] - }, - "docstring-guts-unicode": { - "patterns": [ - { - "include": "#escape-sequence-unicode" + "2": { + "name": "punctuation.definition.string.begin.python" + } }, - { - "include": "#escape-sequence" + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.python" + }, + "2": { + "name": "invalid.illegal.newline.python" + } }, - { - "include": "#string-line-continuation" - } - ] + "patterns": [ + { + "include": "#string-consume-escape" + }, + { + "include": "#codetags" + } + ] + } + ] + }, + "docstring-guts-unicode": { + "patterns": [ + { + "include": "#escape-sequence-unicode" + }, + { + "include": "#escape-sequence" + }, + { + "include": "#string-line-continuation" + } + ] + }, + "docstring-prompt": { + "match": "(?x)\n (?:\n (?:^|\\G) \\s* (?# '\\G' is necessary for ST)\n ((?:>>>|\\.\\.\\.) \\s) (?=\\s*\\S)\n )\n", + "captures": { + "1": { + "name": "keyword.control.flow.python" + } + } + }, + "statement-keyword": { + "patterns": [ + { + "name": "storage.type.function.python", + "match": "\\b((async\\s+)?\\s*def)\\b" + }, + { + "name": "keyword.control.flow.python", + "comment": "if `as` is eventually followed by `:` or line continuation\nit's probably control flow like:\n with foo as bar, \\\n Foo as Bar:\n try:\n do_stuff()\n except Exception as e:\n pass\n", + "match": "\\b(?>>|\\.\\.\\.) \\s) (?=\\s*\\S)\n )\n", - "captures": { - "1": { - "name": "keyword.control.flow.python" - } + "patterns": [ + { + "include": "#function-call" + }, + { + "include": "#member-access-base" + }, + { + "include": "#member-access-attribute" + } + ] + }, + "member-access-base": { + "patterns": [ + { + "include": "#magic-names" + }, + { + "include": "#illegal-names" + }, + { + "include": "#illegal-object-name" + }, + { + "include": "#special-names" + }, + { + "include": "#line-continuation" + }, + { + "include": "#item-access" + } + ] + }, + "member-access-attribute": { + "comment": "Highlight attribute access in otherwise non-specialized cases.", + "name": "meta.attribute.python", + "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n" + }, + "special-names": { + "name": "constant.other.caps.python", + "match": "(?x)\n \\b\n # we want to see \"enough\", meaning 2 or more upper-case\n # letters in the beginning of the constant\n #\n # for more details refer to:\n # https://github.com/MagicStack/MagicPython/issues/42\n (\n _* [[:upper:]] [_\\d]* [[:upper:]]\n )\n [[:upper:]\\d]* (_\\w*)?\n \\b\n" + }, + "curly-braces": { + "begin": "\\{", + "end": "\\}", + "beginCaptures": { + "0": { + "name": "punctuation.definition.dict.begin.python" } }, - "statement-keyword": { - "patterns": [ - { - "name": "storage.type.function.python", - "match": "\\b((async\\s+)?\\s*def)\\b" - }, - { - "name": "keyword.control.flow.python", - "comment": "if `as` is eventually followed by `:` or line continuation\nit's probably control flow like:\n with foo as bar, \\\n Foo as Bar:\n try:\n do_stuff()\n except Exception as e:\n pass\n", - "match": "\\b(?>= | //= | \\*\\*=\n | \\+= | -= | /= | @=\n | \\*= | %= | ~= | \\^= | &= | \\|=\n | =(?!=)\n" + }, + "operator": { + "match": "(?x)\n \\b(?> | & | \\| | \\^ | ~) (?# 3)\n\n | (\\*\\* | \\* | \\+ | - | % | // | / | @) (?# 4)\n\n | (!= | == | >= | <= | < | >) (?# 5)\n", + "captures": { + "1": { + "name": "keyword.operator.logical.python" + }, + "2": { + "name": "keyword.control.flow.python" + }, + "3": { + "name": "keyword.operator.bitwise.python" + }, + "4": { + "name": "keyword.operator.arithmetic.python" + }, + "5": { + "name": "keyword.operator.comparison.python" + } + } + }, + "punctuation": { + "patterns": [ + { + "name": "punctuation.separator.colon.python", + "match": ":" + }, + { + "name": "punctuation.separator.element.python", + "match": "," + } + ] + }, + "literal": { + "patterns": [ + { + "name": "constant.language.python", + "match": "\\b(True|False|None|NotImplemented|Ellipsis)\\b" + }, + { + "include": "#number" + } + ] + }, + "number": { + "name": "constant.numeric.python", + "patterns": [ + { + "include": "#number-float" }, - "endCaptures": { - "0": { - "name": "punctuation.definition.dict.end.python" - } + { + "include": "#number-dec" }, - "patterns": [ - { - "name": "punctuation.separator.dict.python", - "match": ":" - }, - { - "include": "#expression" - } - ] - }, - "list": { - "begin": "\\[", - "end": "\\]", - "beginCaptures": { - "0": { - "name": "punctuation.definition.list.begin.python" - } + { + "include": "#number-hex" }, - "endCaptures": { - "0": { - "name": "punctuation.definition.list.end.python" - } + { + "include": "#number-oct" }, - "patterns": [ - { - "include": "#expression" - } - ] - }, - "odd-function-call": { - "comment": "A bit obscured function call where there may have been an\narbitrary number of other operations to get the function.\nE.g. \"arr[idx](args)\"\n", - "begin": "(?x)\n (?<= \\] | \\) ) \\s*\n (?=\\()\n", - "end": "(\\))", - "endCaptures": { - "1": { - "name": "punctuation.definition.arguments.end.python" - } + { + "include": "#number-bin" }, - "patterns": [ - { - "include": "#function-arguments" - } - ] - }, - "round-braces": { - "begin": "\\(", - "end": "\\)", - "beginCaptures": { - "0": { - "name": "punctuation.parenthesis.begin.python" - } + { + "include": "#number-long" + }, + { + "name": "invalid.illegal.name.python", + "match": "\\b[0-9]+\\w+" + } + ] + }, + "number-float": { + "name": "constant.numeric.float.python", + "match": "(?x)\n (?=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )?\n })\n )\n", + "captures": { + "1": { + "name": "constant.character.format.placeholder.other.python" + }, + "3": { + "name": "storage.type.format.python" + }, + "4": { + "name": "storage.type.format.python" + } } }, - "patterns": [ - { - "include": "#expression" + { + "name": "meta.format.brace.python", + "match": "(?x)\n (\n {\n \\w* (\\.[[:alpha:]_]\\w* | \\[[^\\]'\"]+\\])*\n (![rsa])?\n (:)\n [^'\"{}\\n]* (?:\n \\{ [^'\"}\\n]*? \\} [^'\"{}\\n]*\n )*\n }\n )\n", + "captures": { + "1": { + "name": "constant.character.format.placeholder.other.python" + }, + "3": { + "name": "storage.type.format.python" + }, + "4": { + "name": "storage.type.format.python" + } } - ] - }, - "line-continuation": { - "patterns": [ - { - "match": "(\\\\)\\s*(\\S.*$\\n?)", - "captures": { - "1": { - "name": "punctuation.separator.continuation.line.python" - }, - "2": { - "name": "invalid.illegal.line.continuation.python" - } + } + ] + }, + "fstring-formatting": { + "patterns": [ + { + "include": "#fstring-formatting-braces" + }, + { + "include": "#fstring-formatting-singe-brace" + } + ] + }, + "fstring-formatting-singe-brace": { + "name": "invalid.illegal.brace.python", + "match": "(}(?!}))" + }, + "import": { + "comment": "Import statements used to correctly mark `from`, `import`, and `as`\n", + "patterns": [ + { + "begin": "\\b(?>= | //= | \\*\\*=\n | \\+= | -= | /= | @=\n | \\*= | %= | ~= | \\^= | &= | \\|=\n | =(?!=)\n" - }, - "operator": { - "match": "(?x)\n \\b(?> | & | \\| | \\^ | ~) (?# 3)\n\n | (\\*\\* | \\* | \\+ | - | % | // | / | @) (?# 4)\n\n | (!= | == | >= | <= | < | >) (?# 5)\n", - "captures": { - "1": { - "name": "keyword.operator.logical.python" - }, - "2": { - "name": "keyword.control.flow.python" + { + "include": "#expression" + } + ] + }, + { + "begin": "\\b(?)", + "end": "(?=:)", + "beginCaptures": { + "1": { + "name": "punctuation.separator.annotation.result.python" + } }, - "string-raw-bin-guts": { - "patterns": [ - { - "include": "#string-consume-escape" + "patterns": [ + { + "include": "#expression" + } + ] + }, + "item-access": { + "patterns": [ + { + "name": "meta.item-access.python", + "begin": "(?x)\n \\b(?=\n [[:alpha:]_]\\w* \\s* \\[\n )\n", + "end": "(\\])", + "endCaptures": { + "1": { + "name": "punctuation.definition.arguments.end.python" + } }, - { - "include": "#string-formatting" - } - ] + "patterns": [ + { + "include": "#item-name" + }, + { + "include": "#item-index" + }, + { + "include": "#expression" + } + ] + } + ] + }, + "item-name": { + "patterns": [ + { + "include": "#special-variables" + }, + { + "include": "#builtin-functions" + }, + { + "include": "#special-names" + }, + { + "name": "meta.indexed-name.python", + "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n" + } + ] + }, + "item-index": { + "begin": "(\\[)", + "end": "(?=\\])", + "beginCaptures": { + "1": { + "name": "punctuation.definition.arguments.begin.python" + } }, - "string-entity": { - "patterns": [ - { - "include": "#escape-sequence" - }, - { - "include": "#string-line-continuation" - }, - { - "include": "#string-formatting" - } - ] + "contentName": "meta.item-access.arguments.python", + "patterns": [ + { + "name": "punctuation.separator.slice.python", + "match": ":" + }, + { + "include": "#expression" + } + ] + }, + "decorator": { + "name": "meta.function.decorator.python", + "begin": "(?x)\n ^\\s*\n ((@)) \\s* (?=[[:alpha:]_]\\w*)\n", + "end": "(?x)\n ( \\) )\n # trailing whitespace and comments are legal\n (?: (.*?) (?=\\s*(?:\\#|$)) )\n | (?=\\n|\\#)\n", + "beginCaptures": { + "1": { + "name": "entity.name.function.decorator.python" + }, + "2": { + "name": "punctuation.definition.decorator.python" + } }, - "fstring-guts": { - "patterns": [ - { - "include": "#escape-sequence-unicode" - }, - { - "include": "#escape-sequence" - }, - { - "include": "#string-line-continuation" - }, - { - "include": "#fstring-formatting" - } - ] + "endCaptures": { + "1": { + "name": "punctuation.definition.arguments.end.python" + }, + "2": { + "name": "invalid.illegal.decorator.python" + } }, - "fstring-raw-guts": { - "patterns": [ - { - "include": "#string-consume-escape" - }, - { - "include": "#fstring-formatting" - } - ] - }, - "fstring-illegal-single-brace": { - "comment": "it is illegal to have a multiline brace inside a single-line string", - "begin": "(\\{)(?=[^\\n}]*$\\n?)", - "end": "(\\})|(?=\\n)", - "beginCaptures": { - "1": { - "name": "constant.character.format.placeholder.other.python" - } + "patterns": [ + { + "include": "#decorator-name" }, - "endCaptures": { - "1": { - "name": "constant.character.format.placeholder.other.python" + { + "include": "#function-arguments" + } + ] + }, + "decorator-name": { + "patterns": [ + { + "include": "#builtin-callables" + }, + { + "include": "#illegal-object-name" + }, + { + "name": "entity.name.function.decorator.python", + "match": "(?x)\n ([[:alpha:]_]\\w*) | (\\.)\n", + "captures": { + "2": { + "name": "punctuation.separator.period.python" + } } }, - "patterns": [ - { - "include": "#fstring-terminator-single" - }, - { - "include": "#f-expression" - } - ] - }, - "fstring-illegal-multi-brace": { - "patterns": [ - { - "include": "#impossible" + { + "include": "#line-continuation" + }, + { + "name": "invalid.illegal.decorator.python", + "match": "(?x)\n \\s* ([^([:alpha:]\\s_\\.#\\\\] .*?) (?=\\#|$)\n", + "captures": { + "1": { + "name": "invalid.illegal.decorator.python" + } } - ] + } + ] + }, + "call-wrapper-inheritance": { + "comment": "same as a function call, but in inheritance context", + "name": "meta.function-call.python", + "begin": "(?x)\n \\b(?=\n ([[:alpha:]_]\\w*) \\s* (\\()\n )\n", + "end": "(\\))", + "endCaptures": { + "1": { + "name": "punctuation.definition.arguments.end.python" + } }, - "f-expression": { - "comment": "All valid Python expressions, except comments and line continuation", - "patterns": [ - { - "include": "#expression-bare" - }, - { - "include": "#member-access" - }, - { - "comment": "Tokenize identifiers to help linters", - "match": "(?x) \\b ([[:alpha:]_]\\w*) \\b" - } - ] + "patterns": [ + { + "include": "#inheritance-name" + }, + { + "include": "#function-arguments" + } + ] + }, + "inheritance-name": { + "patterns": [ + { + "include": "#lambda-incomplete" + }, + { + "include": "#builtin-possible-callables" + }, + { + "include": "#inheritance-identifier" + } + ] + }, + "function-call": { + "name": "meta.function-call.python", + "comment": "Regular function call of the type \"name(args)\"", + "begin": "(?x)\n \\b(?=\n ([[:alpha:]_]\\w*) \\s* (\\()\n )\n", + "end": "(\\))", + "endCaptures": { + "1": { + "name": "punctuation.definition.arguments.end.python" + } }, - "escape-sequence-unicode": { - "patterns": [ - { - "name": "constant.character.escape.python", - "match": "(?x)\n \\\\ (\n u[0-9A-Fa-f]{4}\n | U[0-9A-Fa-f]{8}\n | N\\{[\\w\\s]+?\\}\n )\n" - } - ] - }, - "escape-sequence": { - "name": "constant.character.escape.python", - "match": "(?x)\n \\\\ (\n x[0-9A-Fa-f]{2}\n | [0-7]{1,3}\n | [\\\\\"'abfnrtv]\n )\n" - }, - "string-line-continuation": { - "name": "constant.language.python", - "match": "\\\\$" - }, - "string-formatting": { - "name": "meta.format.percent.python", - "match": "(?x)\n (\n % (\\([\\w\\s]*\\))?\n [-+#0 ]*\n (\\d+|\\*)? (\\.(\\d+|\\*))?\n ([hlL])?\n [diouxXeEfFgGcrsab%]\n )\n", - "captures": { - "1": { - "name": "constant.character.format.placeholder.other.python" - } + "patterns": [ + { + "include": "#special-variables" + }, + { + "include": "#function-name" + }, + { + "include": "#function-arguments" + } + ] + }, + "function-name": { + "patterns": [ + { + "include": "#builtin-possible-callables" + }, + { + "comment": "Some color schemas support meta.function-call.generic scope", + "name": "meta.function-call.generic.python", + "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n" + } + ] + }, + "function-arguments": { + "begin": "(\\()", + "end": "(?=\\))(?!\\)\\s*\\()", + "beginCaptures": { + "1": { + "name": "punctuation.definition.arguments.begin.python" } }, - "string-brace-formatting": { - "patterns": [ - { - "name": "meta.format.brace.python", - "match": "(?x)\n (\n {{ | }}\n | (?:\n {\n \\w* (\\.[[:alpha:]_]\\w* | \\[[^\\]'\"]+\\])*\n (![rsa])?\n ( : \\w? [<>=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )?\n })\n )\n", - "captures": { - "1": { - "name": "constant.character.format.placeholder.other.python" - }, - "3": { - "name": "storage.type.format.python" - }, - "4": { - "name": "storage.type.format.python" - } - } - }, - { - "name": "meta.format.brace.python", - "match": "(?x)\n (\n {\n \\w* (\\.[[:alpha:]_]\\w* | \\[[^\\]'\"]+\\])*\n (![rsa])?\n (:)\n [^'\"{}\\n]* (?:\n \\{ [^'\"}\\n]*? \\} [^'\"{}\\n]*\n )*\n }\n )\n", - "captures": { - "1": { - "name": "constant.character.format.placeholder.other.python" - }, - "3": { - "name": "storage.type.format.python" - }, - "4": { - "name": "storage.type.format.python" - } + "contentName": "meta.function-call.arguments.python", + "patterns": [ + { + "name": "punctuation.separator.arguments.python", + "match": "(,)" + }, + { + "match": "(?x)\n (?:(?<=[,(])|^) \\s* (\\*{1,2})\n", + "captures": { + "1": { + "name": "keyword.operator.unpacking.arguments.python" } } - ] - }, - "fstring-formatting": { - "patterns": [ - { - "include": "#fstring-formatting-braces" - }, - { - "include": "#fstring-formatting-singe-brace" - } - ] - }, - "fstring-formatting-singe-brace": { - "name": "invalid.illegal.brace.python", - "match": "(}(?!}))" - }, - "import": { - "comment": "Import statements used to correctly mark `from`, `import`, and `as`\n", - "patterns": [ - { - "begin": "\\b(?" + }, + "regexp-base-expression": { + "patterns": [ + { + "include": "#regexp-quantifier" + }, + { + "include": "#regexp-base-common" + } + ] + }, + "fregexp-base-expression": { + "patterns": [ + { + "include": "#fregexp-quantifier" + }, + { + "include": "#fstring-formatting-braces" + }, + { + "match": "\\{.*?\\}" + }, + { + "include": "#regexp-base-common" + } + ] + }, + "fstring-formatting-braces": { + "patterns": [ + { + "comment": "empty braces are illegal", + "match": "({)(\\s*?)(})", + "captures": { + "1": { + "name": "constant.character.format.placeholder.other.python" }, - "endCaptures": { - "1": { - "name": "punctuation.section.class.begin.python" - } + "2": { + "name": "invalid.illegal.brace.python" }, - "patterns": [ - { - "include": "#class-name" - }, - { - "include": "#class-inheritance" - } - ] - } - ] - }, - "class-name": { - "patterns": [ - { - "include": "#illegal-object-name" - }, - { - "include": "#builtin-possible-callables" - }, - { - "name": "entity.name.type.class.python", - "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n" - } - ] - }, - "class-inheritance": { - "name": "meta.class.inheritance.python", - "begin": "(\\()", - "end": "(\\))", - "beginCaptures": { - "1": { - "name": "punctuation.definition.inheritance.begin.python" + "3": { + "name": "constant.character.format.placeholder.other.python" + } } }, - "endCaptures": { - "1": { - "name": "punctuation.definition.inheritance.end.python" - } + { + "name": "constant.character.escape.python", + "match": "({{|}})" + } + ] + }, + "regexp-base-common": { + "patterns": [ + { + "name": "support.other.match.any.regexp", + "match": "\\." + }, + { + "name": "support.other.match.begin.regexp", + "match": "\\^" + }, + { + "name": "support.other.match.end.regexp", + "match": "\\$" + }, + { + "name": "keyword.operator.quantifier.regexp", + "match": "[+*?]\\??" + }, + { + "name": "keyword.operator.disjunction.regexp", + "match": "\\|" + }, + { + "include": "#regexp-escape-sequence" + } + ] + }, + "regexp-quantifier": { + "name": "keyword.operator.quantifier.regexp", + "match": "(?x)\n \\{(\n \\d+ | \\d+,(\\d+)? | ,\\d+\n )\\}\n" + }, + "fregexp-quantifier": { + "name": "keyword.operator.quantifier.regexp", + "match": "(?x)\n \\{\\{(\n \\d+ | \\d+,(\\d+)? | ,\\d+\n )\\}\\}\n" + }, + "regexp-backreference-number": { + "name": "meta.backreference.regexp", + "match": "(\\\\[1-9]\\d?)", + "captures": { + "1": { + "name": "entity.name.tag.backreference.regexp" + } + } + }, + "regexp-backreference": { + "name": "meta.backreference.named.regexp", + "match": "(?x)\n (\\() (\\?P= \\w+(?:\\s+[[:alnum:]]+)?) (\\))\n", + "captures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.backreference.named.begin.regexp" + }, + "2": { + "name": "entity.name.tag.named.backreference.regexp" + }, + "3": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.backreference.named.end.regexp" + } + } + }, + "regexp-flags": { + "name": "storage.modifier.flag.regexp", + "match": "\\(\\?[aiLmsux]+\\)" + }, + "regexp-escape-special": { + "name": "support.other.escape.special.regexp", + "match": "\\\\([AbBdDsSwWZ])" + }, + "regexp-escape-character": { + "name": "constant.character.escape.regexp", + "match": "(?x)\n \\\\ (\n x[0-9A-Fa-f]{2}\n | 0[0-7]{1,2}\n | [0-7]{3}\n )\n" + }, + "regexp-escape-unicode": { + "name": "constant.character.unicode.regexp", + "match": "(?x)\n \\\\ (\n u[0-9A-Fa-f]{4}\n | U[0-9A-Fa-f]{8}\n )\n" + }, + "regexp-escape-catchall": { + "name": "constant.character.escape.regexp", + "match": "\\\\(.|\\n)" + }, + "regexp-escape-sequence": { + "patterns": [ + { + "include": "#regexp-escape-special" + }, + { + "include": "#regexp-escape-character" + }, + { + "include": "#regexp-escape-unicode" + }, + { + "include": "#regexp-backreference-number" + }, + { + "include": "#regexp-escape-catchall" + } + ] + }, + "regexp-charecter-set-escapes": { + "patterns": [ + { + "name": "constant.character.escape.regexp", + "match": "\\\\[abfnrtv\\\\]" }, - "patterns": [ - { - "name": "keyword.operator.unpacking.arguments.python", - "match": "(\\*\\*|\\*)" - }, - { - "name": "punctuation.separator.inheritance.python", - "match": "," - }, - { - "name": "keyword.operator.assignment.python", - "match": "=(?!=)" - }, - { - "name": "support.type.metaclass.python", - "match": "\\bmetaclass\\b" - }, - { - "include": "#illegal-names" - }, - { - "include": "#class-kwarg" - }, - { - "include": "#call-wrapper-inheritance" - }, - { - "include": "#expression-base" - }, - { - "include": "#member-access-class" - }, - { - "include": "#inheritance-identifier" - } - ] + { + "include": "#regexp-escape-special" + }, + { + "name": "constant.character.escape.regexp", + "match": "\\\\([0-7]{1,3})" + }, + { + "include": "#regexp-escape-character" + }, + { + "include": "#regexp-escape-unicode" + }, + { + "include": "#regexp-escape-catchall" + } + ] + }, + "codetags": { + "match": "(?:\\b(NOTE|XXX|HACK|FIXME|BUG|TODO)\\b)", + "captures": { + "1": { + "name": "keyword.codetag.notation.python" + } + } + }, + "comments-base": { + "name": "comment.line.number-sign.python", + "begin": "(\\#)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.comment.python" + } }, - "class-kwarg": { - "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\s*(=)(?!=)\n", - "captures": { - "1": { - "name": "entity.other.inherited-class.python variable.parameter.class.python" - }, - "2": { - "name": "keyword.operator.assignment.python" - } + "end": "($)", + "patterns": [ + { + "include": "#codetags" + } + ] + }, + "comments-string-single-three": { + "name": "comment.line.number-sign.python", + "begin": "(\\#)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.comment.python" } }, - "inheritance-identifier": { - "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n", - "captures": { - "1": { - "name": "entity.other.inherited-class.python" - } + "end": "($|(?='''))", + "patterns": [ + { + "include": "#codetags" + } + ] + }, + "comments-string-double-three": { + "name": "comment.line.number-sign.python", + "begin": "(\\#)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.comment.python" } }, - "member-access-class": { - "name": "meta.member.access.python", - "begin": "(\\.)\\s*(?!\\.)", - "end": "(?<=\\S)(?=\\W)|$", - "beginCaptures": { - "1": { - "name": "punctuation.separator.period.python" - } + "end": "($|(?=\"\"\"))", + "patterns": [ + { + "include": "#codetags" + } + ] + }, + "single-one-regexp-expression": { + "patterns": [ + { + "include": "#regexp-base-expression" }, - "patterns": [ - { - "include": "#call-wrapper-inheritance" - }, - { - "include": "#member-access-base" - }, - { - "include": "#inheritance-identifier" - } - ] - }, - "lambda": { - "patterns": [ - { - "match": "((?<=\\.)lambda|lambda(?=\\s*[\\.=]))", - "captures": { - "1": { - "name": "keyword.control.flow.python" - } - } - }, - { - "match": "\\b(lambda)\\s*?(?=[,\\n]|$)", - "captures": { - "1": { - "name": "storage.type.function.lambda.python" - } - } - }, - { - "name": "meta.lambda-function.python", - "begin": "(?x)\n \\b (lambda) \\b\n", - "end": "(:)|(\\n)", - "beginCaptures": { - "1": { - "name": "storage.type.function.lambda.python" - } - }, - "endCaptures": { - "1": { - "name": "punctuation.section.function.lambda.begin.python" - } - }, - "contentName": "meta.function.lambda.parameters.python", - "patterns": [ - { - "name": "keyword.operator.unpacking.parameter.python", - "match": "(\\*\\*|\\*)" - }, - { - "include": "#lambda-nested-incomplete" - }, - { - "include": "#illegal-names" - }, - { - "match": "([[:alpha:]_]\\w*)\\s*(?:(,)|(?=:|$))", - "captures": { - "1": { - "name": "variable.parameter.function.language.python" - }, - "2": { - "name": "punctuation.separator.parameters.python" - } - } - }, - { - "include": "#comments" - }, - { - "include": "#backticks" - }, - { - "include": "#illegal-anno" - }, - { - "include": "#lambda-parameter-with-default" - }, - { - "include": "#line-continuation" - }, - { - "include": "#illegal-operator" - } - ] - } - ] - }, - "lambda-incomplete": { - "name": "storage.type.function.lambda.python", - "match": "\\blambda(?=\\s*[,)])" - }, - "lambda-nested-incomplete": { - "name": "storage.type.function.lambda.python", - "match": "\\blambda(?=\\s*[:,)])" - }, - "lambda-parameter-with-default": { - "begin": "(?x)\n \\b\n ([[:alpha:]_]\\w*) \\s* (=)\n", - "end": "(,)|(?=:|$)", - "beginCaptures": { - "1": { - "name": "variable.parameter.function.language.python" - }, - "2": { - "name": "keyword.operator.python" - } + { + "include": "#single-one-regexp-character-set" }, - "endCaptures": { - "1": { - "name": "punctuation.separator.parameters.python" - } + { + "include": "#single-one-regexp-comments" }, - "patterns": [ - { - "include": "#expression" - } - ] - }, - "generator": { - "comment": "Match \"for ... in\" construct used in generators and for loops to\ncorrectly identify the \"in\" as a control flow keyword.\n", - "begin": "\\bfor\\b", - "beginCaptures": { - "0": { - "name": "keyword.control.flow.python" - } + { + "include": "#regexp-flags" }, - "end": "\\bin\\b", - "endCaptures": { - "0": { - "name": "keyword.control.flow.python" - } + { + "include": "#single-one-regexp-named-group" }, - "patterns": [ - { - "include": "#expression" - } - ] - }, - "function-declaration": { - "name": "meta.function.python", - "begin": "(?x)\n \\s*\n (?:\\b(async) \\s+)? \\b(def)\\s+\n (?=\n [[:alpha:]_][[:word:]]* \\s* \\(\n )\n", - "end": "(:|(?=[#'\"\\n]))", - "beginCaptures": { - "1": { - "name": "storage.type.function.async.python" - }, - "2": { - "name": "storage.type.function.python" - } + { + "include": "#regexp-backreference" }, - "endCaptures": { - "1": { - "name": "punctuation.section.function.begin.python" - } + { + "include": "#single-one-regexp-lookahead" }, - "patterns": [ - { - "include": "#function-def-name" - }, - { - "include": "#parameters" - }, - { - "include": "#line-continuation" - }, - { - "include": "#return-annotation" - } - ] - }, - "function-def-name": { - "patterns": [ - { - "include": "#illegal-object-name" - }, - { - "include": "#builtin-possible-callables" - }, - { - "name": "entity.name.function.python", - "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n" - } - ] - }, - "parameters": { - "name": "meta.function.parameters.python", - "begin": "(\\()", - "end": "(\\))", - "beginCaptures": { - "1": { - "name": "punctuation.definition.parameters.begin.python" - } + { + "include": "#single-one-regexp-lookahead-negative" }, - "endCaptures": { - "1": { - "name": "punctuation.definition.parameters.end.python" - } + { + "include": "#single-one-regexp-lookbehind" }, - "patterns": [ - { - "name": "keyword.operator.unpacking.parameter.python", - "match": "(\\*\\*|\\*)" - }, - { - "include": "#lambda-incomplete" - }, - { - "include": "#illegal-names" - }, - { - "include": "#illegal-object-name" - }, - { - "include": "#parameter-special" - }, - { - "match": "(?x)\n ([[:alpha:]_]\\w*)\n \\s* (?: (,) | (?=[)#\\n=]))\n", - "captures": { - "1": { - "name": "variable.parameter.function.language.python" - }, - "2": { - "name": "punctuation.separator.parameters.python" - } + { + "include": "#single-one-regexp-lookbehind-negative" + }, + { + "include": "#single-one-regexp-conditional" + }, + { + "include": "#single-one-regexp-parentheses-non-capturing" + }, + { + "include": "#single-one-regexp-parentheses" + } + ] + }, + "single-one-regexp-character-set": { + "patterns": [ + { + "match": "(?x)\n \\[ \\^? \\] (?! .*?\\])\n" + }, + { + "name": "meta.character.set.regexp", + "begin": "(\\[)(\\^)?(\\])?", + "end": "(\\]|(?=\\'))|((?=(?)\n", + "end": "(\\)|(?=\\'))|((?=(?)", - "end": "(?=:)", - "beginCaptures": { - "1": { - "name": "punctuation.separator.annotation.result.python" - } + "2": { + "name": "invalid.illegal.newline.python" + } + }, + "patterns": [ + { + "include": "#single-one-regexp-expression" + } + ] + }, + "single-one-regexp-lookbehind-negative": { + "begin": "(\\()\\?)\n", + "end": "(\\)|(?=\\'\\'\\'))", + "beginCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp" + }, + "2": { + "name": "entity.name.tag.named.group.regexp" + } + }, + "endCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp" }, - "patterns": [ - { - "include": "#inheritance-name" - }, - { - "include": "#function-arguments" - } - ] + "2": { + "name": "invalid.illegal.newline.python" + } }, - "inheritance-name": { - "patterns": [ - { - "include": "#lambda-incomplete" - }, - { - "include": "#builtin-possible-callables" - }, - { - "include": "#inheritance-identifier" - } - ] - }, - "function-call": { - "name": "meta.function-call.python", - "comment": "Regular function call of the type \"name(args)\"", - "begin": "(?x)\n \\b(?=\n ([[:alpha:]_]\\w*) \\s* (\\()\n )\n", - "end": "(\\))", - "endCaptures": { - "1": { - "name": "punctuation.definition.arguments.end.python" - } + "patterns": [ + { + "include": "#single-three-regexp-expression" }, - "patterns": [ - { - "include": "#special-variables" - }, - { - "include": "#function-name" - }, - { - "include": "#function-arguments" - } - ] + { + "include": "#comments-string-single-three" + } + ] + }, + "single-three-regexp-comments": { + "name": "comment.regexp", + "begin": "\\(\\?#", + "end": "(\\)|(?=\\'\\'\\'))", + "beginCaptures": { + "0": { + "name": "punctuation.comment.begin.regexp" + } }, - "function-name": { - "patterns": [ - { - "include": "#builtin-possible-callables" - }, - { - "comment": "Some color schemas support meta.function-call.generic scope", - "name": "meta.function-call.generic.python", - "match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n" - } - ] - }, - "function-arguments": { - "begin": "(\\()", - "end": "(?=\\))(?!\\)\\s*\\()", - "beginCaptures": { - "1": { - "name": "punctuation.definition.arguments.begin.python" - } + "endCaptures": { + "1": { + "name": "punctuation.comment.end.regexp" }, - "contentName": "meta.function-call.arguments.python", - "patterns": [ - { - "name": "punctuation.separator.arguments.python", - "match": "(,)" - }, - { - "match": "(?x)\n (?:(?<=[,(])|^) \\s* (\\*{1,2})\n", - "captures": { - "1": { - "name": "keyword.operator.unpacking.arguments.python" - } - } - }, - { - "include": "#lambda-incomplete" - }, - { - "include": "#illegal-names" - }, - { - "match": "\\b([[:alpha:]_]\\w*)\\s*(=)(?!=)", - "captures": { - "1": { - "name": "variable.parameter.function-call.python" - }, - "2": { - "name": "keyword.operator.assignment.python" - } - } - }, - { - "name": "keyword.operator.assignment.python", - "match": "=(?!=)" - }, - { - "include": "#expression" - }, - { - "match": "\\s*(\\))\\s*(\\()", - "captures": { - "1": { - "name": "punctuation.definition.arguments.end.python" - }, - "2": { - "name": "punctuation.definition.arguments.begin.python" - } - } - } - ] + "2": { + "name": "invalid.illegal.newline.python" + } }, - "builtin-callables": { - "patterns": [ - { - "include": "#illegal-names" - }, - { - "include": "#illegal-object-name" - }, - { - "include": "#builtin-exceptions" - }, - { - "include": "#builtin-functions" - }, - { - "include": "#builtin-types" - } - ] + "patterns": [ + { + "include": "#codetags" + } + ] + }, + "single-three-regexp-lookahead": { + "begin": "(\\()\\?=", + "end": "(\\)|(?=\\'\\'\\'))", + "beginCaptures": { + "0": { + "name": "keyword.operator.lookahead.regexp" + }, + "1": { + "name": "punctuation.parenthesis.lookahead.begin.regexp" + } }, - "builtin-possible-callables": { - "patterns": [ - { - "include": "#builtin-callables" - }, - { - "include": "#magic-names" - } - ] + "endCaptures": { + "1": { + "name": "keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp" + }, + "2": { + "name": "invalid.illegal.newline.python" + } }, - "builtin-exceptions": { - "name": "support.type.exception.python", - "match": "(?x) (?" + "patterns": [ + { + "include": "#single-three-regexp-expression" + }, + { + "include": "#comments-string-single-three" + } + ] + }, + "single-three-regexp-parentheses": { + "begin": "\\(", + "end": "(\\)|(?=\\'\\'\\'))", + "beginCaptures": { + "0": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp" + } }, - "regexp-base-expression": { - "patterns": [ - { - "include": "#regexp-quantifier" - }, - { - "include": "#regexp-base-common" - } - ] + "endCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.end.regexp" + }, + "2": { + "name": "invalid.illegal.newline.python" + } }, - "fregexp-base-expression": { - "patterns": [ - { - "include": "#fregexp-quantifier" - }, - { - "include": "#fstring-formatting-braces" - }, - { - "match": "\\{.*?\\}" + "patterns": [ + { + "include": "#single-three-regexp-expression" + }, + { + "include": "#comments-string-single-three" + } + ] + }, + "double-one-regexp-expression": { + "patterns": [ + { + "include": "#regexp-base-expression" + }, + { + "include": "#double-one-regexp-character-set" + }, + { + "include": "#double-one-regexp-comments" + }, + { + "include": "#regexp-flags" + }, + { + "include": "#double-one-regexp-named-group" + }, + { + "include": "#regexp-backreference" + }, + { + "include": "#double-one-regexp-lookahead" + }, + { + "include": "#double-one-regexp-lookahead-negative" + }, + { + "include": "#double-one-regexp-lookbehind" + }, + { + "include": "#double-one-regexp-lookbehind-negative" + }, + { + "include": "#double-one-regexp-conditional" + }, + { + "include": "#double-one-regexp-parentheses-non-capturing" + }, + { + "include": "#double-one-regexp-parentheses" + } + ] + }, + "double-one-regexp-character-set": { + "patterns": [ + { + "match": "(?x)\n \\[ \\^? \\] (?! .*?\\])\n" + }, + { + "name": "meta.character.set.regexp", + "begin": "(\\[)(\\^)?(\\])?", + "end": "(\\]|(?=\"))|((?=(?)\n", + "end": "(\\)|(?=\"))|((?=(?)\n", - "end": "(\\)|(?=\\'))|((?=(?)\n", + "end": "(\\)|(?=\"\"\"))", + "beginCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp" + }, + "2": { + "name": "entity.name.tag.named.group.regexp" + } + }, + "endCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp" }, - "endCaptures": { - "1": { - "name": "keyword.operator.lookbehind.regexp punctuation.parenthesis.lookbehind.end.regexp" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + "2": { + "name": "invalid.illegal.newline.python" + } + }, + "patterns": [ + { + "include": "#double-three-regexp-expression" }, - "patterns": [ - { - "include": "#single-one-regexp-expression" - } - ] - }, - "single-one-regexp-lookbehind-negative": { - "begin": "(\\()\\?)\n", - "end": "(\\)|(?=\\'\\'\\'))", - "beginCaptures": { - "1": { - "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp" - }, - "2": { - "name": "entity.name.tag.named.group.regexp" - } + "endCaptures": { + "1": { + "name": "keyword.operator.conditional.negative.regexp punctuation.parenthesis.conditional.end.regexp" }, - "endCaptures": { - "1": { - "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + "2": { + "name": "invalid.illegal.newline.python" + } + }, + "patterns": [ + { + "include": "#double-three-regexp-expression" }, - "patterns": [ - { - "include": "#single-three-regexp-expression" - }, - { - "include": "#comments-string-single-three" - } - ] - }, - "single-three-regexp-comments": { - "name": "comment.regexp", - "begin": "\\(\\?#", - "end": "(\\)|(?=\\'\\'\\'))", - "beginCaptures": { - "0": { - "name": "punctuation.comment.begin.regexp" - } + { + "include": "#comments-string-double-three" + } + ] + }, + "double-three-regexp-parentheses-non-capturing": { + "begin": "\\(\\?:", + "end": "(\\)|(?=\"\"\"))", + "beginCaptures": { + "0": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp" + } + }, + "endCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp" }, - "endCaptures": { - "1": { - "name": "punctuation.comment.end.regexp" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + "2": { + "name": "invalid.illegal.newline.python" + } + }, + "patterns": [ + { + "include": "#double-three-regexp-expression" }, - "patterns": [ - { - "include": "#codetags" - } - ] - }, - "single-three-regexp-lookahead": { - "begin": "(\\()\\?=", - "end": "(\\)|(?=\\'\\'\\'))", - "beginCaptures": { - "0": { - "name": "keyword.operator.lookahead.regexp" - }, - "1": { - "name": "punctuation.parenthesis.lookahead.begin.regexp" - } + { + "include": "#comments-string-double-three" + } + ] + }, + "double-three-regexp-parentheses": { + "begin": "\\(", + "end": "(\\)|(?=\"\"\"))", + "beginCaptures": { + "0": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp" + } + }, + "endCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.end.regexp" }, - "endCaptures": { - "1": { - "name": "keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + "2": { + "name": "invalid.illegal.newline.python" + } + }, + "patterns": [ + { + "include": "#double-three-regexp-expression" }, - "patterns": [ - { - "include": "#single-three-regexp-expression" - }, - { - "include": "#comments-string-single-three" - } - ] - }, - "single-three-regexp-lookahead-negative": { - "begin": "(\\()\\?!", - "end": "(\\)|(?=\\'\\'\\'))", - "beginCaptures": { - "0": { - "name": "keyword.operator.lookahead.negative.regexp" - }, - "1": { - "name": "punctuation.parenthesis.lookahead.begin.regexp" - } + { + "include": "#comments-string-double-three" + } + ] + }, + "regexp-single-one-line": { + "name": "string.regexp.quoted.single.python", + "begin": "\\b(([uU]r)|([bB]r)|(r[bB]?))(\\')", + "end": "(\\')|(?)\n", - "end": "(\\)|(?=\"))|((?=(?)\n", + "end": "(\\)|(?=\\'))|((?=(?)\n", - "end": "(\\)|(?=\"\"\"))", - "beginCaptures": { - "1": { - "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp" - }, - "2": { - "name": "entity.name.tag.named.group.regexp" - } + { + "include": "#single-three-fregexp-lookahead" }, - "endCaptures": { - "1": { - "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "include": "#single-three-fregexp-lookahead-negative" }, - "patterns": [ - { - "include": "#double-three-regexp-expression" - }, - { - "include": "#comments-string-double-three" - } - ] - }, - "double-three-regexp-comments": { - "name": "comment.regexp", - "begin": "\\(\\?#", - "end": "(\\)|(?=\"\"\"))", - "beginCaptures": { - "0": { - "name": "punctuation.comment.begin.regexp" - } + { + "include": "#single-three-fregexp-lookbehind" }, - "endCaptures": { - "1": { - "name": "punctuation.comment.end.regexp" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "include": "#single-three-fregexp-lookbehind-negative" }, - "patterns": [ - { - "include": "#codetags" - } - ] - }, - "double-three-regexp-lookahead": { - "begin": "(\\()\\?=", - "end": "(\\)|(?=\"\"\"))", - "beginCaptures": { - "0": { - "name": "keyword.operator.lookahead.regexp" - }, - "1": { - "name": "punctuation.parenthesis.lookahead.begin.regexp" - } + { + "include": "#single-three-fregexp-conditional" }, - "endCaptures": { - "1": { - "name": "keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "include": "#single-three-fregexp-parentheses-non-capturing" }, - "patterns": [ - { - "include": "#double-three-regexp-expression" - }, - { - "include": "#comments-string-double-three" - } - ] - }, - "double-three-regexp-lookahead-negative": { - "begin": "(\\()\\?!", - "end": "(\\)|(?=\"\"\"))", - "beginCaptures": { - "0": { - "name": "keyword.operator.lookahead.negative.regexp" - }, - "1": { - "name": "punctuation.parenthesis.lookahead.begin.regexp" - } + { + "include": "#single-three-fregexp-parentheses" }, - "endCaptures": { - "1": { - "name": "keyword.operator.lookahead.negative.regexp punctuation.parenthesis.lookahead.end.regexp" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "include": "#comments-string-single-three" + } + ] + }, + "single-three-fregexp-named-group": { + "name": "meta.named.regexp", + "begin": "(?x)\n (\\() (\\?P <\\w+(?:\\s+[[:alnum:]]+)?>)\n", + "end": "(\\)|(?=\\'\\'\\'))", + "beginCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp" + }, + "2": { + "name": "entity.name.tag.named.group.regexp" + } + }, + "endCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp" }, - "patterns": [ - { - "include": "#double-three-regexp-expression" - }, - { - "include": "#comments-string-double-three" - } - ] - }, - "double-three-regexp-lookbehind": { - "begin": "(\\()\\?<=", - "end": "(\\)|(?=\"\"\"))", - "beginCaptures": { - "0": { - "name": "keyword.operator.lookbehind.regexp" - }, - "1": { - "name": "punctuation.parenthesis.lookbehind.begin.regexp" - } + "2": { + "name": "invalid.illegal.newline.python" + } + }, + "patterns": [ + { + "include": "#single-three-fregexp-expression" }, - "endCaptures": { - "1": { - "name": "keyword.operator.lookbehind.regexp punctuation.parenthesis.lookbehind.end.regexp" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "include": "#comments-string-single-three" + } + ] + }, + "single-three-fregexp-lookahead": { + "begin": "(\\()\\?=", + "end": "(\\)|(?=\\'\\'\\'))", + "beginCaptures": { + "0": { + "name": "keyword.operator.lookahead.regexp" + }, + "1": { + "name": "punctuation.parenthesis.lookahead.begin.regexp" + } + }, + "endCaptures": { + "1": { + "name": "keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp" }, - "patterns": [ - { - "include": "#double-three-regexp-expression" - }, - { - "include": "#comments-string-double-three" - } - ] - }, - "double-three-regexp-lookbehind-negative": { - "begin": "(\\()\\?)\n", - "end": "(\\)|(?=\\'))|((?=(?)\n", + "end": "(\\)|(?=\"))|((?=(?)\n", - "end": "(\\)|(?=\\'\\'\\'))", - "beginCaptures": { - "1": { - "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp" - }, - "2": { - "name": "entity.name.tag.named.group.regexp" - } + "patterns": [ + { + "include": "#double-one-fregexp-expression" + } + ] + }, + "double-one-fregexp-parentheses": { + "begin": "\\(", + "end": "(\\)|(?=\"))|((?=(?)\n", + "end": "(\\)|(?=\"\"\"))", + "beginCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp" + }, + "2": { + "name": "entity.name.tag.named.group.regexp" + } + }, + "endCaptures": { + "1": { + "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp" }, - "endCaptures": { - "1": { - "name": "support.other.parenthesis.regexp punctuation.parenthesis.end.regexp" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + "2": { + "name": "invalid.illegal.newline.python" + } + }, + "patterns": [ + { + "include": "#double-three-fregexp-expression" }, - "patterns": [ - { - "include": "#single-three-fregexp-expression" - }, - { - "include": "#comments-string-single-three" - } - ] + { + "include": "#comments-string-double-three" + } + ] + }, + "double-three-fregexp-lookahead": { + "begin": "(\\()\\?=", + "end": "(\\)|(?=\"\"\"))", + "beginCaptures": { + "0": { + "name": "keyword.operator.lookahead.regexp" + }, + "1": { + "name": "punctuation.parenthesis.lookahead.begin.regexp" + } }, - "double-one-fregexp-expression": { - "patterns": [ - { - "include": "#fregexp-base-expression" - }, - { - "include": "#double-one-regexp-character-set" - }, - { - "include": "#double-one-regexp-comments" - }, - { - "include": "#regexp-flags" - }, - { - "include": "#double-one-regexp-named-group" - }, - { - "include": "#regexp-backreference" - }, - { - "include": "#double-one-fregexp-lookahead" - }, - { - "include": "#double-one-fregexp-lookahead-negative" - }, - { - "include": "#double-one-fregexp-lookbehind" - }, - { - "include": "#double-one-fregexp-lookbehind-negative" - }, - { - "include": "#double-one-fregexp-conditional" - }, - { - "include": "#double-one-fregexp-parentheses-non-capturing" - }, - { - "include": "#double-one-fregexp-parentheses" - } - ] - }, - "double-one-fregexp-named-group": { - "name": "meta.named.regexp", - "begin": "(?x)\n (\\() (\\?P <\\w+(?:\\s+[[:alnum:]]+)?>)\n", - "end": "(\\)|(?=\"))|((?=(?)\n", - "end": "(\\)|(?=\"\"\"))", - "beginCaptures": { - "1": { - "name": "support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp" - }, - "2": { - "name": "entity.name.tag.named.group.regexp" - } + "patterns": [ + { + "include": "#single-three-fregexp-expression" + } + ] + }, + "fregexp-double-one-line": { + "name": "string.interpolated.python string.regexp.quoted.single.python", + "begin": "\\b(([uU]r)|([fF]r)|(r[fF]?))(\")", + "end": "(\")|(?=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )(?=})\n", + "captures": { + "1": { + "name": "storage.type.format.python" + }, + "2": { + "name": "storage.type.format.python" + } } }, - "patterns": [ - { - "include": "#string-entity" - } - ] - }, - "string-raw-bin-quoted-single-line": { - "name": "string.quoted.raw.binary.single.python", - "begin": "(\\b(?:R[bB]|[bB]R))((['\"]))", - "end": "(\\2)|((?=^])" }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end.python" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "name": "storage.type.format.python", + "match": "(\\w)" + } + ] + }, + "fstring-fnorm-quoted-multi-line": { + "name": "meta.fstring.python", + "begin": "(\\b[fF])([bBuU])?('''|\"\"\")", + "end": "(\\3)", + "beginCaptures": { + "1": { + "name": "string.interpolated.python string.quoted.multi.python storage.type.string.python" + }, + "2": { + "name": "invalid.illegal.prefix.python" + }, + "3": { + "name": "punctuation.definition.string.begin.python string.interpolated.python string.quoted.multi.python" + } + }, + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.python string.interpolated.python string.quoted.multi.python" }, - "patterns": [ - { - "include": "#string-raw-bin-guts" - } - ] - }, - "string-quoted-multi-line": { - "name": "string.quoted.multi.python", - "begin": "(?:\\b([rR])(?=[uU]))?([uU])?('''|\"\"\")", - "end": "(\\3)", - "beginCaptures": { - "1": { - "name": "invalid.illegal.prefix.python" - }, - "2": { - "name": "storage.type.string.python" - }, - "3": { - "name": "punctuation.definition.string.begin.python" - } + "2": { + "name": "invalid.illegal.newline.python" + } + }, + "patterns": [ + { + "include": "#fstring-guts" }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end.python" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "include": "#fstring-illegal-multi-brace" }, - "patterns": [ - { - "include": "#string-multi-bad-brace1-formatting-unicode" - }, - { - "include": "#string-multi-bad-brace2-formatting-unicode" - }, - { - "include": "#string-unicode-guts" - } - ] - }, - "string-multi-bad-brace1-formatting-unicode": { - "comment": "template using {% ... %}", - "begin": "(?x)\n (?= \\{%\n ( .*? (?!'''|\"\"\") )\n %\\}\n )\n", - "end": "(?='''|\"\"\")", - "patterns": [ - { - "include": "#escape-sequence-unicode" - }, - { - "include": "#escape-sequence" - }, - { - "include": "#string-line-continuation" - } - ] - }, - "string-multi-bad-brace1-formatting-raw": { - "comment": "template using {% ... %}", - "begin": "(?x)\n (?= \\{%\n ( .*? (?!'''|\"\"\") )\n %\\}\n )\n", - "end": "(?='''|\"\"\")", - "patterns": [ - { - "include": "#string-consume-escape" - } - ] - }, - "string-multi-bad-brace2-formatting-unicode": { - "comment": "odd format or format-like syntax", - "begin": "(?x)\n (?!\\{\\{)\n (?= \\{ (\n \\w*? (?!'''|\"\"\") [^!:\\.\\[}\\w]\n )\n .*?(?!'''|\"\"\")\n \\}\n )\n", - "end": "(?='''|\"\"\")", - "patterns": [ - { - "include": "#escape-sequence-unicode" - }, - { - "include": "#string-entity" - } - ] - }, - "string-multi-bad-brace2-formatting-raw": { - "comment": "odd format or format-like syntax", - "begin": "(?x)\n (?!\\{\\{)\n (?= \\{ (\n \\w*? (?!'''|\"\"\") [^!:\\.\\[}\\w]\n )\n .*?(?!'''|\"\"\")\n \\}\n )\n", - "end": "(?='''|\"\"\")", - "patterns": [ - { - "include": "#string-consume-escape" - }, - { - "include": "#string-formatting" - } - ] - }, - "fstring-fnorm-quoted-single-line": { - "name": "meta.fstring.python", - "begin": "(\\b[fF])([bBuU])?((['\"]))", - "end": "(\\3)|((?=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )(?=})\n", - "captures": { - "1": { - "name": "storage.type.format.python" - }, - "2": { - "name": "storage.type.format.python" - } + "endCaptures": { + "1": { + "name": "constant.character.format.placeholder.other.python" + } + }, + "patterns": [ + { + "include": "#fstring-terminator-multi" + }, + { + "include": "#f-expression" + } + ] + }, + "fstring-terminator-multi": { + "patterns": [ + { + "name": "storage.type.format.python", + "match": "(![rsa])(?=})" + }, + { + "match": "(?x)\n (![rsa])?\n ( : \\w? [<>=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )(?=})\n", + "captures": { + "1": { + "name": "storage.type.format.python" + }, + "2": { + "name": "storage.type.format.python" } - }, - { - "include": "#fstring-terminator-single-tail" - } - ] - }, - "fstring-terminator-single-tail": { - "begin": "(![rsa])?(:)(?=.*?{)", - "end": "(?=})|(?=\\n)", - "beginCaptures": { - "1": { - "name": "storage.type.format.python" - }, - "2": { - "name": "storage.type.format.python" } }, - "patterns": [ - { - "include": "#fstring-illegal-single-brace" - }, - { - "include": "#fstring-single-brace" - }, - { - "name": "storage.type.format.python", - "match": "([bcdeEfFgGnosxX%])(?=})" - }, - { - "name": "storage.type.format.python", - "match": "(\\.\\d+)" - }, - { - "name": "storage.type.format.python", - "match": "(,)" - }, - { - "name": "storage.type.format.python", - "match": "(\\d+)" - }, - { - "name": "storage.type.format.python", - "match": "(\\#)" - }, - { - "name": "storage.type.format.python", - "match": "([-+ ])" - }, - { - "name": "storage.type.format.python", - "match": "([<>=^])" - }, - { - "name": "storage.type.format.python", - "match": "(\\w)" - } - ] - }, - "fstring-fnorm-quoted-multi-line": { - "name": "meta.fstring.python", - "begin": "(\\b[fF])([bBuU])?('''|\"\"\")", - "end": "(\\3)", - "beginCaptures": { - "1": { - "name": "string.interpolated.python string.quoted.multi.python storage.type.string.python" - }, - "2": { - "name": "invalid.illegal.prefix.python" - }, - "3": { - "name": "punctuation.definition.string.begin.python string.interpolated.python string.quoted.multi.python" - } + { + "include": "#fstring-terminator-multi-tail" + } + ] + }, + "fstring-terminator-multi-tail": { + "begin": "(![rsa])?(:)(?=.*?{)", + "end": "(?=})", + "beginCaptures": { + "1": { + "name": "storage.type.format.python" + }, + "2": { + "name": "storage.type.format.python" + } + }, + "patterns": [ + { + "include": "#fstring-illegal-multi-brace" }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end.python string.interpolated.python string.quoted.multi.python" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "include": "#fstring-multi-brace" }, - "patterns": [ - { - "include": "#fstring-guts" - }, - { - "include": "#fstring-illegal-multi-brace" - }, - { - "include": "#fstring-multi-brace" - }, - { - "include": "#fstring-multi-core" - } - ] - }, - "fstring-normf-quoted-multi-line": { - "name": "meta.fstring.python", - "begin": "(\\b[bBuU])([fF])('''|\"\"\")", - "end": "(\\3)", - "beginCaptures": { - "1": { - "name": "invalid.illegal.prefix.python" - }, - "2": { - "name": "string.interpolated.python string.quoted.multi.python storage.type.string.python" - }, - "3": { - "name": "punctuation.definition.string.begin.python string.quoted.multi.python" - } + { + "name": "storage.type.format.python", + "match": "([bcdeEfFgGnosxX%])(?=})" }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end.python string.interpolated.python string.quoted.multi.python" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "name": "storage.type.format.python", + "match": "(\\.\\d+)" }, - "patterns": [ - { - "include": "#fstring-guts" - }, - { - "include": "#fstring-illegal-multi-brace" - }, - { - "include": "#fstring-multi-brace" - }, - { - "include": "#fstring-multi-core" - } - ] - }, - "fstring-raw-quoted-multi-line": { - "name": "meta.fstring.python", - "begin": "(\\b(?:[R][fF]|[fF][R]))('''|\"\"\")", - "end": "(\\2)", - "beginCaptures": { - "1": { - "name": "string.interpolated.python string.quoted.raw.multi.python storage.type.string.python" - }, - "2": { - "name": "punctuation.definition.string.begin.python string.quoted.raw.multi.python" - } + { + "name": "storage.type.format.python", + "match": "(,)" }, - "endCaptures": { - "1": { - "name": "punctuation.definition.string.end.python string.interpolated.python string.quoted.raw.multi.python" - }, - "2": { - "name": "invalid.illegal.newline.python" - } + { + "name": "storage.type.format.python", + "match": "(\\d+)" }, - "patterns": [ - { - "include": "#fstring-raw-guts" - }, - { - "include": "#fstring-illegal-multi-brace" - }, - { - "include": "#fstring-multi-brace" - }, - { - "include": "#fstring-raw-multi-core" - } - ] - }, - "fstring-multi-core": { - "name": "string.interpolated.python string.quoted.multi.python", - "match": "(?x)\n (.+?)\n (\n (?# .* and .*? in multi-line match need special handling of\n newlines otherwise SublimeText and Atom will match slightly\n differently.\n\n The guard for newlines has to be separate from the\n lookahead because of special $ matching rule.)\n ($\\n?)\n |\n (?=[\\\\\\}\\{]|'''|\"\"\")\n )\n (?# due to how multiline regexps are matched we need a special case\n for matching a newline character)\n | \\n\n" - }, - "fstring-raw-multi-core": { - "name": "string.interpolated.python string.quoted.raw.multi.python", - "match": "(?x)\n (.+?)\n (\n (?# .* and .*? in multi-line match need special handling of\n newlines otherwise SublimeText and Atom will match slightly\n differently.\n\n The guard for newlines has to be separate from the\n lookahead because of special $ matching rule.)\n ($\\n?)\n |\n (?=[\\\\\\}\\{]|'''|\"\"\")\n )\n (?# due to how multiline regexps are matched we need a special case\n for matching a newline character)\n | \\n\n" - }, - "fstring-multi-brace": { - "comment": "value interpolation using { ... }", - "begin": "(\\{)", - "end": "(?x)\n (\\})\n", - "beginCaptures": { - "1": { - "name": "constant.character.format.placeholder.other.python" - } + { + "name": "storage.type.format.python", + "match": "(\\#)" }, - "endCaptures": { - "1": { - "name": "constant.character.format.placeholder.other.python" - } + { + "name": "storage.type.format.python", + "match": "([-+ ])" }, - "patterns": [ - { - "include": "#fstring-terminator-multi" - }, - { - "include": "#f-expression" - } - ] - }, - "fstring-terminator-multi": { - "patterns": [ - { - "name": "storage.type.format.python", - "match": "(![rsa])(?=})" - }, - { - "match": "(?x)\n (![rsa])?\n ( : \\w? [<>=^]? [-+ ]? \\#?\n \\d* ,? (\\.\\d+)? [bcdeEfFgGnosxX%]? )(?=})\n", - "captures": { - "1": { - "name": "storage.type.format.python" - }, - "2": { - "name": "storage.type.format.python" - } - } - }, - { - "include": "#fstring-terminator-multi-tail" - } - ] - }, - "fstring-terminator-multi-tail": { - "begin": "(![rsa])?(:)(?=.*?{)", - "end": "(?=})", - "beginCaptures": { - "1": { - "name": "storage.type.format.python" - }, - "2": { - "name": "storage.type.format.python" - } + { + "name": "storage.type.format.python", + "match": "([<>=^])" }, - "patterns": [ - { - "include": "#fstring-illegal-multi-brace" - }, - { - "include": "#fstring-multi-brace" - }, - { - "name": "storage.type.format.python", - "match": "([bcdeEfFgGnosxX%])(?=})" - }, - { - "name": "storage.type.format.python", - "match": "(\\.\\d+)" - }, - { - "name": "storage.type.format.python", - "match": "(,)" - }, - { - "name": "storage.type.format.python", - "match": "(\\d+)" - }, - { - "name": "storage.type.format.python", - "match": "(\\#)" - }, - { - "name": "storage.type.format.python", - "match": "([-+ ])" - }, - { - "name": "storage.type.format.python", - "match": "([<>=^])" - }, - { - "name": "storage.type.format.python", - "match": "(\\w)" - } - ] - } + { + "name": "storage.type.format.python", + "match": "(\\w)" + } + ] } } +} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2dcf8ef --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,98 @@ +[project] +name = "trame-code" +version = "1.0.2" +description = "Widget for Monaco VS code editor for trame" +authors = [ + {name = "Kitware Inc."}, +] +dependencies = [ + "trame_client", +] +requires-python = ">=3.9" +readme = "README.rst" +license = {text = "MIT License"} +keywords = ["Python", "Interactive", "Web", "Application", "Framework"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: JavaScript", + "Topic :: Software Development :: Libraries :: Application Frameworks", + "Topic :: Software Development :: Libraries :: Python Modules", +] + +[project.optional-dependencies] +dev = [ + "pre-commit", + "pytest >=6", +] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build] +artifacts = [ + "src/trame_code/module/serve/**", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/trame_code", "src/trame"] + +[tool.semantic_release] +version_toml = [ + "pyproject.toml:project.version", +] +build_command = """ + python -m pip install uv + uv build +""" + +[tool.semantic_release.publish] +dist_glob_patterns = ["dist/*"] +upload_to_vcs_release = true + +[tool.ruff] + +[tool.ruff.lint] +extend-select = [ + "ARG", # flake8-unused-arguments + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "EM", # flake8-errmsg + "EXE", # flake8-executable + "G", # flake8-logging-format + "I", # isort + "ICN", # flake8-import-conventions + "NPY", # NumPy specific rules + "PD", # pandas-vet + "PGH", # pygrep-hooks + "PIE", # flake8-pie + "PL", # pylint + "PT", # flake8-pytest-style + "PTH", # flake8-use-pathlib + "RET", # flake8-return + "RUF", # Ruff-specific + "SIM", # flake8-simplify + "T20", # flake8-print + "UP", # pyupgrade + "YTT", # flake8-2020 +] +ignore = [ + "PLR09", # Too many <...> + "PLR2004", # Magic value used in comparison + "ISC001", # Conflicts with formatter +] +isort.required-imports = [] + +[tool.ruff.lint.per-file-ignores] +"src/**" = ["SIM117"] +# trame namespace shims intentionally re-export and import lazily +"src/trame/**" = ["F401", "F403", "PLC0415"] +# tests use local imports and dummy callbacks +"tests/**" = ["T20", "ARG001", "PLC0415"] +# examples are illustrative demos, not library code +"example/**" = ["T20", "ARG001", "C408", "PLC0415", "PTH123", "RET504", "SIM117"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index bd5df1a..0000000 --- a/setup.cfg +++ /dev/null @@ -1,39 +0,0 @@ -[metadata] -name = trame-code -version = 1.0.2 -description = Widget for Monaco VS code editor for trame -long_description = file: README.rst -long_description_content_type = text/x-rst -author = Kitware Inc. -license = MIT License -classifiers = - Development Status :: 5 - Production/Stable - Environment :: Web Environment - License :: OSI Approved :: MIT License - Natural Language :: English - Operating System :: OS Independent - Programming Language :: Python :: 3 :: Only - Programming Language :: JavaScript - Topic :: Software Development :: Libraries :: Application Frameworks - Topic :: Software Development :: Libraries :: Python Modules -keywords = - Python - Interactive - Web - Application - Framework - -[options] -packages = find: -include_package_data = True -install_requires = - trame_client - # vtk - # pandas - # numpy - # altair - # mpld3 - # plotly - # pydeck -[semantic_release] -version_pattern = setup.cfg:version = (\d+\.\d+\.\d+) diff --git a/setup.py b/setup.py deleted file mode 100644 index 6068493..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() diff --git a/trame/__init__.py b/src/trame/__init__.py similarity index 100% rename from trame/__init__.py rename to src/trame/__init__.py diff --git a/trame/modules/__init__.py b/src/trame/modules/__init__.py similarity index 100% rename from trame/modules/__init__.py rename to src/trame/modules/__init__.py diff --git a/trame/modules/code.py b/src/trame/modules/code.py similarity index 100% rename from trame/modules/code.py rename to src/trame/modules/code.py diff --git a/trame/widgets/__init__.py b/src/trame/widgets/__init__.py similarity index 100% rename from trame/widgets/__init__.py rename to src/trame/widgets/__init__.py diff --git a/trame/widgets/code.py b/src/trame/widgets/code.py similarity index 100% rename from trame/widgets/code.py rename to src/trame/widgets/code.py diff --git a/trame_code/__init__.py b/src/trame_code/__init__.py similarity index 100% rename from trame_code/__init__.py rename to src/trame_code/__init__.py diff --git a/trame_code/module/.gitignore b/src/trame_code/module/.gitignore similarity index 76% rename from trame_code/module/.gitignore rename to src/trame_code/module/.gitignore index 5170b04..c8a91ea 100644 --- a/trame_code/module/.gitignore +++ b/src/trame_code/module/.gitignore @@ -2,4 +2,4 @@ serve serve/*.map serve/*.html serve/*.common.* -serve/*.umd.js \ No newline at end of file +serve/*.umd.js diff --git a/trame_code/module/__init__.py b/src/trame_code/module/__init__.py similarity index 98% rename from trame_code/module/__init__.py rename to src/trame_code/module/__init__.py index b9df95d..3e9bf6d 100644 --- a/trame_code/module/__init__.py +++ b/src/trame_code/module/__init__.py @@ -22,4 +22,3 @@ # Optional if you want to execute custom initialization at module load def setup(app, **kwargs): """Method called at initialization with possibly some custom keyword arguments""" - pass diff --git a/trame_code/widgets/__init__.py b/src/trame_code/widgets/__init__.py similarity index 100% rename from trame_code/widgets/__init__.py rename to src/trame_code/widgets/__init__.py diff --git a/trame_code/widgets/code.py b/src/trame_code/widgets/code.py similarity index 90% rename from trame_code/widgets/code.py rename to src/trame_code/widgets/code.py index fb56580..f43848a 100644 --- a/trame_code/widgets/code.py +++ b/src/trame_code/widgets/code.py @@ -69,10 +69,10 @@ def __init__(self, completion=None, hover=None, **kwargs): # callback is registered as a trigger internally and the client invokes # it by name and awaits the returned value. if completion is not None: - self._attributes[ - "completion_trigger" - ] = f'completion="{self.ctrl.trigger_name(completion)}"' + self._attributes["completion_trigger"] = ( + f'completion="{self.ctrl.trigger_name(completion)}"' + ) if hover is not None: - self._attributes[ - "hover_trigger" - ] = f'hover="{self.ctrl.trigger_name(hover)}"' + self._attributes["hover_trigger"] = ( + f'hover="{self.ctrl.trigger_name(hover)}"' + ) diff --git a/tests/test_import.py b/tests/test_import.py index e929dcc..4e7a2e3 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -1,5 +1,4 @@ def test_import(): - from trame_code.widgets.code import Editor # noqa: F401 - # For components only, the CustomWidget is also importable via trame - from trame.widgets.code import Editor # noqa: F401,F811 + from trame.widgets.code import Editor + from trame_code.widgets.code import Editor # noqa: F401, F811 diff --git a/tests/test_language_features.py b/tests/test_language_features.py index cc397e7..abc3a01 100644 --- a/tests/test_language_features.py +++ b/tests/test_language_features.py @@ -3,6 +3,7 @@ def test_completion_and_hover_register_as_triggers(): surfaces on the element as a trigger-name attribute.""" from trame.app import get_server from trame.ui.html import DivLayout + from trame.widgets import code def on_complete(code_text, line, column): diff --git a/vue-components/.prettierrc.json b/vue-components/.prettierrc.json index 9e26dfe..0967ef4 100644 --- a/vue-components/.prettierrc.json +++ b/vue-components/.prettierrc.json @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/vue-components/README.md b/vue-components/README.md index 54f4bab..76f58df 100644 --- a/vue-components/README.md +++ b/vue-components/README.md @@ -1,24 +1,29 @@ # vue-components ## Project setup + ``` npm install ``` ### Compiles and hot-reloads for development + ``` npm run serve ``` ### Compiles and minifies for production + ``` npm run build ``` ### Lints and fixes files + ``` npm run lint ``` ### Customize configuration + See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/vue-components/src/components/Editor.js b/vue-components/src/components/Editor.js index 268cb14..311ebf8 100644 --- a/vue-components/src/components/Editor.js +++ b/vue-components/src/components/Editor.js @@ -103,7 +103,7 @@ export default { languages, grammars, configs, - true + true, ); } }, @@ -120,7 +120,7 @@ export default { registerLanguages( languages, (v) => this.provider.fetchLanguageInfo(v), - monaco + monaco, ); if (inject) { this.provider.injectCSS(); @@ -244,7 +244,7 @@ export default { : undefined; return { range, contents }; }, - } + }, ); } }, @@ -256,7 +256,7 @@ export default { this.textmate.languages, this.textmate.grammars, this.textmate.configs, - false + false, ); } diff --git a/vue-components/src/themes/README.md b/vue-components/src/themes/README.md index ec3a61f..ec3b203 100644 --- a/vue-components/src/themes/README.md +++ b/vue-components/src/themes/README.md @@ -1 +1,2 @@ -The files are mainly coming from https://github.com/microsoft/vscode/tree/main/extensions/theme-defaults/themes \ No newline at end of file +The files are mainly coming from +https://github.com/microsoft/vscode/tree/main/extensions/theme-defaults/themes diff --git a/vue-components/src/themes/index.js b/vue-components/src/themes/index.js index 9edcc3d..87c77da 100644 --- a/vue-components/src/themes/index.js +++ b/vue-components/src/themes/index.js @@ -65,6 +65,6 @@ Promise.all(values.map((v) => v())).then((results) => { resolvedMap[keys[i]] = results[i]; } results.forEach((v) => - registerTextMateTheme(toTextmateTheme(v, resolvedMap)) + registerTextMateTheme(toTextmateTheme(v, resolvedMap)), ); }); diff --git a/vue-components/src/utils/textmate.js b/vue-components/src/utils/textmate.js index 56611df..c9d3659 100644 --- a/vue-components/src/utils/textmate.js +++ b/vue-components/src/utils/textmate.js @@ -69,7 +69,7 @@ export class SimpleLanguageInfoProvider { this.monaco.languages.getEncodedLanguageId(language); return this.tokensProviderCache.createEncodedTokensProvider( scopeName, - encodedLanguageId + encodedLanguageId, ); } @@ -116,7 +116,7 @@ class TokensProviderCache { .loadGrammarWithConfiguration( scopeName, encodedLanguageId, - grammarConfiguration + grammarConfiguration, ) .then((grammar) => { if (grammar) { @@ -162,9 +162,8 @@ export function registerLanguages(languages, fetchLanguageInfo, monaco) { // Lazy-load the tokens provider and configuration data. monaco.languages.onLanguage(languageId, async () => { - const { tokensProvider, configuration } = await fetchLanguageInfo( - languageId - ); + const { tokensProvider, configuration } = + await fetchLanguageInfo(languageId); if (tokensProvider != null) { monaco.languages.setTokensProvider(languageId, tokensProvider); diff --git a/vue-components/vite.config.ts b/vue-components/vite.config.ts index bbd9668..637265c 100644 --- a/vue-components/vite.config.ts +++ b/vue-components/vite.config.ts @@ -20,8 +20,8 @@ export default { }, }, }, - outDir: "../trame_code/module/serve", + outDir: "../src/trame_code/module/serve", assetsDir: ".", // sourcemap: true, }, -}; \ No newline at end of file +};