mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-01 10:52:24 +01:00
Compare commits
181 Commits
ci-experim
...
sponsor
Author | SHA1 | Date | |
---|---|---|---|
|
6a6041c72c | ||
|
0d93abde67 | ||
|
1cc39a790f | ||
|
2d93da1869 | ||
|
9ad147278f | ||
|
4e36a56014 | ||
|
312c8ef01f | ||
|
f3f8194932 | ||
|
6ce26c43c9 | ||
|
486510395b | ||
|
2ae4ffcdfa | ||
|
f5a7f86a64 | ||
|
0fa99518ce | ||
|
a565662cf3 | ||
|
af44f0b3ff | ||
|
5ae1957c0e | ||
|
36be8d5929 | ||
|
a05c8ee1a8 | ||
|
eb4b1eb28f | ||
|
9287cf6b0b | ||
|
76aa138230 | ||
|
59a8f58be7 | ||
|
d3956be616 | ||
|
53fb0baa06 | ||
|
c2232d457f | ||
|
77f51f0ee3 | ||
|
743c4ccb17 | ||
|
5b37438f08 | ||
|
3f7bff90ba | ||
|
0c19d3e51a | ||
|
e73c3d2378 | ||
|
31ca212f86 | ||
|
68528983d7 | ||
|
f89869b5b2 | ||
|
d4744dbed5 | ||
|
abbccc91ed | ||
|
080c5f3de4 | ||
|
079f6be88c | ||
|
c522ba78ed | ||
|
392bff6666 | ||
|
6dc621ec18 | ||
|
3358b075fb | ||
|
a02713dc15 | ||
|
ee1f5a9e89 | ||
|
84a15f0b6e | ||
|
a3ea798246 | ||
|
63ad53817d | ||
|
6d0eb0749e | ||
|
36c1ea4599 | ||
|
e250da8aaa | ||
|
7fceb4878f | ||
|
29711c178a | ||
|
8072d5a3e3 | ||
|
a5234105e5 | ||
|
4236fa97cb | ||
|
f5e3d9f010 | ||
|
6313e9ef2a | ||
|
ce89fb2751 | ||
|
3338699257 | ||
|
747b15436a | ||
|
206bf5b8d6 | ||
|
9a2979df5f | ||
|
b8e79a2160 | ||
|
715b0d8bf5 | ||
|
0eb4aaac1e | ||
|
bc86c29185 | ||
|
d2175d6382 | ||
|
b3aefd2d41 | ||
|
f7eb55aa01 | ||
|
5e63d67960 | ||
|
6fd78ea3f6 | ||
|
b12503a46a | ||
|
ea2faf45e4 | ||
|
1822c981da | ||
|
5519f9c716 | ||
|
dd0925a946 | ||
|
d7671fa8e3 | ||
|
e79b07bf5e | ||
|
619cf6e6d6 | ||
|
d6ed5e6746 | ||
|
59d4cfb75c | ||
|
194e7bbcd1 | ||
|
5d92a7c591 | ||
|
7fbe090525 | ||
|
eaf64df4c6 | ||
|
a1558fb6bf | ||
|
18e999c92a | ||
|
d5f737f402 | ||
|
7fe4fdf33d | ||
|
0b63ad5e8b | ||
|
4081ace4b9 | ||
|
dde770aa21 | ||
|
6eb2cc9cac | ||
|
f28d9db3d0 | ||
|
deb80af449 | ||
|
dc0acbbb90 | ||
|
92ba42a602 | ||
|
d5e61d2316 | ||
|
ed3246c423 | ||
|
2339d78bf4 | ||
|
3a3cd0acba | ||
|
ce4ddc0911 | ||
|
aed4ea144f | ||
|
eea061c1d9 | ||
|
10288e309e | ||
|
ebdb00d4fc | ||
|
6fc7ebf37a | ||
|
8f6a0cd9e2 | ||
|
994c21a5e1 | ||
|
554374667e | ||
|
043f3381b0 | ||
|
d04a83de7b | ||
|
b622a4d890 | ||
|
b551d28a2f | ||
|
e6caa04209 | ||
|
adadedeab1 | ||
|
a6cf5235aa | ||
|
1477338106 | ||
|
418fce5683 | ||
|
7a15ba3796 | ||
|
0f002a5b06 | ||
|
5344a32d34 | ||
|
c9645693a4 | ||
|
f607263bdc | ||
|
f309d2fbd2 | ||
|
47283f226a | ||
|
aefc8fd824 | ||
|
405a80f3ee | ||
|
ad98d35a48 | ||
|
b69ab219d7 | ||
|
dc8225f682 | ||
|
9d9b266f54 | ||
|
b9d01c1a61 | ||
|
122cae7902 | ||
|
44a332c1c4 | ||
|
5143f3ad43 | ||
|
a6dc25a216 | ||
|
f04d2a9d6a | ||
|
eb3b3b9f8d | ||
|
0994f3783f | ||
|
974dec38e3 | ||
|
a0c363647f | ||
|
d989224a8a | ||
|
82f439e715 | ||
|
b034879eae | ||
|
9ed9a6fc3d | ||
|
e84b702309 | ||
|
6226eba52a | ||
|
9e0ea06435 | ||
|
863d9cacd0 | ||
|
4baa346aae | ||
|
7956485e37 | ||
|
372e42f350 | ||
|
9124271eaf | ||
|
156dec2737 | ||
|
27f046ec03 | ||
|
74ae3dee91 | ||
|
87978e7755 | ||
|
d935ea1cda | ||
|
9602195910 | ||
|
8ca852c728 | ||
|
df067f7d1f | ||
|
a8a81e99d2 | ||
|
65e7c531de | ||
|
7c41bd72da | ||
|
355a82db54 | ||
|
b3e17bde82 | ||
|
4b38e7b1d7 | ||
|
43afae34be | ||
|
27fa55d274 | ||
|
19c3e82abf | ||
|
f1c0fd7343 | ||
|
12dfbdc400 | ||
|
c86a179412 | ||
|
0748783404 | ||
|
b3247d9364 | ||
|
ba8a694314 | ||
|
b146958ecb | ||
|
15c701b196 | ||
|
d8339808a1 | ||
|
3b263f0917 |
73
.github/workflows/CICD.yml
vendored
73
.github/workflows/CICD.yml
vendored
@@ -1,7 +1,7 @@
|
||||
name: CICD
|
||||
|
||||
env:
|
||||
MIN_SUPPORTED_RUST_VERSION: "1.45.0"
|
||||
MIN_SUPPORTED_RUST_VERSION: "1.51.0"
|
||||
CICD_INTERMEDIATES_DIR: "_cicd-intermediates"
|
||||
|
||||
on:
|
||||
@@ -14,6 +14,28 @@ on:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
ensure_cargo_fmt:
|
||||
name: Ensure 'cargo fmt' has been run
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
default: true
|
||||
profile: minimal
|
||||
components: rustfmt
|
||||
- uses: actions/checkout@v2
|
||||
- run: cargo fmt -- --check
|
||||
|
||||
license_checks:
|
||||
name: License checks
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true # we especially want to perform license checks on submodules
|
||||
- run: tests/scripts/license-checks.sh
|
||||
|
||||
min_version:
|
||||
name: Minimum supported rust version
|
||||
runs-on: ubuntu-20.04
|
||||
@@ -27,12 +49,7 @@ jobs:
|
||||
toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
|
||||
default: true
|
||||
profile: minimal # minimal component installation (ie, no documentation)
|
||||
components: clippy, rustfmt
|
||||
- name: Ensure `cargo fmt` has been run
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: -- --check
|
||||
components: clippy
|
||||
- name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
@@ -86,6 +103,21 @@ jobs:
|
||||
run: bat --list-languages
|
||||
- name: List of themes
|
||||
run: bat --list-themes
|
||||
- name: Test custom assets
|
||||
run: tests/syntax-tests/test_custom_assets.sh
|
||||
|
||||
documentation:
|
||||
name: Documentation
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Git checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
default: true
|
||||
profile: minimal
|
||||
- name: Check documentation
|
||||
env:
|
||||
RUSTDOCFLAGS: -D warnings
|
||||
@@ -95,24 +127,23 @@ jobs:
|
||||
args: --locked --no-deps --document-private-items --all-features
|
||||
|
||||
build:
|
||||
name: ${{ matrix.job.os }} (${{ matrix.job.target }})
|
||||
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
|
||||
runs-on: ${{ matrix.job.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- { os: ubuntu-20.04, target: arm-unknown-linux-gnueabihf , use-cross: true }
|
||||
- { os: ubuntu-20.04, target: arm-unknown-linux-musleabihf, use-cross: true }
|
||||
- { os: ubuntu-20.04, target: aarch64-unknown-linux-gnu , use-cross: true }
|
||||
- { os: ubuntu-20.04, target: i686-unknown-linux-gnu , use-cross: true }
|
||||
- { os: ubuntu-20.04, target: i686-unknown-linux-musl , use-cross: true }
|
||||
- { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu }
|
||||
- { os: ubuntu-20.04, target: x86_64-unknown-linux-musl , use-cross: true }
|
||||
- { os: macos-10.15 , target: x86_64-apple-darwin }
|
||||
# - { os: windows-2019, target: i686-pc-windows-gnu } ## disabled; error: linker `i686-w64-mingw32-gcc` not found
|
||||
- { os: windows-2019, target: i686-pc-windows-msvc }
|
||||
- { os: windows-2019, target: x86_64-pc-windows-gnu }
|
||||
- { os: windows-2019, target: x86_64-pc-windows-msvc }
|
||||
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
|
||||
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true }
|
||||
- { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true }
|
||||
- { target: i686-pc-windows-msvc , os: windows-2019 }
|
||||
- { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
|
||||
- { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
|
||||
- { target: x86_64-apple-darwin , os: macos-10.15 }
|
||||
- { target: x86_64-pc-windows-gnu , os: windows-2019 }
|
||||
- { target: x86_64-pc-windows-msvc , os: windows-2019 }
|
||||
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 }
|
||||
- { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v2
|
||||
@@ -285,6 +316,7 @@ jobs:
|
||||
# Autocompletion files
|
||||
cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.bash "$ARCHIVE_DIR/autocomplete/${{ env.PROJECT_NAME }}.bash"
|
||||
cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.fish "$ARCHIVE_DIR/autocomplete/${{ env.PROJECT_NAME }}.fish"
|
||||
cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/_bat.ps1 "$ARCHIVE_DIR/autocomplete/_${{ env.PROJECT_NAME }}.ps1"
|
||||
cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.zsh "$ARCHIVE_DIR/autocomplete/${{ env.PROJECT_NAME }}.zsh"
|
||||
|
||||
# base compressed package
|
||||
@@ -333,6 +365,7 @@ jobs:
|
||||
gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
|
||||
|
||||
# Autocompletion files
|
||||
install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.bash "${DPKG_DIR}/usr/share/bash-completion/completions/${{ env.PROJECT_NAME }}"
|
||||
install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.fish "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ env.PROJECT_NAME }}.fish"
|
||||
install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.zsh "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ env.PROJECT_NAME }}"
|
||||
|
||||
|
18
.gitmodules
vendored
18
.gitmodules
vendored
@@ -67,9 +67,6 @@
|
||||
[submodule "assets/syntaxes/JavaScript (Babel)"]
|
||||
path = assets/syntaxes/02_Extra/JavaScript (Babel)
|
||||
url = https://github.com/babel/babel-sublime
|
||||
[submodule "assets/syntaxes/Dart"]
|
||||
path = assets/syntaxes/02_Extra/Dart
|
||||
url = https://github.com/guillermooo/dart-sublime-bundle
|
||||
[submodule "assets/syntaxes/FSharp"]
|
||||
path = assets/syntaxes/02_Extra/FSharp
|
||||
url = https://github.com/hoest/sublimetext-fsharp
|
||||
@@ -113,9 +110,6 @@
|
||||
[submodule "assets/syntaxes/Org mode"]
|
||||
path = assets/syntaxes/02_Extra/Org mode
|
||||
url = https://github.com/jezcope/Org.tmbundle.git
|
||||
[submodule "assets/syntaxes/requirementstxt"]
|
||||
path = assets/syntaxes/02_Extra/requirementstxt
|
||||
url = https://github.com/wuub/requirementstxt
|
||||
[submodule "assets/syntaxes/DotENV"]
|
||||
path = assets/syntaxes/02_Extra/DotENV
|
||||
url = https://github.com/zaynali53/DotENV
|
||||
@@ -203,6 +197,9 @@
|
||||
[submodule "assets/syntaxes/02_Extra/Lean"]
|
||||
path = assets/syntaxes/02_Extra/Lean
|
||||
url = https://github.com/leanprover/vscode-lean.git
|
||||
[submodule "assets/syntaxes/02_Extra/LiveScript"]
|
||||
path = assets/syntaxes/02_Extra/LiveScript
|
||||
url = https://github.com/paulmillr/LiveScript.tmbundle
|
||||
[submodule "assets/syntaxes/02_Extra/Zig"]
|
||||
path = assets/syntaxes/02_Extra/Zig
|
||||
url = https://github.com/ziglang/sublime-zig-language.git
|
||||
@@ -230,3 +227,12 @@
|
||||
[submodule "assets/syntaxes/02_Extra/Slim"]
|
||||
path = assets/syntaxes/02_Extra/Slim
|
||||
url = https://github.com/slim-template/ruby-slim.tmbundle.git
|
||||
[submodule "assets/syntaxes/02_Extra/Racket"]
|
||||
path = assets/syntaxes/02_Extra/Racket
|
||||
url = https://github.com/follesoe/sublime-racket.git
|
||||
[submodule "assets/syntaxes/02_Extra/MediaWiki"]
|
||||
path = assets/syntaxes/02_Extra/MediaWiki
|
||||
url = https://github.com/tosher/Mediawiker.git
|
||||
[submodule "assets/syntaxes/02_Extra/Dart"]
|
||||
path = assets/syntaxes/02_Extra/Dart
|
||||
url = https://github.com/elMuso/Dartlight.git
|
||||
|
67
CHANGELOG.md
67
CHANGELOG.md
@@ -2,17 +2,54 @@
|
||||
|
||||
## Features
|
||||
|
||||
- `$BAT_CONFIG_DIR` is now a recognized environment variable. It has precedence over `$XDG_CONFIG_HOME`, see #1727 (@billrisher)
|
||||
- New style component `header-filesize` to show size of the displayed file in the header. See #1988 (@mdibaiee)
|
||||
|
||||
## Bugfixes
|
||||
|
||||
## Other
|
||||
|
||||
## Syntaxes
|
||||
|
||||
- `GraphQL`: Add support for interfaces implementing interfaces and consider ampersand an operator. See #2000
|
||||
- Associate `_vimrc` and `_gvimrc` files with the `VimL` syntax. See #2002
|
||||
- Associate `poetry.lock` files with the `TOML` syntax. See #2049
|
||||
- Associate `.mesh`, `.task`, `.rgen`, `.rint`, `.rahit`, `.rchit`, `.rmiss`, and `.rcall` with the `GLSL` syntax. See #2050
|
||||
|
||||
## Themes
|
||||
|
||||
## `bat` as a library
|
||||
|
||||
- Exposed `get_syntax_set` and `get_theme` methods on `HighlightingAssets`. See #2030 (@dandavison)
|
||||
|
||||
# v0.19.0
|
||||
|
||||
## Performance
|
||||
|
||||
- Reduce startup time in loop-through mode (e.g. when redirecting output) by 90%. See #1747 (@Enselic)
|
||||
- Load themes lazily to make bat start 25% faster when disregarding syntax load time. See #1969 (@Enselic)
|
||||
- Python syntax highlighting no longer suffers from abysmal performance in specific scenarios. See #1688 (@keith-hall)
|
||||
- Fix for poor performance when ANSI escape sequences are piped to `bat`, see #1596 (@eth-p)
|
||||
- Fix for incorrect handling of ANSI escape sequences when using `--wrap=never`, see #1596 (@eth-p)
|
||||
- Load custom assets as fast as integrated assets, see #1753 (@Enselic)
|
||||
|
||||
## Features
|
||||
|
||||
- Support for `x:-delta` (minus) syntax in line ranges (e.g. `20:-10`). See #1901 (@bojan88)
|
||||
- Support for `--ignored-suffix` argument. See #1892 (@bojan88)
|
||||
- `$BAT_CONFIG_DIR` is now a recognized environment variable. It has precedence over `$XDG_CONFIG_HOME`, see #1727 (@billrisher)
|
||||
- Support for `x:+delta` syntax in line ranges (e.g. `20:+10`). See #1810 (@bojan88)
|
||||
- Add new `--acknowledgements` option that gives credit to theme and syntax definition authors. See #1971 (@Enselic)
|
||||
- Include git hash in `bat -V` and `bat --version` output if present. See #1921 (@Enselic)
|
||||
|
||||
## Bugfixes
|
||||
|
||||
- First line not shown in diff context. See #1891 (@divagant-martian)
|
||||
- Do not ignore syntaxes that handle file names with a `*.conf` extension. See #1703 (@cbolgiano)
|
||||
|
||||
## Other
|
||||
|
||||
- Load cached assets as fast as integrated assets, see #1753 (@Enselic)
|
||||
- Greatly reduce startup time in loop-through mode, e.g. when redirecting output. Instead of *50 ms* - *100 ms*, startup takes *5 ms* - *10 ms*. See #1747 (@Enselic)
|
||||
|
||||
- Add PowerShell completion, see #1826 (@rashil2000)
|
||||
- Minimum supported Rust version (MSRV) bumped to 1.51, see #1994 (@mdibaiee)
|
||||
|
||||
## Syntaxes
|
||||
|
||||
@@ -22,15 +59,29 @@
|
||||
- Highlight for `vimrc` and `gvimrc` files, see #1763 (@SuperSandro2000)
|
||||
- Syslog highlighting improvements, see #1793 (@scop)
|
||||
- Added support for `slim` syntax, see #1693 (@mfinelli)
|
||||
|
||||
## New themes
|
||||
|
||||
- Racket, see #1884 (@jubnzv)
|
||||
- LiveScript, see #1915 (@Enselic)
|
||||
- MediaWiki, see #1925 (@sorairolake)
|
||||
- The `requirements.txt` syntax has been removed due to incompatible license requirements.
|
||||
- Dart, new highlighter, see #1959 (@Ersikan)
|
||||
- SCSS and Sass syntaxes updated, see #1766 (@Enselic)
|
||||
- PowerShell syntax updated, see #1935 (@Enselic)
|
||||
- TypeScript syntax updated, see #1834 (@Enselic)
|
||||
|
||||
## `bat` as a library
|
||||
|
||||
- Deprecate `HighlightingAssets::syntaxes()` and `HighlightingAssets::syntax_for_file_name()`. Use `HighlightingAssets::get_syntaxes()` and `HighlightingAssets::get_syntax_for_file_name()` instead. They return a `Result` which is needed for upcoming lazy-loading work to improve startup performance. They also return what `SyntaxSet` the returned `SyntaxReference` belongs to. See #1747, #1755 and #1776 (@Enselic)
|
||||
- Deprecate `HighlightingAssets::syntaxes()` and `HighlightingAssets::syntax_for_file_name()`. Use `HighlightingAssets::get_syntaxes()` and `HighlightingAssets::get_syntax_for_path()` instead. They return a `Result` which is needed for upcoming lazy-loading work to improve startup performance. They also return which `SyntaxSet` the returned `SyntaxReference` belongs to. See #1747, #1755, #1776, #1862 (@Enselic)
|
||||
- Remove `HighlightingAssets::from_files` and `HighlightingAssets::save_to_cache`. Instead of calling the former and then the latter you now make a single call to `bat::assets::build`. See #1802, #1971 (@Enselic)
|
||||
- Replace the `error::Error(error::ErrorKind, _)` struct and enum with an `error::Error` enum. `Error(ErrorKind::UnknownSyntax, _)` becomes `Error::UnknownSyntax`, etc. Also remove the `error::ResultExt` trait. These changes stem from replacing `error-chain` with `thiserror`. See #1820 (@Enselic)
|
||||
- Add new `MappingTarget` enum variant `MapExtensionToUnknown`. Refer to its documentation for more information. Also mark `MappingTarget` as `#[non_exhaustive]` since more enum variants might be added in the future. See #1703 (@cbolgiano), #2012 (@Enselic)
|
||||
|
||||
|
||||
# v0.18.3
|
||||
|
||||
## Bugfixes
|
||||
|
||||
- Bump `git2` dependency to fix build with Rust 1.54, see #1761
|
||||
|
||||
|
||||
# v0.18.2
|
||||
|
||||
|
446
Cargo.lock
generated
446
Cargo.lock
generated
@@ -19,20 +19,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ansi_colours"
|
||||
version = "1.0.4"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60e2fb6138a49ad9f1cb3c6d8f8ccbdd5e62b4dab317c1b435a47ecd7da1d28f"
|
||||
checksum = "32678233b67f9056b0c144b39d46dc3218637e8d84ad6038ded339e08b19620d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
"rgb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -46,9 +37,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "assert_cmd"
|
||||
version = "1.0.8"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c98233c6673d8601ab23e77eb38f999c51100d46c5703b17288c57fddf3a1ffe"
|
||||
checksum = "93ae1ddd39efd67689deb1979d80bad3bf7f2b09c6e6117c8d1f2443b5e2f83e"
|
||||
dependencies = [
|
||||
"bstr",
|
||||
"doc-comment",
|
||||
@@ -83,28 +74,30 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
||||
|
||||
[[package]]
|
||||
name = "bat"
|
||||
version = "0.18.2"
|
||||
version = "0.19.0"
|
||||
dependencies = [
|
||||
"ansi_colours",
|
||||
"ansi_term 0.12.1",
|
||||
"ansi_term",
|
||||
"assert_cmd",
|
||||
"atty",
|
||||
"bincode",
|
||||
"bugreport",
|
||||
"bytesize",
|
||||
"clap",
|
||||
"clircle",
|
||||
"console",
|
||||
"content_inspector",
|
||||
"dirs-next",
|
||||
"encoding",
|
||||
"error-chain",
|
||||
"flate2",
|
||||
"git2",
|
||||
"globset",
|
||||
"grep-cli",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"nix",
|
||||
"once_cell",
|
||||
"path_abs",
|
||||
"predicates",
|
||||
"regex",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_yaml",
|
||||
@@ -112,8 +105,10 @@ dependencies = [
|
||||
"shell-words",
|
||||
"syntect",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"unicode-width",
|
||||
"wait-timeout",
|
||||
"walkdir",
|
||||
"wild",
|
||||
]
|
||||
|
||||
@@ -143,15 +138,15 @@ checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "0.2.16"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279"
|
||||
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"memchr",
|
||||
@@ -170,16 +165,22 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
name = "bytemuck"
|
||||
version = "1.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
checksum = "439989e6b8c38d1b6570a384ef1e49c8848128f5a97f3914baef02920842712f"
|
||||
|
||||
[[package]]
|
||||
name = "bytesize"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.67"
|
||||
version = "1.0.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd"
|
||||
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
]
|
||||
@@ -190,23 +191,13 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.33.3"
|
||||
version = "2.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
|
||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
dependencies = [
|
||||
"ansi_term 0.11.0",
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"strsim",
|
||||
@@ -230,13 +221,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "console"
|
||||
version = "0.14.1"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3993e6445baa160675931ec041a5e03ca84b9c6e32a056150d3aa2bdda0a1f45"
|
||||
checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31"
|
||||
dependencies = [
|
||||
"encode_unicode",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"terminal_size",
|
||||
"unicode-width",
|
||||
@@ -254,9 +245,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.2.1"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
|
||||
checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
@@ -294,12 +285,6 @@ version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.6.1"
|
||||
@@ -376,15 +361,6 @@ version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
|
||||
|
||||
[[package]]
|
||||
name = "error-chain"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fancy-regex"
|
||||
version = "0.7.1"
|
||||
@@ -396,10 +372,19 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.20"
|
||||
name = "fastrand"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0"
|
||||
checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
|
||||
dependencies = [
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crc32fast",
|
||||
@@ -434,9 +419,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
@@ -445,9 +430,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "git-version"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94918e83f1e01dedc2e361d00ce9487b14c58c7f40bab148026fa39d42cb41e2"
|
||||
checksum = "f6b0decc02f4636b9ccad390dcbe77b722a77efedfa393caf8379a51d5c61899"
|
||||
dependencies = [
|
||||
"git-version-macro",
|
||||
"proc-macro-hack",
|
||||
@@ -455,9 +440,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "git-version-macro"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34a97a52fdee1870a34fa6e4b77570cba531b27d1838874fef4429a791a3d657"
|
||||
checksum = "fe69f1cbdb6e28af2bac214e943b99ce8a0a06b447d15d3e61161b0423139f3f"
|
||||
dependencies = [
|
||||
"proc-macro-hack",
|
||||
"proc-macro2",
|
||||
@@ -467,9 +452,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.13.20"
|
||||
version = "0.13.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9831e983241f8c5591ed53f17d874833e2fa82cac2625f3888c50cbfe136cba"
|
||||
checksum = "f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
@@ -516,15 +501,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.9.1"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
|
||||
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.18"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
@@ -542,9 +527,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.6.2"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
|
||||
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
@@ -552,33 +537,39 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.9"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
|
||||
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.1"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf"
|
||||
checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.7"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.22"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd"
|
||||
checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
@@ -597,15 +588,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.98"
|
||||
version = "0.2.112"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790"
|
||||
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
|
||||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.12.21+1.1.0"
|
||||
version = "0.12.26+1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86271bacd72b2b9e854c3dcfb82efd538f15f870e4c11af66900effb462f6825"
|
||||
checksum = "19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@@ -642,9 +633,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.4"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
|
||||
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
@@ -660,21 +651,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.8"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
|
||||
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.0"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
|
||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.6.4"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9"
|
||||
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
@@ -691,9 +682,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.22.0"
|
||||
version = "0.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1e25ee6b412c2a1e3fcb6a4499a5c1bfe7f43e014bdce9a6b6666e5aa2d187"
|
||||
checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
@@ -708,16 +699,6 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.14"
|
||||
@@ -728,10 +709,16 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "onig"
|
||||
version = "6.1.1"
|
||||
name = "once_cell"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30b46fd9edbc018f0be4e366c24c46db44fac49cd01c039ae85308088b089dd5"
|
||||
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
|
||||
|
||||
[[package]]
|
||||
name = "onig"
|
||||
version = "6.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67ddfe2c93bb389eea6e6d713306880c7f6dcc99a75b659ce145d962c861b225"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"lazy_static",
|
||||
@@ -741,9 +728,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "onig_sys"
|
||||
version = "69.6.0"
|
||||
version = "69.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed063c96cf4c0f2e5d09324409d158b38a0a85a7b90fbd68c8cad75c495d5775"
|
||||
checksum = "5dd3eee045c84695b53b20255bb7317063df090b68e18bfac0abb6c39cf7f33e"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"pkg-config",
|
||||
@@ -751,9 +738,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.1"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
|
||||
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
|
||||
dependencies = [
|
||||
"instant",
|
||||
"lock_api",
|
||||
@@ -762,9 +749,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
|
||||
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"instant",
|
||||
@@ -791,35 +778,29 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.19"
|
||||
version = "0.3.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
|
||||
checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
|
||||
|
||||
[[package]]
|
||||
name = "plist"
|
||||
version = "1.1.0"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "679104537029ed2287c216bfb942bbf723f48ee98f0aef15611634173a74ef21"
|
||||
checksum = "bd39bc6cdc9355ad1dc5eeedefee696bb35c34caf21768741e81826c0bbd7225"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"chrono",
|
||||
"indexmap",
|
||||
"line-wrap",
|
||||
"serde",
|
||||
"time",
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "predicates"
|
||||
version = "2.0.1"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc3d91237f5de3bcd9d927e24d03b495adb6135097b001cea7403e2d573d00a9"
|
||||
checksum = "95e5a7689e456ab905c22c2b48225bb921aba7c8dfa58440d68ba13f6222a715"
|
||||
dependencies = [
|
||||
"difflib",
|
||||
"float-cmp",
|
||||
@@ -837,12 +818,12 @@ checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451"
|
||||
|
||||
[[package]]
|
||||
name = "predicates-tree"
|
||||
version = "1.0.2"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15f553275e5721409451eb85e15fd9a860a6e5ab4496eb215987502b5f5391f2"
|
||||
checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7"
|
||||
dependencies = [
|
||||
"predicates-core",
|
||||
"treeline",
|
||||
"termtree",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -853,67 +834,27 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.26"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
|
||||
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.9"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
|
||||
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.8"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc"
|
||||
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
@@ -941,12 +882,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.9"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
@@ -964,10 +902,19 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
name = "rgb"
|
||||
version = "0.8.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||
checksum = "9a374af9a0e5fdcdd98c1c7b64f05004f9ea2555b6c75f211daa81268a3c50f1"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
|
||||
|
||||
[[package]]
|
||||
name = "safemem"
|
||||
@@ -998,18 +945,18 @@ checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.127"
|
||||
version = "1.0.136"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8"
|
||||
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.127"
|
||||
version = "1.0.136"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc"
|
||||
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1018,23 +965,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.64"
|
||||
version = "1.0.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
|
||||
checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"itoa 1.0.1",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.8.17"
|
||||
version = "0.8.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23"
|
||||
checksum = "a4a521f2940385c165a24ee286aa8599633d162077a54bdcae2a6fd5a7bfa7a0"
|
||||
dependencies = [
|
||||
"dtoa",
|
||||
"linked-hash-map",
|
||||
"indexmap",
|
||||
"ryu",
|
||||
"serde",
|
||||
"yaml-rust",
|
||||
]
|
||||
@@ -1075,9 +1022,9 @@ checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.6.1"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
|
||||
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
|
||||
|
||||
[[package]]
|
||||
name = "std_prelude"
|
||||
@@ -1093,9 +1040,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.72"
|
||||
version = "1.0.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82"
|
||||
checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1127,9 +1074,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sys-info"
|
||||
version = "0.9.0"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33fcecee49339531cf6bd84ecf3ed94f9c8ef4a7e700f2a1cac9cc1ca485383a"
|
||||
checksum = "0b3a0d0aba8bf96a0e1ddfdc352fc53b3df7f39318c71854910c3c4b024ae52c"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@@ -1137,13 +1084,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.2.0"
|
||||
version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
|
||||
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"libc",
|
||||
"rand",
|
||||
"redox_syscall",
|
||||
"remove_dir_all",
|
||||
"winapi",
|
||||
@@ -1170,14 +1117,20 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.1.16"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86ca8ced750734db02076f44132d802af0b33b09942331f4459dde8636fd2406"
|
||||
checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termtree"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16"
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
@@ -1189,10 +1142,40 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.2.0"
|
||||
name = "thiserror"
|
||||
version = "1.0.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342"
|
||||
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41effe7cfa8af36f439fac33861b66b049edc6f9a32331e2312660529c1c24ad"
|
||||
dependencies = [
|
||||
"itoa 0.4.8",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2"
|
||||
dependencies = [
|
||||
"tinyvec_macros",
|
||||
]
|
||||
@@ -1203,35 +1186,26 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||
|
||||
[[package]]
|
||||
name = "treeline"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.5"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0"
|
||||
dependencies = [
|
||||
"matches",
|
||||
]
|
||||
checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.17"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef"
|
||||
checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.8"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
||||
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
@@ -1253,9 +1227,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.12"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbdbff6266a24120518560b5dc983096efb98462e51d0d68169895b237be3e5d"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
@@ -1263,12 +1237,6 @@ version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
|
||||
|
||||
[[package]]
|
||||
name = "wait-timeout"
|
||||
version = "0.2.0"
|
||||
@@ -1337,9 +1305,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "xml-rs"
|
||||
version = "0.8.3"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a"
|
||||
checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust"
|
||||
|
42
Cargo.toml
42
Cargo.toml
@@ -6,7 +6,7 @@ homepage = "https://github.com/sharkdp/bat"
|
||||
license = "MIT/Apache-2.0"
|
||||
name = "bat"
|
||||
repository = "https://github.com/sharkdp/bat"
|
||||
version = "0.18.2"
|
||||
version = "0.19.0"
|
||||
exclude = ["assets/syntaxes/*", "assets/themes/*"]
|
||||
build = "build.rs"
|
||||
edition = '2018'
|
||||
@@ -27,15 +27,14 @@ minimal-application = [
|
||||
"atty",
|
||||
"clap",
|
||||
"dirs-next",
|
||||
"lazy_static",
|
||||
"paging",
|
||||
"regex-onig",
|
||||
"wild",
|
||||
]
|
||||
git = ["git2"] # Support indicating git modifications
|
||||
paging = ["shell-words"] # Support applying a pager on the output
|
||||
paging = ["shell-words", "grep-cli"] # Support applying a pager on the output
|
||||
# Add "syntect/plist-load" when https://github.com/trishume/syntect/pull/345 reaches us
|
||||
build-assets = ["syntect/yaml-load", "syntect/dump-create"]
|
||||
build-assets = ["syntect/yaml-load", "syntect/dump-create", "regex", "walkdir"]
|
||||
|
||||
# You need to use one of these if you depend on bat as a library:
|
||||
regex-onig = ["syntect/regex-onig"] # Use the "oniguruma" regex engine
|
||||
@@ -44,15 +43,17 @@ regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine
|
||||
[dependencies]
|
||||
atty = { version = "0.2.14", optional = true }
|
||||
ansi_term = "^0.12.1"
|
||||
ansi_colours = "^1.0"
|
||||
console = "0.14.1"
|
||||
lazy_static = { version = "1.4", optional = true }
|
||||
lazycell = "1.0"
|
||||
ansi_colours = "^1.1"
|
||||
bincode = "1.0"
|
||||
console = "0.15.0"
|
||||
flate2 = "1.0"
|
||||
once_cell = "1.9"
|
||||
thiserror = "1.0"
|
||||
wild = { version = "2.0", optional = true }
|
||||
content_inspector = "0.2.4"
|
||||
encoding = "0.2"
|
||||
shell-words = { version = "1.0.0", optional = true }
|
||||
unicode-width = "0.1.8"
|
||||
unicode-width = "0.1.9"
|
||||
globset = "0.4"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_yaml = "0.8"
|
||||
@@ -61,7 +62,10 @@ path_abs = { version = "0.5", default-features = false }
|
||||
clircle = "0.3"
|
||||
bugreport = { version = "0.4", optional = true }
|
||||
dirs-next = { version = "2.0.0", optional = true }
|
||||
grep-cli = "0.1.6"
|
||||
grep-cli = { version = "0.1.6", optional = true }
|
||||
regex = { version = "1.0", optional = true }
|
||||
walkdir = { version = "2.0", optional = true }
|
||||
bytesize = { version = "1.1.0" }
|
||||
|
||||
[dependencies.git2]
|
||||
version = "0.13"
|
||||
@@ -71,30 +75,26 @@ default-features = false
|
||||
[dependencies.syntect]
|
||||
version = "4.6.0"
|
||||
default-features = false
|
||||
features = ["parsing", "dump-load"]
|
||||
features = ["parsing"]
|
||||
|
||||
[dependencies.clap]
|
||||
version = "2.33"
|
||||
version = "2.34"
|
||||
optional = true
|
||||
default-features = false
|
||||
features = ["suggestions", "color", "wrap_help"]
|
||||
|
||||
[dependencies.error-chain]
|
||||
version = "0.12"
|
||||
default-features = false
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd = "1.0.8"
|
||||
assert_cmd = "2.0.4"
|
||||
serial_test = "0.5.1"
|
||||
predicates = "2.0.1"
|
||||
predicates = "2.1.0"
|
||||
wait-timeout = "0.2.0"
|
||||
tempfile = "3.2.0"
|
||||
tempfile = "3.3.0"
|
||||
|
||||
[target.'cfg(unix)'.dev-dependencies]
|
||||
nix = "0.22.0"
|
||||
nix = "0.23.1"
|
||||
|
||||
[build-dependencies]
|
||||
clap = { version = "2.33", optional = true }
|
||||
clap = { version = "2.34", optional = true }
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
6
NOTICE
Normal file
6
NOTICE
Normal file
@@ -0,0 +1,6 @@
|
||||
Copyright (c) 2018-2021 bat-developers (https://github.com/sharkdp/bat).
|
||||
|
||||
bat is made available under the terms of either the MIT License or the Apache
|
||||
License 2.0, at your option.
|
||||
|
||||
See the LICENSE-APACHE and LICENSE-MIT files for license details.
|
75
README.md
75
README.md
@@ -12,9 +12,26 @@
|
||||
<a href="#installation">Installation</a> •
|
||||
<a href="#customization">Customization</a> •
|
||||
<a href="#project-goals-and-alternatives">Project goals, alternatives</a><br>
|
||||
[<a href="https://github.com/chinanf-boy/bat-zh">中文</a>] [<a href="doc/README-ja.md">日本語</a>] [<a href="doc/README-ko.md">한국어</a>] [<a href="doc/README-ru.md">Русский</a>]
|
||||
[English]
|
||||
[<a href="doc/README-zh.md">中文</a>]
|
||||
[<a href="doc/README-ja.md">日本語</a>]
|
||||
[<a href="doc/README-ko.md">한국어</a>]
|
||||
[<a href="doc/README-ru.md">Русский</a>]
|
||||
</p>
|
||||
|
||||
### Sponsors
|
||||
|
||||
a special thank you goes to our biggest <a href="doc/sponsors.md">sponsors</a>:<br>
|
||||
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=bat&utm_source=github">
|
||||
<img src="doc/sponsors/workos-logo-white-bg.svg" width="200" alt="WorkOS">
|
||||
<br>
|
||||
<strong>Your app, enterprise-ready.</strong>
|
||||
<br>
|
||||
<sub>Start selling to enterprise customers with just a few lines of code.</sub>
|
||||
<br>
|
||||
<sup>Add Single Sign-On (and more) in minutes instead of months.</sup>
|
||||
</a>
|
||||
|
||||
### Syntax highlighting
|
||||
|
||||
`bat` supports syntax highlighting for a large number of programming and markup
|
||||
@@ -38,7 +55,7 @@ characters:
|
||||
|
||||
### Automatic paging
|
||||
|
||||
By default, `bat` pipes its own output to a pager (e.g `less`) if the output is too large for one screen.
|
||||
By default, `bat` pipes its own output to a pager (e.g. `less`) if the output is too large for one screen.
|
||||
If you would rather `bat` work like `cat` all the time (never page output), you can set `--paging=never` as an option, either on the command line or in your configuration file.
|
||||
If you intend to alias `cat` to `bat` in your shell configuration, you can use `alias cat='bat --paging=never'` to preserve the default behavior.
|
||||
|
||||
@@ -99,19 +116,23 @@ bat f - g # output 'f', then stdin, then 'g'.
|
||||
You can use `bat` as a previewer for [`fzf`](https://github.com/junegunn/fzf). To do this,
|
||||
use `bat`s `--color=always` option to force colorized output. You can also use `--line-range`
|
||||
option to restrict the load times for long files:
|
||||
|
||||
```bash
|
||||
fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}'
|
||||
```
|
||||
For more information, see [`fzf`s `README`](https://github.com/junegunn/fzf#preview-window).
|
||||
|
||||
For more information, see [`fzf`'s `README`](https://github.com/junegunn/fzf#preview-window).
|
||||
|
||||
#### `find` or `fd`
|
||||
|
||||
You can use the `-exec` option of `find` to preview all search results with `bat`:
|
||||
|
||||
```bash
|
||||
find … -exec bat {} +
|
||||
```
|
||||
|
||||
If you happen to use [`fd`](https://github.com/sharkdp/fd), you can use the `-X`/`--exec-batch` option to do the same:
|
||||
|
||||
```bash
|
||||
fd … -X bat
|
||||
```
|
||||
@@ -127,9 +148,11 @@ batgrep needle src/
|
||||
#### `tail -f`
|
||||
|
||||
`bat` can be combined with `tail -f` to continuously monitor a given file with syntax highlighting.
|
||||
|
||||
```bash
|
||||
tail -f /var/log/pacman.log | bat --paging=never -l log
|
||||
```
|
||||
|
||||
Note that we have to switch off paging in order for this to work. We have also specified the syntax
|
||||
explicitly (`-l log`), as it can not be auto-detected in this case.
|
||||
|
||||
@@ -137,6 +160,7 @@ explicitly (`-l log`), as it can not be auto-detected in this case.
|
||||
|
||||
You can combine `bat` with `git show` to view an older version of a given file with proper syntax
|
||||
highlighting:
|
||||
|
||||
```bash
|
||||
git show v0.6.0:src/main.rs | bat -l rs
|
||||
```
|
||||
@@ -173,7 +197,7 @@ bat main.cpp | xclip
|
||||
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
||||
man 2 select
|
||||
```
|
||||
(replace `bat` by `batcat` if you are on Debian or Ubuntu)
|
||||
(replace `bat` with `batcat` if you are on Debian or Ubuntu)
|
||||
|
||||
It might also be necessary to set `MANROFFOPT="-c"` if you experience
|
||||
formatting problems.
|
||||
@@ -196,15 +220,12 @@ The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.
|
||||
### On Ubuntu (using `apt`)
|
||||
*... and other Debian-based Linux distributions.*
|
||||
|
||||
`bat` is making its way through the [Ubuntu](https://packages.ubuntu.com/eoan/bat) and
|
||||
[Debian](https://packages.debian.org/testing/bat) package release process, and is available
|
||||
for Ubuntu as of Eoan 19.10. On Debian `bat` is currently available on the unstable
|
||||
"Sid" branch and on the testing branch.
|
||||
`bat` is available on [Ubuntu since 20.04 ("Focal")](https://packages.ubuntu.com/search?keywords=bat&exact=1) and [Debian since August 2021 (Debian 11 - "Bullseye")](https://packages.debian.org/bullseye/bat).
|
||||
|
||||
If your Ubuntu/Debian installation is new enough you can simply run:
|
||||
|
||||
```bash
|
||||
apt install bat
|
||||
sudo apt install bat
|
||||
```
|
||||
|
||||
**Important**: If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name
|
||||
@@ -222,7 +243,7 @@ the most recent release of `bat`, download the latest `.deb` package from the
|
||||
[release page](https://github.com/sharkdp/bat/releases) and install it via:
|
||||
|
||||
```bash
|
||||
sudo dpkg -i bat_0.18.2_amd64.deb # adapt version number and architecture
|
||||
sudo dpkg -i bat_0.18.3_amd64.deb # adapt version number and architecture
|
||||
```
|
||||
|
||||
### On Alpine Linux
|
||||
@@ -251,6 +272,14 @@ You can install [the `bat` package](https://koji.fedoraproject.org/koji/packagei
|
||||
dnf install bat
|
||||
```
|
||||
|
||||
### On Funtoo Linux
|
||||
|
||||
You can install [the `bat` package](https://github.com/funtoo/dev-kit/tree/1.4-release/sys-apps/bat) from dev-kit.
|
||||
|
||||
```bash
|
||||
emerge sys-apps/bat
|
||||
```
|
||||
|
||||
### On Gentoo Linux
|
||||
|
||||
You can install [the `bat` package](https://packages.gentoo.org/packages/sys-apps/bat)
|
||||
@@ -289,6 +318,14 @@ cd /usr/ports/textproc/bat
|
||||
make install
|
||||
```
|
||||
|
||||
### On OpenBSD
|
||||
|
||||
You can install `bat` package using [`pkg_add(1)`](https://man.openbsd.org/pkg_add.1):
|
||||
|
||||
```bash
|
||||
pkg_add bat
|
||||
```
|
||||
|
||||
### Via nix
|
||||
|
||||
You can install `bat` using the [nix package manager](https://nixos.org/nix):
|
||||
@@ -363,7 +400,7 @@ binaries are also available: look for archives with `musl` in the file name.
|
||||
|
||||
### From source
|
||||
|
||||
If you want to build `bat` from source, you need Rust 1.45 or
|
||||
If you want to build `bat` from source, you need Rust 1.51 or
|
||||
higher. You can then use `cargo` to build everything:
|
||||
|
||||
```bash
|
||||
@@ -491,8 +528,9 @@ command line option. The option takes an argument of the form `pattern:syntax` w
|
||||
the absolute file path. The `syntax` part is the full name of a supported language
|
||||
(use `bat --list-languages` for an overview).
|
||||
|
||||
Note: You probably want to use this option as an entry in `bat`s configuration file instead
|
||||
of passing it on the command line (see below).
|
||||
**Note:** You probably want to use this option as [an entry in `bat`'s configuration file](#configuration-file)
|
||||
for persistence instead of passing it on the command line as a one-off. Generally
|
||||
you'd just use `-l` if you want to manually specify a language for a file.
|
||||
|
||||
Example: To use "INI" syntax highlighting for all files with a `.conf` file extension, use
|
||||
```bash
|
||||
@@ -568,7 +606,7 @@ alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /de
|
||||
|
||||
`bat` can also be customized with a configuration file. The location of the file is dependent
|
||||
on your operating system. To get the default path for your system, call
|
||||
```
|
||||
```bash
|
||||
bat --config-file
|
||||
```
|
||||
|
||||
@@ -598,7 +636,7 @@ Example configuration file:
|
||||
# Use italic text on the terminal (not supported on all terminals)
|
||||
--italic-text=always
|
||||
|
||||
# Use C++ syntax for .ino files
|
||||
# Use C++ syntax for Arduino .ino files
|
||||
--map-syntax "*.ino:C++"
|
||||
```
|
||||
|
||||
@@ -650,6 +688,13 @@ bat() {
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Garbled output
|
||||
|
||||
If an input file contains color codes or other ANSI escape sequences or control characters, `bat` will have problems
|
||||
performing syntax highlighting and text wrapping, and thus the output can become garbled.
|
||||
When displaying such files it is recommended to disable both syntax highlighting and wrapping by
|
||||
passing the `--color=never --wrap=never` options to `bat`.
|
||||
|
||||
### Terminals & colors
|
||||
|
||||
`bat` handles terminals *with* and *without* truecolor support. However, the colors in most syntax
|
||||
|
BIN
assets/acknowledgements.bin
vendored
Normal file
BIN
assets/acknowledgements.bin
vendored
Normal file
Binary file not shown.
92
assets/completions/_bat.ps1.in
vendored
Normal file
92
assets/completions/_bat.ps1.in
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
using namespace System.Management.Automation
|
||||
using namespace System.Management.Automation.Language
|
||||
|
||||
Register-ArgumentCompleter -Native -CommandName '{{PROJECT_EXECUTABLE}}' -ScriptBlock {
|
||||
param($wordToComplete, $commandAst, $cursorPosition)
|
||||
|
||||
$commandElements = $commandAst.CommandElements
|
||||
$command = @(
|
||||
'{{PROJECT_EXECUTABLE}}'
|
||||
for ($i = 1; $i -lt $commandElements.Count; $i++) {
|
||||
$element = $commandElements[$i]
|
||||
if ($element -isnot [StringConstantExpressionAst] -or
|
||||
$element.StringConstantType -ne [StringConstantType]::BareWord -or
|
||||
$element.Value.StartsWith('-')) {
|
||||
break
|
||||
}
|
||||
$element.Value
|
||||
}) -join ';'
|
||||
|
||||
$completions = @(switch ($command) {
|
||||
'{{PROJECT_EXECUTABLE}}' {
|
||||
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Set the language for syntax highlighting.')
|
||||
[CompletionResult]::new('--language', 'language', [CompletionResultType]::ParameterName, 'Set the language for syntax highlighting.')
|
||||
[CompletionResult]::new('-H', 'H', [CompletionResultType]::ParameterName, 'Highlight lines N through M.')
|
||||
[CompletionResult]::new('--highlight-line', 'highlight-line', [CompletionResultType]::ParameterName, 'Highlight lines N through M.')
|
||||
[CompletionResult]::new('--file-name', 'file-name', [CompletionResultType]::ParameterName, 'Specify the name to display for a file.')
|
||||
[CompletionResult]::new('--diff-context', 'diff-context', [CompletionResultType]::ParameterName, 'diff-context')
|
||||
[CompletionResult]::new('--tabs', 'tabs', [CompletionResultType]::ParameterName, 'Set the tab width to T spaces.')
|
||||
[CompletionResult]::new('--wrap', 'wrap', [CompletionResultType]::ParameterName, 'Specify the text-wrapping mode (*auto*, never, character).')
|
||||
[CompletionResult]::new('--terminal-width', 'terminal-width', [CompletionResultType]::ParameterName, 'Explicitly set the width of the terminal instead of determining it automatically. If prefixed with ''+'' or ''-'', the value will be treated as an offset to the actual terminal width. See also: ''--wrap''.')
|
||||
[CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'When to use colors (*auto*, never, always).')
|
||||
[CompletionResult]::new('--italic-text', 'italic-text', [CompletionResultType]::ParameterName, 'Use italics in output (always, *never*)')
|
||||
[CompletionResult]::new('--decorations', 'decorations', [CompletionResultType]::ParameterName, 'When to show the decorations (*auto*, never, always).')
|
||||
[CompletionResult]::new('--paging', 'paging', [CompletionResultType]::ParameterName, 'Specify when to use the pager, or use `-P` to disable (*auto*, never, always).')
|
||||
[CompletionResult]::new('--pager', 'pager', [CompletionResultType]::ParameterName, 'Determine which pager to use.')
|
||||
[CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').')
|
||||
[CompletionResult]::new('--map-syntax', 'map-syntax', [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').')
|
||||
[CompletionResult]::new('--theme', 'theme', [CompletionResultType]::ParameterName, 'Set the color theme for syntax highlighting.')
|
||||
[CompletionResult]::new('--style', 'style', [CompletionResultType]::ParameterName, 'Comma-separated list of style elements to display (*auto*, full, plain, changes, header, grid, rule, numbers, snip).')
|
||||
[CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Only print the lines from N to M.')
|
||||
[CompletionResult]::new('--line-range', 'line-range', [CompletionResultType]::ParameterName, 'Only print the lines from N to M.')
|
||||
[CompletionResult]::new('-A', 'A', [CompletionResultType]::ParameterName, 'Show non-printable characters (space, tab, newline, ..).')
|
||||
[CompletionResult]::new('--show-all', 'show-all', [CompletionResultType]::ParameterName, 'Show non-printable characters (space, tab, newline, ..).')
|
||||
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Show plain style (alias for ''--style=plain'').')
|
||||
[CompletionResult]::new('--plain', 'plain', [CompletionResultType]::ParameterName, 'Show plain style (alias for ''--style=plain'').')
|
||||
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Only show lines that have been added/removed/modified.')
|
||||
[CompletionResult]::new('--diff', 'diff', [CompletionResultType]::ParameterName, 'Only show lines that have been added/removed/modified.')
|
||||
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Show line numbers (alias for ''--style=numbers'').')
|
||||
[CompletionResult]::new('--number', 'number', [CompletionResultType]::ParameterName, 'Show line numbers (alias for ''--style=numbers'').')
|
||||
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'f')
|
||||
[CompletionResult]::new('--force-colorization', 'force-colorization', [CompletionResultType]::ParameterName, 'force-colorization')
|
||||
[CompletionResult]::new('-P', 'P', [CompletionResultType]::ParameterName, 'Alias for ''--paging=never''')
|
||||
[CompletionResult]::new('--no-paging', 'no-paging', [CompletionResultType]::ParameterName, 'Alias for ''--paging=never''')
|
||||
[CompletionResult]::new('--list-themes', 'list-themes', [CompletionResultType]::ParameterName, 'Display all supported highlighting themes.')
|
||||
[CompletionResult]::new('-L', 'L', [CompletionResultType]::ParameterName, 'Display all supported languages.')
|
||||
[CompletionResult]::new('--list-languages', 'list-languages', [CompletionResultType]::ParameterName, 'Display all supported languages.')
|
||||
[CompletionResult]::new('-u', 'u', [CompletionResultType]::ParameterName, 'u')
|
||||
[CompletionResult]::new('--unbuffered', 'unbuffered', [CompletionResultType]::ParameterName, 'unbuffered')
|
||||
[CompletionResult]::new('--no-config', 'no-config', [CompletionResultType]::ParameterName, 'Do not use the configuration file')
|
||||
[CompletionResult]::new('--no-custom-assets', 'no-custom-assets', [CompletionResultType]::ParameterName, 'Do not load custom assets')
|
||||
[CompletionResult]::new('--config-file', 'config-file', [CompletionResultType]::ParameterName, 'Show path to the configuration file.')
|
||||
[CompletionResult]::new('--generate-config-file', 'generate-config-file', [CompletionResultType]::ParameterName, 'Generates a default configuration file.')
|
||||
[CompletionResult]::new('--config-dir', 'config-dir', [CompletionResultType]::ParameterName, 'Show bat''s configuration directory.')
|
||||
[CompletionResult]::new('--cache-dir', 'cache-dir', [CompletionResultType]::ParameterName, 'Show bat''s cache directory.')
|
||||
[CompletionResult]::new('--diagnostic', 'diagnostic', [CompletionResultType]::ParameterName, 'Show diagnostic information for bug reports.')
|
||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print this help message.')
|
||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print this help message.')
|
||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Show version information.')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Show version information.')
|
||||
[CompletionResult]::new('cache', 'cache', [CompletionResultType]::ParameterValue, 'Modify the syntax-definition and theme cache')
|
||||
break
|
||||
}
|
||||
'{{PROJECT_EXECUTABLE}};cache' {
|
||||
[CompletionResult]::new('--source', 'source', [CompletionResultType]::ParameterName, 'Use a different directory to load syntaxes and themes from.')
|
||||
[CompletionResult]::new('--target', 'target', [CompletionResultType]::ParameterName, 'Use a different directory to store the cached syntax and theme set.')
|
||||
[CompletionResult]::new('-b', 'b', [CompletionResultType]::ParameterName, 'Initialize (or update) the syntax/theme cache.')
|
||||
[CompletionResult]::new('--build', 'build', [CompletionResultType]::ParameterName, 'Initialize (or update) the syntax/theme cache.')
|
||||
[CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Remove the cached syntax definitions and themes.')
|
||||
[CompletionResult]::new('--clear', 'clear', [CompletionResultType]::ParameterName, 'Remove the cached syntax definitions and themes.')
|
||||
[CompletionResult]::new('--blank', 'blank', [CompletionResultType]::ParameterName, 'Create completely new syntax and theme sets (instead of appending to the default sets).')
|
||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
|
||||
Sort-Object -Property ListItemText
|
||||
}
|
2
assets/completions/bat.fish.in
vendored
2
assets/completions/bat.fish.in
vendored
@@ -56,7 +56,7 @@ complete -c {{PROJECT_EXECUTABLE}} -s P -d "Disable paging. Alias for '--paging=
|
||||
|
||||
complete -c {{PROJECT_EXECUTABLE}} -s A -l show-all -d "Show non-printable characters like space/tab/newline" -n "not __fish_seen_subcommand_from cache"
|
||||
|
||||
complete -c {{PROJECT_EXECUTABLE}} -l style -xka "auto full plain changes header grid numbers" -d "Comma-separated list of style elements or presets to display with file contents" -n "not __fish_seen_subcommand_from cache"
|
||||
complete -c {{PROJECT_EXECUTABLE}} -l style -xka "auto full plain changes header grid rule numbers snip" -d "Comma-separated list of style elements or presets to display with file contents" -n "not __fish_seen_subcommand_from cache"
|
||||
|
||||
complete -c {{PROJECT_EXECUTABLE}} -l tabs -x -d "<T> Set the tab width to T spaces (width of 0 passes tabs through directly)" -n "not __fish_seen_subcommand_from cache"
|
||||
|
||||
|
2
assets/completions/bat.zsh.in
vendored
2
assets/completions/bat.zsh.in
vendored
@@ -75,7 +75,7 @@ _{{PROJECT_EXECUTABLE}}_main() {
|
||||
;;
|
||||
|
||||
style)
|
||||
_values -s , 'style' auto full plain changes header grid numbers snip
|
||||
_values -s , 'style' auto full plain changes header grid rule numbers snip
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
20
assets/create.sh
vendored
20
assets/create.sh
vendored
@@ -46,6 +46,7 @@ bat cache --clear
|
||||
# - Remove the JavaDoc patch once https://github.com/trishume/syntect/issues/222 has been fixed
|
||||
# - Remove the C# patch once https://github.com/sublimehq/Packages/pull/2331 has been merged
|
||||
|
||||
# Apply patches
|
||||
(
|
||||
cd "$ASSET_DIR"
|
||||
for patch in patches/*.patch; do
|
||||
@@ -53,11 +54,16 @@ bat cache --clear
|
||||
done
|
||||
)
|
||||
|
||||
bat cache --build --blank --source="$ASSET_DIR" --target="$ASSET_DIR"
|
||||
reverse_patches() {
|
||||
(
|
||||
cd "$ASSET_DIR"
|
||||
for patch in patches/*.patch; do
|
||||
patch --strip=0 --reverse <"$patch"
|
||||
done
|
||||
)
|
||||
}
|
||||
|
||||
(
|
||||
cd "$ASSET_DIR"
|
||||
for patch in patches/*.patch; do
|
||||
patch --strip=0 --reverse < "$patch"
|
||||
done
|
||||
)
|
||||
# Make sure to always reverse patches, even if the `bat cache` command fails or aborts
|
||||
trap reverse_patches EXIT
|
||||
|
||||
bat cache --build --blank --acknowledgements --source="$ASSET_DIR" --target="$ASSET_DIR"
|
||||
|
6
assets/manual/bat.1.in
vendored
6
assets/manual/bat.1.in
vendored
@@ -50,6 +50,8 @@ highlights lines 30 to 40
|
||||
highlights lines 1 to 40
|
||||
.IP "\-\-highlight\-line 40:"
|
||||
highlights lines 40 to the end of the file
|
||||
.IP "\-\-highlight\-line 30:+10"
|
||||
highlights lines 30 to 40
|
||||
.RE
|
||||
.HP
|
||||
\fB\-\-file\-name\fR <name>...
|
||||
@@ -116,6 +118,8 @@ which pager is used, see the '\-\-pager' option. Possible values: *auto*, never,
|
||||
Determine which pager is used. This option will override the PAGER and BAT_PAGER
|
||||
environment variables. The default pager is 'less'. To control when the pager is used, see
|
||||
the '\-\-paging' option. Example: '\-\-pager "less \fB\-RF\fR"'.
|
||||
|
||||
Note: By default, if the pager is set to 'less' (and no command-line options are specified), 'bat' will pass the following command line options to the pager: '-R'/'--RAW-CONTROL-CHARS', '-F'/'--quit-if-one-screen' and '-X'/'--no-init'. The last option ('-X') is only used for 'less' versions older than 530. The '-R' option is needed to interpret ANSI colors correctly. The second option ('-F') instructs less to exit immediately if the output size is smaller than the vertical size of the terminal. This is convenient for small files because you do not have to press 'q' to quit the pager. The third option ('-X') is needed to fix a bug with the '--quit-if-one-screen' feature in old versions of 'less'. Unfortunately, it also breaks mouse-wheel support in 'less'. If you want to enable mouse-wheel scrolling on older versions of 'less', you can pass just '-R' (as in the example above, this will disable the quit-if-one-screen feature). For less 530 or newer, it should work out of the box.
|
||||
.HP
|
||||
\fB\-m\fR, \fB\-\-map\-syntax\fR <glob-pattern:syntax-name>...
|
||||
.IP
|
||||
@@ -154,6 +158,8 @@ prints lines 30 to 40
|
||||
prints lines 1 to 40
|
||||
.IP "\-\-line\-range 40:"
|
||||
prints lines 40 to the end of the file
|
||||
.IP "\-\-line\-range 30:+10"
|
||||
prints lines 30 to 40
|
||||
.RE
|
||||
.HP
|
||||
\fB\-L\fR, \fB\-\-list\-languages\fR
|
||||
|
13
assets/patches/MediaWiki.sublime-syntax.patch
vendored
Normal file
13
assets/patches/MediaWiki.sublime-syntax.patch
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
diff --git syntaxes/02_Extra/MediaWiki/MediawikiNG.sublime-syntax syntaxes/02_Extra/MediaWiki/MediawikiNG.sublime-syntax
|
||||
index f542c9e..8eaf020 100644
|
||||
--- syntaxes/02_Extra/MediaWiki/MediawikiNG.sublime-syntax
|
||||
+++ syntaxes/02_Extra/MediaWiki/MediawikiNG.sublime-syntax
|
||||
@@ -1,7 +1,7 @@
|
||||
%YAML 1.2
|
||||
---
|
||||
# http://www.sublimetext.com/docs/3/syntax.html
|
||||
-name: Mediawiki NG
|
||||
+name: MediaWiki
|
||||
file_extensions: [mediawiki, wikipedia, wiki]
|
||||
scope: text.html.mediawiki
|
||||
|
BIN
assets/syntaxes.bin
vendored
BIN
assets/syntaxes.bin
vendored
Binary file not shown.
2
assets/syntaxes/02_Extra/Dart
vendored
2
assets/syntaxes/02_Extra/Dart
vendored
Submodule assets/syntaxes/02_Extra/Dart updated: d891fb36c9...2734901b01
332
assets/syntaxes/02_Extra/Dart.sublime-syntax
vendored
332
assets/syntaxes/02_Extra/Dart.sublime-syntax
vendored
@@ -1,6 +1,6 @@
|
||||
%YAML 1.2
|
||||
---
|
||||
# http://www.sublimetext.com/docs/3/syntax.html
|
||||
# http://www.sublimetext.com/docs/syntax.html
|
||||
name: Dart
|
||||
file_extensions:
|
||||
- dart
|
||||
@@ -9,7 +9,7 @@ contexts:
|
||||
main:
|
||||
- match: ^(#!.*)$
|
||||
scope: meta.preprocessor.script.dart
|
||||
- match: ^\s*\b(library|import|export|part of|part)\b
|
||||
- match: ^\w*\b(library|import|part of|part|export)\b
|
||||
captures:
|
||||
0: keyword.other.import.dart
|
||||
push:
|
||||
@@ -19,242 +19,114 @@ contexts:
|
||||
0: punctuation.terminator.dart
|
||||
pop: true
|
||||
- include: strings
|
||||
- match: \b(as|show|hide|deferred)\b
|
||||
- include: comments
|
||||
- match: \b(as|show|hide)\b
|
||||
scope: keyword.other.import.dart
|
||||
- include: comments
|
||||
- include: constants-and-special-vars
|
||||
- include: punctuation
|
||||
- include: annotations
|
||||
- include: decl-typedef
|
||||
- include: decl-class
|
||||
- include: decl-enum
|
||||
- include: decl-function
|
||||
- include: keywords
|
||||
- include: constants-and-special-vars
|
||||
- include: strings
|
||||
annotations:
|
||||
- match: '^(?:\s*)((@)([a-zA-Z0-9_]+))'
|
||||
captures:
|
||||
1: annotation.dart
|
||||
2: entity.name.function.annotation.dart
|
||||
3: support.type.dart
|
||||
- match: '@[a-zA-Z]+'
|
||||
scope: storage.type.annotation.dart
|
||||
comments:
|
||||
- match: /\*\*/
|
||||
scope: comment.block.empty.dart
|
||||
captures:
|
||||
0: punctuation.definition.comment.dart
|
||||
- include: comments-doc-oldschool
|
||||
- include: comments-doc
|
||||
- include: comments-inline
|
||||
comments-inline:
|
||||
comments-block:
|
||||
- match: /\*
|
||||
push:
|
||||
- meta_scope: comment.block.dart
|
||||
- match: \*/
|
||||
pop: true
|
||||
- include: scope:text.dart-doccomments
|
||||
- match: (///)
|
||||
captures:
|
||||
1: marker.dart
|
||||
- include: comments-block
|
||||
comments-doc:
|
||||
- match: ///
|
||||
push:
|
||||
- meta_scope: comment.line.triple-slash.dart
|
||||
- match: $
|
||||
- meta_scope: comment.block.documentation.dart
|
||||
- match: .*
|
||||
pop: true
|
||||
- include: scope:text.dart-doccomments
|
||||
- match: (//)
|
||||
captures:
|
||||
1: marker.dart
|
||||
- include: dartdoc
|
||||
comments-doc-oldschool:
|
||||
- match: /\*\*
|
||||
push:
|
||||
- meta_scope: comment.line.double-slash.dart
|
||||
- match: $
|
||||
- meta_scope: comment.block.documentation.dart
|
||||
- match: \*/
|
||||
pop: true
|
||||
- include: scope:text.dart-doccomments
|
||||
- include: comments-doc-oldschool
|
||||
- include: comments-block
|
||||
- include: dartdoc
|
||||
comments-inline:
|
||||
- include: comments-block
|
||||
- match: ((//).*)$
|
||||
captures:
|
||||
1: comment.line.double-slash.dart
|
||||
constants-and-special-vars:
|
||||
- match: \b(true|false|null)\b
|
||||
- match: (?<!\$)\b(true|false|null)\b(?!\$)
|
||||
scope: constant.language.dart
|
||||
- match: \b(this|super)\b
|
||||
- match: (?<!\$)\b(this|super)\b(?!\$)
|
||||
scope: variable.language.dart
|
||||
- match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b'
|
||||
- match: '(?<!\$)\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b(?!\$)'
|
||||
scope: constant.numeric.dart
|
||||
decl-class:
|
||||
- match: \bclass\b
|
||||
- match: '(?<![a-zA-Z0-9_$])([_$]*[A-Z][a-zA-Z0-9_$]*|bool\b|num\b|int\b|double\b|dynamic\b)'
|
||||
scope: support.class.dart
|
||||
- match: '([_$]*[a-z][a-zA-Z0-9_$]*)(<|\(|\s+=>)'
|
||||
captures:
|
||||
0: keyword.control.new.dart
|
||||
1: entity.name.function.dart
|
||||
dartdoc:
|
||||
- match: '(\[.*?\])'
|
||||
captures:
|
||||
0: variable.name.source.dart
|
||||
- match: '^ {4,}(?![ \*]).*'
|
||||
captures:
|
||||
0: variable.name.source.dart
|
||||
- match: '```.*?$'
|
||||
push:
|
||||
- meta_scope: meta.declaration.class.dart
|
||||
- match: "(?={)"
|
||||
- meta_content_scope: variable.other.source.dart
|
||||
- match: '```'
|
||||
pop: true
|
||||
- include: keywords
|
||||
- match: "[A-Za-z_][A-Za-z0-9_]*"
|
||||
scope: class.name.dart
|
||||
decl-enum:
|
||||
- match: \benum\b
|
||||
- match: (`.*?`)
|
||||
captures:
|
||||
0: keyword.declaration.dart
|
||||
push:
|
||||
- meta_scope: meta.declaration.enum.dart
|
||||
- match: "(?={)"
|
||||
pop: true
|
||||
- include: keywords
|
||||
- match: "[A-Za-z_][A-Za-z0-9_]*"
|
||||
scope: enum.name.dart
|
||||
decl-function:
|
||||
- match: ^\s*(?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b)\s+(get)\s+(\w+)\s+(?==>)
|
||||
comment: A getter with a primitive return type.
|
||||
scope: meta.declaration.function.dart
|
||||
0: variable.other.source.dart
|
||||
- match: (`.*?`)
|
||||
captures:
|
||||
1: storage.type.primitive.dart
|
||||
2: keyword.declaration.dart
|
||||
3: function.name.dart
|
||||
- match: ^\s*(?:\b(\w+)\b\s+)?(get)\s+(\w+)\s+(?==>)
|
||||
comment: A getter with a user-defined return type or no return type.
|
||||
scope: meta.declaration.function.dart
|
||||
0: variable.other.source.dart
|
||||
- match: (\* (( ).*))$
|
||||
captures:
|
||||
1: type.user-defined.dart
|
||||
2: keyword.declaration.dart
|
||||
3: function.name.dart
|
||||
- match: ^\s*(set)\s+(\w+)(?=\()
|
||||
comment: A setter.
|
||||
captures:
|
||||
1: keyword.declaration.dart
|
||||
2: function.name.dart
|
||||
push:
|
||||
- meta_scope: meta.declaration.function.dart
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: comments-inline
|
||||
- include: decl-function-parameter
|
||||
- include: strings
|
||||
- include: keywords
|
||||
- match: ^\s*(?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b)\s+(\w+)(?=\()
|
||||
comment: A function with a primitive return type.
|
||||
captures:
|
||||
1: storage.type.primitive.dart
|
||||
2: function.name.dart
|
||||
push:
|
||||
- meta_scope: meta.declaration.function.dart
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: comments-inline
|
||||
- include: decl-function-parameter
|
||||
- include: strings
|
||||
- include: keywords
|
||||
- match: ^\s*(?:\b(return)\b)\s+(\w+)(?=\()
|
||||
comment: A function invocation after 'return'
|
||||
captures:
|
||||
1: keyword.control.dart
|
||||
2: function.name.dart
|
||||
push:
|
||||
- meta_scope: meta.invocation.function.dart
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: comments-inline
|
||||
- include: decl-function-parameter
|
||||
- include: strings
|
||||
- include: keywords
|
||||
- match: ^\s*\b(new)\b\s+(\w+)(?=\()
|
||||
comment: A class instantiation after 'new'
|
||||
captures:
|
||||
1: keyword.declaration.dart
|
||||
2: function.name.dart
|
||||
push:
|
||||
- meta_scope: meta.invocation.function.dart
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: comments-inline
|
||||
- include: decl-function-parameter
|
||||
- include: strings
|
||||
- include: keywords
|
||||
decl-function-parameter:
|
||||
- include: constants-and-special-vars
|
||||
- match: (?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b)\s+(\w+)(?=\()
|
||||
comment: A function with a primitive return type.
|
||||
captures:
|
||||
1: storage.type.primitive.dart
|
||||
2: function.name.dart
|
||||
push:
|
||||
- meta_scope: meta.parameter.function.dart
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: decl-function-parameter
|
||||
- include: strings
|
||||
- include: keywords
|
||||
- match: \b(new)\b\s+(\w+)(?=\()
|
||||
comment: A class instantiation after 'new'
|
||||
captures:
|
||||
1: keyword.declaration.dart
|
||||
2: function.name.dart
|
||||
push:
|
||||
- meta_scope: meta.invocation.function.dart
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: decl-function-parameter
|
||||
- include: strings
|
||||
- include: keywords
|
||||
- match: (?:\b(\w+)\b)\s+(\w+)(?=\()
|
||||
comment: A function with a user-defined return type.
|
||||
captures:
|
||||
1: type.user-defined.dart
|
||||
2: function.name.dart
|
||||
push:
|
||||
- meta_scope: meta.parameter.function.dart
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: decl-function-parameter
|
||||
- include: strings
|
||||
- include: keywords
|
||||
- match: (\w+)(?=\()
|
||||
comment: A function with no return type.
|
||||
captures:
|
||||
1: function.name.dart
|
||||
push:
|
||||
- meta_scope: meta.parameter.function.dart
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: decl-function-parameter
|
||||
- include: strings
|
||||
- include: keywords
|
||||
decl-typedef:
|
||||
- match: typedef
|
||||
captures:
|
||||
0: keyword.control.new.dart
|
||||
push:
|
||||
- meta_scope: meta.declaration.typedef.dart
|
||||
- match: ;
|
||||
captures:
|
||||
0: punctuation.terminator.dart
|
||||
pop: true
|
||||
- match: '(?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b|([a-zA-Z_][a-zA-Z0-9_]*))\s+([a-zA-Z_][a-zA-Z0-9_]+)'
|
||||
captures:
|
||||
1: storage.type.primitive.dart
|
||||
2: typedef.return.dart
|
||||
3: typedef.name.dart
|
||||
- match: \(
|
||||
push:
|
||||
- meta_scope: typedef.params.dart
|
||||
- match: \)
|
||||
pop: true
|
||||
- include: keywords
|
||||
2: variable.other.source.dart
|
||||
- match: (\* .*)$
|
||||
keywords:
|
||||
- match: \bassert\b
|
||||
scope: keyword.control.assert.dart
|
||||
- match: \bas\b
|
||||
- match: (?<!\$)\bas\b(?!\$)
|
||||
scope: keyword.cast.dart
|
||||
- match: \b(try|catch|finally|throw|on|rethrow)\b
|
||||
- match: (?<!\$)\b(try|on|catch|finally|throw|rethrow)\b(?!\$)
|
||||
scope: keyword.control.catch-exception.dart
|
||||
- match: \s+\?\s+|\s+:\s+
|
||||
scope: keyword.control.ternary.dart
|
||||
- match: \b(break|case|continue|default|do|else|for|if|in|return|switch|while)\b
|
||||
- match: (?<!\$)\b(break|case|continue|default|do|else|for|if|in|return|switch|while)\b(?!\$)
|
||||
scope: keyword.control.dart
|
||||
- match: \b(async\*|async|await\*|await|yield)\b
|
||||
scope: keyword.control.async.dart
|
||||
- match: \b(new)\b
|
||||
- match: (?<!\$)\b(sync(\*)?|async(\*)?|await|yield(\*)?)\b(?!\$)
|
||||
scope: keyword.control.dart
|
||||
- match: (?<!\$)\bassert\b(?!\$)
|
||||
scope: keyword.control.dart
|
||||
- match: (?<!\$)\b(new)\b(?!\$)
|
||||
scope: keyword.control.new.dart
|
||||
- match: \b(abstract|extends|external|factory|implements|with|interface|get|native|operator|set|typedef)\b
|
||||
- match: (?<!\$)\b(abstract|class|enum|extends|external|factory|implements|get|mixin|native|operator|set|typedef|with|covariant)\b(?!\$)
|
||||
scope: keyword.declaration.dart
|
||||
- match: \b(is\!?)\b
|
||||
- match: (?<!\$)\b(is\!?)\b(?!\$)
|
||||
scope: keyword.operator.dart
|
||||
- match: '\?|:'
|
||||
scope: keyword.operator.ternary.dart
|
||||
- match: (<<|>>>?|~|\^|\||&)
|
||||
scope: keyword.operator.bitwise.dart
|
||||
- match: ((&|\^|\||<<|>>>?)=)
|
||||
scope: keyword.operator.assignment.bitwise.dart
|
||||
- match: (===?|!==?|<=?|>=?)
|
||||
- match: (=>)
|
||||
scope: keyword.operator.closure.dart
|
||||
- match: (==|!=|<=?|>=?)
|
||||
scope: keyword.operator.comparison.dart
|
||||
- match: '(([+*/%-]|\~)=)'
|
||||
scope: keyword.operator.assignment.arithmetic.dart
|
||||
@@ -266,56 +138,22 @@ contexts:
|
||||
scope: keyword.operator.arithmetic.dart
|
||||
- match: (!|&&|\|\|)
|
||||
scope: keyword.operator.logical.dart
|
||||
- match: (?<!\$)\b(static|final|const)\b(?!\$)
|
||||
scope: storage.modifier.dart
|
||||
- match: (?<!\$)\b(?:void|var)\b(?!\$)
|
||||
scope: storage.type.primitive.dart
|
||||
punctuation:
|
||||
- match: ','
|
||||
scope: punctuation.comma.dart
|
||||
- match: ;
|
||||
scope: punctuation.terminator.dart
|
||||
- match: \b(static|final|const)\b
|
||||
scope: storage.modifier.dart
|
||||
- match: \b(?:void|bool|num|int|double|dynamic|var|String|List|Map)\b
|
||||
scope: storage.type.primitive.dart
|
||||
regexp:
|
||||
- match: '\\[^''"]'
|
||||
scope: constant.character.escaped.regex.dart
|
||||
- match: \(
|
||||
push:
|
||||
- meta_content_scope: meta.capture.regex.dart
|
||||
- match: \)
|
||||
pop: true
|
||||
- match: \?(:|=|!)
|
||||
scope: ignore.capture.regex.dart
|
||||
- match: \*|\+|\?|\.|\|
|
||||
scope: keyword.other.regex.dart
|
||||
- match: \^|\$
|
||||
scope: keyword.other.regex.dart
|
||||
- match: \.
|
||||
scope: constant.other.regex.dart
|
||||
- match: '\[(\^)?'
|
||||
captures:
|
||||
1: keyword.other.negation.regex.dart
|
||||
push:
|
||||
- meta_scope: constant.character.range.regex.dart
|
||||
- match: '\]'
|
||||
pop: true
|
||||
- match: '\\[^"'']'
|
||||
scope: constant.character.escaped.regex.dart
|
||||
- match: '\{(?:\d+)?,(?:\d+)?\}'
|
||||
scope: keyword.other.regex.dart
|
||||
scope: punctuation.dot.dart
|
||||
string-interp:
|
||||
- match: '(\$)(\{)'
|
||||
- match: '\$((\w+)|\{([^{}]+)\})'
|
||||
captures:
|
||||
1: keyword.other.dart
|
||||
2: keyword.other.dart
|
||||
push:
|
||||
- meta_scope: interpolation.dart
|
||||
- meta_content_scope: source.dart
|
||||
- match: '(\})'
|
||||
captures:
|
||||
1: keyword.other.dart
|
||||
pop: true
|
||||
- include: main
|
||||
- match: (\$)(\w+)
|
||||
captures:
|
||||
1: keyword.other.dart
|
||||
2: variable.parameter.dart
|
||||
3: variable.parameter.dart
|
||||
- match: \\.
|
||||
scope: constant.character.escape.dart
|
||||
strings:
|
||||
@@ -328,7 +166,7 @@ contexts:
|
||||
- match: (?<!r)'''
|
||||
push:
|
||||
- meta_scope: string.interpolated.triple.single.dart
|
||||
- match: "'''(?!')"
|
||||
- match: '''''''(?!'')'
|
||||
pop: true
|
||||
- include: string-interp
|
||||
- match: r"""
|
||||
@@ -339,9 +177,9 @@ contexts:
|
||||
- match: r'''
|
||||
push:
|
||||
- meta_scope: string.quoted.triple.single.dart
|
||||
- match: "'''(?!')"
|
||||
- match: '''''''(?!'')'
|
||||
pop: true
|
||||
- match: (?<!\\|r)"
|
||||
- match: (?<!\|r)"
|
||||
push:
|
||||
- meta_scope: string.interpolated.double.dart
|
||||
- match: '"'
|
||||
@@ -354,16 +192,20 @@ contexts:
|
||||
- meta_scope: string.quoted.double.dart
|
||||
- match: '"'
|
||||
pop: true
|
||||
- include: regexp
|
||||
- match: \n
|
||||
scope: invalid.string.newline
|
||||
- match: (?<!\|r)'
|
||||
push:
|
||||
- meta_scope: string.interpolated.single.dart
|
||||
- match: "'"
|
||||
pop: true
|
||||
- match: \n
|
||||
scope: invalid.string.newline
|
||||
- include: string-interp
|
||||
- match: r'
|
||||
push:
|
||||
- meta_scope: string.quoted.single.dart
|
||||
- match: "'"
|
||||
pop: true
|
||||
- include: regexp
|
||||
- match: \n
|
||||
scope: invalid.string.newline
|
||||
|
2
assets/syntaxes/02_Extra/GLSL
vendored
2
assets/syntaxes/02_Extra/GLSL
vendored
Submodule assets/syntaxes/02_Extra/GLSL updated: 4cd4acfffc...59a5f8a312
2
assets/syntaxes/02_Extra/GraphQL
vendored
2
assets/syntaxes/02_Extra/GraphQL
vendored
Submodule assets/syntaxes/02_Extra/GraphQL updated: 59304d6c7b...9b6f6d0a86
2
assets/syntaxes/02_Extra/Julia
vendored
2
assets/syntaxes/02_Extra/Julia
vendored
Submodule assets/syntaxes/02_Extra/Julia updated: 48639e1dbf...1e55f3211b
2
assets/syntaxes/02_Extra/LESS
vendored
2
assets/syntaxes/02_Extra/LESS
vendored
Submodule assets/syntaxes/02_Extra/LESS updated: a2eae0453e...836b47ec61
1
assets/syntaxes/02_Extra/LiveScript
vendored
Submodule
1
assets/syntaxes/02_Extra/LiveScript
vendored
Submodule
Submodule assets/syntaxes/02_Extra/LiveScript added at 2575013851
400
assets/syntaxes/02_Extra/LiveScript.sublime-syntax
vendored
Normal file
400
assets/syntaxes/02_Extra/LiveScript.sublime-syntax
vendored
Normal file
@@ -0,0 +1,400 @@
|
||||
%YAML 1.2
|
||||
---
|
||||
# http://www.sublimetext.com/docs/3/syntax.html
|
||||
name: LiveScript
|
||||
comment: "LiveScript Syntax: version 1"
|
||||
file_extensions:
|
||||
- ls
|
||||
- Slakefile
|
||||
- ls.erb
|
||||
first_line_match: ^#!.*\bls
|
||||
scope: source.livescript
|
||||
contexts:
|
||||
main:
|
||||
- match: |-
|
||||
(?x)
|
||||
!?[~-]{1,2}>\*?
|
||||
|<[~-]{1,2}!?
|
||||
|\(\s* (?= instanceof[\s)]|and[\s)]|or[\s)]|is[\s)]|isnt[\s)]|in[\s)]|import[\s)]|import\ all[\s)] |\.|[-+/*%^&<>=|][\b\s)\w$]|\*\*|\%\%)
|
||||
| (?<=[\s(]instanceof|[\s(]and|[\s(]or|[\s(]is|[\s(]isnt|[\s(]in|[\s(]import|[\s(]import\ all|[\s(]do|\.|\*\*|\%\%|[\b\s(\w$][-+/*%^&<>=|]) \s*\)
|
||||
scope: storage.type.function.livescript
|
||||
- match: \/\*
|
||||
captures:
|
||||
0: punctuation.definition.comment.livescript
|
||||
push:
|
||||
- meta_scope: comment.block.livescript
|
||||
- match: \*\/
|
||||
captures:
|
||||
0: punctuation.definition.comment.livescript
|
||||
pop: true
|
||||
- match: '@\w*'
|
||||
scope: storage.type.annotation.livescriptscript
|
||||
- match: '(#)(?!\{).*$\n?'
|
||||
scope: comment.line.number-sign.livescript
|
||||
captures:
|
||||
1: punctuation.definition.comment.livescript
|
||||
- match: '((?:!|~|!~|~!)?function\*?)\s+([$\w\-]*[$\w]+)'
|
||||
captures:
|
||||
1: storage.type.function.livescript
|
||||
2: entity.name.function.livescript
|
||||
- match: (new)\s+(\w+(?:\.\w*)*)
|
||||
captures:
|
||||
1: keyword.operator.new.livescript
|
||||
2: entity.name.type.instance.livescript
|
||||
- match: \b(package|private|protected|public|interface|enum|static)(?!-)\b
|
||||
scope: keyword.illegal.livescript
|
||||
- match: "'''"
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.livescript
|
||||
push:
|
||||
- meta_scope: string.quoted.heredoc.livescript
|
||||
- match: "'''"
|
||||
captures:
|
||||
0: punctuation.definition.string.end.livescript
|
||||
pop: true
|
||||
- match: '"""'
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.livescript
|
||||
push:
|
||||
- meta_scope: string.quoted.double.heredoc.livescript
|
||||
- match: '"""'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.livescript
|
||||
pop: true
|
||||
- match: \\.
|
||||
scope: constant.character.escape.livescript
|
||||
- include: interpolated_livescript
|
||||
- match: "``"
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.livescript
|
||||
push:
|
||||
- meta_scope: string.quoted.script.livescript
|
||||
- match: "``"
|
||||
captures:
|
||||
0: punctuation.definition.string.end.livescript
|
||||
pop: true
|
||||
- match: '\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)'
|
||||
scope: constant.character.escape.livescript
|
||||
- match: '<\['
|
||||
push:
|
||||
- meta_scope: string.array-literal.livescript
|
||||
- match: '\]>'
|
||||
pop: true
|
||||
- match: '/{2}(?![\s=/*+{}?]).*?[^\\]/[igmy]{0,4}(?![a-zA-Z0-9])/{2}'
|
||||
scope: string.regexp.livescript
|
||||
- match: '/{2}\n'
|
||||
push:
|
||||
- meta_scope: string.regexp.livescript
|
||||
- match: "/{2}[imgy]{0,4}"
|
||||
pop: true
|
||||
- include: embedded_spaced_comment
|
||||
- include: interpolated_livescript
|
||||
- match: "/{2}"
|
||||
push:
|
||||
- meta_scope: string.regexp.livescript
|
||||
- match: "/{2}[imgy]{0,4}"
|
||||
pop: true
|
||||
- match: '\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)'
|
||||
scope: constant.character.escape.livescript
|
||||
- include: interpolated_livescript
|
||||
- match: '/(?![\s=/*+{}?]).*?[^\\]/[igmy]{0,4}(?![a-zA-Z0-9])'
|
||||
scope: string.regexp.livescript
|
||||
- match: |-
|
||||
(?x)
|
||||
\b(?<![\.\$\-@])(
|
||||
instanceof|new|delete|typeof|and|or|is|isnt|not
|
||||
)(?!\-|\s*:)\b
|
||||
scope: keyword.operator.livescript
|
||||
- match: <\||\|>
|
||||
scope: keyword.operator.livescript
|
||||
- match: "=>"
|
||||
scope: keyword.control.livescript
|
||||
- match: |-
|
||||
(?x)
|
||||
\b(?<![\.\$\-@])(?:
|
||||
return|break|continue|throw
|
||||
|try|if|while|for|for\s+own|switch|unless|until
|
||||
|catch|finally|else|nobreak|case|default|fallthrough|when|otherwise|then
|
||||
|yield
|
||||
)(?!\-|\s*:)\b
|
||||
scope: keyword.control.livescript
|
||||
- match: |-
|
||||
(?x)
|
||||
and=|or=|%|&|\^|\*|\/|(?<![a-zA-Z$_])(\-)?\-(?!\-?>)|\+\+|\+|
|
||||
~(?!~?>)|==|=|!=|<=|>=|<<=|>>=|
|
||||
>>>=|<>|<(?!\[)|(?<!\])>|(?<!\w)!(?!([~\-]+)?>)|&&|\.\.(\.)?|\s\.\s|\?|\|\||\:|\*=|(?<!\()/=|%=|\+=|\-=|\.=|&=
|
||||
|\^=
|
||||
scope: keyword.operator.livescript
|
||||
- match: |-
|
||||
(?x)
|
||||
\b(?<![\.\$\-@])(?:
|
||||
function
|
||||
)(?!\-|\s*:)\b
|
||||
scope: storage.type.function.livescript
|
||||
- match: |-
|
||||
(?x)
|
||||
\b(?<![\.\$\-@])(?:
|
||||
this|throw|then|try|typeof!?|til|to
|
||||
|continue|const|case|catch|class
|
||||
|in|instanceof|import|import\s+all|implements|if|is
|
||||
|default|delete|debugger|do
|
||||
|for|for\s+own|finally|function|from|fallthrough
|
||||
|super|switch
|
||||
|else|nobreak|extends|export|eval
|
||||
|and|arguments
|
||||
|new|not
|
||||
|unless|until
|
||||
|while|with|when
|
||||
|of|or|otherwise
|
||||
|let|var|loop
|
||||
|match
|
||||
|by|yield
|
||||
)(?!\-|\s*:)\b
|
||||
scope: keyword.other.livescript
|
||||
- match: '([a-zA-Z\$_](?:[\w$.-])*)\s*(?!\::)((:)|(=(?!>)))\s*(?!(\s*!?\s*\(.*\))?\s*(!?[~-]{1,2}>\*?))'
|
||||
captures:
|
||||
1: variable.assignment.livescript
|
||||
3: punctuation.separator.key-value, keyword.operator.livescript
|
||||
4: keyword.operator.livescript
|
||||
- match: '(?<=\s|^)([\[\{])(?=.*?[\]\}]\s+[:=])'
|
||||
captures:
|
||||
0: keyword.operator.livescript
|
||||
push:
|
||||
- meta_scope: meta.variable.assignment.destructured.livescript
|
||||
- match: '([\]\}]\s*[:=])'
|
||||
captures:
|
||||
0: keyword.operator.livescript
|
||||
pop: true
|
||||
- include: variable_name
|
||||
- include: instance_variable
|
||||
- include: single_quoted_string
|
||||
- include: double_quoted_string
|
||||
- include: numeric
|
||||
- match: |-
|
||||
(?x)
|
||||
(\s*)
|
||||
(?=[a-zA-Z\$_])
|
||||
([a-zA-Z\$_]([\w$.:-])*)\s*
|
||||
(?=[:=](\s*!?\s*\(.*\))?\s*(!?[~-]{1,2}>\*?))
|
||||
scope: meta.function.livescript
|
||||
captures:
|
||||
2: entity.name.function.livescript
|
||||
3: entity.name.function.livescript
|
||||
4: variable.parameter.function.livescript
|
||||
5: storage.type.function.livescript
|
||||
- match: \b(?<!\.)(true|on|yes)(?!\s*:)\b
|
||||
scope: constant.language.boolean.true.livescript
|
||||
- match: \b(?<!\.)(false|off|no)(?!\s*:)\b
|
||||
scope: constant.language.boolean.false.livescript
|
||||
- match: \b(?<!\.)(null|void)(?!\s*:)\b
|
||||
scope: constant.language.null.livescript
|
||||
- match: \b(?<!\.)(super|this|extends)(?!\s*:)\b
|
||||
scope: variable.language.livescript
|
||||
- match: '(class\b)\s+(@?[a-zA-Z$_][\w$.-]*)?(?:\s+(extends)\s+(@?[a-zA-Z$_][\w$.-]*))?'
|
||||
scope: meta.class.livescript
|
||||
captures:
|
||||
1: storage.type.class.livescript
|
||||
2: entity.name.type.class.livescript
|
||||
3: keyword.control.inheritance.livescript
|
||||
4: entity.other.inherited-class.livescript
|
||||
- match: \b(debugger|\\)\b
|
||||
scope: keyword.other.livescript
|
||||
- match: |-
|
||||
(?x)\b(
|
||||
Array|ArrayBuffer|Blob|Boolean|Date|document|event|Function|
|
||||
Int(8|16|32|64)Array|Math|Map|Number|
|
||||
Object|Proxy|RegExp|Set|String|WeakMap|
|
||||
window|Uint(8|16|32|64)Array|XMLHttpRequest
|
||||
)\b
|
||||
scope: support.class.livescript
|
||||
- match: \b(console)\b
|
||||
scope: entity.name.type.object.livescript
|
||||
- match: \b(Infinity|NaN|undefined)\b
|
||||
scope: constant.language.livescript
|
||||
- match: \;
|
||||
scope: punctuation.terminator.statement.livescript
|
||||
- match: ',[ |\t]*'
|
||||
scope: meta.delimiter.object.comma.livescript
|
||||
- match: \.
|
||||
scope: meta.delimiter.method.period.livescript
|
||||
- match: '\{|\}'
|
||||
scope: meta.brace.curly.livescript
|
||||
- match: \(|\)
|
||||
scope: meta.brace.round.livescript
|
||||
- match: '\[|\]\s*'
|
||||
scope: meta.brace.square.livescript
|
||||
- include: instance_variable
|
||||
- include: backslash_string
|
||||
- include: single_quoted_string
|
||||
- include: double_quoted_string
|
||||
- include: numeric
|
||||
- match: '()(@|@@|[$\w\-]*[$\w]+)\s*(`)'
|
||||
captures:
|
||||
1: keyword.operator.livescript
|
||||
2: meta.function-call.livescript
|
||||
3: keyword.operator.livescript
|
||||
- match: "`"
|
||||
scope: keyword.operator.livescript
|
||||
- match: '()(@|@@|[$\w\-]*[$\w]+)(?:(\??\!)|[(])'
|
||||
captures:
|
||||
1: keyword.operator.livescript
|
||||
2: meta.function-call.livescript
|
||||
3: keyword.operator.livescript
|
||||
- match: '(@|@@|[$\w\-]*[$\w]+)(\?)? (?!\s*(((by|of|and|or|with|when|unless|if|is|isnt|else|nobreak|for|from|not in|in|catch|til|to|then|import|extends|implements|instanceof)\b)|[=:.*\/+\-%\^<>][ =)]|[`}%*)]|/(?!.*?/)|&&|[.][^.]|=>|\/ +|\||\|\||\-\-|\+\+|\|>|<|\||$|\n|\#|/\*))'
|
||||
captures:
|
||||
1: meta.function-call.livescript
|
||||
2: keyword.operator.livescript
|
||||
- match: \| _
|
||||
scope: keyword.control.livescript
|
||||
- match: '\|(?![.])'
|
||||
scope: keyword.control.livescript
|
||||
- match: \|
|
||||
scope: keyword.operator.livescript
|
||||
- match: ((?<=console\.)(debug|warn|info|log|error|time(End|-end)|assert))\b
|
||||
scope: support.function.console.livescript
|
||||
- match: |-
|
||||
(?x)\b(
|
||||
decodeURI(Component)?|encodeURI(Component)?|eval|parse(Float|Int)|require
|
||||
)\b
|
||||
scope: support.function.livescript
|
||||
- match: |-
|
||||
(?x)(?<![.-])\b(
|
||||
map|filter|reject|partition|find|each|head|tail|last|initial|empty|
|
||||
values|keys|length|cons|append|join|reverse|fold(l|r)?1?|unfoldr|
|
||||
and(List|-list)|or(List|-list)|any|all|unique|sum|product|mean|compact|
|
||||
concat(Map|-map)?|maximum|minimum|scan(l|r)?1?|replicate|slice|apply|
|
||||
split(At|-at)?|take(While|-while)?|drop(While|-while)?|span|first|
|
||||
break(It|-it)|list(ToObj|-to-obj)|obj(ToFunc|-to-func)|
|
||||
pairs(ToObj|-to-obj)|obj(ToPairs|-to-pairs|ToLists|-to-lists)|
|
||||
zip(All|-all)?(With|-with)?|compose|curry|partial|flip|fix|
|
||||
sort(With|-with|By|-by)?|group(By|-by)|break(List|-list|Str|-str)|
|
||||
difference|intersection|union|average|flatten|chars|unchars|repeat|
|
||||
lines|unlines|words|unwords|max|min|negate|abs|signum|quot|rem|div|mod|
|
||||
recip|pi|tau|exp|sqrt|ln|pow|sin|cos|tan|asin|acos|atan|atan2|truncate|
|
||||
round|ceiling|floor|is(It|-it)NaN|even|odd|gcd|lcm|disabled__id
|
||||
)\b(?![.-])
|
||||
comment: |
|
||||
Generated by DOM query from http://gkz.github.com/prelude-ls/:
|
||||
[].slice
|
||||
.call(document.querySelectorAll(".nav-pills li a"))
|
||||
.map(function(_) {return _.innerText})
|
||||
.filter(function(_) {return _.trim() !== '})
|
||||
.slice(2)
|
||||
.join("|")
|
||||
scope: support.function.prelude.livescript
|
||||
- match: '(?x)(?<![.-])\b(that|it|e|_)\b'
|
||||
scope: support.function.semireserved.livescript
|
||||
- match: |-
|
||||
(?x)((?<=(\.|\]|\)))(
|
||||
apply|call|concat|every|filter|for(Each|-each)|
|
||||
from|has(Own|-own)(Property|-property)|index(Of|-of)|
|
||||
is(Prototype|-prototype)(Of|-of)|join|last(Index|-index)(Of|-of)|
|
||||
map|of|pop|property(Is|-is)(Enumerable|-enumerable)|push|
|
||||
reduce(Right|-right)?|reverse|shift|slice|some|sort|
|
||||
splice|to(Locale|-locale)?(String|-string)|unshift|valueOf
|
||||
))\b(?!-)
|
||||
scope: support.function.method.array.livescript
|
||||
- match: |-
|
||||
(?x)((?<=Array\.)(
|
||||
isArray
|
||||
))\b
|
||||
scope: support.function.static.array.livescript
|
||||
- match: |-
|
||||
(?x)((?<=Object\.)(
|
||||
create|define(Propert|-propert)(ies|y)|freeze|
|
||||
get(Own|-own)(Property|-property)(Descriptors?|Names)|
|
||||
get(Property|-property)(Descriptor|Names)|getPrototypeOf|
|
||||
is((Extensible|-extensible)|(Frozen|-frozen)|(Sealed|-sealed))?|
|
||||
keys|prevent(Extensions|-extensions)|seal
|
||||
))\b
|
||||
scope: support.function.static.object.livescript
|
||||
- match: |-
|
||||
(?x)((?<=Math\.)(
|
||||
abs|acos|acosh|asin|asinh|atan|atan2|atanh|ceil|cos|cosh|exp|expm1|floor|
|
||||
hypot|log|log10|log1p|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|
|
||||
tan|tanh|trunc
|
||||
))\b
|
||||
scope: support.function.static.math.livescript
|
||||
- match: |-
|
||||
(?x)((?<=Number\.)(
|
||||
is(Finite|Integer|NaN)|to(Integer|-integer)
|
||||
))\b
|
||||
scope: support.function.static.number.livescript
|
||||
- match: '[\$\w][\w-]*'
|
||||
scope: variable.other.livescript
|
||||
backslash_string:
|
||||
- match: '\\([\\)\s,\};\]])?'
|
||||
captures:
|
||||
0: string.quoted.single.livescript
|
||||
push:
|
||||
- meta_content_scope: string.quoted.single.livescript
|
||||
- match: '([\\)\s,\};\]])'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.livescript
|
||||
pop: true
|
||||
constructor_variable:
|
||||
- match: '([a-zA-Z$_][\w$-]*)(@{2})([a-zA-Z$_][\w$-]*)?'
|
||||
scope: variable.other.readwrite.constructor.livescript
|
||||
double_quoted_string:
|
||||
- match: '"'
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.livescript
|
||||
push:
|
||||
- meta_scope: string.quoted.double.livescript
|
||||
- match: '"'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.livescript
|
||||
pop: true
|
||||
- match: '\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)'
|
||||
scope: constant.character.escape.livescript
|
||||
- include: interpolated_livescript
|
||||
embedded_comment:
|
||||
- match: (?<!\\)(#).*$\n
|
||||
scope: comment.line.number-sign.livescript
|
||||
captures:
|
||||
1: punctuation.definition.comment.livescript
|
||||
embedded_spaced_comment:
|
||||
- match: (?<!\\)(#\s).*$\n
|
||||
scope: comment.line.number-sign.livescript
|
||||
captures:
|
||||
1: punctuation.definition.comment.livescript
|
||||
instance_variable:
|
||||
- match: '(?<![$\w\-])(@)'
|
||||
scope: variable.other.readwrite.instance.livescript
|
||||
interpolated_livescript:
|
||||
- match: '\#\{'
|
||||
captures:
|
||||
0: punctuation.section.embedded.livescript
|
||||
push:
|
||||
- meta_scope: source.livescript.embedded.source
|
||||
- match: '\}'
|
||||
captures:
|
||||
0: punctuation.section.embedded.livescript
|
||||
pop: true
|
||||
- include: main
|
||||
- match: '\#'
|
||||
push:
|
||||
- meta_scope: source.livescript.embedded.source.simple
|
||||
- match: ""
|
||||
pop: true
|
||||
- include: main
|
||||
numeric:
|
||||
- match: '(?<![\$@a-zA-Z_])(([0-9]+r[0-9_]+)|((16r|0[xX])[0-9a-fA-F_]+)|([0-9]+(\.[0-9]+[0-9_]*)?(e[+\-]?[0-9_]+)?)[_a-zA-Z0-9]*)'
|
||||
scope: constant.numeric.livescript
|
||||
single_quoted_string:
|
||||
- match: "'"
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.livescript
|
||||
push:
|
||||
- meta_scope: string.quoted.single.livescript
|
||||
- match: "'"
|
||||
captures:
|
||||
0: punctuation.definition.string.end.livescript
|
||||
pop: true
|
||||
- match: '\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)'
|
||||
scope: constant.character.escape.livescript
|
||||
variable_name:
|
||||
- match: '([a-zA-Z\$_][\w$-]*(\.\w+)*)(?!\-)'
|
||||
scope: variable.assignment.livescript
|
||||
captures:
|
||||
1: variable.assignment.livescript
|
1
assets/syntaxes/02_Extra/MediaWiki
vendored
Submodule
1
assets/syntaxes/02_Extra/MediaWiki
vendored
Submodule
Submodule assets/syntaxes/02_Extra/MediaWiki added at 81bf97cace
1
assets/syntaxes/02_Extra/Nim.sublime-syntax
vendored
1
assets/syntaxes/02_Extra/Nim.sublime-syntax
vendored
@@ -5,6 +5,7 @@ name: Nim
|
||||
file_extensions:
|
||||
- nim
|
||||
- nims
|
||||
- nimble
|
||||
scope: source.nim
|
||||
contexts:
|
||||
main:
|
||||
|
2
assets/syntaxes/02_Extra/PowerShell
vendored
2
assets/syntaxes/02_Extra/PowerShell
vendored
Submodule assets/syntaxes/02_Extra/PowerShell updated: 4a0a076661...742f0b5d4b
106
assets/syntaxes/02_Extra/PowerShell.sublime-syntax
vendored
106
assets/syntaxes/02_Extra/PowerShell.sublime-syntax
vendored
@@ -24,7 +24,7 @@ contexts:
|
||||
- include: commands
|
||||
- include: commentLine
|
||||
- include: variable
|
||||
- include: interpolatedStringContent
|
||||
- include: subexpression
|
||||
- include: function
|
||||
- include: attribute
|
||||
- include: UsingDirective
|
||||
@@ -33,32 +33,38 @@ contexts:
|
||||
- include: doubleQuotedString
|
||||
- include: scriptblock
|
||||
- include: doubleQuotedStringEscapes
|
||||
- match: (?<!')'
|
||||
- match: '[''\x{2018}-\x{201B}]'
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.powershell
|
||||
push:
|
||||
- meta_scope: string.quoted.single.powershell
|
||||
- match: "'(?!')"
|
||||
- match: '[''\x{2018}-\x{201B}]{2}'
|
||||
scope: constant.character.escape.powershell
|
||||
- match: '[''\x{2018}-\x{201B}]'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.powershell
|
||||
pop: true
|
||||
- match: "''"
|
||||
scope: constant.character.escape.powershell
|
||||
- match: \@"(?=$)
|
||||
- match: '(@["\x{201C}-\x{201E}])\s*$'
|
||||
captures:
|
||||
1: punctuation.definition.string.begin.powershell
|
||||
push:
|
||||
- meta_scope: string.quoted.double.heredoc.powershell
|
||||
- match: ^"@
|
||||
- match: '^["\x{201C}-\x{201E}]@'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.powershell
|
||||
pop: true
|
||||
- include: variableNoProperty
|
||||
- include: doubleQuotedStringEscapes
|
||||
- include: interpolation
|
||||
- match: \@'(?=$)
|
||||
- match: '(@[''\x{2018}-\x{201B}])\s*$'
|
||||
captures:
|
||||
1: punctuation.definition.string.begin.powershell
|
||||
push:
|
||||
- meta_scope: string.quoted.single.heredoc.powershell
|
||||
- match: ^'@
|
||||
- match: '^[''\x{2018}-\x{201B}]@'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.powershell
|
||||
pop: true
|
||||
- match: "''"
|
||||
scope: constant.character.escape.powershell
|
||||
- include: numericConstant
|
||||
- match: (@)(\()
|
||||
captures:
|
||||
@@ -71,11 +77,12 @@ contexts:
|
||||
0: punctuation.section.group.end.powershell
|
||||
pop: true
|
||||
- include: main
|
||||
- match: (\$)(\()
|
||||
- match: ((\$))(\()
|
||||
comment: "TODO: move to repo; make recursive."
|
||||
captures:
|
||||
1: punctuation.definition.variable.powershell
|
||||
2: punctuation.section.group.begin.powershell
|
||||
1: keyword.other.substatement.powershell
|
||||
2: punctuation.definition.subexpression.powershell
|
||||
3: punctuation.section.group.begin.powershell
|
||||
push:
|
||||
- meta_scope: meta.group.complex.subexpression.powershell
|
||||
- match: \)
|
||||
@@ -85,7 +92,7 @@ contexts:
|
||||
- include: main
|
||||
- match: '(\b(([A-Za-z0-9\-_\.]+)\.(?i:exe|com|cmd|bat))\b)'
|
||||
scope: support.function.powershell
|
||||
- match: (?<!\w|-|\.)((?i:begin|break|catch|continue|data|default|define|do|dynamicparam|else|elseif|end|exit|finally|for|from|if|in|inlinescript|parallel|param|process|return|sequence|switch|throw|trap|try|until|var|while)|%|\?)(?!\w)
|
||||
- match: (?<!\w|-|\.)((?i:begin|break|catch|clean|continue|data|default|define|do|dynamicparam|else|elseif|end|exit|finally|for|from|if|in|inlinescript|parallel|param|process|return|sequence|switch|throw|trap|try|until|var|while)|%|\?)(?!\w)
|
||||
scope: keyword.control.powershell
|
||||
- match: '(?<!\w|-|[^\)]\.)((?i:(foreach|where)(?!-object))|%|\?)(?!\w)'
|
||||
scope: keyword.control.powershell
|
||||
@@ -135,7 +142,7 @@ contexts:
|
||||
- meta_scope: meta.requires.powershell
|
||||
- match: $
|
||||
pop: true
|
||||
- match: \-(?i:Modules|PSSnapin|RunAsAdministrator|ShellId|Version)
|
||||
- match: \-(?i:Modules|PSSnapin|RunAsAdministrator|ShellId|Version|Assembly|PSEdition)
|
||||
scope: keyword.other.powershell
|
||||
- match: '(?<!-)\b\p{L}+|\d+(?:\.\d+)*'
|
||||
scope: variable.parameter.powershell
|
||||
@@ -187,51 +194,53 @@ contexts:
|
||||
comment: Builtin cmdlets with reserved verbs
|
||||
scope: support.function.powershell
|
||||
commentEmbeddedDocs:
|
||||
- match: ^(?i:(?:\s?|#)+(\.)(COMPONENT|DESCRIPTION|EXAMPLE|EXTERNALHELP|FORWARDHELPCATEGORY|FORWARDHELPTARGETNAME|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|REMOTEHELPRUNSPACE|ROLE|SYNOPSIS))
|
||||
- match: (?:^|\G)(?i:\s*(\.)(COMPONENT|DESCRIPTION|EXAMPLE|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|ROLE|SYNOPSIS))\s*$
|
||||
comment: these embedded doc keywords do not support arguments, must be the only thing on the line
|
||||
scope: comment.documentation.embedded.powershell
|
||||
captures:
|
||||
1: constant.string.documentation.powershell
|
||||
2: keyword.operator.documentation.powershell
|
||||
- match: '(?i:\s?(\.)(PARAMETER|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\s+([a-z0-9-_]+))'
|
||||
- match: (?:^|\G)(?i:\s*(\.)(EXTERNALHELP|FORWARDHELP(?:CATEGORY|TARGETNAME)|PARAMETER|REMOTEHELPRUNSPACE))\s+(.+?)\s*$
|
||||
comment: these embedded doc keywords require arguments though the type required may be inconsistent, they may not all be able to use the same argument match
|
||||
scope: comment.documentation.embedded.powershell
|
||||
captures:
|
||||
1: constant.string.documentation.powershell
|
||||
2: keyword.operator.documentation.powershell
|
||||
3: keyword.operator.documentation.powershell
|
||||
commentLine:
|
||||
- match: '(?<![`\\-])#'
|
||||
- match: '(?<![`\\-])(#)#*'
|
||||
captures:
|
||||
0: punctuation.definition.comment.powershell
|
||||
1: punctuation.definition.comment.powershell
|
||||
push:
|
||||
- meta_scope: comment.line.powershell
|
||||
- match: $\n?
|
||||
captures:
|
||||
0: punctuation.definition.comment.powershell
|
||||
1: punctuation.definition.comment.powershell
|
||||
pop: true
|
||||
- include: commentEmbeddedDocs
|
||||
- include: RequiresDirective
|
||||
doubleQuotedString:
|
||||
- match: (?<!(?<!`)")"
|
||||
- match: '["\x{201C}-\x{201E}]'
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.powershell
|
||||
push:
|
||||
- meta_scope: string.quoted.double.powershell
|
||||
- match: '"(?!")'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.powershell
|
||||
pop: true
|
||||
- match: '(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,64}\b'
|
||||
- include: variableNoProperty
|
||||
- include: doubleQuotedStringEscapes
|
||||
- match: '["\x{201C}-\x{201E}]{2}'
|
||||
scope: constant.character.escape.powershell
|
||||
- include: interpolation
|
||||
- match: '`\s*$'
|
||||
scope: keyword.other.powershell
|
||||
- match: '["\x{201C}-\x{201E}]'
|
||||
captures:
|
||||
0: punctuation.definition.string.end.powershell
|
||||
pop: true
|
||||
doubleQuotedStringEscapes:
|
||||
- match: '`[`0abefnrtv"''$]'
|
||||
- match: '`[`0abefnrtv''"\x{2018}-\x{201E}$]'
|
||||
scope: constant.character.escape.powershell
|
||||
- include: unicodeEscape
|
||||
- match: '""'
|
||||
scope: constant.character.escape.powershell
|
||||
function:
|
||||
- match: '^(?:\s*+)(?i)(function|filter|configuration|workflow)\s+(?:(global|local|script|private):)?((?:\p{L}|\d|_|-|\.)+)'
|
||||
captures:
|
||||
@@ -263,33 +272,23 @@ contexts:
|
||||
4: keyword.operator.assignment.powershell
|
||||
- include: scriptblock
|
||||
- include: main
|
||||
interpolatedStringContent:
|
||||
- match: \(
|
||||
captures:
|
||||
0: punctuation.section.group.begin.powershell
|
||||
push:
|
||||
- meta_content_scope: interpolated.simple.source.powershell
|
||||
- match: \)
|
||||
captures:
|
||||
0: punctuation.section.group.end.powershell
|
||||
pop: true
|
||||
- include: main
|
||||
- include: interpolation
|
||||
- include: interpolatedStringContent
|
||||
interpolation:
|
||||
- match: (\$)(\()
|
||||
- match: (((\$)))((\())
|
||||
captures:
|
||||
1: punctuation.definition.variable.powershell
|
||||
2: punctuation.section.group.begin.powershell
|
||||
1: keyword.other.substatement.powershell
|
||||
2: punctuation.definition.substatement.powershell
|
||||
3: punctuation.section.embedded.substatement.begin.powershell
|
||||
4: punctuation.section.group.begin.powershell
|
||||
5: punctuation.section.embedded.substatement.begin.powershell
|
||||
push:
|
||||
- meta_scope: meta.embedded.substatement.powershell
|
||||
- meta_content_scope: interpolated.complex.source.powershell
|
||||
- match: \)
|
||||
- match: (\))
|
||||
captures:
|
||||
0: punctuation.section.group.end.powershell
|
||||
1: punctuation.section.embedded.substatement.end.powershell
|
||||
pop: true
|
||||
- include: main
|
||||
- include: interpolation
|
||||
- include: interpolatedStringContent
|
||||
numericConstant:
|
||||
- match: '(?<!\w)([-+]?0(?:x|X)[0-9a-fA-F_]+(?:U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?)((?i:[kmgtp]b)?)\b'
|
||||
captures:
|
||||
@@ -330,6 +329,17 @@ contexts:
|
||||
0: punctuation.section.braces.end.powershell
|
||||
pop: true
|
||||
- include: main
|
||||
subexpression:
|
||||
- match: \(
|
||||
captures:
|
||||
0: punctuation.section.group.begin.powershell
|
||||
push:
|
||||
- meta_scope: meta.group.simple.subexpression.powershell
|
||||
- match: \)
|
||||
captures:
|
||||
0: punctuation.section.group.end.powershell
|
||||
pop: true
|
||||
- include: main
|
||||
type:
|
||||
- match: '\['
|
||||
captures:
|
||||
|
1
assets/syntaxes/02_Extra/Racket
vendored
Submodule
1
assets/syntaxes/02_Extra/Racket
vendored
Submodule
Submodule assets/syntaxes/02_Extra/Racket added at 7df4479c07
52
assets/syntaxes/02_Extra/Racket.sublime-syntax
vendored
Normal file
52
assets/syntaxes/02_Extra/Racket.sublime-syntax
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
%YAML 1.2
|
||||
---
|
||||
# http://www.sublimetext.com/docs/3/syntax.html
|
||||
name: Racket
|
||||
file_extensions:
|
||||
- rkt
|
||||
scope: source.racket
|
||||
contexts:
|
||||
main:
|
||||
- match: '[^\\](\"[^\"]*\")'
|
||||
captures:
|
||||
1: string.quoted.double.source.racket
|
||||
- match: '\((define)\s+([a-zA-Z0-9_\-?\+^]+)\s*'
|
||||
scope: meta.variable.source.racket
|
||||
captures:
|
||||
1: keyword.source.racket
|
||||
2: entity.name.variable.source.racket
|
||||
- match: '\((define)\s+\(([a-zA-Z0-9_\-?\+^]+)\s*'
|
||||
scope: meta.function.source.racket
|
||||
captures:
|
||||
1: keyword.source.racket
|
||||
2: entity.name.function
|
||||
- match: '\((struct)\s+([a-zA-Z0-9_\-?\+^]+)\s+'
|
||||
scope: meta.struct.source.racket
|
||||
captures:
|
||||
1: keyword.source.racket
|
||||
2: entity.name.type
|
||||
- match: '[\s\(](if|lambda|cond|define|type-case|let|letrec|let!|\#lang|require|test|else|first|rest|define-type|define-type-alias|define-struct|not|local|error|lang)[\s\)]'
|
||||
scope: meta.keywords.source.racket
|
||||
captures:
|
||||
1: keyword.source.racket
|
||||
- match: '[\s\(](true|false|empty|null)[\s\)]'
|
||||
captures:
|
||||
1: constant.language.source.racket
|
||||
- match: '[\s\(\[\{](#t|#true|#f|#false)[\s\)\]\}]'
|
||||
captures:
|
||||
1: constant.language.source.racket
|
||||
- match: '(#\\[a-zA-Z0-9_\-?\+\.\!\"]+)'
|
||||
captures:
|
||||
1: constant.language.source.racket
|
||||
- match: '\b(0|([1-9][0-9_]*))\b'
|
||||
scope: constant.numeric.integer.source.racket
|
||||
- match: ;
|
||||
push:
|
||||
- meta_scope: comment.line.documentation.source.racket
|
||||
- match: $\n
|
||||
pop: true
|
||||
- match: '#\|'
|
||||
push:
|
||||
- meta_scope: comment.block.source.racket
|
||||
- match: '\|#'
|
||||
pop: true
|
2
assets/syntaxes/02_Extra/SCSS_Sass
vendored
2
assets/syntaxes/02_Extra/SCSS_Sass
vendored
Submodule assets/syntaxes/02_Extra/SCSS_Sass updated: 63819a1ab6...d3d9404640
@@ -197,7 +197,7 @@ contexts:
|
||||
scope: entity.other.attribute-name.stylus
|
||||
- match: |-
|
||||
(?x) # multi-line regex definition mode
|
||||
(?<=^|;|{)\s* # starts after begining of line, '{' or ';''
|
||||
(?<=^|;|{)\s* # starts after beginning of line, '{' or ';''
|
||||
(?= # lookahead for
|
||||
(
|
||||
[a-zA-Z0-9_-] # then a letter
|
||||
@@ -207,7 +207,7 @@ contexts:
|
||||
(/\*.*?\*/) # comment
|
||||
)+
|
||||
|
||||
\s*[:\s]\s* # value is separted by colon or space
|
||||
\s*[:\s]\s* # value is separated by colon or space
|
||||
|
||||
(?!(\s*\{)) # if there are only spaces afterwards
|
||||
|
||||
|
2
assets/syntaxes/02_Extra/TOML
vendored
2
assets/syntaxes/02_Extra/TOML
vendored
Submodule assets/syntaxes/02_Extra/TOML updated: 0f14b7caf3...ed38438900
2
assets/syntaxes/02_Extra/TypeScript
vendored
2
assets/syntaxes/02_Extra/TypeScript
vendored
Submodule assets/syntaxes/02_Extra/TypeScript updated: a607ddfec9...ba45efd058
384
assets/syntaxes/02_Extra/TypeScript.sublime-syntax
vendored
384
assets/syntaxes/02_Extra/TypeScript.sublime-syntax
vendored
@@ -44,7 +44,7 @@ contexts:
|
||||
- match: (?=$)
|
||||
pop: true
|
||||
access-modifier:
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(abstract|public|protected|private|readonly|static|declare)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(abstract|declare|override|public|protected|private|readonly|static)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
scope: storage.modifier.ts
|
||||
after-operator-block-as-object-literal:
|
||||
- match: '(?<!\+\+|--)(?<=[:=(,\[?+!>]|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^yield|[^\._$[:alnum:]]yield|^throw|[^\._$[:alnum:]]throw|^in|[^\._$[:alnum:]]in|^of|[^\._$[:alnum:]]of|^typeof|[^\._$[:alnum:]]typeof|&&|\|\||\*)\s*(\{)'
|
||||
@@ -106,7 +106,7 @@ contexts:
|
||||
(?=
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -116,9 +116,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
)
|
||||
@@ -268,7 +268,7 @@ contexts:
|
||||
- include: decorator
|
||||
- match: (?<=:)\s*
|
||||
push:
|
||||
- match: '(?=\s|[;),}\]:\-\+]|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
- match: '(?=\s|[;),}\]:\-\+]|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
pop: true
|
||||
- include: expression
|
||||
- include: method-declaration
|
||||
@@ -317,7 +317,12 @@ contexts:
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(break|continue|do|goto|while)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
scope: keyword.control.loop.ts
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(return)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
scope: keyword.control.flow.ts
|
||||
captures:
|
||||
0: keyword.control.flow.ts
|
||||
push:
|
||||
- match: '(?=[;}]|$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
pop: true
|
||||
- include: expression
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(case|default|switch)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
scope: keyword.control.switch.ts
|
||||
- include: if-statement
|
||||
@@ -762,7 +767,7 @@ contexts:
|
||||
4: keyword.control.default.ts
|
||||
push:
|
||||
- meta_scope: meta.export.default.ts
|
||||
- match: (?=$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))
|
||||
- match: (?=$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))
|
||||
pop: true
|
||||
- include: interface-declaration
|
||||
- include: expression
|
||||
@@ -772,7 +777,7 @@ contexts:
|
||||
2: keyword.control.type.ts
|
||||
push:
|
||||
- meta_scope: meta.export.ts
|
||||
- match: (?=$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))
|
||||
- match: (?=$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))
|
||||
pop: true
|
||||
- include: import-export-declaration
|
||||
expression:
|
||||
@@ -785,11 +790,11 @@ contexts:
|
||||
- include: string
|
||||
- include: decorator
|
||||
- include: destructuring-parameter
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|protected|private|readonly)\s+(?=(public|protected|private|readonly)\s+)'
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(override|public|protected|private|readonly)\s+(?=(override|public|protected|private|readonly)\s+)'
|
||||
captures:
|
||||
1: storage.modifier.ts
|
||||
- match: |-
|
||||
(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*
|
||||
(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(override|public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*
|
||||
# function assignment |
|
||||
(=\s*(
|
||||
((async\s+)?(
|
||||
@@ -798,10 +803,10 @@ contexts:
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -811,9 +816,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -831,18 +836,18 @@ contexts:
|
||||
))
|
||||
)) |
|
||||
(:\s*(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))Function(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) |
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
((async\s+)?(
|
||||
(function\s*[(<*]) |
|
||||
(function\s+) |
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -852,9 +857,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -865,7 +870,7 @@ contexts:
|
||||
3: entity.name.function.ts variable.language.this.ts
|
||||
4: entity.name.function.ts
|
||||
5: keyword.operator.optional.ts
|
||||
- match: '(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*[:,]|$)'
|
||||
- match: '(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(override|public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*[:,]|$)'
|
||||
captures:
|
||||
1: storage.modifier.ts
|
||||
2: keyword.operator.rest.ts
|
||||
@@ -930,10 +935,11 @@ contexts:
|
||||
scope: keyword.operator.comparison.ts
|
||||
- match: <=|>=|<>|<|>
|
||||
scope: keyword.operator.relational.ts
|
||||
- match: '(?<=[_$[:alnum:]])(\!)\s*(/)(?![/*])'
|
||||
- match: '(?<=[_$[:alnum:]])(\!)\s*(?:(/=)|(?:(/)(?![/*])))'
|
||||
captures:
|
||||
1: keyword.operator.logical.ts
|
||||
2: keyword.operator.arithmetic.ts
|
||||
2: keyword.operator.assignment.compound.ts
|
||||
3: keyword.operator.arithmetic.ts
|
||||
- match: \!|&&|\|\||\?\?
|
||||
scope: keyword.operator.logical.ts
|
||||
- match: \&|~|\^|\|
|
||||
@@ -946,16 +952,18 @@ contexts:
|
||||
scope: keyword.operator.increment.ts
|
||||
- match: '%|\*|/|-|\+'
|
||||
scope: keyword.operator.arithmetic.ts
|
||||
- match: '(?<=[_$[:alnum:])\]])\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)+(/)(?![/*]))'
|
||||
- match: '(?<=[_$[:alnum:])\]])\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)+(?:(/=)|(?:(/)(?![/*]))))'
|
||||
push:
|
||||
- match: '(/)(?!\*([^\*]|(\*[^\/]))*\*\/)'
|
||||
- match: '(?:(/=)|(?:(/)(?!\*([^\*]|(\*[^\/]))*\*\/)))'
|
||||
captures:
|
||||
1: keyword.operator.arithmetic.ts
|
||||
1: keyword.operator.assignment.compound.ts
|
||||
2: keyword.operator.arithmetic.ts
|
||||
pop: true
|
||||
- include: comment
|
||||
- match: '(?<=[_$[:alnum:])\]])\s*(/)(?![/*])'
|
||||
- match: '(?<=[_$[:alnum:])\]])\s*(?:(/=)|(?:(/)(?![/*])))'
|
||||
captures:
|
||||
1: keyword.operator.arithmetic.ts
|
||||
1: keyword.operator.assignment.compound.ts
|
||||
2: keyword.operator.arithmetic.ts
|
||||
expressionPunctuations:
|
||||
- include: punctuation-comma
|
||||
- include: punctuation-accessor
|
||||
@@ -1021,10 +1029,10 @@ contexts:
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -1034,9 +1042,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -1054,18 +1062,18 @@ contexts:
|
||||
))
|
||||
)) |
|
||||
(:\s*(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))Function(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) |
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
((async\s+)?(
|
||||
(function\s*[(<*]) |
|
||||
(function\s+) |
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -1075,9 +1083,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -1118,18 +1126,19 @@ contexts:
|
||||
- include: type-parameters
|
||||
- include: function-parameters
|
||||
- include: return-type
|
||||
- include: type-function-return-type
|
||||
- include: decl-block
|
||||
- match: \*
|
||||
scope: keyword.generator.asterisk.ts
|
||||
function-call:
|
||||
- match: '(?=(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)?\())'
|
||||
- match: '(?=(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)?\())'
|
||||
push:
|
||||
- match: '(?<=\))(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)?\())'
|
||||
- match: '(?<=\))(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)?\())'
|
||||
pop: true
|
||||
- match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))'
|
||||
push:
|
||||
- meta_scope: meta.function-call.ts
|
||||
- match: '(?=\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)?\())'
|
||||
- match: '(?=\s*(?:(\?\.\s*)|(\!))?((<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)?\())'
|
||||
pop: true
|
||||
- include: function-call-target
|
||||
- include: comment
|
||||
@@ -1169,7 +1178,7 @@ contexts:
|
||||
6: meta.definition.function.ts entity.name.function.ts
|
||||
push:
|
||||
- meta_scope: meta.function.ts
|
||||
- match: '(?=;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))|(?<=\})'
|
||||
- match: '(?=;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))|(?<=\})'
|
||||
pop: true
|
||||
- include: function-name
|
||||
- include: function-body
|
||||
@@ -1221,10 +1230,10 @@ contexts:
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -1234,9 +1243,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -1260,7 +1269,7 @@ contexts:
|
||||
- match: "[_$[:alpha:]][_$[:alnum:]]*"
|
||||
scope: variable.other.readwrite.ts
|
||||
if-statement:
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?=\bif\s*(\(([^\(\)]|(\([^\(\)]*\)))*\))\s*(?!\{))'
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?=\bif\s*(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))\s*(?!\{))'
|
||||
push:
|
||||
- match: '(?=;|$|\})'
|
||||
pop: true
|
||||
@@ -1275,12 +1284,12 @@ contexts:
|
||||
0: meta.brace.round.ts
|
||||
pop: true
|
||||
- include: expression
|
||||
- match: '(?<=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))'
|
||||
- match: '(?<=\))\s*\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))'
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.ts
|
||||
push:
|
||||
- meta_scope: string.regexp.ts
|
||||
- match: "(/)([gimsuy]*)"
|
||||
- match: "(/)([dgimsuy]*)"
|
||||
captures:
|
||||
1: punctuation.definition.string.end.ts
|
||||
2: keyword.other.ts
|
||||
@@ -1414,6 +1423,9 @@ contexts:
|
||||
2: keyword.operator.type.modifier.ts
|
||||
3: keyword.operator.optional.ts
|
||||
pop: true
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(as)\s+'
|
||||
captures:
|
||||
1: keyword.control.as.ts
|
||||
- include: type
|
||||
inline-tags:
|
||||
- match: '(\[)[^\]]+(\])(?={@(?:link|linkcode|linkplain|tutorial))'
|
||||
@@ -1504,25 +1516,27 @@ contexts:
|
||||
- include: this-literal
|
||||
- include: super-literal
|
||||
method-declaration:
|
||||
- match: '(?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?\s*\b(constructor)\b(?!:)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
- match: '(?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(override)\s+)?(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?\s*\b(constructor)\b(?!:)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
captures:
|
||||
1: storage.modifier.ts
|
||||
2: storage.modifier.ts
|
||||
3: storage.modifier.async.ts
|
||||
4: storage.type.ts
|
||||
3: storage.modifier.ts
|
||||
4: storage.modifier.async.ts
|
||||
5: storage.type.ts
|
||||
push:
|
||||
- meta_scope: meta.method.declaration.ts
|
||||
- match: '(?=\}|;|,|$)|(?<=\})'
|
||||
pop: true
|
||||
- include: method-declaration-name
|
||||
- include: function-body
|
||||
- match: '(?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:(?:\s*\b(new)\b(?!:)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|(?:(\*)\s*)?)(?=\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])'
|
||||
- match: '(?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(override)\s+)?(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:(?:\s*\b(new)\b(?!:)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|(?:(\*)\s*)?)(?=\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])'
|
||||
captures:
|
||||
1: storage.modifier.ts
|
||||
2: storage.modifier.ts
|
||||
3: storage.modifier.async.ts
|
||||
4: keyword.operator.new.ts
|
||||
5: keyword.generator.asterisk.ts
|
||||
3: storage.modifier.ts
|
||||
4: storage.modifier.async.ts
|
||||
5: keyword.operator.new.ts
|
||||
6: keyword.generator.asterisk.ts
|
||||
push:
|
||||
- meta_scope: meta.method.declaration.ts
|
||||
- match: '(?=\}|;|,|$)|(?<=\})'
|
||||
@@ -1530,7 +1544,7 @@ contexts:
|
||||
- include: method-declaration-name
|
||||
- include: function-body
|
||||
- match: |-
|
||||
(?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=\s*(((\b(?<!\$)0(?:x|X)[0-9a-fA-F][0-9a-fA-F_]*(n)?\b(?!\$))|(\b(?<!\$)0(?:b|B)[01][01_]*(n)?\b(?!\$))|(\b(?<!\$)0(?:o|O)?[0-7][0-7_]*(n)?\b(?!\$))|((?<!\$)(?:
|
||||
(?x)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:\b(override)\s+)?(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=\s*(((\b(?<!\$)0(?:x|X)[0-9a-fA-F][0-9a-fA-F_]*(n)?\b(?!\$))|(\b(?<!\$)0(?:b|B)[01][01_]*(n)?\b(?!\$))|(\b(?<!\$)0(?:o|O)?[0-7][0-7_]*(n)?\b(?!\$))|((?<!\$)(?:
|
||||
(?:\b[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)| # 1.1E+3
|
||||
(?:\b[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*(n)?\b)| # 1.E+3
|
||||
(?:\B(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)| # .1E+3
|
||||
@@ -1539,13 +1553,14 @@ contexts:
|
||||
(?:\b[0-9][0-9_]*(\.)(n)?\B)| # 1.
|
||||
(?:\B(\.)[0-9][0-9_]*(n)?\b)| # .1
|
||||
(?:\b[0-9][0-9_]*(n)?\b(?!\.)) # 1
|
||||
)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])
|
||||
)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])
|
||||
captures:
|
||||
1: storage.modifier.ts
|
||||
2: storage.modifier.ts
|
||||
3: storage.modifier.async.ts
|
||||
4: storage.type.property.ts
|
||||
5: keyword.generator.asterisk.ts
|
||||
3: storage.modifier.ts
|
||||
4: storage.modifier.async.ts
|
||||
5: storage.type.property.ts
|
||||
6: keyword.generator.asterisk.ts
|
||||
push:
|
||||
- meta_scope: meta.method.declaration.ts
|
||||
- match: '(?=\}|;|,|$)|(?<=\})'
|
||||
@@ -1582,7 +1597,7 @@ contexts:
|
||||
3: storage.type.namespace.ts
|
||||
push:
|
||||
- meta_scope: meta.namespace.declaration.ts
|
||||
- match: '(?<=\})|(?=;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
- match: '(?<=\})|(?=;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
pop: true
|
||||
- include: comment
|
||||
- include: string
|
||||
@@ -1598,9 +1613,7 @@ contexts:
|
||||
- meta_scope: new.expr.ts
|
||||
- match: '(?<=\))|(?=[;),}\]:?\-\+\>]|\|\||\&\&|\!\=\=|$|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))new(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))'
|
||||
pop: true
|
||||
- include: paren-expression
|
||||
- include: class-declaration
|
||||
- include: type
|
||||
- include: expression
|
||||
null-literal:
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))null(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
scope: constant.language.null.ts
|
||||
@@ -1781,7 +1794,7 @@ contexts:
|
||||
(?:\b[0-9][0-9_]*(\.)(n)?\B)| # 1.
|
||||
(?:\B(\.)[0-9][0-9_]*(n)?\b)| # .1
|
||||
(?:\b[0-9][0-9_]*(n)?\b(?!\.)) # 1
|
||||
)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])
|
||||
)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])
|
||||
captures:
|
||||
1: storage.modifier.async.ts
|
||||
2: storage.type.property.ts
|
||||
@@ -1802,7 +1815,7 @@ contexts:
|
||||
(?:\b[0-9][0-9_]*(\.)(n)?\B)| # 1.
|
||||
(?:\B(\.)[0-9][0-9_]*(n)?\b)| # .1
|
||||
(?:\b[0-9][0-9_]*(n)?\b(?!\.)) # 1
|
||||
)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])
|
||||
)(?!\$))|([_$[:alpha:]][_$[:alnum:]]*)|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`)|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])
|
||||
captures:
|
||||
1: storage.modifier.async.ts
|
||||
2: storage.type.property.ts
|
||||
@@ -1864,10 +1877,10 @@ contexts:
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -1877,9 +1890,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -1930,7 +1943,7 @@ contexts:
|
||||
- meta_scope: meta.object.member.ts
|
||||
- match: '(?=,|\})'
|
||||
pop: true
|
||||
- match: '(?<=:)\s*(async)?(?=\s*(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)\(\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))'
|
||||
- match: '(?<=:)\s*(async)?(?=\s*(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)\(\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))'
|
||||
captures:
|
||||
1: storage.modifier.async.ts
|
||||
push:
|
||||
@@ -1946,7 +1959,7 @@ contexts:
|
||||
0: meta.brace.round.ts
|
||||
pop: true
|
||||
- include: expression-inside-possibly-arrow-parens
|
||||
- match: '(?<=:)\s*(async)?\s*(\()(?=\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))'
|
||||
- match: '(?<=:)\s*(async)?\s*(\()(?=\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))'
|
||||
captures:
|
||||
1: storage.modifier.async.ts
|
||||
2: meta.brace.round.ts
|
||||
@@ -1963,7 +1976,7 @@ contexts:
|
||||
- match: (?<=\>)
|
||||
pop: true
|
||||
- include: type-parameters
|
||||
- match: '(?<=\>)\s*(\()(?=\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))'
|
||||
- match: '(?<=\>)\s*(\()(?=\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))'
|
||||
captures:
|
||||
1: meta.brace.round.ts
|
||||
push:
|
||||
@@ -1997,11 +2010,11 @@ contexts:
|
||||
- include: destructuring-parameter-rest
|
||||
- include: variable-initializer
|
||||
parameter-name:
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|protected|private|readonly)\s+(?=(public|protected|private|readonly)\s+)'
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(override|public|protected|private|readonly)\s+(?=(override|public|protected|private|readonly)\s+)'
|
||||
captures:
|
||||
1: storage.modifier.ts
|
||||
- match: |-
|
||||
(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*
|
||||
(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(override|public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*
|
||||
# function assignment |
|
||||
(=\s*(
|
||||
((async\s+)?(
|
||||
@@ -2010,10 +2023,10 @@ contexts:
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -2023,9 +2036,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -2043,18 +2056,18 @@ contexts:
|
||||
))
|
||||
)) |
|
||||
(:\s*(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))Function(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) |
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
((async\s+)?(
|
||||
(function\s*[(<*]) |
|
||||
(function\s+) |
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -2064,9 +2077,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -2077,7 +2090,7 @@ contexts:
|
||||
3: entity.name.function.ts variable.language.this.ts
|
||||
4: entity.name.function.ts
|
||||
5: keyword.operator.optional.ts
|
||||
- match: '(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)'
|
||||
- match: '(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(override|public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)'
|
||||
captures:
|
||||
1: storage.modifier.ts
|
||||
2: keyword.operator.rest.ts
|
||||
@@ -2137,14 +2150,14 @@ contexts:
|
||||
pop: true
|
||||
- include: expression
|
||||
paren-expression-possibly-arrow:
|
||||
- match: '(?<=[(=,])\s*(async)?(?=\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?\(\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))'
|
||||
- match: '(?<=[(=,])\s*(async)?(?=\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?\(\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))'
|
||||
captures:
|
||||
1: storage.modifier.async.ts
|
||||
push:
|
||||
- match: (?<=\))
|
||||
pop: true
|
||||
- include: paren-expression-possibly-arrow-with-typeparameters
|
||||
- match: '(?<=[(=,]|=>|^return|[^\._$[:alnum:]]return)\s*(async)?(?=\s*((((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?\()|(<))\s*$)'
|
||||
- match: '(?<=[(=,]|=>|^return|[^\._$[:alnum:]]return)\s*(async)?(?=\s*((((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?\()|(<))\s*$)'
|
||||
captures:
|
||||
1: storage.modifier.async.ts
|
||||
push:
|
||||
@@ -2164,7 +2177,7 @@ contexts:
|
||||
pop: true
|
||||
- include: expression-inside-possibly-arrow-parens
|
||||
possibly-arrow-return-type:
|
||||
- match: '(?<=\)|^)\s*(:)(?=\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*=>)'
|
||||
- match: '(?<=\)|^)\s*(:)(?=\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*=>)'
|
||||
captures:
|
||||
1: meta.arrow.ts meta.return.type.arrow.ts keyword.operator.type.annotation.ts
|
||||
push:
|
||||
@@ -2211,23 +2224,23 @@ contexts:
|
||||
pop: true
|
||||
- include: string-character-escape
|
||||
regex:
|
||||
- match: '(?<!\+\+|--|})(?<=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))'
|
||||
- match: '(?<!\+\+|--|})(?<=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=>|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))'
|
||||
captures:
|
||||
1: punctuation.definition.string.begin.ts
|
||||
push:
|
||||
- meta_scope: string.regexp.ts
|
||||
- match: "(/)([gimsuy]*)"
|
||||
- match: "(/)([dgimsuy]*)"
|
||||
captures:
|
||||
1: punctuation.definition.string.end.ts
|
||||
2: keyword.other.ts
|
||||
pop: true
|
||||
- include: regexp
|
||||
- match: '((?<![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?<=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)+\])+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))'
|
||||
- match: '((?<![_$[:alnum:])\]]|\+\+|--|}|\*\/)|((?<=^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case))\s*)\/(?![\/*])(?=(?:[^\/\\\[]|\\.|\[([^\]\\]|\\.)*\])+\/([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))'
|
||||
captures:
|
||||
0: punctuation.definition.string.begin.ts
|
||||
push:
|
||||
- meta_scope: string.regexp.ts
|
||||
- match: "(/)([gimsuy]*)"
|
||||
- match: "(/)([dgimsuy]*)"
|
||||
captures:
|
||||
1: punctuation.definition.string.end.ts
|
||||
2: keyword.other.ts
|
||||
@@ -2430,7 +2443,7 @@ contexts:
|
||||
4: support.variable.property.target.ts
|
||||
- match: |-
|
||||
(?x) (?:(\.)|(\?\.(?!\s*[[:digit:]]))) \s* (?:
|
||||
(?:(constructor|length|prototype|__proto__)\b(?!\$|\s*(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?\())
|
||||
(?:(constructor|length|prototype|__proto__)\b(?!\$|\s*(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?\())
|
||||
|
|
||||
(?:(EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY)\b(?!\$)))
|
||||
captures:
|
||||
@@ -2536,7 +2549,7 @@ contexts:
|
||||
|siblingBelow|size|source|specified|standby|start|status|statusbar|statusText|style|styleSheets|suffixes|summary
|
||||
|systemId|systemLanguage|tagName|tags|target|tBodies|text|textAlign|textDecoration|textIndent|textTransform|tFoot|tHead
|
||||
|title|toolbar|top|type|undefined|uniqueID|updateInterval|URL|URLUnencoded|useMap|userAgent|userLanguage|userProfile
|
||||
|vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\b(?!\$|\s*(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?\()
|
||||
|vAlign|value|valueType|vendor|vendorSub|version|visibility|vspace|whiteSpace|width|X[MS]LDocument|zIndex))\b(?!\$|\s*(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?\()
|
||||
captures:
|
||||
1: punctuation.accessor.ts
|
||||
2: punctuation.accessor.optional.ts
|
||||
@@ -2703,27 +2716,7 @@ contexts:
|
||||
0: case-clause.expr.ts punctuation.definition.section.case-statement.ts
|
||||
- include: statements
|
||||
template:
|
||||
- match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*)(<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)?`)'
|
||||
push:
|
||||
- meta_scope: string.template.ts
|
||||
- match: (?=`)
|
||||
pop: true
|
||||
- match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*))'
|
||||
push:
|
||||
- match: '(?=(<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)?`)'
|
||||
pop: true
|
||||
- include: support-function-call-identifiers
|
||||
- match: "([_$[:alpha:]][_$[:alnum:]]*)"
|
||||
scope: entity.name.function.tagged-template.ts
|
||||
- include: type-arguments
|
||||
- match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=(<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|awaited|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)`)'
|
||||
captures:
|
||||
1: entity.name.function.tagged-template.ts
|
||||
push:
|
||||
- meta_scope: string.template.ts
|
||||
- match: (?=`)
|
||||
pop: true
|
||||
- include: type-arguments
|
||||
- include: template-call
|
||||
- match: "([_$[:alpha:]][_$[:alnum:]]*)?(`)"
|
||||
captures:
|
||||
1: entity.name.function.tagged-template.ts
|
||||
@@ -2736,6 +2729,28 @@ contexts:
|
||||
pop: true
|
||||
- include: template-substitution-element
|
||||
- include: string-character-escape
|
||||
template-call:
|
||||
- match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*)(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)?`)'
|
||||
push:
|
||||
- meta_scope: string.template.ts
|
||||
- match: (?=`)
|
||||
pop: true
|
||||
- match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*))'
|
||||
push:
|
||||
- match: '(?=(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)?`)'
|
||||
pop: true
|
||||
- include: support-function-call-identifiers
|
||||
- match: "([_$[:alpha:]][_$[:alnum:]]*)"
|
||||
scope: entity.name.function.tagged-template.ts
|
||||
- include: type-arguments
|
||||
- match: '([_$[:alpha:]][_$[:alnum:]]*)?\s*(?=(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\''([^\''\\]|\\.)*\'')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(?<==)\>)*(?<!=)\>))*(?<!=)\>)*(?<!=)>\s*)`)'
|
||||
captures:
|
||||
1: entity.name.function.tagged-template.ts
|
||||
push:
|
||||
- meta_scope: string.template.ts
|
||||
- match: (?=`)
|
||||
pop: true
|
||||
- include: type-arguments
|
||||
template-substitution-element:
|
||||
- match: '\$\{'
|
||||
captures:
|
||||
@@ -2748,6 +2763,32 @@ contexts:
|
||||
0: punctuation.definition.template-expression.end.ts
|
||||
pop: true
|
||||
- include: expression
|
||||
template-type:
|
||||
- include: template-call
|
||||
- match: "([_$[:alpha:]][_$[:alnum:]]*)?(`)"
|
||||
captures:
|
||||
1: entity.name.function.tagged-template.ts
|
||||
2: punctuation.definition.string.template.begin.ts
|
||||
push:
|
||||
- meta_scope: string.template.ts
|
||||
- match: "`"
|
||||
captures:
|
||||
0: punctuation.definition.string.template.end.ts
|
||||
pop: true
|
||||
- include: template-type-substitution-element
|
||||
- include: string-character-escape
|
||||
template-type-substitution-element:
|
||||
- match: '\$\{'
|
||||
captures:
|
||||
0: punctuation.definition.template-expression.begin.ts
|
||||
push:
|
||||
- meta_scope: meta.template.expression.ts
|
||||
- meta_content_scope: meta.embedded.line.ts
|
||||
- match: '\}'
|
||||
captures:
|
||||
0: punctuation.definition.template-expression.end.ts
|
||||
pop: true
|
||||
- include: type
|
||||
ternary-expression:
|
||||
- match: '(?!\?\.\s*[^[:digit:]])(\?)(?!\?)'
|
||||
captures:
|
||||
@@ -2763,7 +2804,7 @@ contexts:
|
||||
scope: variable.language.this.ts
|
||||
type:
|
||||
- include: comment
|
||||
- include: string
|
||||
- include: type-string
|
||||
- include: numeric-literal
|
||||
- include: type-primitive
|
||||
- include: type-builtin-literals
|
||||
@@ -2788,15 +2829,23 @@ contexts:
|
||||
4: entity.name.type.alias.ts
|
||||
push:
|
||||
- meta_scope: meta.type.declaration.ts
|
||||
- match: '(?=\}|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
- match: '(?=\}|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
pop: true
|
||||
- include: comment
|
||||
- include: type-parameters
|
||||
- match: '(=)\s*(intrinsic)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
captures:
|
||||
1: keyword.operator.assignment.ts
|
||||
2: keyword.control.intrinsic.ts
|
||||
push:
|
||||
- match: '(?=\}|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
pop: true
|
||||
- include: type
|
||||
- match: (=)\s*
|
||||
captures:
|
||||
1: keyword.operator.assignment.ts
|
||||
push:
|
||||
- match: '(?=\}|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
- match: '(?=\}|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
pop: true
|
||||
- include: type
|
||||
type-annotation:
|
||||
@@ -2854,17 +2903,19 @@ contexts:
|
||||
- include: type
|
||||
- include: type
|
||||
type-fn-type-parameters:
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(new)\b(?=\s*\<)'
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(abstract)\s+)?(new)\b(?=\s*\<)'
|
||||
captures:
|
||||
1: meta.type.constructor.ts keyword.control.new.ts
|
||||
1: meta.type.constructor.ts storage.modifier.ts
|
||||
2: meta.type.constructor.ts keyword.control.new.ts
|
||||
push:
|
||||
- match: (?<=>)
|
||||
pop: true
|
||||
- include: comment
|
||||
- include: type-parameters
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(new)\b\s*(?=\()'
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(abstract)\s+)?(new)\b\s*(?=\()'
|
||||
captures:
|
||||
1: keyword.control.new.ts
|
||||
1: storage.modifier.ts
|
||||
2: keyword.control.new.ts
|
||||
push:
|
||||
- meta_scope: meta.type.constructor.ts
|
||||
- match: (?<=\))
|
||||
@@ -2993,8 +3044,6 @@ contexts:
|
||||
scope: keyword.operator.ternary.ts
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))infer(?=\s+[_$[:alpha:]])'
|
||||
scope: keyword.operator.expression.infer.ts
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))awaited(?=\s+[_$[:alpha:]])'
|
||||
scope: keyword.operator.expression.awaited.ts
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))import(?=\s*\()'
|
||||
scope: keyword.operator.expression.import.ts
|
||||
type-parameters:
|
||||
@@ -3037,7 +3086,7 @@ contexts:
|
||||
))
|
||||
)) |
|
||||
(:\s*(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))Function(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) |
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))))
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))))
|
||||
captures:
|
||||
1: storage.modifier.ts
|
||||
2: keyword.operator.rest.ts
|
||||
@@ -3074,6 +3123,10 @@ contexts:
|
||||
type-primitive:
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(string|number|bigint|boolean|symbol|any|void|never|unknown)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
scope: support.type.primitive.ts
|
||||
type-string:
|
||||
- include: qstring-single
|
||||
- include: qstring-double
|
||||
- include: template-type
|
||||
type-tuple:
|
||||
- match: '\['
|
||||
captures:
|
||||
@@ -3095,7 +3148,12 @@ contexts:
|
||||
- include: punctuation-comma
|
||||
typeof-operator:
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))typeof(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
scope: keyword.operator.expression.typeof.ts
|
||||
captures:
|
||||
0: keyword.operator.expression.typeof.ts
|
||||
push:
|
||||
- match: '(?=[,);}\]=>:&|{\?]|$|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))'
|
||||
pop: true
|
||||
- include: expression
|
||||
undefined-literal:
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))undefined(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))'
|
||||
scope: constant.language.undefined.ts
|
||||
@@ -3103,7 +3161,7 @@ contexts:
|
||||
- match: '(?=(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))'
|
||||
push:
|
||||
- meta_scope: meta.var.expr.ts
|
||||
- match: '(?!(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+)|^\s*$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))|((?<!^let|[^\._$[:alnum:]]let|^var|[^\._$[:alnum:]]var)(?=\s*$)))'
|
||||
- match: '(?!(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+)|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))|((?<!^let|[^\._$[:alnum:]]let|^var|[^\._$[:alnum:]]var)(?=\s*$)))'
|
||||
pop: true
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(var|let)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*'
|
||||
captures:
|
||||
@@ -3136,7 +3194,7 @@ contexts:
|
||||
3: storage.type.ts
|
||||
push:
|
||||
- meta_scope: meta.var.expr.ts
|
||||
- match: '(?!(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+)|^\s*$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))|((?<!^const|[^\._$[:alnum:]]const)(?=\s*$)))'
|
||||
- match: '(?!(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))((?=;|}|((?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(of|in)\s+)|;|^\s*$|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))|((?<!^const|[^\._$[:alnum:]]const)(?=\s*$)))'
|
||||
pop: true
|
||||
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?\b(const(?!\s+enum\b))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*'
|
||||
captures:
|
||||
@@ -3173,10 +3231,10 @@ contexts:
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -3186,9 +3244,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -3206,18 +3264,18 @@ contexts:
|
||||
))
|
||||
)) |
|
||||
(:\s*(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))Function(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) |
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
((async\s+)?(
|
||||
(function\s*[(<*]) |
|
||||
(function\s+) |
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -3227,9 +3285,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -3260,10 +3318,10 @@ contexts:
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -3273,9 +3331,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
@@ -3293,18 +3351,18 @@ contexts:
|
||||
))
|
||||
)) |
|
||||
(:\s*(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))Function(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))) |
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
((async\s+)?(
|
||||
(function\s*[(<*]) |
|
||||
(function\s+) |
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
@@ -3314,9 +3372,9 @@ contexts:
|
||||
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{([^\{\}]|\{[^\{\}]*\})*\}))*\})|(\[([^\[\]]|(\[([^\[\]]|\[[^\[\]]*\])*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()\'\"\`]|(\(([^\(\)]|(\(([^\(\)]|\([^\(\)]*\))*\)))*\))|(\'([^\'\\]|\\.)*\')|(\"([^\"\\]|\\.)*\")|(\`([^\`\\]|\\.)*\`))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<([^<>]|\<[^<>]+\>)+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
|
1381
assets/syntaxes/02_Extra/TypsecriptReact.sublime-syntax
vendored
1381
assets/syntaxes/02_Extra/TypsecriptReact.sublime-syntax
vendored
File diff suppressed because it is too large
Load Diff
2
assets/syntaxes/02_Extra/VimL
vendored
2
assets/syntaxes/02_Extra/VimL
vendored
Submodule assets/syntaxes/02_Extra/VimL updated: c91fe3ab02...ee85822cbe
1
assets/syntaxes/02_Extra/requirementstxt
vendored
1
assets/syntaxes/02_Extra/requirementstxt
vendored
Submodule assets/syntaxes/02_Extra/requirementstxt deleted from 775e6dd62a
@@ -1,19 +0,0 @@
|
||||
%YAML 1.2
|
||||
---
|
||||
# http://www.sublimetext.com/docs/3/syntax.html
|
||||
name: requirements.txt
|
||||
file_extensions:
|
||||
- requirements.txt
|
||||
scope: source.requirementstxt
|
||||
contexts:
|
||||
main:
|
||||
- match: (#).*$\n?
|
||||
scope: comment.line.requirementstxt
|
||||
captures:
|
||||
1: punctuation.definition.comment.requirementstxt
|
||||
- match: '(?i)^[a-z0-9_\-\.]+'
|
||||
scope: string.package_name.requirementstxt
|
||||
- match: (?i)==|<|<=|>=|>
|
||||
scope: keyword.operator.logical.punctuation.requirementstxt
|
||||
- match: '(?i)\d+\.[\da-z\-_\.]*'
|
||||
scope: constant.numeric.verions.requirementstxt
|
2
assets/syntaxes/02_Extra/ssh-config
vendored
2
assets/syntaxes/02_Extra/ssh-config
vendored
Submodule assets/syntaxes/02_Extra/ssh-config updated: 201816b609...e1012e9f13
BIN
assets/themes.bin
vendored
BIN
assets/themes.bin
vendored
Binary file not shown.
5
build.rs
5
build.rs
@@ -64,6 +64,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
"assets/completions/bat.fish.in",
|
||||
out_dir.join("assets/completions/bat.fish"),
|
||||
)?;
|
||||
template(
|
||||
&variables,
|
||||
"assets/completions/_bat.ps1.in",
|
||||
out_dir.join("assets/completions/_bat.ps1"),
|
||||
)?;
|
||||
template(
|
||||
&variables,
|
||||
"assets/completions/bat.zsh.in",
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<p align="center">
|
||||
<img src="logo-header.svg" alt="bat - a cat clone with wings"><br>
|
||||
<a href="https://travis-ci.org/sharkdp/bat"><img src="https://travis-ci.org/sharkdp/bat.svg?branch=master" alt="Build Status"></a>
|
||||
<a href="https://ci.appveyor.com/project/sharkdp/bat"><img src="https://ci.appveyor.com/api/projects/status/cptsmtbiwbnr2vhf?svg=true"></a>
|
||||
<a href="https://github.com/sharkdp/bat/actions?query=workflow%3ACICD"><img src="https://github.com/sharkdp/bat/workflows/CICD/badge.svg" alt="Build Status"></a>
|
||||
<img src="https://img.shields.io/crates/l/bat.svg" alt="license">
|
||||
<a href="https://crates.io/crates/bat"><img src="https://img.shields.io/crates/v/bat.svg?colorB=319e8c" alt="Version info"></a><br>
|
||||
シンタックスハイライトとGitとの連携機能付きの <i>cat(1)</i> クローン。
|
||||
@@ -12,8 +11,12 @@
|
||||
<a href="#使い方">使い方</a> •
|
||||
<a href="#インストール">インストール</a> •
|
||||
<a href="#カスタマイズ">カスタマイズ</a> •
|
||||
<a href="#プロジェクトの目標と既存の類似したOSS">プロジェクトの目標と既存の類似したOSS</a> •
|
||||
翻訳 [<a href="https://github.com/chinanf-boy/bat-zh">中文</a>][<a href="README-ja.md">日本語</a>][<a href="README-ko.md">한국어</a>]
|
||||
<a href="#プロジェクトの目標と既存の類似したOSS">プロジェクトの目標と既存の類似したOSS</a><br>
|
||||
[<a href="../README.md">English</a>]
|
||||
[<a href="README-zh.md">中文</a>]
|
||||
[日本語]
|
||||
[<a href="README-ko.md">한국어</a>]
|
||||
[<a href="README-ru.md">Русский</a>]
|
||||
</p>
|
||||
|
||||
### シンタックスハイライト
|
||||
@@ -202,7 +205,7 @@ ln -s /usr/bin/batcat ~/.local/bin/bat
|
||||
batの最新リリースを実行する場合、または Ubuntu/Debian の古いバージョンを使用している場合は、[release page](https://github.com/sharkdp/bat/releases) から最新の `.deb` パッケージをダウンロードし、
|
||||
次の方法でインストールします:
|
||||
```bash
|
||||
sudo dpkg -i bat_0.18.2_amd64.deb # adapt version number and architecture
|
||||
sudo dpkg -i bat_0.18.3_amd64.deb # adapt version number and architecture
|
||||
```
|
||||
|
||||
### On Alpine Linux
|
||||
@@ -363,7 +366,7 @@ ansible-galaxy install aeimer.install_bat
|
||||
### From source
|
||||
|
||||
|
||||
`bat` をソースからビルドしたいならば、Rust 1.36 以上の環境が必要です。
|
||||
`bat` をソースからビルドしたいならば、Rust 1.51 以上の環境が必要です。
|
||||
`cargo` を使用してビルドすることができます:
|
||||
|
||||
```bash
|
||||
@@ -522,7 +525,7 @@ export BAT_CONFIG_PATH="/path/to/bat.conf"
|
||||
# Use italic text on the terminal (not supported on all terminals)
|
||||
--italic-text=always
|
||||
|
||||
# Use C++ syntax for .ino files
|
||||
# Use C++ syntax for Arduino .ino files
|
||||
--map-syntax "*.ino:C++"
|
||||
|
||||
# Use ".gitignore"-style highlighting for ".ignore" files
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<p align="center">
|
||||
<img src="../doc/logo-header.svg" alt="bat - a cat clone with wings"><br>
|
||||
<img src="logo-header.svg" alt="bat - a cat clone with wings"><br>
|
||||
<a href="https://github.com/sharkdp/bat/actions?query=workflow%3ACICD"><img src="https://github.com/sharkdp/bat/workflows/CICD/badge.svg" alt="Build Status"></a>
|
||||
<img src="https://img.shields.io/crates/l/bat.svg" alt="license">
|
||||
<a href="https://crates.io/crates/bat"><img src="https://img.shields.io/crates/v/bat.svg?colorB=319e8c" alt="Version info"></a><br>
|
||||
@@ -11,8 +11,12 @@
|
||||
<a href="#사용법">사용법</a> •
|
||||
<a href="#설치">설치</a> •
|
||||
<a href="#사용자화">사용자화</a> •
|
||||
<a href="#프로젝트-목표와-대안들">프로젝트 목표와 대안들</a> •
|
||||
[<a href="https://github.com/chinanf-boy/bat-zh">中文</a>] [<a href="../doc/README-ja.md">日本語</a>] [<a href="../doc/README-ko.md">한국어</a>] [<a href="../doc/README-ru.md">Русский</a>]
|
||||
<a href="#프로젝트-목표와-대안들">프로젝트 목표와 대안들</a><br>
|
||||
[<a href="../README.md">English</a>]
|
||||
[<a href="README-zh.md">中文</a>]
|
||||
[<a href="README-ja.md">日本語</a>]
|
||||
[한국어]
|
||||
[<a href="README-ru.md">Русский</a>]
|
||||
</p>
|
||||
|
||||
### 문법 강조
|
||||
@@ -218,7 +222,7 @@ man 2 select
|
||||
`bat`은 [Ubuntu](https://packages.ubuntu.com/eoan/bat)와
|
||||
[Debian](https://packages.debian.org/sid/bat) 패키지 배포 과정에 도입되는 중이며,
|
||||
Eoan 19.10 버전의 Ubuntu에서부터 제공됩니다.
|
||||
현재 Debain에서는 불안정한 "Sid" 브랜치에서만 `bat`이 제공됩니다.
|
||||
현재 Debian에서는 불안정한 "Sid" 브랜치에서만 `bat`이 제공됩니다.
|
||||
|
||||
만약 충분히 최신 버전의 Ubuntu/Debian이 설치되어 있다면 간단히 다음을 실행하세요:
|
||||
|
||||
@@ -244,7 +248,7 @@ ln -s /usr/bin/batcat ~/.local/bin/bat
|
||||
다음과 같이 `.deb` 패키지를 받아 설치하세요:
|
||||
|
||||
```bash
|
||||
sudo dpkg -i bat_0.18.2_amd64.deb # adapt version number and architecture
|
||||
sudo dpkg -i bat_0.18.3_amd64.deb # adapt version number and architecture
|
||||
```
|
||||
|
||||
### Alpine Linux에서
|
||||
@@ -279,6 +283,14 @@ pacman -S bat
|
||||
dnf install bat
|
||||
```
|
||||
|
||||
### Funtoo Linux에서
|
||||
|
||||
dev-kit을 통해 [`bat` 패키지](https://github.com/funtoo/dev-kit/tree/1.4-release/sys-apps/bat)를 설치할 수 있습니다:
|
||||
|
||||
```bash
|
||||
emerge sys-apps/bat
|
||||
```
|
||||
|
||||
### Gentoo Linux에서
|
||||
|
||||
공식 소스를 통해
|
||||
@@ -404,7 +416,7 @@ scoop install bat
|
||||
|
||||
### 소스에서
|
||||
|
||||
`bat`의 소스를 빌드하기 위해서는, Rust 1.45 이상이 필요합니다.
|
||||
`bat`의 소스를 빌드하기 위해서는, Rust 1.51 이상이 필요합니다.
|
||||
`cargo`를 이용해 전부 빌드할 수 있습니다:
|
||||
|
||||
```bash
|
||||
@@ -663,7 +675,7 @@ bat --generate-config-file
|
||||
# 터미널에서 이탤릭체 쓰기 (일부 터미널에서 미지원)
|
||||
--italic-text=always
|
||||
|
||||
# .ino 파일에 C++ 문법 쓰기
|
||||
# Arduino .ino 파일에 C++ 문법 쓰기
|
||||
--map-syntax "*.ino:C++"
|
||||
```
|
||||
|
||||
@@ -797,6 +809,10 @@ cargo install --locked --force
|
||||
- [keith-hall](https://github.com/keith-hall)
|
||||
- [Enselic](https://github.com/Enselic)
|
||||
|
||||
## 보안 취약점
|
||||
|
||||
만약 `bat`의 취약점을 발견하였다면, [David Peter](https://david-peter.de/)에게 메일로 연락주시기 바랍니다.
|
||||
|
||||
## 프로젝트 목표와 대안들
|
||||
|
||||
`bat`은 다음과 같은 목표를 달성하려고 합니다:
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<p align="center">
|
||||
<img src="doc/logo-header.svg" alt="bat - a cat clone with wings"><br>
|
||||
<a href="https://travis-ci.org/sharkdp/bat"><img src="https://travis-ci.org/sharkdp/bat.svg?branch=master" alt="Build Status"></a>
|
||||
<a href="https://ci.appveyor.com/project/sharkdp/bat"><img src="https://ci.appveyor.com/api/projects/status/cptsmtbiwbnr2vhf/branch/master?svg=true"></a>
|
||||
<img src="logo-header.svg" alt="bat - a cat clone with wings"><br>
|
||||
<a href="https://github.com/sharkdp/bat/actions?query=workflow%3ACICD"><img src="https://github.com/sharkdp/bat/workflows/CICD/badge.svg" alt="Build Status"></a>
|
||||
<img src="https://img.shields.io/crates/l/bat.svg" alt="license">
|
||||
<a href="https://crates.io/crates/bat"><img src="https://img.shields.io/crates/v/bat.svg?colorB=319e8c" alt="Version info"></a><br>
|
||||
Клон утилиты <i>cat(1)</i> с поддержкой выделения синтаксиса и Git
|
||||
@@ -12,8 +11,12 @@
|
||||
<a href="#как-использовать">Использование</a> •
|
||||
<a href="#установка">Установка</a> •
|
||||
<a href="#кастомизация">Кастомизация</a> •
|
||||
<a href="#цели-и-альтернативы">Цели и альтернативы </a> •
|
||||
Перевод [<a href="https://github.com/chinanf-boy/bat-zh">中文</a>][<a href="doc/README-ja.md">日本語</a>][<a href="doc/README-ko.md">한국어</a>][<a href="doc/README-ru.md">Русский</a>]
|
||||
<a href="#цели-и-альтернативы">Цели и альтернативы </a><br>
|
||||
[<a href="../README.md">English]
|
||||
[<a href="README-zh.md">中文</a>]
|
||||
[<a href="README-ja.md">日本語</a>]
|
||||
[<a href="README-ko.md">한국어</a>]
|
||||
[Русский]
|
||||
</p>
|
||||
|
||||
### Выделение синтаксиса
|
||||
@@ -185,7 +188,7 @@ ln -s /usr/bin/batcat ~/.local/bin/bat
|
||||
[release page](https://github.com/sharkdp/bat/releases) и установить так:
|
||||
|
||||
```bash
|
||||
sudo dpkg -i bat_0.18.2_amd64.deb # измените архитектуру и версию
|
||||
sudo dpkg -i bat_0.18.3_amd64.deb # измените архитектуру и версию
|
||||
```
|
||||
|
||||
### Alpine Linux
|
||||
@@ -341,7 +344,7 @@ ansible-galaxy install aeimer.install_bat
|
||||
|
||||
### Из исходников
|
||||
|
||||
Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.45 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
|
||||
Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.51 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
|
||||
|
||||
```bash
|
||||
cargo install --locked bat
|
||||
@@ -481,7 +484,7 @@ bat --generate-config-file
|
||||
# Использовать курсив (поддерживается не всеми терминалами)
|
||||
--italic-text=always
|
||||
|
||||
# Использовать синтаксис C++ для всех .ino файлов
|
||||
# Использовать синтаксис C++ для всех Arduino .ino файлов
|
||||
--map-syntax "*.ino:C++"
|
||||
|
||||
# Использовать синтаксик Git Ignore для всех файлов .ignore
|
||||
|
678
doc/README-zh.md
Normal file
678
doc/README-zh.md
Normal file
@@ -0,0 +1,678 @@
|
||||
<p align="center">
|
||||
<img src="logo-header.svg" alt="bat - a cat clone with wings"><br>
|
||||
<a href="https://github.com/sharkdp/bat/actions?query=workflow%3ACICD"><img src="https://github.com/sharkdp/bat/workflows/CICD/badge.svg" alt="Build Status"></a>
|
||||
<img src="https://img.shields.io/crates/l/bat.svg" alt="license">
|
||||
<a href="https://crates.io/crates/bat"><img src="https://img.shields.io/crates/v/bat.svg?colorB=319e8c" alt="Version info"></a><br>
|
||||
类似 <i>cat(1)</i>,但带有 git 集成和语法高亮.
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#语法高亮">主要功能</a> •
|
||||
<a href="#如何使用">使用方法</a> •
|
||||
<a href="#安装">安装</a> •
|
||||
<a href="#自定义">自定义</a> •
|
||||
<a href="#project-goals-and-alternatives">项目目标和替代方案</a><br>
|
||||
[<a href="../README.md">English</a>]
|
||||
[中文]
|
||||
[<a href="README-ja.md">日本語</a>]
|
||||
[<a href="README-ko.md">한국어</a>]
|
||||
[<a href="README-ru.md">Русский</a>]
|
||||
</p>
|
||||
|
||||
### 语法高亮
|
||||
|
||||
`bat` 对大部分编程语言和标记语言提供语法高亮:
|
||||
|
||||

|
||||
|
||||
### Git 集成
|
||||
|
||||
`bat` 能从 git 中获取文件的修改并展示在边栏(见下图):
|
||||
|
||||

|
||||
|
||||
### 不可打印(non-printable)字符可视化
|
||||
|
||||
添加`-A`/`--show-all`参数可以文件文件中的不可打印字符:
|
||||
|
||||

|
||||
|
||||
### 自动分页
|
||||
|
||||
`bat`会在一般情况下将大于屏幕可显示范围的内容输出到分页器(pager, e.g. `less`)。
|
||||
|
||||
你可以在调用时添加`--paging=never`参数来使`bat`不使用分页器(就像`cat`一样)。如果你想要用为`cat`使用`bat`别名,可以在 shell 配置文件(shell configuration)中添加`alias cat='bat --paging=never'`。
|
||||
|
||||
#### 智能输出
|
||||
|
||||
`bat`能够在设置了分页器选项的同时进行管道:wink:。
|
||||
当`bat`检测到当前环境为非可交互终端或管道时(例如使用`bat`并将内容用管道输出到文件),`bat`会像`cat`一样,一次输出文件内容为纯文本且无视`--paging`参数。
|
||||
|
||||
## 如何使用
|
||||
|
||||
在终端中查看一个文件
|
||||
|
||||
```bash
|
||||
> bat README.md
|
||||
```
|
||||
|
||||
一次性展示多个文件
|
||||
|
||||
```bash
|
||||
> bat src/*.rs
|
||||
```
|
||||
|
||||
从`stdin`读入流,自动为内容添加语法高亮(前提是输入内容的语言可以被正确识别,通常根据内容第一行的 shebang 标记,形如`#!bin/sh`)
|
||||
|
||||
```bash
|
||||
> curl -s https://sh.rustup.rs | bat
|
||||
```
|
||||
|
||||
显式指定`stdin`输入的语言
|
||||
|
||||
```bash
|
||||
> yaml2json .travis.yml | json_pp | bat -l json
|
||||
```
|
||||
|
||||
显示不可打印字符
|
||||
|
||||
```bash
|
||||
> bat -A /etc/hosts
|
||||
```
|
||||
|
||||
与`cat`的兼容性
|
||||
|
||||
```bash
|
||||
bat > note.md # 创建一个空文件
|
||||
|
||||
bat header.md content.md footer.md > document.md
|
||||
|
||||
bat -n main.rs # 只显示行号
|
||||
|
||||
bat f - g # 输出 f,接着是标准输入流,最后 g
|
||||
```
|
||||
|
||||
### 第三方工具交互
|
||||
|
||||
#### `fzf`
|
||||
|
||||
你可以使用`bat`作为`fzf`的预览器。这需要在`bat`后添加`--color=always`选项,以及`--line-range` 选项来限制大文件的加载次数。
|
||||
|
||||
```bash
|
||||
fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}'
|
||||
```
|
||||
|
||||
更多信息请参阅[`fzf`的说明](https://github.com/junegunn/fzf#preview-window)。
|
||||
|
||||
#### `find` 或 `fd`
|
||||
|
||||
你可以使用`find`的`-exec`选项来用`bat`预览搜索结果:
|
||||
|
||||
```bash
|
||||
find … -exec bat {} +
|
||||
```
|
||||
|
||||
亦或者在用`fd`时添加`-X`/`--exec-batch`选项:
|
||||
|
||||
```bash
|
||||
fd … -X bat
|
||||
```
|
||||
|
||||
#### `ripgrep`
|
||||
|
||||
`bat`也能用`batgrep`来显示`ripgrep`的搜索结果。
|
||||
|
||||
```bash
|
||||
batgrep needle src/
|
||||
```
|
||||
|
||||
#### `tail -f`
|
||||
|
||||
当与`tail -f`一起使用,`bat`可以持续监视文件内容并为其添加语法高亮。
|
||||
|
||||
```bash
|
||||
tail -f /var/log/pacman.log | bat --paging=never -l log
|
||||
```
|
||||
|
||||
注意:这项功能需要在关闭分页时使用,同时要手动指定输入的内容语法(通过`-l log`)。
|
||||
|
||||
#### `git`
|
||||
|
||||
`bat`也能直接接受来自`git show`的输出并为其添加语法高亮(当然也需要手动指定语法):
|
||||
|
||||
```bash
|
||||
git show v0.6.0:src/main.rs | bat -l rs
|
||||
```
|
||||
|
||||
#### `git diff`
|
||||
|
||||
`bat`也可以和`git diff`一起使用:
|
||||
|
||||
```bash
|
||||
batdiff() {
|
||||
git diff --name-only --diff-filter=d | xargs bat --diff
|
||||
}
|
||||
```
|
||||
|
||||
该功能也作为一个独立工具提供,你可以在[`bat-extras`](https://github.com/eth-p/bat-extras)中找到`batdiff`。
|
||||
|
||||
如果你想了解更多 git 和 diff 的信息,参阅[`delta`](https://github.com/dandavison/delta)。
|
||||
|
||||
#### `xclip`
|
||||
|
||||
当需要拷贝文件内容时,行号以及 git 标记会影响输出,此时可以使用`-p`/`--plain`参数来把纯文本传递给`xclip`。
|
||||
|
||||
```bash
|
||||
bat main.cpp | xclip
|
||||
```
|
||||
|
||||
`bat`会检测输出是否是管道重定向来决定是否使用纯文本输出。
|
||||
|
||||
#### `man`
|
||||
|
||||
`bat`也能给`man`的输出上色。这需要设置`MANPAGER`环境变量:
|
||||
|
||||
```bash
|
||||
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
||||
man 2 select
|
||||
```
|
||||
|
||||
(如果你使用的是 Debian 或者 Ubuntu,使用`batcat`替换`bat`)
|
||||
|
||||
如果你遇到格式化问题,设置`MANROFFOPT="-c"`也许会有帮助。
|
||||
|
||||
`batman`能提供类似功能——作为一个独立的命令。
|
||||
|
||||
注意:[man page 语法](assets/syntaxes/02_Extra/Manpage.sublime-syntax) 还需要完善。在使用特定的`man`实现时该功能[无法正常工作](https://github.com/sharkdp/bat/issues/1145)。
|
||||
|
||||
#### `prettier` / `shfmt` / `rustfmt`
|
||||
|
||||
`prettybat`脚本能够格式化代码并用`bat`输出。
|
||||
|
||||
## 安装
|
||||
|
||||
[](https://repology.org/project/bat-cat/versions)
|
||||
|
||||
### Ubuntu (使用 `apt`)
|
||||
|
||||
*... 以及其他基于 Debian的发行版.*
|
||||
|
||||
`bat` 要求的版本: [Ubuntu 高于 20.04 ("Focal")](https://packages.ubuntu.com/search?keywords=bat&exact=1) 和 [Debian 高于 August 2021 (Debian 11 - "Bullseye")](https://packages.debian.org/bullseye/bat).
|
||||
|
||||
当你的发行版满足条件那么直接在终端运执行:
|
||||
|
||||
```bash
|
||||
sudo apt install bat
|
||||
```
|
||||
|
||||
重要:如果你通过这种方法安装`bat`,请留意你所安装的可执行文件是否为`batcat`(由[其他包的可执行文件名冲突](https://github.com/sharkdp/bat/issues/982)造成)。你可以创建一个`bat -> batcat`的符号链接(symlink)或别名来避免因为可执行文件不同带来的问题并与其他发行版保持一致性。
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.local/bin
|
||||
ln -s /usr/bin/batcat ~/.local/bin/bat
|
||||
```
|
||||
|
||||
### Ubuntu (使用`.deb`包)
|
||||
|
||||
*... 以及其他基于 Debian的发行版.*
|
||||
|
||||
如果你无法使用上一种方法安装,或需要用最新版的`bat`,你可以从[release 页面](https://github.com/sharkdp/bat/releases)下载最新的`.deb`包并通过下述方法安装:
|
||||
|
||||
```bash
|
||||
sudo dpkg -i bat_0.18.3_amd64.deb # adapt version number and architecture
|
||||
```
|
||||
|
||||
### Alpine Linux
|
||||
|
||||
你可以用下面下列命令从官方源中安装[`bat 包`](https://pkgs.alpinelinux.org/packages?name=bat):
|
||||
|
||||
```bash
|
||||
apk add bat
|
||||
```
|
||||
|
||||
### Arch Linux
|
||||
|
||||
你可以用下面下列命令从官方源中安装[`bat`包](https://www.archlinux.org/packages/community/x86_64/bat/):
|
||||
|
||||
```bash
|
||||
pacman -S bat
|
||||
```
|
||||
|
||||
### Fedora
|
||||
|
||||
你可以使用下列命令从官方[Fedora Modular](https://docs.fedoraproject.org/en-US/modularity/using-modules/)仓库安装[`bat` 包](https://koji.fedoraproject.org/koji/packageinfo?packageID=27506):
|
||||
|
||||
```bash
|
||||
dnf install bat
|
||||
```
|
||||
|
||||
### Funtoo Linux
|
||||
|
||||
你可以从 dev-kit 中安装[`bat` 包](https://github.com/funtoo/dev-kit/tree/1.4-release/sys-apps/bat):
|
||||
|
||||
```bash
|
||||
emerge sys-apps/bat
|
||||
```
|
||||
|
||||
### Gentoo Linux
|
||||
|
||||
你可以使用下列命令从官方源中安装 [`bat` 包](https://packages.gentoo.org/packages/sys-apps/bat):
|
||||
|
||||
|
||||
```bash
|
||||
emerge sys-apps/bat
|
||||
```
|
||||
|
||||
### Void Linux
|
||||
|
||||
你可以用 xbps-install 安装`bat`:
|
||||
|
||||
```bash
|
||||
xbps-install -S bat
|
||||
```
|
||||
|
||||
### Termux:
|
||||
|
||||
你可以用 pkg 安装`bat:
|
||||
|
||||
```bash
|
||||
pkg install bat
|
||||
```
|
||||
|
||||
### FreeBSD
|
||||
|
||||
你可以用 pkg 来安装一份预编译的[`bat` 包](https://www.freshports.org/textproc/bat):
|
||||
|
||||
```bash
|
||||
pkg install bat
|
||||
```
|
||||
|
||||
或从 FreeBSD ports 自己编译一份:
|
||||
|
||||
```bash
|
||||
cd /usr/ports/textproc/bat
|
||||
make install
|
||||
```
|
||||
|
||||
### OpenBSD
|
||||
|
||||
你可以用`pkg——add`安装`bat`包
|
||||
|
||||
```bash
|
||||
pkg_add bat
|
||||
```
|
||||
|
||||
### 通过 nix
|
||||
|
||||
你可以用[nix 包管理器](https://nixos.org/nix)安装`bat`:
|
||||
|
||||
```bash
|
||||
nix-env -i bat
|
||||
```
|
||||
|
||||
### openSUSE
|
||||
|
||||
你可以用 zypper 安装`bat`:
|
||||
|
||||
```bash
|
||||
zypper install bat
|
||||
```
|
||||
|
||||
### 通过 snap
|
||||
|
||||
目前还没有推荐的 snap 包可用。可以使用其他现存的包但不会受到官方支持且可能会遇到[问题](https://github.com/sharkdp/bat/issues/1519)。
|
||||
|
||||
### macOS (或 Linux) 通过 Homebrew
|
||||
|
||||
你可以用 [Homebrew on MacOS](https://formulae.brew.sh/formula/bat) 或者 [Homebrew on Linux](https://formulae.brew.sh/formula-linux/bat) 安装`bat`:
|
||||
|
||||
```bash
|
||||
brew install bat
|
||||
```
|
||||
|
||||
### macOS 通过 MacPorts
|
||||
|
||||
或用 [MacPorts](https://ports.macports.org/port/bat/summary) 安装`bat`:
|
||||
|
||||
```bash
|
||||
port install bat
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
在 Windows 上具有多种安装`bat`的方法。若你已完成安装,记得看看 ["在 Windows 上使用`bat`"](#在-Windows-中使用-bat) 。
|
||||
|
||||
#### 前置条件
|
||||
|
||||
你必须已安装 [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) 包。
|
||||
|
||||
#### 使用 Chocolatey
|
||||
|
||||
你可以用[Chocolatey](https://chocolatey.org/packages/Bat) 安装`bat`:
|
||||
|
||||
```bash
|
||||
choco install bat
|
||||
```
|
||||
|
||||
#### 使用 Scoop
|
||||
|
||||
你可以用 [scoop](https://scoop.sh/) 安装`bat`:
|
||||
|
||||
```bash
|
||||
scoop install bat
|
||||
```
|
||||
|
||||
#### 使用预编译二进制版本
|
||||
|
||||
直接从 [Release 发布页](https://github.com/sharkdp/bat/releases) 下载已经编译好的二进制包,前提是你安装了 [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) 包。
|
||||
|
||||
### 使用二进制版本
|
||||
|
||||
在 [Release 发布页](https://github.com/sharkdp/bat/releases) 中可以找到为多种架构构建的`bat`版本和静态编译的二进制文件(文件名带有`musl`)。
|
||||
|
||||
### 从源码编译
|
||||
|
||||
如果你想要自己构建`bat`,那么你需要安装有高于1.51版本的 Rust。
|
||||
|
||||
使用以下命令编译。
|
||||
|
||||
```bash
|
||||
cargo install --locked bat
|
||||
```
|
||||
|
||||
注意:man page或 shell 自动补全所需要的额外文件无法通过该方法安装。但你可以在`cargo`的生成目录找到这些文件(`build`目录下)。
|
||||
|
||||
## 自定义
|
||||
|
||||
### 语法高亮主题
|
||||
|
||||
使用 `bat --list-themes` 一份语法高亮主题的清单,然后用`--theme=TwoDark`来指定主题为`TwoDark`,也可以通过设置`BAT_THEME`环境变量来选定主题。把`export BAT_THEME="TwoDark"`添加到 shell 的启动脚本(shell startup file)来取得永久效果。或者使用`bat`的[配置文件](#c配置文件)
|
||||
|
||||
若想要查看所有主题在一个文件上的显示效果可以用一下命令(需要安装`fzf`):
|
||||
|
||||
```bash
|
||||
bat --list-themes | fzf --preview="bat --theme={} --color=always /path/to/file"
|
||||
```
|
||||
|
||||
`bat`在默认情况下能够在黑色主题背景下获得较好的效果,如果你的终端使用亮色背景,可以试试`GitHub`或`OneHalfLight`。想要添加自定义主题可以参考[添加主题](#添加主题)。
|
||||
|
||||
### 8-bit 主题
|
||||
|
||||
`bat` 自带三个 [8-bit 色彩](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) 主题:
|
||||
|
||||
- `ansi` 适应于大部分终端。它使用 3-bit 色彩:黑红绿黄蓝洋红靛青白。
|
||||
- `base16`专为 [base16](https://github.com/chriskempson/base16) 终端设计。它使用 4-bit 色彩(带有亮度的 3-bit 色彩)。根据 [base16 styling guidelines](https://github.com/chriskempson/base16/blob/master/styling.md) 制作。
|
||||
- `base16-25`专为 [base16-shell](https://github.com/chriskempson/base16-shell) 设计。它把部分亮色替换为 8-bit 色彩。请不要直接使用该主题,除非你清楚你的256色终端是否使用 base16-shell。
|
||||
|
||||
尽管这些主题具有诸多限制,但具有一些 truecolor 主题不具有的三个优点:
|
||||
|
||||
- 享有最佳兼容性。并不是所有终端工具都支持高于 3-bit 的色彩。
|
||||
- 适应终端主题。
|
||||
- 视觉上和其他的终端工具更协调。
|
||||
|
||||
### 输出样式
|
||||
|
||||
你可以用`--style`参数来控制`bat`输出的样式。使用`--style=numbers,chanegs`可以只开启 Git 修改和行号显示而不添加其他内容。`BAT_STYLE`环境变量具有相同功能。
|
||||
|
||||
### 添加新的语言和语法
|
||||
|
||||
当现有的`bat`不支持某个语言或语法时你可以自己添加。
|
||||
|
||||
`bat`使用`syntect`库来支持语法高亮,该库使用 [Sublime Text `.sublime-syntax` 语法文件](https://www.sublimetext.com/docs/3/syntax.html)和主题。而后者中的大部分可以在 [Package Control](https://packagecontrol.io/) 找到。
|
||||
|
||||
当你找到一份语法文件,按照下列方法:
|
||||
|
||||
1. 创建包含语法描述文件的目录:
|
||||
|
||||
```bash
|
||||
mkdir -p "$(bat --config-dir)/syntaxes"
|
||||
cd "$(bat --config-dir)/syntaxes"
|
||||
|
||||
# Put new '.sublime-syntax' language definition files
|
||||
# in this folder (or its subdirectories), for example:
|
||||
git clone https://github.com/tellnobody1/sublime-purescript-syntax
|
||||
```
|
||||
|
||||
2. 调用下面指令把文件转换为二进制缓存:
|
||||
|
||||
```bash
|
||||
bat cache --build
|
||||
```
|
||||
|
||||
3. 最后用`bat --list-languages`来检查新的语法是否被成功导入。如果想要回滚到最初状态,执行:
|
||||
|
||||
```bash
|
||||
bat cache --clear
|
||||
```
|
||||
|
||||
4. 如果你觉得`bat`有必要自带该语法支持,请在阅读[指导](doc/assets.md)后向仓库提交 [Syntax Request](https://github.com/sharkdp/bat/issues/new?labels=syntax-request&template=syntax_request.md)。
|
||||
|
||||
### 添加主题
|
||||
|
||||
类似添加语法支持,第一步也是创建一个带有语法高亮的目录
|
||||
|
||||
```bash
|
||||
mkdir -p "$(bat --config-dir)/themes"
|
||||
cd "$(bat --config-dir)/themes"
|
||||
|
||||
# 下载一个主题
|
||||
git clone https://github.com/greggb/sublime-snazzy
|
||||
|
||||
# 更新二进制缓存
|
||||
bat cache --build
|
||||
```
|
||||
|
||||
然后用`bat --list-themes`检查添加是否成功。
|
||||
|
||||
### 添加或修改文件关联
|
||||
|
||||
你可以用`--map-syntax`参数添加或修改文件名模板。它需要一个类似`pattern:syntax`的参数来指定,其中`pattern`是 glob 文件匹配模板,`syntax`则是支持的语法的完整名(使用`bat --list-languages`来查看获取一份清单)。
|
||||
|
||||
注意:方便起见,你可能需要把参数添加到配置文件,而不是每次都在命令行中传递该参数。
|
||||
|
||||
以下展示了把“INI”关联到具有`.conf`扩展名的文件
|
||||
|
||||
```bash
|
||||
--map-syntax='*.conf:INI'
|
||||
```
|
||||
|
||||
把`.ignore`文件与“Git Ignore”关联
|
||||
|
||||
```bash
|
||||
--map-syntax='.ignore:Git Ignore'
|
||||
```
|
||||
|
||||
把`/etc/apache2`内的`.conf`文件关联到“Apache Conf”语法(`bat`已默认绑定)
|
||||
|
||||
```bash
|
||||
--map-syntax='/etc/apache2/**/*.conf:Apache Conf'
|
||||
```
|
||||
|
||||
### 使用自定义分页器
|
||||
|
||||
`bat`默认使用`PAGER`环境变量定义的分页器,如果没有定义则使用`less`。`bat`提供了`BAT_PAGER`环境变量来专为`bat`选择分页器(优先级高于`PAGER`)。
|
||||
|
||||
注意:当`PAGER`设置为`more`或`most`时,`bat`会使用`less`来代替以确保能提供色彩支持。
|
||||
|
||||
```bash
|
||||
export BAT_PAGER="less -RF"
|
||||
```
|
||||
|
||||
除了使用环境变量来改变`bat`使用的的分页器,也可以在配置文件中提供`--pager`参数。
|
||||
|
||||
注意:`bat`会把部分命令行参数直接传递给分页器:`-R`/`--RAW-CONTROL-CHARS`,`-F`/`--quit-if-one-screen`以及`-X`/`--no-init`(该参数仅适用于高于530版本的`less`)。其中`-R` 参数需要在解释 ANSI 标准颜色时起作用。`-F`则指示`less`在输出内容的垂直尺寸小于终端尺寸时立即退出。当文件内容可以在一个屏幕里完全显示时,就不需要按`q`键退出阅读模式,很方便就是了。`-X`则能修复`-F`在`less`的老版本中的一些bug(代价是不支持鼠标滚轮,但可以用`-R`来取消`quit-if-one-screen`功能。)。
|
||||
|
||||
### 缩进
|
||||
|
||||
`bat` 使用四个空格宽的制表符,而不受分页器影响,同时也可以用`--tabs`参数来自定义。
|
||||
|
||||
注意:通过其他方法针对分页器的制表符设置不会生效(例如通过`bat`的`--pager`参数传递或`less`使用的`LESS`环境变量)。因为在输出提交给分页器之前,内容中的制表符就已经被`bat`替换为了特定长度的空格以避免由于边栏导致的缩进问题。你可以用给`bat`传递`--tabs=0`参数来取消该设定并让分页器自己处理制表符。
|
||||
|
||||
### 暗色模式
|
||||
|
||||
如果你用的 macOS 处于暗色模式,你可以为`bat`启用基于系统主题的主题。如下所示操作会让`bat`在系统处于亮色模式时加载`GitHub`主题和暗色模式时加载`default`主题。
|
||||
|
||||
```bash
|
||||
alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)"
|
||||
```
|
||||
|
||||
## 配置文件
|
||||
|
||||
```bash
|
||||
bat --config-file
|
||||
```
|
||||
|
||||
你也可以用`BAT_CONFIG_PATH`来为`bat`指定自定义位置的配置文件:
|
||||
|
||||
```bash
|
||||
export BAT_CONFIG_PATH="/path/to/bat.conf"
|
||||
```
|
||||
|
||||
使用`--generate-config-file`参数调用`bat`会在指定位置生成一份默认的`bat`配置文件:
|
||||
|
||||
```bash
|
||||
bat --generate-config-file
|
||||
```
|
||||
|
||||
### 格式
|
||||
|
||||
配置文件其实是一份按行分割的命令行参数列表。你可以用`bat --help`来查看所有可用的参数和适用的值。配置文件中`#`打头的行会被视为注释而不生效。
|
||||
|
||||
以下是一份示例:
|
||||
|
||||
```bash
|
||||
# 设置主题为 TwoDark
|
||||
--theme="TwoDark"
|
||||
|
||||
# 显示行号和 Git 修改信息, 但没有边框
|
||||
--style="numbers,changes,header"
|
||||
|
||||
# 在终端中以斜体输出文本(不是所有终端都支持)
|
||||
--italic-text=always
|
||||
|
||||
# 使用 C++ 语法来给 Ardiuno 的 .ino 文件提供高亮
|
||||
--map-syntax "*.ino:C++"
|
||||
```
|
||||
|
||||
## 在 Windows 中使用 `bat`
|
||||
|
||||
`bat` 在 Windows 上开箱即用,除了部分功能需要额外配置。
|
||||
|
||||
### 前置条件
|
||||
|
||||
你需要先安装 [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) 包。
|
||||
|
||||
### 分页
|
||||
|
||||
Windows 只有一个提供有限功能的分页器,你可以从[这里下载](http://www.greenwoodsoftware.com/less/download.html)或用 [Chocolatey 安装](https://chocolatey.org/packages/Less) Windows 版本的`less`。第一种方法需要你把它所在目录加入`PATH`环境变量或[定义分页器变量](#使用自定义分页器)
|
||||
|
||||
### 色彩
|
||||
|
||||
Windows 10 从 [v1511](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update)) 开始 shell(`conhost.exe`,命令提示符或 Powershell)原生支持色彩。在早些版本的 Windows 中你可以用第三方终端如 [Cmder](http://cmder.net/) (使用[ConEmu](https://conemu.github.io/))。
|
||||
|
||||
注意:Git 和 MSYS 版本的 `less` 没法正确在 Windows 表达色彩。如果你没有安装其他分页器,你可以直接用`--paging=never`或设置`BAT_PAGER`为空字符串来关闭分页功能。
|
||||
|
||||
### Cygwin
|
||||
|
||||
Windows 上的`bat`原生不支持 Cygwin' unix-style 路径(`/cygdrive/*`)。当传递一个绝对 cygwin 路径作为参数值时,`bat`会产生`The system cannot find the path specified. (os error 3)`的错误。你可以`.bash_profile`文件中添加以下函数来解决这个问题。
|
||||
|
||||
```bash
|
||||
bat() {
|
||||
local index
|
||||
local args=("$@")
|
||||
for index in $(seq 0 ${#args[@]}) ; do
|
||||
case "${args[index]}" in
|
||||
-*) continue;;
|
||||
*) [ -e "${args[index]}" ] && args[index]="$(cygpath --windows "${args[index]}")";;
|
||||
esac
|
||||
done
|
||||
command bat "${args[@]}"
|
||||
}
|
||||
```
|
||||
|
||||
## 疑难解答
|
||||
|
||||
### 输出内容含糊不清
|
||||
|
||||
当输入文件包含颜色代码和其他 ANSI 转义符号时,`bat`会产生错误的语法高亮和文本,导致输出看起来令人无法理解。当你需要输出该文件时,请使用`--color=never --wrap=never`参数来关闭上色和文字包裹。
|
||||
|
||||
### 终端与色彩
|
||||
|
||||
`bat`会区分支持 truecolor 和不支持 truecolor 的终端。但是大部分语法高亮主题都是用了没有为 8-bit 色彩支持的颜色,因此强烈推荐使用一个支持 24-bit 色彩的终端(`terminator`,`konsole`,`iTerm2`...),或使用一个 [8-bit 主题](#8-bit-主题)来限制一些颜色。查看[这篇文章使用自定义分页器](https://gist.github.com/XVilka/8346728)了解更多支持 truecolor 的终端。你需要定义`COLORTERM`变量为`truecolor`或`24bit`来确保`bat`能够识别终端的对颜色的支持,否则会使用 8 bit 模式。
|
||||
|
||||
### 行号和边框很难看清
|
||||
|
||||
试试其他主题,说不定能有所改善(用`bat --list-themes`查看主题列表)。
|
||||
|
||||
### 文件编码
|
||||
|
||||
`bat`原生支持 UTF-8 和 UTF-16。至于其他文件你可能需要在使用`bat`之前先把编码转换到UTF-8。
|
||||
|
||||
这里展示了使用`iconv`来把 Latin-1(ISO-8859-1) 编码的 PHP 文件转换到 UTF-8:
|
||||
|
||||
```bash
|
||||
iconv -f ISO-8859-1 -t UTF-8 my-file.php | bat
|
||||
```
|
||||
|
||||
注意: 当`bat`无法识别语言时你可能会需要`-l`/`--language`参数。
|
||||
|
||||
## Development
|
||||
|
||||
```bash
|
||||
# Recursive clone to retrieve all submodules
|
||||
git clone --recursive https://github.com/sharkdp/bat
|
||||
|
||||
# Build (debug version)
|
||||
cd bat
|
||||
cargo build --bins
|
||||
|
||||
# Run unit tests and integration tests
|
||||
cargo test
|
||||
|
||||
# Install (release version)
|
||||
cargo install --path . --locked
|
||||
|
||||
# Build a bat binary with modified syntaxes and themes
|
||||
bash assets/create.sh
|
||||
cargo install --path . --locked --force
|
||||
```
|
||||
|
||||
If you want to build an application that uses `bat`s pretty-printing
|
||||
features as a library, check out the [the API documentation](https://docs.rs/bat/).
|
||||
Note that you have to use either `regex-onig` or `regex-fancy` as a feature
|
||||
when you depend on `bat` as a library.
|
||||
|
||||
## Contributing
|
||||
|
||||
Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide.
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [sharkdp](https://github.com/sharkdp)
|
||||
- [eth-p](https://github.com/eth-p)
|
||||
- [keith-hall](https://github.com/keith-hall)
|
||||
- [Enselic](https://github.com/Enselic)
|
||||
|
||||
## Security vulnerabilities
|
||||
|
||||
Please contact [David Peter](https://david-peter.de/) via email if you want to report a vulnerability in `bat`.
|
||||
|
||||
## Project goals and alternatives
|
||||
|
||||
`bat` tries to achieve the following goals:
|
||||
|
||||
- Provide beautiful, advanced syntax highlighting
|
||||
- Integrate with Git to show file modifications
|
||||
- Be a drop-in replacement for (POSIX) `cat`
|
||||
- Offer a user-friendly command-line interface
|
||||
|
||||
There are a lot of alternatives, if you are looking for similar programs. See
|
||||
[this document](doc/alternatives.md) for a comparison.
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2018-2021 [bat-developers](https://github.com/sharkdp/bat).
|
||||
|
||||
`bat` is made available under the terms of either the MIT License or the Apache License 2.0, at your option.
|
||||
|
||||
See the [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) files for license details.
|
@@ -22,3 +22,42 @@ request.
|
||||
Some other alternatives that are also related, but not yet included in the table:
|
||||
- [lesspipe](https://github.com/wofr06/lesspipe)
|
||||
- [vimpager](https://github.com/rkitover/vimpager)
|
||||
|
||||
## Benchmarks
|
||||
|
||||
The benchmarks above have been created with this script:
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
|
||||
|
||||
if ! command -v hyperfine > /dev/null 2>&1; then
|
||||
echo "'hyperfine' does not seem to be installed."
|
||||
echo "You can get it here: https://github.com/sharkdp/hyperfine"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SRC="test-src/jquery-3.3.1.js"
|
||||
|
||||
|
||||
cmd_bat="bat --style=full --color=always --paging=never '$SRC'"
|
||||
cmd_bat_simple="bat --plain --wrap=never --tabs=0 --color=always --paging=never '$SRC'"
|
||||
cmd_pygmentize="pygmentize -g '$SRC'"
|
||||
cmd_highlight="highlight -O truecolor '$SRC'"
|
||||
cmd_ccat="ccat --color=always '$SRC'"
|
||||
cmd_source_highlight="source-highlight --failsafe --infer-lang -f esc -i '$SRC'"
|
||||
cmd_hicat="hicat '$SRC'"
|
||||
cmd_coderay="coderay '$SRC'"
|
||||
cmd_rouge="rougify '$SRC'"
|
||||
|
||||
hyperfine --warmup 3 \
|
||||
"$cmd_bat" \
|
||||
"$cmd_bat_simple" \
|
||||
"$cmd_pygmentize" \
|
||||
"$cmd_highlight" \
|
||||
"$cmd_ccat" \
|
||||
"$cmd_source_highlight" \
|
||||
"$cmd_hicat" \
|
||||
"$cmd_coderay" \
|
||||
"$cmd_rouge" \
|
||||
```
|
||||
|
@@ -6,9 +6,10 @@ See this page for a good overview: https://deps.rs/repo/github/sharkdp/bat
|
||||
|
||||
- [ ] Optional: update dependencies with `cargo update`. This is also done by
|
||||
dependabot, so it is not strictly necessary.
|
||||
- [ ] Check for outdated dependencies (`cargo outdated`) and decide for each of
|
||||
them whether we want to (manually) upgrade. This will require changes to
|
||||
`Cargo.toml`.
|
||||
- [ ] Install [cargo-outdated](https://crates.io/crates/cargo-outdated). Check
|
||||
for outdated dependencies with `cargo outdated --root-deps-only` and
|
||||
decide for each of them whether we want to (manually) upgrade. This will
|
||||
require changes to `Cargo.toml`.
|
||||
|
||||
## Version bump
|
||||
|
||||
@@ -17,9 +18,9 @@ See this page for a good overview: https://deps.rs/repo/github/sharkdp/bat
|
||||
- [ ] Find the current min. supported Rust version by running
|
||||
`grep '^\s*MIN_SUPPORTED_RUST_VERSION' .github/workflows/CICD.yml`.
|
||||
- [ ] Update the version and the min. supported Rust version in `README.md` and
|
||||
`doc/README-*.md`.
|
||||
- [ ] Update `CHANGELOG.md`. Introduce a section for the new release and
|
||||
prepare a new (empty) "unreleased" section at the top.
|
||||
`doc/README-*.md`. Check with `git grep -i 'rust.*1\.'` and
|
||||
`git grep -i '1\..*rust'`.
|
||||
- [ ] Update `CHANGELOG.md`. Introduce a section for the new release.
|
||||
|
||||
## Update syntaxes and themes (build assets)
|
||||
|
||||
@@ -38,14 +39,14 @@ See this page for a good overview: https://deps.rs/repo/github/sharkdp/bat
|
||||
- [ ] Push all changes and wait for CI to succeed (before continuing with the
|
||||
next section).
|
||||
- [ ] Optional: manually test the new features and command-line options. To do
|
||||
this, install the latest `bat` version again (to include the new synaxes
|
||||
this, install the latest `bat` version again (to include the new syntaxes
|
||||
and themes).
|
||||
- [ ] Run `cargo publish --dry-run --allow-dirty` to make sure that it will
|
||||
succeed later (after creating the GitHub release).
|
||||
|
||||
## Release
|
||||
|
||||
- [ ] Create a tag and push it to the remote `git tag vX.Y.Z; git push --tags`.
|
||||
- [ ] Create a tag and push it: `git tag vX.Y.Z; git push origin tag vX.Y.Z`.
|
||||
This will trigger the deployment via GitHub Actions.
|
||||
- [ ] Go to https://github.com/sharkdp/bat/releases/new to create the new
|
||||
release. Select the new tag and also use it as the release title. For the
|
||||
@@ -56,3 +57,7 @@ See this page for a good overview: https://deps.rs/repo/github/sharkdp/bat
|
||||
appear when the CI run for the Git tag has finished).
|
||||
- [ ] Publish to crates.io by running `cargo publish` in a *clean* repository.
|
||||
The safest way to do this is to clone a fresh copy.
|
||||
|
||||
## Post-release
|
||||
|
||||
- [ ] Prepare a new (empty) "unreleased" section at the top of `CHANGELOG.md`.
|
||||
|
12
doc/sponsors.md
Normal file
12
doc/sponsors.md
Normal file
@@ -0,0 +1,12 @@
|
||||
## Sponsors
|
||||
|
||||
Please note, that being sponsored does not affect the individuality of the `bat`
|
||||
project or affect the maintainers' actions in any way.
|
||||
We remain impartial and continue to assess pull requests solely on merit - the
|
||||
features added, bugs solved, and effect on the overall complexity of the code.
|
||||
No issue will have a different priority based on sponsorship status of the
|
||||
reporter.
|
||||
|
||||
Contributions from anybody are most welcomed, please see our [`CONTRIBUTING.md`](../CONTRIBUTING.md) guide.
|
||||
|
||||
If you want to see our biggest sponsors, check the top of [`README.md`](../README.md#sponsors).
|
11
doc/sponsors/workos-logo-white-bg.svg
Normal file
11
doc/sponsors/workos-logo-white-bg.svg
Normal file
@@ -0,0 +1,11 @@
|
||||
<svg width="1354" height="420" viewBox="0 0 1354 420" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="1354" height="420" rx="20" fill="white"/>
|
||||
<path d="M434.751 133.122H466.637L489.595 227.729C493.852 245.585 494.697 256.219 494.697 256.219H495.128C495.128 256.219 496.61 245.808 500.867 227.729L522.757 133.122H558.9L582.066 227.729C586.53 246.223 587.598 256.219 587.598 256.219H588.236C588.236 256.219 588.666 246.223 592.907 227.729L615.02 133.122H646.907L606.523 288.313H571.017L546.576 194.344C541.474 173.936 541.044 164.801 541.044 164.801H540.614C540.614 164.801 540.183 173.936 535.512 194.344L512.553 288.313H475.996L434.751 133.122Z" fill="black"/>
|
||||
<path d="M641.583 231.934C641.583 196.428 664.541 173.47 699.202 173.47C733.639 173.47 756.597 196.428 756.597 231.934C756.597 267.647 733.639 290.828 699.202 290.828C664.557 290.812 641.583 267.647 641.583 231.934ZM726.832 231.934C726.832 208.976 715.783 195.998 699.202 195.998C681.346 195.998 671.349 210.458 671.349 231.934C671.349 255.323 682.398 268.284 699.202 268.284C717.058 268.284 726.832 253.824 726.832 231.934Z" fill="black"/>
|
||||
<path d="M770.836 175.21H799.103V196.048H799.741C804.635 185.207 816.322 174.365 836.299 174.365C839.695 174.365 841.831 174.796 843.314 175.21V203.478H842.469C842.469 203.478 839.918 202.633 832.903 202.633C811.013 202.633 799.103 215.594 799.103 239.828V288.295H770.836V175.21Z" fill="black"/>
|
||||
<path d="M856.5 133.122H884.767V182.865C884.767 212.2 884.336 217.509 884.336 217.509H884.767L926.857 175.212H962.139L912.843 224.11L970.031 288.313H936.646L895.401 241.536L884.767 251.946V288.297H856.5V133.122Z" fill="black"/>
|
||||
<path d="M970.444 211.285C970.444 163.455 1000.21 131.569 1044.85 131.569C1089.49 131.569 1119.26 163.455 1119.26 211.285C1119.26 259.114 1089.49 291.001 1044.85 291.001C1000.21 291.001 970.444 259.114 970.444 211.285ZM1088.42 211.285C1088.42 178.761 1071 156.855 1044.84 156.855C1018.67 156.855 1001.26 178.761 1001.26 211.285C1001.26 243.809 1018.69 265.715 1044.84 265.715C1070.98 265.715 1088.42 243.809 1088.42 211.285Z" fill="black"/>
|
||||
<path d="M1130.08 236.656H1162.4C1162.4 254.943 1174.95 265.146 1194.08 265.146C1210.23 265.146 1221.29 257.063 1221.29 245.584C1221.29 232.622 1212.79 229.21 1185.79 223.901C1161.12 219.007 1134.98 210.716 1134.98 178.399C1134.98 151.408 1157.93 131 1193.01 131C1229.57 131 1252.11 150.132 1252.11 179.037H1219.79C1219.79 165.007 1208.95 156.286 1193.01 156.286C1176.86 156.286 1166.86 164.146 1166.86 175.625C1166.86 187.742 1173.88 192.413 1195.56 196.878C1227.65 203.685 1254.02 207.288 1254.02 243.001C1254.02 271.3 1229.36 290.432 1193.01 290.432C1156.02 290.432 1130.08 268.957 1130.08 236.656Z" fill="black"/>
|
||||
<path d="M100 210C100 214.824 101.269 219.647 103.723 223.793L148.231 300.878C152.8 308.747 159.739 315.178 168.369 318.055C185.377 323.724 202.977 316.447 211.354 301.893L222.1 283.278L179.708 210L224.47 132.408L235.216 113.792C238.431 108.208 242.747 103.638 247.824 100H243.17H178.777C166.677 100 155.508 106.431 149.5 116.923L103.723 196.208C101.269 200.354 100 205.177 100 210Z" fill="#6363F1"/>
|
||||
<path d="M353.847 210C353.847 205.177 352.578 200.353 350.124 196.207L305.024 118.107C296.647 103.638 279.047 96.3608 262.039 101.945C253.409 104.822 246.47 111.253 241.901 119.122L231.747 136.638L274.139 210L229.378 287.592L218.632 306.208C215.416 311.708 211.101 316.362 206.024 320H210.678H275.07C287.17 320 298.34 313.569 304.347 303.077L350.124 223.792C352.578 219.646 353.847 214.823 353.847 210Z" fill="#6363F1"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.4 KiB |
537
src/assets.rs
537
src/assets.rs
@@ -1,25 +1,39 @@
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
|
||||
use lazycell::LazyCell;
|
||||
use once_cell::unsync::OnceCell;
|
||||
|
||||
use syntect::dumps::{from_binary, from_reader};
|
||||
use syntect::highlighting::{Theme, ThemeSet};
|
||||
use syntect::highlighting::Theme;
|
||||
use syntect::parsing::{SyntaxReference, SyntaxSet};
|
||||
|
||||
use path_abs::PathAbs;
|
||||
|
||||
use crate::bat_warning;
|
||||
use crate::error::*;
|
||||
use crate::input::{InputReader, OpenedInput, OpenedInputKind};
|
||||
use crate::syntax_mapping::{MappingTarget, SyntaxMapping};
|
||||
use crate::input::{InputReader, OpenedInput};
|
||||
use crate::syntax_mapping::ignored_suffixes::IgnoredSuffixes;
|
||||
use crate::syntax_mapping::MappingTarget;
|
||||
use crate::{bat_warning, SyntaxMapping};
|
||||
|
||||
use lazy_theme_set::LazyThemeSet;
|
||||
|
||||
use serialized_syntax_set::*;
|
||||
|
||||
#[cfg(feature = "build-assets")]
|
||||
pub use crate::assets::build_assets::*;
|
||||
|
||||
pub(crate) mod assets_metadata;
|
||||
#[cfg(feature = "build-assets")]
|
||||
mod build_assets;
|
||||
mod lazy_theme_set;
|
||||
mod serialized_syntax_set;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct HighlightingAssets {
|
||||
syntax_set_cell: LazyCell<SyntaxSet>,
|
||||
serialized_syntax_set: Option<SerializedSyntaxSet>,
|
||||
theme_set: ThemeSet,
|
||||
syntax_set_cell: OnceCell<SyntaxSet>,
|
||||
serialized_syntax_set: SerializedSyntaxSet,
|
||||
|
||||
theme_set: LazyThemeSet,
|
||||
fallback_theme: Option<&'static str>,
|
||||
}
|
||||
|
||||
@@ -29,38 +43,25 @@ pub struct SyntaxReferenceInSet<'a> {
|
||||
pub syntax_set: &'a SyntaxSet,
|
||||
}
|
||||
|
||||
const IGNORED_SUFFIXES: [&str; 10] = [
|
||||
// Editor etc backups
|
||||
"~",
|
||||
".bak",
|
||||
".old",
|
||||
".orig",
|
||||
// Debian and derivatives apt/dpkg backups
|
||||
".dpkg-dist",
|
||||
".dpkg-old",
|
||||
// Red Hat and derivatives rpm backups
|
||||
".rpmnew",
|
||||
".rpmorig",
|
||||
".rpmsave",
|
||||
// Build system input/template files
|
||||
".in",
|
||||
];
|
||||
/// Compress for size of ~700 kB instead of ~4600 kB at the cost of ~30% longer deserialization time
|
||||
pub(crate) const COMPRESS_SYNTAXES: bool = true;
|
||||
|
||||
/// We don't want to compress our [LazyThemeSet] since the lazy-loaded themes
|
||||
/// within it are already compressed, and compressing another time just makes
|
||||
/// performance suffer
|
||||
pub(crate) const COMPRESS_THEMES: bool = false;
|
||||
|
||||
/// Compress for size of ~40 kB instead of ~200 kB without much difference in
|
||||
/// performance due to lazy-loading
|
||||
pub(crate) const COMPRESS_LAZY_THEMES: bool = true;
|
||||
|
||||
/// Compress for size of ~10 kB instead of ~120 kB
|
||||
pub(crate) const COMPRESS_ACKNOWLEDGEMENTS: bool = true;
|
||||
|
||||
impl HighlightingAssets {
|
||||
fn new(
|
||||
syntax_set: Option<SyntaxSet>,
|
||||
serialized_syntax_set: Option<SerializedSyntaxSet>,
|
||||
theme_set: ThemeSet,
|
||||
) -> Self {
|
||||
assert!(syntax_set.is_some() || serialized_syntax_set.is_some());
|
||||
|
||||
let syntax_set_cell = LazyCell::new();
|
||||
if let Some(syntax_set) = syntax_set {
|
||||
syntax_set_cell.fill(syntax_set).expect("can never fail");
|
||||
}
|
||||
|
||||
fn new(serialized_syntax_set: SerializedSyntaxSet, theme_set: LazyThemeSet) -> Self {
|
||||
HighlightingAssets {
|
||||
syntax_set_cell,
|
||||
syntax_set_cell: OnceCell::new(),
|
||||
serialized_syntax_set,
|
||||
theme_set,
|
||||
fallback_theme: None,
|
||||
@@ -71,127 +72,28 @@ impl HighlightingAssets {
|
||||
"Monokai Extended"
|
||||
}
|
||||
|
||||
#[cfg(feature = "build-assets")]
|
||||
pub fn from_files(source_dir: &Path, include_integrated_assets: bool) -> Result<Self> {
|
||||
let mut theme_set = if include_integrated_assets {
|
||||
get_integrated_themeset()
|
||||
} else {
|
||||
ThemeSet::new()
|
||||
};
|
||||
|
||||
let theme_dir = source_dir.join("themes");
|
||||
if theme_dir.exists() {
|
||||
let res = theme_set.add_from_folder(&theme_dir);
|
||||
if let Err(err) = res {
|
||||
println!(
|
||||
"Failed to load one or more themes from '{}' (reason: '{}')",
|
||||
theme_dir.to_string_lossy(),
|
||||
err,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
println!(
|
||||
"No themes were found in '{}', using the default set",
|
||||
theme_dir.to_string_lossy()
|
||||
);
|
||||
}
|
||||
|
||||
let mut syntax_set_builder = if !include_integrated_assets {
|
||||
let mut builder = syntect::parsing::SyntaxSetBuilder::new();
|
||||
builder.add_plain_text_syntax();
|
||||
builder
|
||||
} else {
|
||||
from_binary::<SyntaxSet>(get_serialized_integrated_syntaxset()).into_builder()
|
||||
};
|
||||
|
||||
let syntax_dir = source_dir.join("syntaxes");
|
||||
if syntax_dir.exists() {
|
||||
syntax_set_builder.add_from_folder(syntax_dir, true)?;
|
||||
} else {
|
||||
println!(
|
||||
"No syntaxes were found in '{}', using the default set.",
|
||||
syntax_dir.to_string_lossy()
|
||||
);
|
||||
}
|
||||
|
||||
if std::env::var("BAT_PRINT_SYNTAX_DEPENDENCIES").is_ok() {
|
||||
// To trigger this code, run:
|
||||
// BAT_PRINT_SYNTAX_DEPENDENCIES=1 cargo run -- cache --build --source assets --blank --target /tmp
|
||||
crate::syntax_dependencies::print_syntax_dependencies(&syntax_set_builder);
|
||||
}
|
||||
|
||||
let syntax_set = syntax_set_builder.build();
|
||||
let missing_contexts = syntax_set.find_unlinked_contexts();
|
||||
if !missing_contexts.is_empty() {
|
||||
println!("Some referenced contexts could not be found!");
|
||||
for context in missing_contexts {
|
||||
println!("- {}", context);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(HighlightingAssets::new(Some(syntax_set), None, theme_set))
|
||||
}
|
||||
|
||||
pub fn from_cache(cache_path: &Path) -> Result<Self> {
|
||||
Ok(HighlightingAssets::new(
|
||||
None,
|
||||
Some(SerializedSyntaxSet::FromFile(
|
||||
cache_path.join("syntaxes.bin"),
|
||||
)),
|
||||
asset_from_cache(&cache_path.join("themes.bin"), "theme set")?,
|
||||
SerializedSyntaxSet::FromFile(cache_path.join("syntaxes.bin")),
|
||||
asset_from_cache(&cache_path.join("themes.bin"), "theme set", COMPRESS_THEMES)?,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn from_binary() -> Self {
|
||||
HighlightingAssets::new(
|
||||
None,
|
||||
Some(SerializedSyntaxSet::FromBinary(
|
||||
get_serialized_integrated_syntaxset(),
|
||||
)),
|
||||
SerializedSyntaxSet::FromBinary(get_serialized_integrated_syntaxset()),
|
||||
get_integrated_themeset(),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "build-assets")]
|
||||
pub fn save_to_cache(&self, target_dir: &Path, current_version: &str) -> Result<()> {
|
||||
let _ = fs::create_dir_all(target_dir);
|
||||
asset_to_cache(
|
||||
self.get_theme_set(),
|
||||
&target_dir.join("themes.bin"),
|
||||
"theme set",
|
||||
)?;
|
||||
asset_to_cache(
|
||||
self.get_syntax_set()?,
|
||||
&target_dir.join("syntaxes.bin"),
|
||||
"syntax set",
|
||||
)?;
|
||||
|
||||
print!(
|
||||
"Writing metadata to folder {} ... ",
|
||||
target_dir.to_string_lossy()
|
||||
);
|
||||
crate::assets_metadata::AssetsMetadata::new(current_version).save_to_folder(target_dir)?;
|
||||
println!("okay");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_fallback_theme(&mut self, theme: &'static str) {
|
||||
self.fallback_theme = Some(theme);
|
||||
}
|
||||
|
||||
pub(crate) fn get_syntax_set(&self) -> Result<&SyntaxSet> {
|
||||
if !self.syntax_set_cell.filled() {
|
||||
self.syntax_set_cell.fill(
|
||||
self.serialized_syntax_set
|
||||
.as_ref()
|
||||
.expect("a dev forgot to setup serialized_syntax_set, please report to https://github.com/sharkdp/bat/issues")
|
||||
.deserialize()?
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
// It is safe to .unwrap() because we just made sure it was .filled()
|
||||
Ok(self.syntax_set_cell.borrow().unwrap())
|
||||
/// Return the collection of syntect syntax definitions.
|
||||
pub fn get_syntax_set(&self) -> Result<&SyntaxSet> {
|
||||
self.syntax_set_cell
|
||||
.get_or_try_init(|| self.serialized_syntax_set.deserialize())
|
||||
}
|
||||
|
||||
/// Use [Self::get_syntaxes] instead
|
||||
@@ -206,48 +108,88 @@ impl HighlightingAssets {
|
||||
Ok(self.get_syntax_set()?.syntaxes())
|
||||
}
|
||||
|
||||
fn get_theme_set(&self) -> &ThemeSet {
|
||||
fn get_theme_set(&self) -> &LazyThemeSet {
|
||||
&self.theme_set
|
||||
}
|
||||
|
||||
pub fn themes(&self) -> impl Iterator<Item = &str> {
|
||||
self.get_theme_set().themes.keys().map(|s| s.as_ref())
|
||||
self.get_theme_set().themes()
|
||||
}
|
||||
|
||||
/// Use [Self::get_syntax_for_file_name] instead
|
||||
/// Use [Self::get_syntax_for_path] instead
|
||||
#[deprecated]
|
||||
pub fn syntax_for_file_name(
|
||||
&self,
|
||||
file_name: impl AsRef<Path>,
|
||||
mapping: &SyntaxMapping,
|
||||
) -> Option<&SyntaxReference> {
|
||||
self.get_syntax_for_file_name(file_name, mapping)
|
||||
.expect(
|
||||
".syntax_for_file_name() is deprecated, use .get_syntax_for_file_name() instead",
|
||||
)
|
||||
self.get_syntax_for_path(file_name, mapping)
|
||||
.ok()
|
||||
.map(|syntax_in_set| syntax_in_set.syntax)
|
||||
}
|
||||
|
||||
pub fn get_syntax_for_file_name(
|
||||
/// Detect the syntax based on, in order:
|
||||
/// 1. Syntax mappings with [MappingTarget::MapTo] and [MappingTarget::MapToUnknown]
|
||||
/// (e.g. `/etc/profile` -> `Bourne Again Shell (bash)`)
|
||||
/// 2. The file name (e.g. `Dockerfile`)
|
||||
/// 3. Syntax mappings with [MappingTarget::MapExtensionToUnknown]
|
||||
/// (e.g. `*.conf`)
|
||||
/// 4. The file name extension (e.g. `.rs`)
|
||||
///
|
||||
/// When detecting syntax based on syntax mappings, the full path is taken
|
||||
/// into account. When detecting syntax based on file name, no regard is
|
||||
/// taken to the path of the file. Only the file name itself matters. When
|
||||
/// detecting syntax based on file name extension, only the file name
|
||||
/// extension itself matters.
|
||||
///
|
||||
/// Returns [Error::UndetectedSyntax] if it was not possible detect syntax
|
||||
/// based on path/file name/extension (or if the path was mapped to
|
||||
/// [MappingTarget::MapToUnknown] or [MappingTarget::MapExtensionToUnknown]).
|
||||
/// In this case it is appropriate to fall back to other methods to detect
|
||||
/// syntax. Such as using the contents of the first line of the file.
|
||||
///
|
||||
/// Returns [Error::UnknownSyntax] if a syntax mapping exist, but the mapped
|
||||
/// syntax does not exist.
|
||||
pub fn get_syntax_for_path(
|
||||
&self,
|
||||
file_name: impl AsRef<Path>,
|
||||
path: impl AsRef<Path>,
|
||||
mapping: &SyntaxMapping,
|
||||
) -> Result<Option<SyntaxReferenceInSet>> {
|
||||
let file_name = file_name.as_ref();
|
||||
Ok(match mapping.get_syntax_for(file_name) {
|
||||
Some(MappingTarget::MapToUnknown) => None,
|
||||
Some(MappingTarget::MapTo(syntax_name)) => {
|
||||
let syntax_set = self.get_syntax_set()?;
|
||||
syntax_set
|
||||
.find_syntax_by_name(syntax_name)
|
||||
.map(|syntax| SyntaxReferenceInSet { syntax, syntax_set })
|
||||
) -> Result<SyntaxReferenceInSet> {
|
||||
let path = path.as_ref();
|
||||
|
||||
let syntax_match = mapping.get_syntax_for(path);
|
||||
|
||||
if let Some(MappingTarget::MapToUnknown) = syntax_match {
|
||||
return Err(Error::UndetectedSyntax(path.to_string_lossy().into()));
|
||||
}
|
||||
|
||||
if let Some(MappingTarget::MapTo(syntax_name)) = syntax_match {
|
||||
return self
|
||||
.find_syntax_by_name(syntax_name)?
|
||||
.ok_or_else(|| Error::UnknownSyntax(syntax_name.to_owned()));
|
||||
}
|
||||
|
||||
let file_name = path.file_name().unwrap_or_default();
|
||||
|
||||
match (
|
||||
self.get_syntax_for_file_name(file_name, &mapping.ignored_suffixes)?,
|
||||
syntax_match,
|
||||
) {
|
||||
(Some(syntax), _) => Ok(syntax),
|
||||
|
||||
(_, Some(MappingTarget::MapExtensionToUnknown)) => {
|
||||
Err(Error::UndetectedSyntax(path.to_string_lossy().into()))
|
||||
}
|
||||
None => self.get_extension_syntax(file_name.as_os_str())?,
|
||||
})
|
||||
|
||||
_ => self
|
||||
.get_syntax_for_file_extension(file_name, &mapping.ignored_suffixes)?
|
||||
.ok_or_else(|| Error::UndetectedSyntax(path.to_string_lossy().into())),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_theme(&self, theme: &str) -> &Theme {
|
||||
match self.get_theme_set().themes.get(theme) {
|
||||
/// Look up a syntect theme by name.
|
||||
pub fn get_theme(&self, theme: &str) -> &Theme {
|
||||
match self.get_theme_set().get(theme) {
|
||||
Some(theme) => theme,
|
||||
None => {
|
||||
if theme == "ansi-light" || theme == "ansi-dark" {
|
||||
@@ -257,8 +199,9 @@ impl HighlightingAssets {
|
||||
if !theme.is_empty() {
|
||||
bat_warning!("Unknown theme '{}', using default.", theme)
|
||||
}
|
||||
&self.get_theme_set().themes
|
||||
[self.fallback_theme.unwrap_or_else(|| Self::default_theme())]
|
||||
self.get_theme_set()
|
||||
.get(self.fallback_theme.unwrap_or_else(Self::default_theme))
|
||||
.expect("something is very wrong if the default theme is missing")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,112 +214,78 @@ impl HighlightingAssets {
|
||||
) -> Result<SyntaxReferenceInSet> {
|
||||
if let Some(language) = language {
|
||||
let syntax_set = self.get_syntax_set()?;
|
||||
syntax_set
|
||||
return syntax_set
|
||||
.find_syntax_by_token(language)
|
||||
.map(|syntax| SyntaxReferenceInSet { syntax, syntax_set })
|
||||
.ok_or_else(|| ErrorKind::UnknownSyntax(language.to_owned()).into())
|
||||
.ok_or_else(|| Error::UnknownSyntax(language.to_owned()));
|
||||
}
|
||||
|
||||
let path = input.path();
|
||||
let path_syntax = if let Some(path) = path {
|
||||
self.get_syntax_for_path(
|
||||
PathAbs::new(path).map_or_else(|_| path.to_owned(), |p| p.as_path().to_path_buf()),
|
||||
mapping,
|
||||
)
|
||||
} else {
|
||||
let line_syntax = self.get_first_line_syntax(&mut input.reader)?;
|
||||
Err(Error::UndetectedSyntax("[unknown]".into()))
|
||||
};
|
||||
|
||||
// Get the path of the file:
|
||||
// If this was set by the metadata, that will take priority.
|
||||
// If it wasn't, it will use the real file path (if available).
|
||||
let path_str =
|
||||
input
|
||||
.metadata
|
||||
.user_provided_name
|
||||
.as_ref()
|
||||
.or_else(|| match input.kind {
|
||||
OpenedInputKind::OrdinaryFile(ref path) => Some(path),
|
||||
_ => None,
|
||||
});
|
||||
|
||||
if let Some(path_str) = path_str {
|
||||
// If a path was provided, we try and detect the syntax based on extension mappings.
|
||||
let path = Path::new(path_str);
|
||||
let absolute_path = PathAbs::new(path)
|
||||
.ok()
|
||||
.map(|p| p.as_path().to_path_buf())
|
||||
.unwrap_or_else(|| path.to_owned());
|
||||
|
||||
match mapping.get_syntax_for(absolute_path) {
|
||||
Some(MappingTarget::MapToUnknown) => line_syntax.ok_or_else(|| {
|
||||
ErrorKind::UndetectedSyntax(path.to_string_lossy().into()).into()
|
||||
}),
|
||||
|
||||
Some(MappingTarget::MapTo(syntax_name)) => {
|
||||
let syntax_set = self.get_syntax_set()?;
|
||||
syntax_set
|
||||
.find_syntax_by_name(syntax_name)
|
||||
.map(|syntax| SyntaxReferenceInSet { syntax, syntax_set })
|
||||
.ok_or_else(|| ErrorKind::UnknownSyntax(syntax_name.to_owned()).into())
|
||||
}
|
||||
|
||||
None => {
|
||||
let file_name = path.file_name().unwrap_or_default();
|
||||
self.get_extension_syntax(file_name)?
|
||||
.or(line_syntax)
|
||||
.ok_or_else(|| {
|
||||
ErrorKind::UndetectedSyntax(path.to_string_lossy().into()).into()
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If a path wasn't provided, we fall back to the detect first-line syntax.
|
||||
line_syntax.ok_or_else(|| ErrorKind::UndetectedSyntax("[unknown]".into()).into())
|
||||
}
|
||||
match path_syntax {
|
||||
// If a path wasn't provided, or if path based syntax detection
|
||||
// above failed, we fall back to first-line syntax detection.
|
||||
Err(Error::UndetectedSyntax(path)) => self
|
||||
.get_first_line_syntax(&mut input.reader)?
|
||||
.ok_or(Error::UndetectedSyntax(path)),
|
||||
_ => path_syntax,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_extension_syntax(&self, file_name: &OsStr) -> Result<Option<SyntaxReferenceInSet>> {
|
||||
let mut syntax = self.find_syntax_by_file_name(file_name)?;
|
||||
pub(crate) fn find_syntax_by_name(
|
||||
&self,
|
||||
syntax_name: &str,
|
||||
) -> Result<Option<SyntaxReferenceInSet>> {
|
||||
let syntax_set = self.get_syntax_set()?;
|
||||
Ok(syntax_set
|
||||
.find_syntax_by_name(syntax_name)
|
||||
.map(|syntax| SyntaxReferenceInSet { syntax, syntax_set }))
|
||||
}
|
||||
|
||||
fn find_syntax_by_extension(&self, e: Option<&OsStr>) -> Result<Option<SyntaxReferenceInSet>> {
|
||||
let syntax_set = self.get_syntax_set()?;
|
||||
let extension = e.and_then(|x| x.to_str()).unwrap_or_default();
|
||||
Ok(syntax_set
|
||||
.find_syntax_by_extension(extension)
|
||||
.map(|syntax| SyntaxReferenceInSet { syntax, syntax_set }))
|
||||
}
|
||||
|
||||
fn get_syntax_for_file_name(
|
||||
&self,
|
||||
file_name: &OsStr,
|
||||
ignored_suffixes: &IgnoredSuffixes,
|
||||
) -> Result<Option<SyntaxReferenceInSet>> {
|
||||
let mut syntax = self.find_syntax_by_extension(Some(file_name))?;
|
||||
if syntax.is_none() {
|
||||
syntax = self.find_syntax_by_file_name_extension(file_name)?;
|
||||
}
|
||||
if syntax.is_none() {
|
||||
syntax = self.get_extension_syntax_with_stripped_suffix(file_name)?;
|
||||
syntax =
|
||||
ignored_suffixes.try_with_stripped_suffix(file_name, |stripped_file_name| {
|
||||
// Note: recursion
|
||||
self.get_syntax_for_file_name(stripped_file_name, ignored_suffixes)
|
||||
})?;
|
||||
}
|
||||
Ok(syntax)
|
||||
}
|
||||
|
||||
fn find_syntax_by_file_name(&self, file_name: &OsStr) -> Result<Option<SyntaxReferenceInSet>> {
|
||||
let syntax_set = self.get_syntax_set()?;
|
||||
Ok(syntax_set
|
||||
.find_syntax_by_extension(file_name.to_str().unwrap_or_default())
|
||||
.map(|syntax| SyntaxReferenceInSet { syntax, syntax_set }))
|
||||
}
|
||||
|
||||
fn find_syntax_by_file_name_extension(
|
||||
fn get_syntax_for_file_extension(
|
||||
&self,
|
||||
file_name: &OsStr,
|
||||
ignored_suffixes: &IgnoredSuffixes,
|
||||
) -> Result<Option<SyntaxReferenceInSet>> {
|
||||
let file_path = Path::new(file_name);
|
||||
let syntax_set = self.get_syntax_set()?;
|
||||
Ok(syntax_set
|
||||
.find_syntax_by_extension(
|
||||
file_path
|
||||
.extension()
|
||||
.and_then(|x| x.to_str())
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
.map(|syntax| SyntaxReferenceInSet { syntax, syntax_set }))
|
||||
}
|
||||
|
||||
/// If we find an ignored suffix on the file name, e.g. '~', we strip it and
|
||||
/// then try again to find a syntax without it. Note that we do this recursively.
|
||||
fn get_extension_syntax_with_stripped_suffix(
|
||||
&self,
|
||||
file_name: &OsStr,
|
||||
) -> Result<Option<SyntaxReferenceInSet>> {
|
||||
let file_path = Path::new(file_name);
|
||||
let mut syntax = None;
|
||||
if let Some(file_str) = file_path.to_str() {
|
||||
for suffix in IGNORED_SUFFIXES.iter() {
|
||||
if let Some(stripped_filename) = file_str.strip_suffix(suffix) {
|
||||
syntax = self.get_extension_syntax(OsStr::new(stripped_filename))?;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let mut syntax = self.find_syntax_by_extension(Path::new(file_name).extension())?;
|
||||
if syntax.is_none() {
|
||||
syntax =
|
||||
ignored_suffixes.try_with_stripped_suffix(file_name, |stripped_file_name| {
|
||||
// Note: recursion
|
||||
self.get_syntax_for_file_extension(stripped_file_name, ignored_suffixes)
|
||||
})?;
|
||||
}
|
||||
Ok(syntax)
|
||||
}
|
||||
@@ -393,57 +302,53 @@ impl HighlightingAssets {
|
||||
}
|
||||
}
|
||||
|
||||
/// A SyntaxSet in serialized form, i.e. bincoded and flate2 compressed.
|
||||
/// We keep it in this format since we want to load it lazily.
|
||||
#[derive(Debug)]
|
||||
enum SerializedSyntaxSet {
|
||||
/// The data comes from a user-generated cache file.
|
||||
FromFile(PathBuf),
|
||||
|
||||
/// The data to use is embedded into the bat binary.
|
||||
FromBinary(&'static [u8]),
|
||||
}
|
||||
|
||||
impl SerializedSyntaxSet {
|
||||
fn deserialize(&self) -> Result<SyntaxSet> {
|
||||
match self {
|
||||
SerializedSyntaxSet::FromBinary(data) => Ok(from_binary(data)),
|
||||
SerializedSyntaxSet::FromFile(ref path) => asset_from_cache(path, "syntax set"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_serialized_integrated_syntaxset() -> &'static [u8] {
|
||||
pub(crate) fn get_serialized_integrated_syntaxset() -> &'static [u8] {
|
||||
include_bytes!("../assets/syntaxes.bin")
|
||||
}
|
||||
|
||||
fn get_integrated_themeset() -> ThemeSet {
|
||||
from_binary(include_bytes!("../assets/themes.bin"))
|
||||
pub(crate) fn get_integrated_themeset() -> LazyThemeSet {
|
||||
from_binary(include_bytes!("../assets/themes.bin"), COMPRESS_THEMES)
|
||||
}
|
||||
|
||||
#[cfg(feature = "build-assets")]
|
||||
fn asset_to_cache<T: serde::Serialize>(asset: &T, path: &Path, description: &str) -> Result<()> {
|
||||
print!("Writing {} to {} ... ", description, path.to_string_lossy());
|
||||
syntect::dumps::dump_to_file(asset, &path).chain_err(|| {
|
||||
format!(
|
||||
"Could not save {} to {}",
|
||||
description,
|
||||
path.to_string_lossy()
|
||||
)
|
||||
})?;
|
||||
println!("okay");
|
||||
Ok(())
|
||||
pub fn get_acknowledgements() -> String {
|
||||
from_binary(
|
||||
include_bytes!("../assets/acknowledgements.bin"),
|
||||
COMPRESS_ACKNOWLEDGEMENTS,
|
||||
)
|
||||
}
|
||||
|
||||
fn asset_from_cache<T: serde::de::DeserializeOwned>(path: &Path, description: &str) -> Result<T> {
|
||||
let contents = fs::read(path).chain_err(|| {
|
||||
pub(crate) fn from_binary<T: serde::de::DeserializeOwned>(v: &[u8], compressed: bool) -> T {
|
||||
asset_from_contents(v, "n/a", compressed)
|
||||
.expect("data integrated in binary is never faulty, but make sure `compressed` is in sync!")
|
||||
}
|
||||
|
||||
fn asset_from_contents<T: serde::de::DeserializeOwned>(
|
||||
contents: &[u8],
|
||||
description: &str,
|
||||
compressed: bool,
|
||||
) -> Result<T> {
|
||||
if compressed {
|
||||
bincode::deserialize_from(flate2::read::ZlibDecoder::new(contents))
|
||||
} else {
|
||||
bincode::deserialize_from(contents)
|
||||
}
|
||||
.map_err(|_| format!("Could not parse {}", description).into())
|
||||
}
|
||||
|
||||
fn asset_from_cache<T: serde::de::DeserializeOwned>(
|
||||
path: &Path,
|
||||
description: &str,
|
||||
compressed: bool,
|
||||
) -> Result<T> {
|
||||
let contents = fs::read(path).map_err(|_| {
|
||||
format!(
|
||||
"Could not load cached {} '{}'",
|
||||
description,
|
||||
path.to_string_lossy()
|
||||
)
|
||||
})?;
|
||||
from_reader(&contents[..]).chain_err(|| format!("Could not parse cached {}", description))
|
||||
asset_from_contents(&contents[..], description, compressed)
|
||||
.map_err(|_| format!("Could not parse cached {}", description).into())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -639,6 +544,42 @@ mod tests {
|
||||
assert_eq!(test.syntax_for_file("test.h"), "C");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn syntax_detection_with_extension_mapping_to_unknown() {
|
||||
let mut test = SyntaxDetectionTest::new();
|
||||
|
||||
// Normally, a CMakeLists.txt file shall use the CMake syntax, even if it is
|
||||
// a bash script in disguise
|
||||
assert_eq!(
|
||||
test.syntax_for_file_with_content("CMakeLists.txt", "#!/bin/bash"),
|
||||
"CMake"
|
||||
);
|
||||
|
||||
// Other .txt files shall use the Plain Text syntax
|
||||
assert_eq!(
|
||||
test.syntax_for_file_with_content("some-other.txt", "#!/bin/bash"),
|
||||
"Plain Text"
|
||||
);
|
||||
|
||||
// If we setup MapExtensionToUnknown on *.txt, the match on the full
|
||||
// file name of "CMakeLists.txt" shall have higher prio, and CMake shall
|
||||
// still be used for it
|
||||
test.syntax_mapping
|
||||
.insert("*.txt", MappingTarget::MapExtensionToUnknown)
|
||||
.ok();
|
||||
assert_eq!(
|
||||
test.syntax_for_file_with_content("CMakeLists.txt", "#!/bin/bash"),
|
||||
"CMake"
|
||||
);
|
||||
|
||||
// However, for *other* files with a .txt extension, first-line fallback
|
||||
// shall now be used
|
||||
assert_eq!(
|
||||
test.syntax_for_file_with_content("some-other.txt", "#!/bin/bash"),
|
||||
"Bourne Again Shell (bash)"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn syntax_detection_is_case_sensitive() {
|
||||
let mut test = SyntaxDetectionTest::new();
|
||||
|
@@ -52,16 +52,15 @@ impl AssetsMetadata {
|
||||
pub fn load_from_folder(path: &Path) -> Result<Option<Self>> {
|
||||
match Self::try_load_from_folder(path) {
|
||||
Ok(metadata) => Ok(Some(metadata)),
|
||||
Err(e) => match e.kind() {
|
||||
ErrorKind::SerdeYamlError(_) => Err(e),
|
||||
_ => {
|
||||
if path.join("syntaxes.bin").exists() || path.join("themes.bin").exists() {
|
||||
Ok(Some(Self::default()))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
Err(e) => {
|
||||
if let Error::SerdeYamlError(_) = e {
|
||||
Err(e)
|
||||
} else if path.join("syntaxes.bin").exists() || path.join("themes.bin").exists() {
|
||||
Ok(Some(Self::default()))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
176
src/assets/build_assets.rs
Normal file
176
src/assets/build_assets.rs
Normal file
@@ -0,0 +1,176 @@
|
||||
use std::convert::TryInto;
|
||||
use std::path::Path;
|
||||
|
||||
use syntect::highlighting::ThemeSet;
|
||||
use syntect::parsing::{SyntaxSet, SyntaxSetBuilder};
|
||||
|
||||
use crate::assets::*;
|
||||
use acknowledgements::build_acknowledgements;
|
||||
|
||||
mod acknowledgements;
|
||||
|
||||
pub fn build(
|
||||
source_dir: &Path,
|
||||
include_integrated_assets: bool,
|
||||
include_acknowledgements: bool,
|
||||
target_dir: &Path,
|
||||
current_version: &str,
|
||||
) -> Result<()> {
|
||||
let theme_set = build_theme_set(source_dir, include_integrated_assets)?;
|
||||
|
||||
let syntax_set_builder = build_syntax_set_builder(source_dir, include_integrated_assets)?;
|
||||
|
||||
let syntax_set = syntax_set_builder.build();
|
||||
|
||||
let acknowledgements = build_acknowledgements(source_dir, include_acknowledgements)?;
|
||||
|
||||
print_unlinked_contexts(&syntax_set);
|
||||
|
||||
write_assets(
|
||||
&theme_set,
|
||||
&syntax_set,
|
||||
&acknowledgements,
|
||||
target_dir,
|
||||
current_version,
|
||||
)
|
||||
}
|
||||
|
||||
fn build_theme_set(source_dir: &Path, include_integrated_assets: bool) -> Result<LazyThemeSet> {
|
||||
let mut theme_set = if include_integrated_assets {
|
||||
crate::assets::get_integrated_themeset().try_into()?
|
||||
} else {
|
||||
ThemeSet::new()
|
||||
};
|
||||
|
||||
let theme_dir = source_dir.join("themes");
|
||||
if theme_dir.exists() {
|
||||
let res = theme_set.add_from_folder(&theme_dir);
|
||||
if let Err(err) = res {
|
||||
println!(
|
||||
"Failed to load one or more themes from '{}' (reason: '{}')",
|
||||
theme_dir.to_string_lossy(),
|
||||
err,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
println!(
|
||||
"No themes were found in '{}', using the default set",
|
||||
theme_dir.to_string_lossy()
|
||||
);
|
||||
}
|
||||
|
||||
theme_set.try_into()
|
||||
}
|
||||
|
||||
fn build_syntax_set_builder(
|
||||
source_dir: &Path,
|
||||
include_integrated_assets: bool,
|
||||
) -> Result<SyntaxSetBuilder> {
|
||||
let mut syntax_set_builder = if !include_integrated_assets {
|
||||
let mut builder = syntect::parsing::SyntaxSetBuilder::new();
|
||||
builder.add_plain_text_syntax();
|
||||
builder
|
||||
} else {
|
||||
from_binary::<SyntaxSet>(get_serialized_integrated_syntaxset(), COMPRESS_SYNTAXES)
|
||||
.into_builder()
|
||||
};
|
||||
|
||||
let syntax_dir = source_dir.join("syntaxes");
|
||||
if syntax_dir.exists() {
|
||||
syntax_set_builder.add_from_folder(syntax_dir, true)?;
|
||||
} else {
|
||||
println!(
|
||||
"No syntaxes were found in '{}', using the default set.",
|
||||
syntax_dir.to_string_lossy()
|
||||
);
|
||||
}
|
||||
|
||||
Ok(syntax_set_builder)
|
||||
}
|
||||
|
||||
fn print_unlinked_contexts(syntax_set: &SyntaxSet) {
|
||||
let missing_contexts = syntax_set.find_unlinked_contexts();
|
||||
if !missing_contexts.is_empty() {
|
||||
println!("Some referenced contexts could not be found!");
|
||||
for context in missing_contexts {
|
||||
println!("- {}", context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn write_assets(
|
||||
theme_set: &LazyThemeSet,
|
||||
syntax_set: &SyntaxSet,
|
||||
acknowledgements: &Option<String>,
|
||||
target_dir: &Path,
|
||||
current_version: &str,
|
||||
) -> Result<()> {
|
||||
let _ = std::fs::create_dir_all(target_dir);
|
||||
asset_to_cache(
|
||||
theme_set,
|
||||
&target_dir.join("themes.bin"),
|
||||
"theme set",
|
||||
COMPRESS_THEMES,
|
||||
)?;
|
||||
asset_to_cache(
|
||||
syntax_set,
|
||||
&target_dir.join("syntaxes.bin"),
|
||||
"syntax set",
|
||||
COMPRESS_SYNTAXES,
|
||||
)?;
|
||||
|
||||
if let Some(acknowledgements) = acknowledgements {
|
||||
asset_to_cache(
|
||||
acknowledgements,
|
||||
&target_dir.join("acknowledgements.bin"),
|
||||
"acknowledgements",
|
||||
COMPRESS_ACKNOWLEDGEMENTS,
|
||||
)?;
|
||||
}
|
||||
|
||||
print!(
|
||||
"Writing metadata to folder {} ... ",
|
||||
target_dir.to_string_lossy()
|
||||
);
|
||||
crate::assets_metadata::AssetsMetadata::new(current_version).save_to_folder(target_dir)?;
|
||||
println!("okay");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn asset_to_contents<T: serde::Serialize>(
|
||||
asset: &T,
|
||||
description: &str,
|
||||
compressed: bool,
|
||||
) -> Result<Vec<u8>> {
|
||||
let mut contents = vec![];
|
||||
if compressed {
|
||||
bincode::serialize_into(
|
||||
flate2::write::ZlibEncoder::new(&mut contents, flate2::Compression::best()),
|
||||
asset,
|
||||
)
|
||||
} else {
|
||||
bincode::serialize_into(&mut contents, asset)
|
||||
}
|
||||
.map_err(|_| format!("Could not serialize {}", description))?;
|
||||
Ok(contents)
|
||||
}
|
||||
|
||||
fn asset_to_cache<T: serde::Serialize>(
|
||||
asset: &T,
|
||||
path: &Path,
|
||||
description: &str,
|
||||
compressed: bool,
|
||||
) -> Result<()> {
|
||||
print!("Writing {} to {} ... ", description, path.to_string_lossy());
|
||||
let contents = asset_to_contents(asset, description, compressed)?;
|
||||
std::fs::write(path, &contents[..]).map_err(|_| {
|
||||
format!(
|
||||
"Could not save {} to {}",
|
||||
description,
|
||||
path.to_string_lossy()
|
||||
)
|
||||
})?;
|
||||
println!("okay");
|
||||
Ok(())
|
||||
}
|
222
src/assets/build_assets/acknowledgements.rs
Normal file
222
src/assets/build_assets/acknowledgements.rs
Normal file
@@ -0,0 +1,222 @@
|
||||
use std::fs::read_to_string;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use walkdir::DirEntry;
|
||||
|
||||
use crate::error::*;
|
||||
|
||||
struct PathAndStem {
|
||||
path: PathBuf,
|
||||
stem: String,
|
||||
relative_path: String,
|
||||
}
|
||||
|
||||
/// Looks for LICENSE and NOTICE files in `source_dir`, does some rudimentary
|
||||
/// analysis, and compiles them together in a single string that is meant to be
|
||||
/// used in the output to `--acknowledgements`
|
||||
pub fn build_acknowledgements(
|
||||
source_dir: &Path,
|
||||
include_acknowledgements: bool,
|
||||
) -> Result<Option<String>> {
|
||||
if !include_acknowledgements {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let mut acknowledgements = format!("{}\n\n", include_str!("../../../NOTICE"));
|
||||
|
||||
// Sort entries so the order is stable over time
|
||||
let entries = walkdir::WalkDir::new(source_dir).sort_by(|a, b| a.path().cmp(b.path()));
|
||||
for path_and_stem in entries
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.flat_map(|entry| to_path_and_stem(source_dir, entry))
|
||||
{
|
||||
if let Some(license_text) = handle_file(&path_and_stem)? {
|
||||
append_to_acknowledgements(
|
||||
&mut acknowledgements,
|
||||
&path_and_stem.relative_path,
|
||||
&license_text,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Some(acknowledgements))
|
||||
}
|
||||
|
||||
fn to_path_and_stem(source_dir: &Path, entry: DirEntry) -> Option<PathAndStem> {
|
||||
let path = entry.path();
|
||||
|
||||
Some(PathAndStem {
|
||||
path: path.to_owned(),
|
||||
stem: path.file_stem().map(|s| s.to_string_lossy().to_string())?,
|
||||
relative_path: path
|
||||
.strip_prefix(source_dir)
|
||||
.map(|p| p.to_string_lossy().to_string())
|
||||
.ok()?,
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_file(path_and_stem: &PathAndStem) -> Result<Option<String>> {
|
||||
if path_and_stem.stem == "NOTICE" {
|
||||
handle_notice(&path_and_stem.path)
|
||||
} else if path_and_stem.stem.to_ascii_uppercase() == "LICENSE" {
|
||||
handle_license(&path_and_stem.path)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_notice(path: &Path) -> Result<Option<String>> {
|
||||
// Assume NOTICE as defined by Apache License 2.0. These must be part of acknowledgements.
|
||||
Ok(Some(read_to_string(path)?))
|
||||
}
|
||||
|
||||
fn handle_license(path: &Path) -> Result<Option<String>> {
|
||||
let license_text = read_to_string(path)?;
|
||||
|
||||
if include_license_in_acknowledgments(&license_text) {
|
||||
Ok(Some(license_text))
|
||||
} else if license_not_needed_in_acknowledgements(&license_text) {
|
||||
Ok(None)
|
||||
} else {
|
||||
Err(format!("ERROR: License is of unknown type: {:?}", path).into())
|
||||
}
|
||||
}
|
||||
|
||||
fn include_license_in_acknowledgments(license_text: &str) -> bool {
|
||||
let markers = vec![
|
||||
// MIT
|
||||
"The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.",
|
||||
|
||||
// BSD
|
||||
"Redistributions in binary form must reproduce the above copyright notice,",
|
||||
|
||||
// Apache 2.0
|
||||
"Apache License Version 2.0, January 2004 http://www.apache.org/licenses/",
|
||||
"Licensed under the Apache License, Version 2.0 (the \"License\");",
|
||||
];
|
||||
|
||||
license_contains_marker(license_text, &markers)
|
||||
}
|
||||
|
||||
fn license_not_needed_in_acknowledgements(license_text: &str) -> bool {
|
||||
let markers = vec![
|
||||
// Public domain
|
||||
"This is free and unencumbered software released into the public domain.",
|
||||
|
||||
// Public domain with stronger wording than above
|
||||
"DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE",
|
||||
|
||||
// Special license of assets/syntaxes/01_Packages/LICENSE
|
||||
"Permission to copy, use, modify, sell and distribute this software is granted. This software is provided \"as is\" without express or implied warranty, and with no claim as to its suitability for any purpose."
|
||||
];
|
||||
|
||||
license_contains_marker(license_text, &markers)
|
||||
}
|
||||
|
||||
fn license_contains_marker(license_text: &str, markers: &[&str]) -> bool {
|
||||
let normalized_license_text = normalize_license_text(license_text);
|
||||
markers.iter().any(|m| normalized_license_text.contains(m))
|
||||
}
|
||||
|
||||
fn append_to_acknowledgements(
|
||||
acknowledgements: &mut String,
|
||||
relative_path: &str,
|
||||
license_text: &str,
|
||||
) {
|
||||
acknowledgements.push_str(&format!("## {}\n\n{}", relative_path, license_text));
|
||||
|
||||
// Make sure the last char is a newline to not mess up formatting later
|
||||
if acknowledgements
|
||||
.chars()
|
||||
.last()
|
||||
.expect("acknowledgements is not the empty string")
|
||||
!= '\n'
|
||||
{
|
||||
acknowledgements.push('\n');
|
||||
}
|
||||
|
||||
// Add two more newlines to make it easy to distinguish where this text ends
|
||||
// and the next starts
|
||||
acknowledgements.push_str("\n\n");
|
||||
}
|
||||
|
||||
/// Replaces newlines with a space character, and replaces multiple spaces with one space.
|
||||
/// This makes the text easier to analyze.
|
||||
fn normalize_license_text(license_text: &str) -> String {
|
||||
use regex::Regex;
|
||||
|
||||
let whitespace_and_newlines = Regex::new(r"\s").unwrap();
|
||||
let as_single_line = whitespace_and_newlines.replace_all(license_text, " ");
|
||||
|
||||
let many_spaces = Regex::new(" +").unwrap();
|
||||
many_spaces.replace_all(&as_single_line, " ").to_string()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[cfg(test)]
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_normalize_license_text() {
|
||||
let license_text = "This is a license text with these terms:
|
||||
* Complicated multi-line
|
||||
term with indentation";
|
||||
|
||||
assert_eq!(
|
||||
"This is a license text with these terms: * Complicated multi-line term with indentation".to_owned(),
|
||||
normalize_license_text(license_text),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_normalize_license_text_with_windows_line_endings() {
|
||||
let license_text = "This license text includes windows line endings\r
|
||||
and we need to handle that.";
|
||||
|
||||
assert_eq!(
|
||||
"This license text includes windows line endings and we need to handle that."
|
||||
.to_owned(),
|
||||
normalize_license_text(license_text),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_append_to_acknowledgements_adds_newline_if_missing() {
|
||||
let mut acknowledgements = "preamble\n\n\n".to_owned();
|
||||
|
||||
append_to_acknowledgements(&mut acknowledgements, "some/path", "line without newline");
|
||||
assert_eq!(
|
||||
"preamble
|
||||
|
||||
|
||||
## some/path
|
||||
|
||||
line without newline
|
||||
|
||||
|
||||
",
|
||||
acknowledgements
|
||||
);
|
||||
|
||||
append_to_acknowledgements(&mut acknowledgements, "another/path", "line with newline\n");
|
||||
assert_eq!(
|
||||
"preamble
|
||||
|
||||
|
||||
## some/path
|
||||
|
||||
line without newline
|
||||
|
||||
|
||||
## another/path
|
||||
|
||||
line with newline
|
||||
|
||||
|
||||
",
|
||||
acknowledgements
|
||||
);
|
||||
}
|
||||
}
|
104
src/assets/lazy_theme_set.rs
Normal file
104
src/assets/lazy_theme_set.rs
Normal file
@@ -0,0 +1,104 @@
|
||||
use super::*;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
use once_cell::unsync::OnceCell;
|
||||
|
||||
use syntect::highlighting::{Theme, ThemeSet};
|
||||
|
||||
/// Same structure as a [`syntect::highlighting::ThemeSet`] but with themes
|
||||
/// stored in raw serialized form, and deserialized on demand.
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
pub struct LazyThemeSet {
|
||||
/// This is a [`BTreeMap`] because that's what [`syntect::highlighting::ThemeSet`] uses
|
||||
themes: BTreeMap<String, LazyTheme>,
|
||||
}
|
||||
|
||||
/// Stores raw serialized data for a theme with methods to lazily deserialize
|
||||
/// (load) the theme.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
struct LazyTheme {
|
||||
serialized: Vec<u8>,
|
||||
|
||||
#[serde(skip, default = "OnceCell::new")]
|
||||
deserialized: OnceCell<syntect::highlighting::Theme>,
|
||||
}
|
||||
|
||||
impl LazyThemeSet {
|
||||
/// Lazily load the given theme
|
||||
pub fn get(&self, name: &str) -> Option<&Theme> {
|
||||
self.themes.get(name).and_then(|lazy_theme| {
|
||||
lazy_theme
|
||||
.deserialized
|
||||
.get_or_try_init(|| lazy_theme.deserialize())
|
||||
.ok()
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the name of all themes.
|
||||
pub fn themes(&self) -> impl Iterator<Item = &str> {
|
||||
self.themes.keys().map(|name| name.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl LazyTheme {
|
||||
fn deserialize(&self) -> Result<Theme> {
|
||||
asset_from_contents(
|
||||
&self.serialized[..],
|
||||
"lazy-loaded theme",
|
||||
COMPRESS_LAZY_THEMES,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<LazyThemeSet> for ThemeSet {
|
||||
type Error = Error;
|
||||
|
||||
/// Since the user might want to add custom themes to bat, we need a way to
|
||||
/// convert from a `LazyThemeSet` to a regular [`ThemeSet`] so that more
|
||||
/// themes can be added. This function does that pretty straight-forward
|
||||
/// conversion.
|
||||
fn try_from(lazy_theme_set: LazyThemeSet) -> Result<Self> {
|
||||
let mut theme_set = ThemeSet::default();
|
||||
|
||||
for (name, lazy_theme) in lazy_theme_set.themes {
|
||||
theme_set.themes.insert(name, lazy_theme.deserialize()?);
|
||||
}
|
||||
|
||||
Ok(theme_set)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "build-assets")]
|
||||
impl TryFrom<ThemeSet> for LazyThemeSet {
|
||||
type Error = Error;
|
||||
|
||||
/// To collect themes, a [`ThemeSet`] is needed. Once all desired themes
|
||||
/// have been added, we need a way to convert that into [`LazyThemeSet`] so
|
||||
/// that themes can be lazy-loaded later. This function does that
|
||||
/// conversion.
|
||||
fn try_from(theme_set: ThemeSet) -> Result<Self> {
|
||||
let mut lazy_theme_set = LazyThemeSet::default();
|
||||
|
||||
for (name, theme) in theme_set.themes {
|
||||
// All we have to do is to serialize the theme
|
||||
let lazy_theme = LazyTheme {
|
||||
serialized: crate::assets::build_assets::asset_to_contents(
|
||||
&theme,
|
||||
&format!("theme {}", name),
|
||||
COMPRESS_LAZY_THEMES,
|
||||
)?,
|
||||
deserialized: OnceCell::new(),
|
||||
};
|
||||
|
||||
// Ok done, now we can add it
|
||||
lazy_theme_set.themes.insert(name, lazy_theme);
|
||||
}
|
||||
|
||||
Ok(lazy_theme_set)
|
||||
}
|
||||
}
|
27
src/assets/serialized_syntax_set.rs
Normal file
27
src/assets/serialized_syntax_set.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use syntect::parsing::SyntaxSet;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// A SyntaxSet in serialized form, i.e. bincoded and flate2 compressed.
|
||||
/// We keep it in this format since we want to load it lazily.
|
||||
#[derive(Debug)]
|
||||
pub enum SerializedSyntaxSet {
|
||||
/// The data comes from a user-generated cache file.
|
||||
FromFile(PathBuf),
|
||||
|
||||
/// The data to use is embedded into the bat binary.
|
||||
FromBinary(&'static [u8]),
|
||||
}
|
||||
|
||||
impl SerializedSyntaxSet {
|
||||
pub fn deserialize(&self) -> Result<SyntaxSet> {
|
||||
match self {
|
||||
SerializedSyntaxSet::FromBinary(data) => Ok(from_binary(data, COMPRESS_SYNTAXES)),
|
||||
SerializedSyntaxSet::FromFile(ref path) => {
|
||||
asset_from_cache(path, "syntax set", COMPRESS_SYNTAXES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -62,7 +62,7 @@ impl App {
|
||||
// Read arguments from bats config file
|
||||
let mut args = get_args_from_env_var()
|
||||
.unwrap_or_else(get_args_from_config_file)
|
||||
.chain_err(|| "Could not parse configuration file")?;
|
||||
.map_err(|_| "Could not parse configuration file")?;
|
||||
|
||||
// Put the zero-th CLI argument (program name) first
|
||||
args.insert(0, cli_args.next().unwrap());
|
||||
@@ -107,6 +107,12 @@ impl App {
|
||||
|
||||
let mut syntax_mapping = SyntaxMapping::builtin();
|
||||
|
||||
if let Some(values) = self.matches.values_of("ignored-suffix") {
|
||||
for suffix in values {
|
||||
syntax_mapping.insert_ignored_suffix(suffix);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(values) = self.matches.values_of("map-syntax") {
|
||||
for from_to in values {
|
||||
let parts: Vec<_> = from_to.split(':').collect();
|
||||
@@ -301,7 +307,7 @@ impl App {
|
||||
.map(|style_str| {
|
||||
style_str
|
||||
.split(',')
|
||||
.map(|x| StyleComponent::from_str(x))
|
||||
.map(StyleComponent::from_str)
|
||||
.collect::<Result<Vec<StyleComponent>>>()
|
||||
})
|
||||
.transpose()?;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
use std::borrow::Cow;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
|
||||
use clap::crate_version;
|
||||
|
||||
@@ -51,6 +52,14 @@ pub fn assets_from_cache_or_binary(use_custom_assets: bool) -> Result<Highlighti
|
||||
|
||||
fn clear_asset(filename: &str, description: &str) {
|
||||
print!("Clearing {} ... ", description);
|
||||
fs::remove_file(PROJECT_DIRS.cache_dir().join(filename)).ok();
|
||||
println!("okay");
|
||||
let path = PROJECT_DIRS.cache_dir().join(filename);
|
||||
match fs::remove_file(&path) {
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => {
|
||||
println!("skipped (not present)");
|
||||
}
|
||||
Err(err) => {
|
||||
println!("could not remove the cache file {:?}: {}", &path, err);
|
||||
}
|
||||
Ok(_) => println!("okay"),
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,21 @@
|
||||
use clap::{crate_name, crate_version, App as ClapApp, AppSettings, Arg, ArgGroup, SubCommand};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
static VERSION: Lazy<String> = Lazy::new(|| {
|
||||
#[cfg(feature = "bugreport")]
|
||||
let git_version = bugreport::git_version!(fallback = "");
|
||||
#[cfg(not(feature = "bugreport"))]
|
||||
let git_version = "";
|
||||
|
||||
if git_version.is_empty() {
|
||||
crate_version!().to_string()
|
||||
} else {
|
||||
format!("{} ({})", crate_version!(), git_version)
|
||||
}
|
||||
});
|
||||
|
||||
pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
let clap_color_setting = if interactive_output && env::var_os("NO_COLOR").is_none() {
|
||||
AppSettings::ColoredHelp
|
||||
@@ -10,7 +24,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
};
|
||||
|
||||
let mut app = ClapApp::new(crate_name!())
|
||||
.version(crate_version!())
|
||||
.version(VERSION.as_str())
|
||||
.global_setting(clap_color_setting)
|
||||
.global_setting(AppSettings::DeriveDisplayOrder)
|
||||
.global_setting(AppSettings::UnifiedHelpMessage)
|
||||
@@ -95,7 +109,8 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
'--highlight-line 40' highlights line 40\n \
|
||||
'--highlight-line 30:40' highlights lines 30 to 40\n \
|
||||
'--highlight-line :40' highlights lines 1 to 40\n \
|
||||
'--highlight-line 40:' highlights lines 40 to the end of the file",
|
||||
'--highlight-line 40:' highlights lines 40 to the end of the file\n \
|
||||
'--highlight-line 30:+10' highlights lines 30 to 40",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
@@ -334,6 +349,18 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
)
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("ignored-suffix")
|
||||
.number_of_values(1)
|
||||
.multiple(true)
|
||||
.takes_value(true)
|
||||
.long("ignored-suffix")
|
||||
.hidden_short_help(true)
|
||||
.help(
|
||||
"Ignore extension. For example:\n \
|
||||
'bat --ignored-suffix \".dev\" my_file.json.dev' will use JSON syntax, and ignore '.dev'"
|
||||
)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("theme")
|
||||
.long("theme")
|
||||
@@ -369,11 +396,19 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
.validator(|val| {
|
||||
let mut invalid_vals = val.split(',').filter(|style| {
|
||||
!&[
|
||||
"auto", "full", "plain", "header", "grid", "rule", "numbers", "snip",
|
||||
"auto",
|
||||
"full",
|
||||
"plain",
|
||||
"header",
|
||||
"header-filename",
|
||||
"header-filesize",
|
||||
"grid",
|
||||
"rule",
|
||||
"numbers",
|
||||
"snip",
|
||||
#[cfg(feature = "git")]
|
||||
"changes",
|
||||
]
|
||||
.contains(style)
|
||||
"changes",
|
||||
].contains(style)
|
||||
});
|
||||
|
||||
if let Some(invalid) = invalid_vals.next() {
|
||||
@@ -399,7 +434,9 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
* auto: same as 'full', unless the output is piped.\n \
|
||||
* plain: disables all available components.\n \
|
||||
* changes: show Git modification markers.\n \
|
||||
* header: show filenames before the content.\n \
|
||||
* header: alias for 'header-filename'.\n \
|
||||
* header-filename: show filenames before the content.\n \
|
||||
* header-filesize: show file sizes before the content.\n \
|
||||
* grid: vertical/horizontal lines to separate side bar\n \
|
||||
and the header from the content.\n \
|
||||
* rule: horizontal lines to delimit files.\n \
|
||||
@@ -423,7 +460,8 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
'--line-range 30:40' prints lines 30 to 40\n \
|
||||
'--line-range :40' prints lines 1 to 40\n \
|
||||
'--line-range 40:' prints lines 40 to the end of the file\n \
|
||||
'--line-range 40' only prints line 40",
|
||||
'--line-range 40' only prints line 40\n \
|
||||
'--line-range 30:+10' prints lines 30 to 40",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
@@ -492,6 +530,12 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
.hidden_short_help(true)
|
||||
.help("Show diagnostic information for bug reports.")
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("acknowledgements")
|
||||
.long("acknowledgements")
|
||||
.hidden_short_help(true)
|
||||
.help("Show acknowledgements."),
|
||||
)
|
||||
.help_message("Print this help message.")
|
||||
.version_message("Show version information.");
|
||||
|
||||
@@ -550,6 +594,12 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
||||
"Create completely new syntax and theme sets \
|
||||
(instead of appending to the default sets).",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("acknowledgements")
|
||||
.long("acknowledgements")
|
||||
.requires("build")
|
||||
.help("Build acknowledgements.bin."),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ pub fn generate_config_file() -> bat::error::Result<()> {
|
||||
#--pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse"
|
||||
|
||||
# Syntax mappings: map a certain filename pattern to a language.
|
||||
# Example 1: use the C++ syntax for .ino files
|
||||
# Example 1: use the C++ syntax for Arduino .ino files
|
||||
# Example 2: Use ".gitignore"-style highlighting for ".ignore" files
|
||||
#--map-syntax "*.ino:C++"
|
||||
#--map-syntax ".ignore:Git Ignore"
|
||||
@@ -104,7 +104,7 @@ fn get_args_from_str(content: &str) -> Result<Vec<OsString>, shell_words::ParseE
|
||||
.map(|line| line.trim())
|
||||
.filter(|line| !line.is_empty())
|
||||
.filter(|line| !line.starts_with('#'))
|
||||
.map(|line| shell_words::split(line))
|
||||
.map(shell_words::split)
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
Ok(args_per_line
|
||||
|
@@ -1,7 +1,7 @@
|
||||
use std::env;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
/// Wrapper for 'dirs' that treats MacOS more like Linux, by following the XDG specification.
|
||||
/// The `XDG_CACHE_HOME` environment variable is checked first. `BAT_CONFIG_DIR`
|
||||
@@ -68,7 +68,5 @@ impl BatProjectDirs {
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref PROJECT_DIRS: BatProjectDirs =
|
||||
BatProjectDirs::new().expect("Could not get home directory");
|
||||
}
|
||||
pub static PROJECT_DIRS: Lazy<BatProjectDirs> =
|
||||
Lazy::new(|| BatProjectDirs::new().expect("Could not get home directory"));
|
||||
|
@@ -1,5 +1,4 @@
|
||||
// `error_chain!` can recurse deeply
|
||||
#![recursion_limit = "1024"]
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
mod app;
|
||||
mod assets;
|
||||
@@ -48,10 +47,13 @@ fn build_assets(matches: &clap::ArgMatches) -> Result<()> {
|
||||
.map(Path::new)
|
||||
.unwrap_or_else(|| PROJECT_DIRS.cache_dir());
|
||||
|
||||
let blank = matches.is_present("blank");
|
||||
|
||||
let assets = bat::assets::HighlightingAssets::from_files(source_dir, !blank)?;
|
||||
assets.save_to_cache(target_dir, clap::crate_version!())
|
||||
bat::assets::build(
|
||||
source_dir,
|
||||
!matches.is_present("blank"),
|
||||
matches.is_present("acknowledgements"),
|
||||
target_dir,
|
||||
clap::crate_version!(),
|
||||
)
|
||||
}
|
||||
|
||||
fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
|
||||
@@ -72,12 +74,9 @@ fn get_syntax_mapping_to_paths<'a>(
|
||||
) -> HashMap<&'a str, Vec<String>> {
|
||||
let mut map = HashMap::new();
|
||||
for mapping in mappings {
|
||||
match mapping {
|
||||
(_, MappingTarget::MapToUnknown) => {}
|
||||
(matcher, MappingTarget::MapTo(s)) => {
|
||||
let globs = map.entry(*s).or_insert_with(Vec::new);
|
||||
globs.push(matcher.glob().glob().into());
|
||||
}
|
||||
if let (matcher, MappingTarget::MapTo(s)) = mapping {
|
||||
let globs = map.entry(*s).or_insert_with(Vec::new);
|
||||
globs.push(matcher.glob().glob().into());
|
||||
}
|
||||
}
|
||||
map
|
||||
@@ -95,7 +94,7 @@ pub fn get_languages(config: &Config) -> Result<String> {
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Handling of file-extension conflicts, see issue #1076
|
||||
for lang in languages.iter_mut() {
|
||||
for lang in &mut languages {
|
||||
let lang_name = lang.name.clone();
|
||||
lang.file_extensions.retain(|extension| {
|
||||
// The 'extension' variable is not certainly a real extension.
|
||||
@@ -104,17 +103,12 @@ pub fn get_languages(config: &Config) -> Result<String> {
|
||||
// Also skip if the 'extension' contains another real extension, likely
|
||||
// that is a full match file name like 'CMakeLists.txt' and 'Cargo.lock'
|
||||
if extension.starts_with('.') || Path::new(extension).extension().is_some() {
|
||||
true
|
||||
} else {
|
||||
let test_file = Path::new("test").with_extension(extension);
|
||||
let syntax_in_set = assets
|
||||
.get_syntax_for_file_name(test_file, &config.syntax_mapping)
|
||||
.unwrap(); // safe since .get_syntaxes() above worked
|
||||
match syntax_in_set {
|
||||
Some(syntax_in_set) => syntax_in_set.syntax.name == lang_name,
|
||||
None => false,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
let test_file = Path::new("test").with_extension(extension);
|
||||
let syntax_in_set = assets.get_syntax_for_path(test_file, &config.syntax_mapping);
|
||||
matches!(syntax_in_set, Ok(syntax_in_set) if syntax_in_set.syntax.name == lang_name)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -122,7 +116,7 @@ pub fn get_languages(config: &Config) -> Result<String> {
|
||||
|
||||
let configured_languages = get_syntax_mapping_to_paths(config.syntax_mapping.mappings());
|
||||
|
||||
for lang in languages.iter_mut() {
|
||||
for lang in &mut languages {
|
||||
if let Some(additional_paths) = configured_languages.get(lang.name.as_str()) {
|
||||
lang.file_extensions
|
||||
.extend(additional_paths.iter().cloned());
|
||||
@@ -236,7 +230,7 @@ fn invoke_bugreport(app: &App) {
|
||||
let pager = bat::config::get_pager_executable(app.matches.value_of("pager"))
|
||||
.unwrap_or_else(|| "less".to_owned()); // FIXME: Avoid non-canonical path to "less".
|
||||
|
||||
let report = bugreport!()
|
||||
let mut report = bugreport!()
|
||||
.info(SoftwareVersion::default())
|
||||
.info(OperatingSystem::default())
|
||||
.info(CommandLine::default())
|
||||
@@ -244,6 +238,8 @@ fn invoke_bugreport(app: &App) {
|
||||
"SHELL",
|
||||
"PAGER",
|
||||
"LESS",
|
||||
"LANG",
|
||||
"LC_ALL",
|
||||
"BAT_PAGER",
|
||||
"BAT_CACHE_PATH",
|
||||
"BAT_CONFIG_PATH",
|
||||
@@ -260,14 +256,13 @@ fn invoke_bugreport(app: &App) {
|
||||
.info(FileContent::new("Config file", config_file()))
|
||||
.info(CompileTimeInformation::default());
|
||||
|
||||
let mut report = if let Ok(resolved_path) = grep_cli::resolve_binary(pager) {
|
||||
report.info(CommandOutput::new(
|
||||
#[cfg(feature = "paging")]
|
||||
if let Ok(resolved_path) = grep_cli::resolve_binary(pager) {
|
||||
report = report.info(CommandOutput::new(
|
||||
"Less version",
|
||||
resolved_path,
|
||||
&["--version"],
|
||||
))
|
||||
} else {
|
||||
report
|
||||
};
|
||||
|
||||
report.print::<Markdown>();
|
||||
@@ -329,6 +324,9 @@ fn run() -> Result<bool> {
|
||||
} else if app.matches.is_present("cache-dir") {
|
||||
writeln!(io::stdout(), "{}", cache_dir())?;
|
||||
Ok(true)
|
||||
} else if app.matches.is_present("acknowledgements") {
|
||||
writeln!(io::stdout(), "{}", bat::assets::get_acknowledgements())?;
|
||||
Ok(true)
|
||||
} else {
|
||||
run_controller(inputs, &config)
|
||||
}
|
||||
|
@@ -90,11 +90,10 @@ pub struct Config<'a> {
|
||||
|
||||
#[cfg(all(feature = "minimal-application", feature = "paging"))]
|
||||
pub fn get_pager_executable(config_pager: Option<&str>) -> Option<String> {
|
||||
if let Ok(Some(pager)) = crate::pager::get_pager(config_pager) {
|
||||
Some(pager.bin)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
crate::pager::get_pager(config_pager)
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|pager| pager.bin)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@@ -1,4 +1,4 @@
|
||||
use std::io::{self, Write};
|
||||
use std::io::{self, BufRead, Write};
|
||||
|
||||
use crate::assets::HighlightingAssets;
|
||||
use crate::config::{Config, VisibleLines};
|
||||
@@ -14,7 +14,7 @@ use crate::output::OutputType;
|
||||
use crate::paging::PagingMode;
|
||||
use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
|
||||
|
||||
use clircle::Clircle;
|
||||
use clircle::{Clircle, Identifier};
|
||||
|
||||
pub struct Controller<'a> {
|
||||
config: &'a Config<'a>,
|
||||
@@ -76,85 +76,91 @@ impl<'b> Controller<'b> {
|
||||
|
||||
let writer = output_type.handle()?;
|
||||
let mut no_errors: bool = true;
|
||||
|
||||
let stderr = io::stderr();
|
||||
let print_error = |error: &Error, write: &mut dyn Write| {
|
||||
if attached_to_pager {
|
||||
handle_error(error, write);
|
||||
} else {
|
||||
handle_error(error, &mut stderr.lock());
|
||||
}
|
||||
};
|
||||
|
||||
for (index, input) in inputs.into_iter().enumerate() {
|
||||
match input.open(io::stdin().lock(), stdout_identifier.as_ref()) {
|
||||
Err(error) => {
|
||||
print_error(&error, writer);
|
||||
no_errors = false;
|
||||
}
|
||||
Ok(mut opened_input) => {
|
||||
#[cfg(feature = "git")]
|
||||
let line_changes = if self.config.visible_lines.diff_mode()
|
||||
|| (!self.config.loop_through && self.config.style_components.changes())
|
||||
{
|
||||
match opened_input.kind {
|
||||
crate::input::OpenedInputKind::OrdinaryFile(ref path) => {
|
||||
let diff = get_git_diff(path);
|
||||
|
||||
// Skip files without Git modifications
|
||||
if self.config.visible_lines.diff_mode()
|
||||
&& diff
|
||||
.as_ref()
|
||||
.map(|changes| changes.is_empty())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
diff
|
||||
}
|
||||
_ if self.config.visible_lines.diff_mode() => {
|
||||
// Skip non-file inputs in diff mode
|
||||
continue;
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let mut printer: Box<dyn Printer> = if self.config.loop_through {
|
||||
Box::new(SimplePrinter::new(self.config))
|
||||
} else {
|
||||
Box::new(InteractivePrinter::new(
|
||||
self.config,
|
||||
self.assets,
|
||||
&mut opened_input,
|
||||
#[cfg(feature = "git")]
|
||||
&line_changes,
|
||||
)?)
|
||||
};
|
||||
|
||||
let result = self.print_file(
|
||||
&mut *printer,
|
||||
writer,
|
||||
&mut opened_input,
|
||||
index != 0,
|
||||
#[cfg(feature = "git")]
|
||||
&line_changes,
|
||||
);
|
||||
|
||||
if let Err(error) = result {
|
||||
print_error(&error, writer);
|
||||
no_errors = false;
|
||||
}
|
||||
let identifier = stdout_identifier.as_ref();
|
||||
let is_first = index == 0;
|
||||
let result = if input.is_stdin() {
|
||||
self.print_input(input, writer, io::stdin().lock(), identifier, is_first)
|
||||
} else {
|
||||
// Use dummy stdin since stdin is actually not used (#1902)
|
||||
self.print_input(input, writer, io::empty(), identifier, is_first)
|
||||
};
|
||||
if let Err(error) = result {
|
||||
if attached_to_pager {
|
||||
handle_error(&error, writer);
|
||||
} else {
|
||||
handle_error(&error, &mut stderr.lock());
|
||||
}
|
||||
no_errors = false;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(no_errors)
|
||||
}
|
||||
|
||||
fn print_input<R: BufRead>(
|
||||
&self,
|
||||
input: Input,
|
||||
writer: &mut dyn Write,
|
||||
stdin: R,
|
||||
stdout_identifier: Option<&Identifier>,
|
||||
is_first: bool,
|
||||
) -> Result<()> {
|
||||
let mut opened_input = input.open(stdin, stdout_identifier)?;
|
||||
#[cfg(feature = "git")]
|
||||
let line_changes = if self.config.visible_lines.diff_mode()
|
||||
|| (!self.config.loop_through && self.config.style_components.changes())
|
||||
{
|
||||
match opened_input.kind {
|
||||
crate::input::OpenedInputKind::OrdinaryFile(ref path) => {
|
||||
let diff = get_git_diff(path);
|
||||
|
||||
// Skip files without Git modifications
|
||||
if self.config.visible_lines.diff_mode()
|
||||
&& diff
|
||||
.as_ref()
|
||||
.map(|changes| changes.is_empty())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
diff
|
||||
}
|
||||
_ if self.config.visible_lines.diff_mode() => {
|
||||
// Skip non-file inputs in diff mode
|
||||
return Ok(());
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let mut printer: Box<dyn Printer> = if self.config.loop_through {
|
||||
Box::new(SimplePrinter::new(self.config))
|
||||
} else {
|
||||
Box::new(InteractivePrinter::new(
|
||||
self.config,
|
||||
self.assets,
|
||||
&mut opened_input,
|
||||
#[cfg(feature = "git")]
|
||||
&line_changes,
|
||||
)?)
|
||||
};
|
||||
|
||||
self.print_file(
|
||||
&mut *printer,
|
||||
writer,
|
||||
&mut opened_input,
|
||||
!is_first,
|
||||
#[cfg(feature = "git")]
|
||||
&line_changes,
|
||||
)
|
||||
}
|
||||
|
||||
fn print_file(
|
||||
&self,
|
||||
printer: &mut dyn Printer,
|
||||
@@ -175,9 +181,10 @@ impl<'b> Controller<'b> {
|
||||
let mut line_ranges: Vec<LineRange> = vec![];
|
||||
|
||||
if let Some(line_changes) = line_changes {
|
||||
for line in line_changes.keys() {
|
||||
let line = *line as usize;
|
||||
line_ranges.push(LineRange::new(line - context, line + context));
|
||||
for &line in line_changes.keys() {
|
||||
let line = line as usize;
|
||||
line_ranges
|
||||
.push(LineRange::new(line.saturating_sub(context), line + context));
|
||||
}
|
||||
}
|
||||
|
||||
|
64
src/error.rs
64
src/error.rs
@@ -1,42 +1,52 @@
|
||||
use error_chain::error_chain;
|
||||
use std::io::Write;
|
||||
use thiserror::Error;
|
||||
|
||||
error_chain! {
|
||||
foreign_links {
|
||||
Clap(::clap::Error) #[cfg(feature = "minimal-application")];
|
||||
Io(::std::io::Error);
|
||||
SyntectError(::syntect::LoadingError);
|
||||
ParseIntError(::std::num::ParseIntError);
|
||||
GlobParsingError(::globset::Error);
|
||||
SerdeYamlError(::serde_yaml::Error);
|
||||
}
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error(transparent)]
|
||||
Io(#[from] ::std::io::Error),
|
||||
#[error(transparent)]
|
||||
SyntectError(#[from] ::syntect::LoadingError),
|
||||
#[error(transparent)]
|
||||
ParseIntError(#[from] ::std::num::ParseIntError),
|
||||
#[error(transparent)]
|
||||
GlobParsingError(#[from] ::globset::Error),
|
||||
#[error(transparent)]
|
||||
SerdeYamlError(#[from] ::serde_yaml::Error),
|
||||
#[error("unable to detect syntax for {0}")]
|
||||
UndetectedSyntax(String),
|
||||
#[error("unknown syntax: '{0}'")]
|
||||
UnknownSyntax(String),
|
||||
#[error("Unknown style '{0}'")]
|
||||
UnknownStyle(String),
|
||||
#[error("Use of bat as a pager is disallowed in order to avoid infinite recursion problems")]
|
||||
InvalidPagerValueBat,
|
||||
#[error("{0}")]
|
||||
Msg(String),
|
||||
}
|
||||
|
||||
errors {
|
||||
UndetectedSyntax(input: String) {
|
||||
description("unable to detect syntax"),
|
||||
display("unable to detect syntax for {}", input)
|
||||
}
|
||||
UnknownSyntax(name: String) {
|
||||
description("unknown syntax"),
|
||||
display("unknown syntax: '{}'", name)
|
||||
}
|
||||
InvalidPagerValueBat {
|
||||
description("invalid value `bat` for pager property"),
|
||||
display("Use of bat as a pager is disallowed in order to avoid infinite recursion problems")
|
||||
}
|
||||
impl From<&'static str> for Error {
|
||||
fn from(s: &'static str) -> Self {
|
||||
Error::Msg(s.to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Error {
|
||||
fn from(s: String) -> Self {
|
||||
Error::Msg(s)
|
||||
}
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
pub fn default_error_handler(error: &Error, output: &mut dyn Write) {
|
||||
use ansi_term::Colour::Red;
|
||||
|
||||
match error {
|
||||
Error(ErrorKind::Io(ref io_error), _)
|
||||
if io_error.kind() == ::std::io::ErrorKind::BrokenPipe =>
|
||||
{
|
||||
Error::Io(ref io_error) if io_error.kind() == ::std::io::ErrorKind::BrokenPipe => {
|
||||
::std::process::exit(0);
|
||||
}
|
||||
Error(ErrorKind::SerdeYamlError(_), _) => {
|
||||
Error::SerdeYamlError(_) => {
|
||||
writeln!(
|
||||
output,
|
||||
"{}: Error while parsing metadata.yaml file: {}",
|
||||
|
46
src/input.rs
46
src/input.rs
@@ -1,4 +1,5 @@
|
||||
use std::convert::TryFrom;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::{self, BufRead, BufReader, Read};
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -50,7 +51,7 @@ impl InputDescription {
|
||||
}
|
||||
|
||||
pub fn title(&self) -> &String {
|
||||
match self.title.as_ref() {
|
||||
match &self.title {
|
||||
Some(title) => title,
|
||||
None => &self.name,
|
||||
}
|
||||
@@ -87,6 +88,7 @@ impl<'a> InputKind<'a> {
|
||||
#[derive(Clone, Default)]
|
||||
pub(crate) struct InputMetadata {
|
||||
pub(crate) user_provided_name: Option<PathBuf>,
|
||||
pub(crate) size: Option<u64>,
|
||||
}
|
||||
|
||||
pub struct Input<'a> {
|
||||
@@ -108,6 +110,21 @@ pub(crate) struct OpenedInput<'a> {
|
||||
pub(crate) description: InputDescription,
|
||||
}
|
||||
|
||||
impl OpenedInput<'_> {
|
||||
/// Get the path of the file:
|
||||
/// If this was set by the metadata, that will take priority.
|
||||
/// If it wasn't, it will use the real file path (if available).
|
||||
pub(crate) fn path(&self) -> Option<&PathBuf> {
|
||||
self.metadata
|
||||
.user_provided_name
|
||||
.as_ref()
|
||||
.or_else(|| match self.kind {
|
||||
OpenedInputKind::OrdinaryFile(ref path) => Some(path),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Input<'a> {
|
||||
pub fn ordinary_file(path: impl AsRef<Path>) -> Self {
|
||||
Self::_ordinary_file(path.as_ref())
|
||||
@@ -115,9 +132,14 @@ impl<'a> Input<'a> {
|
||||
|
||||
fn _ordinary_file(path: &Path) -> Self {
|
||||
let kind = InputKind::OrdinaryFile(path.to_path_buf());
|
||||
let metadata = InputMetadata {
|
||||
size: fs::metadata(path).map(|m| m.len()).ok(),
|
||||
..InputMetadata::default()
|
||||
};
|
||||
|
||||
Input {
|
||||
description: kind.description(),
|
||||
metadata: InputMetadata::default(),
|
||||
metadata,
|
||||
kind,
|
||||
}
|
||||
}
|
||||
@@ -256,18 +278,18 @@ impl<'a> InputReader<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn read_line(&mut self, buf: &mut Vec<u8>) -> io::Result<bool> {
|
||||
if self.first_line.is_empty() {
|
||||
let res = self.inner.read_until(b'\n', buf).map(|size| size > 0)?;
|
||||
|
||||
if self.content_type == Some(ContentType::UTF_16LE) {
|
||||
self.inner.read_until(0x00, buf).ok();
|
||||
}
|
||||
|
||||
Ok(res)
|
||||
} else {
|
||||
if !self.first_line.is_empty() {
|
||||
buf.append(&mut self.first_line);
|
||||
Ok(true)
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
let res = self.inner.read_until(b'\n', buf).map(|size| size > 0)?;
|
||||
|
||||
if self.content_type == Some(ContentType::UTF_16LE) {
|
||||
let _ = self.inner.read_until(0x00, buf);
|
||||
}
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
|
12
src/less.rs
12
src/less.rs
@@ -11,13 +11,13 @@ pub fn retrieve_less_version(less_path: &dyn AsRef<OsStr>) -> Option<usize> {
|
||||
}
|
||||
|
||||
fn parse_less_version(output: &[u8]) -> Option<usize> {
|
||||
if output.starts_with(b"less ") {
|
||||
let version = std::str::from_utf8(&output[5..]).ok()?;
|
||||
let end = version.find(|c: char| !c.is_ascii_digit())?;
|
||||
version[..end].parse::<usize>().ok()
|
||||
} else {
|
||||
None
|
||||
if !output.starts_with(b"less ") {
|
||||
return None;
|
||||
}
|
||||
|
||||
let version = std::str::from_utf8(&output[5..]).ok()?;
|
||||
let end = version.find(|c: char| !c.is_ascii_digit())?;
|
||||
version[..end].parse::<usize>().ok()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@@ -19,10 +19,14 @@
|
||||
//! .unwrap();
|
||||
//! ```
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
mod macros;
|
||||
|
||||
pub mod assets;
|
||||
pub mod assets_metadata;
|
||||
pub mod assets_metadata {
|
||||
pub use super::assets::assets_metadata::*;
|
||||
}
|
||||
pub mod config;
|
||||
pub mod controller;
|
||||
mod decorations;
|
||||
@@ -40,10 +44,9 @@ mod preprocessor;
|
||||
mod pretty_printer;
|
||||
pub(crate) mod printer;
|
||||
pub mod style;
|
||||
#[cfg(feature = "build-assets")]
|
||||
mod syntax_dependencies;
|
||||
pub(crate) mod syntax_mapping;
|
||||
mod terminal;
|
||||
mod vscreen;
|
||||
pub(crate) mod wrapping;
|
||||
|
||||
pub use pretty_printer::{Input, PrettyPrinter};
|
||||
|
@@ -47,7 +47,28 @@ impl LineRange {
|
||||
}
|
||||
2 => {
|
||||
new_range.lower = line_numbers[0].parse()?;
|
||||
new_range.upper = line_numbers[1].parse()?;
|
||||
let first_byte = line_numbers[1].bytes().next();
|
||||
|
||||
new_range.upper = if first_byte == Some(b'+') {
|
||||
let more_lines = &line_numbers[1][1..]
|
||||
.parse()
|
||||
.map_err(|_| "Invalid character after +")?;
|
||||
new_range.lower + more_lines
|
||||
} else if first_byte == Some(b'-') {
|
||||
// this will prevent values like "-+5" even though "+5" is valid integer
|
||||
if line_numbers[1][1..].bytes().next() == Some(b'+') {
|
||||
return Err("Invalid character after -".into());
|
||||
}
|
||||
let prior_lines = &line_numbers[1][1..]
|
||||
.parse()
|
||||
.map_err(|_| "Invalid character after -")?;
|
||||
let prev_lower = new_range.lower;
|
||||
new_range.lower = new_range.lower.saturating_sub(*prior_lines);
|
||||
prev_lower
|
||||
} else {
|
||||
line_numbers[1].parse()?
|
||||
};
|
||||
|
||||
Ok(new_range)
|
||||
}
|
||||
_ => Err(
|
||||
@@ -100,6 +121,53 @@ fn test_parse_fail() {
|
||||
assert!(range.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_plus() {
|
||||
let range = LineRange::from("40:+10").expect("Shouldn't fail on test!");
|
||||
assert_eq!(40, range.lower);
|
||||
assert_eq!(50, range.upper);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_plus_fail() {
|
||||
let range = LineRange::from("40:+z");
|
||||
assert!(range.is_err());
|
||||
let range = LineRange::from("40:+-10");
|
||||
assert!(range.is_err());
|
||||
let range = LineRange::from("40:+");
|
||||
assert!(range.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_minus_success() {
|
||||
let range = LineRange::from("40:-10").expect("Shouldn't fail on test!");
|
||||
assert_eq!(30, range.lower);
|
||||
assert_eq!(40, range.upper);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_minus_edge_cases_success() {
|
||||
let range = LineRange::from("5:-4").expect("Shouldn't fail on test!");
|
||||
assert_eq!(1, range.lower);
|
||||
assert_eq!(5, range.upper);
|
||||
let range = LineRange::from("5:-5").expect("Shouldn't fail on test!");
|
||||
assert_eq!(0, range.lower);
|
||||
assert_eq!(5, range.upper);
|
||||
let range = LineRange::from("5:-100").expect("Shouldn't fail on test!");
|
||||
assert_eq!(0, range.lower);
|
||||
assert_eq!(5, range.upper);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_minus_fail() {
|
||||
let range = LineRange::from("40:-z");
|
||||
assert!(range.is_err());
|
||||
let range = LineRange::from("40:-+10");
|
||||
assert!(range.is_err());
|
||||
let range = LineRange::from("40:-");
|
||||
assert!(range.is_err());
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum RangeCheckResult {
|
||||
// Within one of the given ranges
|
||||
|
@@ -52,7 +52,7 @@ impl OutputType {
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
let pager_opt =
|
||||
pager::get_pager(pager_from_config).chain_err(|| "Could not parse pager command.")?;
|
||||
pager::get_pager(pager_from_config).map_err(|_| "Could not parse pager command.")?;
|
||||
|
||||
let pager = match pager_opt {
|
||||
Some(pager) => pager,
|
||||
@@ -60,7 +60,7 @@ impl OutputType {
|
||||
};
|
||||
|
||||
if pager.kind == PagerKind::Bat {
|
||||
return Err(ErrorKind::InvalidPagerValueBat.into());
|
||||
return Err(Error::InvalidPagerValueBat);
|
||||
}
|
||||
|
||||
let resolved_path = match grep_cli::resolve_binary(&pager.bin) {
|
||||
@@ -142,7 +142,7 @@ impl OutputType {
|
||||
OutputType::Pager(ref mut command) => command
|
||||
.stdin
|
||||
.as_mut()
|
||||
.chain_err(|| "Could not open stdin for pager")?,
|
||||
.ok_or("Could not open stdin for pager")?,
|
||||
OutputType::Stdout(ref mut handle) => handle,
|
||||
})
|
||||
}
|
||||
|
299
src/printer.rs
299
src/printer.rs
@@ -4,6 +4,8 @@ use std::vec::Vec;
|
||||
use ansi_term::Colour::{Fixed, Green, Red, Yellow};
|
||||
use ansi_term::Style;
|
||||
|
||||
use bytesize::ByteSize;
|
||||
|
||||
use console::AnsiCodeIterator;
|
||||
|
||||
use syntect::easy::HighlightLines;
|
||||
@@ -29,7 +31,9 @@ use crate::error::*;
|
||||
use crate::input::OpenedInput;
|
||||
use crate::line_range::RangeCheckResult;
|
||||
use crate::preprocessor::{expand_tabs, replace_nonprintable};
|
||||
use crate::style::StyleComponent;
|
||||
use crate::terminal::{as_terminal_escaped, to_ansi_color};
|
||||
use crate::vscreen::AnsiStyle;
|
||||
use crate::wrapping::WrappingMode;
|
||||
|
||||
pub(crate) trait Printer {
|
||||
@@ -99,17 +103,30 @@ impl<'a> Printer for SimplePrinter<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
struct HighlighterFromSet<'a> {
|
||||
highlighter: HighlightLines<'a>,
|
||||
syntax_set: &'a SyntaxSet,
|
||||
}
|
||||
|
||||
impl<'a> HighlighterFromSet<'a> {
|
||||
fn new(syntax_in_set: SyntaxReferenceInSet<'a>, theme: &'a Theme) -> Self {
|
||||
Self {
|
||||
highlighter: HighlightLines::new(syntax_in_set.syntax, theme),
|
||||
syntax_set: syntax_in_set.syntax_set,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct InteractivePrinter<'a> {
|
||||
colors: Colors,
|
||||
config: &'a Config<'a>,
|
||||
decorations: Vec<Box<dyn Decoration>>,
|
||||
panel_width: usize,
|
||||
ansi_prefix_sgr: String,
|
||||
ansi_style: AnsiStyle,
|
||||
content_type: Option<ContentType>,
|
||||
#[cfg(feature = "git")]
|
||||
pub line_changes: &'a Option<LineChanges>,
|
||||
highlighter: Option<HighlightLines<'a>>,
|
||||
syntax_set: &'a SyntaxSet,
|
||||
highlighter_from_set: Option<HighlighterFromSet<'a>>,
|
||||
background_color_highlight: Option<Color>,
|
||||
}
|
||||
|
||||
@@ -163,29 +180,24 @@ impl<'a> InteractivePrinter<'a> {
|
||||
panel_width = 0;
|
||||
}
|
||||
|
||||
let (highlighter, syntax_set) = if input
|
||||
let highlighter_from_set = if input
|
||||
.reader
|
||||
.content_type
|
||||
.map_or(false, |c| c.is_binary() && !config.show_nonprintable)
|
||||
{
|
||||
(None, assets.get_syntax_set()?)
|
||||
None
|
||||
} else {
|
||||
// Determine the type of syntax for highlighting
|
||||
let syntax_in_set =
|
||||
match assets.get_syntax(config.language, input, &config.syntax_mapping) {
|
||||
Ok(syntax_in_set) => syntax_in_set,
|
||||
Err(Error(ErrorKind::UndetectedSyntax(_), _)) => {
|
||||
let syntax_set = assets.get_syntax_set()?;
|
||||
let syntax = syntax_set.find_syntax_plain_text();
|
||||
SyntaxReferenceInSet { syntax, syntax_set }
|
||||
}
|
||||
Err(Error::UndetectedSyntax(_)) => assets
|
||||
.find_syntax_by_name("Plain Text")?
|
||||
.expect("A plain text syntax is available"),
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
|
||||
(
|
||||
Some(HighlightLines::new(syntax_in_set.syntax, theme)),
|
||||
syntax_in_set.syntax_set,
|
||||
)
|
||||
Some(HighlighterFromSet::new(syntax_in_set, theme))
|
||||
};
|
||||
|
||||
Ok(InteractivePrinter {
|
||||
@@ -194,11 +206,10 @@ impl<'a> InteractivePrinter<'a> {
|
||||
config,
|
||||
decorations,
|
||||
content_type: input.reader.content_type,
|
||||
ansi_prefix_sgr: String::new(),
|
||||
ansi_style: AnsiStyle::new(),
|
||||
#[cfg(feature = "git")]
|
||||
line_changes,
|
||||
highlighter,
|
||||
syntax_set,
|
||||
highlighter_from_set,
|
||||
background_color_highlight,
|
||||
})
|
||||
}
|
||||
@@ -226,29 +237,44 @@ impl<'a> InteractivePrinter<'a> {
|
||||
|
||||
fn create_fake_panel(&self, text: &str) -> String {
|
||||
if self.panel_width == 0 {
|
||||
"".to_string()
|
||||
return "".to_string();
|
||||
}
|
||||
|
||||
let text_truncated: String = text.chars().take(self.panel_width - 1).collect();
|
||||
let text_filled: String = format!(
|
||||
"{}{}",
|
||||
text_truncated,
|
||||
" ".repeat(self.panel_width - 1 - text_truncated.len())
|
||||
);
|
||||
if self.config.style_components.grid() {
|
||||
format!("{} │ ", text_filled)
|
||||
} else {
|
||||
let text_truncated: String = text.chars().take(self.panel_width - 1).collect();
|
||||
let text_filled: String = format!(
|
||||
text_filled
|
||||
}
|
||||
}
|
||||
|
||||
fn print_header_component_indent(&mut self, handle: &mut dyn Write) -> std::io::Result<()> {
|
||||
if self.config.style_components.grid() {
|
||||
write!(
|
||||
handle,
|
||||
"{}{}",
|
||||
text_truncated,
|
||||
" ".repeat(self.panel_width - 1 - text_truncated.len())
|
||||
);
|
||||
if self.config.style_components.grid() {
|
||||
format!("{} │ ", text_filled)
|
||||
} else {
|
||||
text_filled
|
||||
}
|
||||
" ".repeat(self.panel_width),
|
||||
self.colors
|
||||
.grid
|
||||
.paint(if self.panel_width > 0 { "│ " } else { "" }),
|
||||
)
|
||||
} else {
|
||||
write!(handle, "{}", " ".repeat(self.panel_width))
|
||||
}
|
||||
}
|
||||
|
||||
fn preprocess(&self, text: &str, cursor: &mut usize) -> String {
|
||||
if self.config.tab_width > 0 {
|
||||
expand_tabs(text, self.config.tab_width, cursor)
|
||||
} else {
|
||||
*cursor += text.len();
|
||||
text.to_string()
|
||||
return expand_tabs(text, self.config.tab_width, cursor);
|
||||
}
|
||||
|
||||
*cursor += text.len();
|
||||
text.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,25 +305,6 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if self.config.style_components.grid() {
|
||||
self.print_horizontal_line(handle, '┬')?;
|
||||
|
||||
write!(
|
||||
handle,
|
||||
"{}{}",
|
||||
" ".repeat(self.panel_width),
|
||||
self.colors
|
||||
.grid
|
||||
.paint(if self.panel_width > 0 { "│ " } else { "" }),
|
||||
)?;
|
||||
} else {
|
||||
// Only pad space between files, if we haven't already drawn a horizontal rule
|
||||
if add_header_padding && !self.config.style_components.rule() {
|
||||
writeln!(handle)?;
|
||||
}
|
||||
write!(handle, "{}", " ".repeat(self.panel_width))?;
|
||||
}
|
||||
|
||||
let mode = match self.content_type {
|
||||
Some(ContentType::BINARY) => " <BINARY>",
|
||||
Some(ContentType::UTF_16LE) => " <UTF-16LE>",
|
||||
@@ -307,17 +314,60 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
};
|
||||
|
||||
let description = &input.description;
|
||||
let metadata = &input.metadata;
|
||||
|
||||
writeln!(
|
||||
handle,
|
||||
"{}{}{}",
|
||||
description
|
||||
.kind()
|
||||
.map(|kind| format!("{}: ", kind))
|
||||
.unwrap_or_else(|| "".into()),
|
||||
self.colors.filename.paint(description.title()),
|
||||
mode
|
||||
)?;
|
||||
// We use this iterator to have a deterministic order for
|
||||
// header components. HashSet has arbitrary order, but Vec is ordered.
|
||||
let header_components: Vec<StyleComponent> = [
|
||||
(
|
||||
StyleComponent::HeaderFilename,
|
||||
self.config.style_components.header_filename(),
|
||||
),
|
||||
(
|
||||
StyleComponent::HeaderFilesize,
|
||||
self.config.style_components.header_filesize(),
|
||||
),
|
||||
]
|
||||
.iter()
|
||||
.filter(|(_, is_enabled)| *is_enabled)
|
||||
.map(|(component, _)| *component)
|
||||
.collect();
|
||||
|
||||
// Print the cornering grid before the first header component
|
||||
if self.config.style_components.grid() {
|
||||
self.print_horizontal_line(handle, '┬')?;
|
||||
} else {
|
||||
// Only pad space between files, if we haven't already drawn a horizontal rule
|
||||
if add_header_padding && !self.config.style_components.rule() {
|
||||
writeln!(handle)?;
|
||||
}
|
||||
}
|
||||
|
||||
header_components.iter().try_for_each(|component| {
|
||||
self.print_header_component_indent(handle)?;
|
||||
|
||||
match component {
|
||||
StyleComponent::HeaderFilename => writeln!(
|
||||
handle,
|
||||
"{}{}{}",
|
||||
description
|
||||
.kind()
|
||||
.map(|kind| format!("{}: ", kind))
|
||||
.unwrap_or_else(|| "".into()),
|
||||
self.colors.header_value.paint(description.title()),
|
||||
mode
|
||||
),
|
||||
|
||||
StyleComponent::HeaderFilesize => {
|
||||
let bsize = metadata
|
||||
.size
|
||||
.map(|s| format!("{}", ByteSize(s)))
|
||||
.unwrap_or_else(|| "-".into());
|
||||
writeln!(handle, "Size: {}", self.colors.header_value.paint(bsize))
|
||||
}
|
||||
_ => Ok(()),
|
||||
}
|
||||
})?;
|
||||
|
||||
if self.config.style_components.grid() {
|
||||
if self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable {
|
||||
@@ -389,13 +439,15 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
};
|
||||
|
||||
let regions = {
|
||||
let highlighter = match self.highlighter {
|
||||
Some(ref mut highlighter) => highlighter,
|
||||
let highlighter_from_set = match self.highlighter_from_set {
|
||||
Some(ref mut highlighter_from_set) => highlighter_from_set,
|
||||
_ => {
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
highlighter.highlight(line.as_ref(), self.syntax_set)
|
||||
highlighter_from_set
|
||||
.highlighter
|
||||
.highlight(&line, highlighter_from_set.syntax_set)
|
||||
};
|
||||
|
||||
if out_of_range {
|
||||
@@ -420,8 +472,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
let decorations = self
|
||||
.decorations
|
||||
.iter()
|
||||
.map(|d| d.generate(line_number, false, self))
|
||||
.collect::<Vec<_>>();
|
||||
.map(|d| d.generate(line_number, false, self));
|
||||
|
||||
for deco in decorations {
|
||||
write!(handle, "{} ", deco.text)?;
|
||||
@@ -435,36 +486,52 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
let colored_output = self.config.colored_output;
|
||||
let italics = self.config.use_italic_text;
|
||||
|
||||
for &(style, region) in regions.iter() {
|
||||
let text = &*self.preprocess(region, &mut cursor_total);
|
||||
let text_trimmed = text.trim_end_matches(|c| c == '\r' || c == '\n');
|
||||
write!(
|
||||
handle,
|
||||
"{}",
|
||||
as_terminal_escaped(
|
||||
style,
|
||||
text_trimmed,
|
||||
true_color,
|
||||
colored_output,
|
||||
italics,
|
||||
background_color
|
||||
)
|
||||
)?;
|
||||
for &(style, region) in ®ions {
|
||||
let ansi_iterator = AnsiCodeIterator::new(region);
|
||||
for chunk in ansi_iterator {
|
||||
match chunk {
|
||||
// ANSI escape passthrough.
|
||||
(ansi, true) => {
|
||||
self.ansi_style.update(ansi);
|
||||
write!(handle, "{}", ansi)?;
|
||||
}
|
||||
|
||||
if text.len() != text_trimmed.len() {
|
||||
if let Some(background_color) = background_color {
|
||||
let ansi_style = Style {
|
||||
background: to_ansi_color(background_color, true_color),
|
||||
..Default::default()
|
||||
};
|
||||
let width = if cursor_total <= cursor_max {
|
||||
cursor_max - cursor_total + 1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
write!(handle, "{}", ansi_style.paint(" ".repeat(width)))?;
|
||||
// Regular text.
|
||||
(text, false) => {
|
||||
let text = &*self.preprocess(text, &mut cursor_total);
|
||||
let text_trimmed = text.trim_end_matches(|c| c == '\r' || c == '\n');
|
||||
|
||||
write!(
|
||||
handle,
|
||||
"{}",
|
||||
as_terminal_escaped(
|
||||
style,
|
||||
&format!("{}{}", self.ansi_style, text_trimmed),
|
||||
true_color,
|
||||
colored_output,
|
||||
italics,
|
||||
background_color
|
||||
)
|
||||
)?;
|
||||
|
||||
if text.len() != text_trimmed.len() {
|
||||
if let Some(background_color) = background_color {
|
||||
let ansi_style = Style {
|
||||
background: to_ansi_color(background_color, true_color),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let width = if cursor_total <= cursor_max {
|
||||
cursor_max - cursor_total + 1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
write!(handle, "{}", ansi_style.paint(" ".repeat(width)))?;
|
||||
}
|
||||
write!(handle, "{}", &text[text_trimmed.len()..])?;
|
||||
}
|
||||
}
|
||||
}
|
||||
write!(handle, "{}", &text[text_trimmed.len()..])?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,33 +539,14 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
writeln!(handle)?;
|
||||
}
|
||||
} else {
|
||||
for &(style, region) in regions.iter() {
|
||||
for &(style, region) in ®ions {
|
||||
let ansi_iterator = AnsiCodeIterator::new(region);
|
||||
let mut ansi_prefix: String = String::new();
|
||||
for chunk in ansi_iterator {
|
||||
match chunk {
|
||||
// ANSI escape passthrough.
|
||||
(text, true) => {
|
||||
let is_ansi_csi = text.starts_with("\x1B[");
|
||||
|
||||
if is_ansi_csi && text.ends_with('m') {
|
||||
// It's an ANSI SGR sequence.
|
||||
// We should be mostly safe to just append these together.
|
||||
ansi_prefix.push_str(text);
|
||||
if text == "\x1B[0m" {
|
||||
self.ansi_prefix_sgr = "\x1B[0m".to_owned();
|
||||
} else {
|
||||
self.ansi_prefix_sgr.push_str(text);
|
||||
}
|
||||
} else if is_ansi_csi {
|
||||
// It's a regular CSI sequence.
|
||||
// We should be mostly safe to just append these together.
|
||||
ansi_prefix.push_str(text);
|
||||
} else {
|
||||
// It's probably a VT100 code.
|
||||
// Passing it through is the safest bet.
|
||||
write!(handle, "{}", text)?;
|
||||
}
|
||||
(ansi, true) => {
|
||||
self.ansi_style.update(ansi);
|
||||
write!(handle, "{}", ansi)?;
|
||||
}
|
||||
|
||||
// Regular text.
|
||||
@@ -548,10 +596,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
"{}\n{}",
|
||||
as_terminal_escaped(
|
||||
style,
|
||||
&*format!(
|
||||
"{}{}{}",
|
||||
self.ansi_prefix_sgr, ansi_prefix, line_buf
|
||||
),
|
||||
&*format!("{}{}", self.ansi_style, line_buf),
|
||||
self.config.true_color,
|
||||
self.config.colored_output,
|
||||
self.config.use_italic_text,
|
||||
@@ -577,19 +622,13 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
"{}",
|
||||
as_terminal_escaped(
|
||||
style,
|
||||
&*format!(
|
||||
"{}{}{}",
|
||||
self.ansi_prefix_sgr, ansi_prefix, line_buf
|
||||
),
|
||||
&*format!("{}{}", self.ansi_style, line_buf),
|
||||
self.config.true_color,
|
||||
self.config.colored_output,
|
||||
self.config.use_italic_text,
|
||||
background_color
|
||||
)
|
||||
)?;
|
||||
|
||||
// Clear the ANSI prefix buffer.
|
||||
ansi_prefix.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -620,7 +659,7 @@ const DEFAULT_GUTTER_COLOR: u8 = 238;
|
||||
pub struct Colors {
|
||||
pub grid: Style,
|
||||
pub rule: Style,
|
||||
pub filename: Style,
|
||||
pub header_value: Style,
|
||||
pub git_added: Style,
|
||||
pub git_removed: Style,
|
||||
pub git_modified: Style,
|
||||
@@ -649,7 +688,7 @@ impl Colors {
|
||||
Colors {
|
||||
grid: gutter_style,
|
||||
rule: gutter_style,
|
||||
filename: Style::new().bold(),
|
||||
header_value: Style::new().bold(),
|
||||
git_added: Green.normal(),
|
||||
git_removed: Red.normal(),
|
||||
git_modified: Yellow.normal(),
|
||||
|
22
src/style.rs
22
src/style.rs
@@ -3,6 +3,7 @@ use std::str::FromStr;
|
||||
|
||||
use crate::error::*;
|
||||
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
|
||||
pub enum StyleComponent {
|
||||
Auto,
|
||||
@@ -11,6 +12,8 @@ pub enum StyleComponent {
|
||||
Grid,
|
||||
Rule,
|
||||
Header,
|
||||
HeaderFilename,
|
||||
HeaderFilesize,
|
||||
LineNumbers,
|
||||
Snip,
|
||||
Full,
|
||||
@@ -31,14 +34,17 @@ impl StyleComponent {
|
||||
StyleComponent::Changes => &[StyleComponent::Changes],
|
||||
StyleComponent::Grid => &[StyleComponent::Grid],
|
||||
StyleComponent::Rule => &[StyleComponent::Rule],
|
||||
StyleComponent::Header => &[StyleComponent::Header],
|
||||
StyleComponent::Header => &[StyleComponent::HeaderFilename],
|
||||
StyleComponent::HeaderFilename => &[StyleComponent::HeaderFilename],
|
||||
StyleComponent::HeaderFilesize => &[StyleComponent::HeaderFilesize],
|
||||
StyleComponent::LineNumbers => &[StyleComponent::LineNumbers],
|
||||
StyleComponent::Snip => &[StyleComponent::Snip],
|
||||
StyleComponent::Full => &[
|
||||
#[cfg(feature = "git")]
|
||||
StyleComponent::Changes,
|
||||
StyleComponent::Grid,
|
||||
StyleComponent::Header,
|
||||
StyleComponent::HeaderFilename,
|
||||
StyleComponent::HeaderFilesize,
|
||||
StyleComponent::LineNumbers,
|
||||
StyleComponent::Snip,
|
||||
],
|
||||
@@ -58,6 +64,8 @@ impl FromStr for StyleComponent {
|
||||
"grid" => Ok(StyleComponent::Grid),
|
||||
"rule" => Ok(StyleComponent::Rule),
|
||||
"header" => Ok(StyleComponent::Header),
|
||||
"header-filename" => Ok(StyleComponent::HeaderFilename),
|
||||
"header-filesize" => Ok(StyleComponent::HeaderFilesize),
|
||||
"numbers" => Ok(StyleComponent::LineNumbers),
|
||||
"snip" => Ok(StyleComponent::Snip),
|
||||
"full" => Ok(StyleComponent::Full),
|
||||
@@ -89,7 +97,15 @@ impl StyleComponents {
|
||||
}
|
||||
|
||||
pub fn header(&self) -> bool {
|
||||
self.0.contains(&StyleComponent::Header)
|
||||
self.header_filename() || self.header_filesize()
|
||||
}
|
||||
|
||||
pub fn header_filename(&self) -> bool {
|
||||
self.0.contains(&StyleComponent::HeaderFilename)
|
||||
}
|
||||
|
||||
pub fn header_filesize(&self) -> bool {
|
||||
self.0.contains(&StyleComponent::HeaderFilesize)
|
||||
}
|
||||
|
||||
pub fn numbers(&self) -> bool {
|
||||
|
@@ -1,184 +0,0 @@
|
||||
use std::collections::HashMap;
|
||||
use syntect::parsing::syntax_definition::{
|
||||
ContextReference, MatchOperation, MatchPattern, Pattern, SyntaxDefinition,
|
||||
};
|
||||
use syntect::parsing::{Scope, SyntaxSet, SyntaxSetBuilder};
|
||||
|
||||
type SyntaxName = String;
|
||||
|
||||
/// Used to look up what dependencies a given [SyntaxDefinition] has
|
||||
type SyntaxToDependencies = HashMap<SyntaxName, Vec<Dependency>>;
|
||||
|
||||
/// Used to look up which [SyntaxDefinition] corresponds to a given [Dependency]
|
||||
type DependencyToSyntax<'a> = HashMap<Dependency, &'a SyntaxDefinition>;
|
||||
|
||||
/// Represents a dependency on an external `.sublime-syntax` file.
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Hash)]
|
||||
enum Dependency {
|
||||
/// By name. Example YAML: `include: C.sublime-syntax`
|
||||
ByName(String),
|
||||
|
||||
/// By scope. Example YAML: `embed: scope:source.c`
|
||||
ByScope(Scope),
|
||||
}
|
||||
|
||||
/// Generates independent [SyntaxSet]s after analyzing dependencies between syntaxes
|
||||
/// in a [SyntaxSetBuilder], and then prints the reults.
|
||||
pub(crate) fn print_syntax_dependencies(syntax_set_builder: &SyntaxSetBuilder) {
|
||||
println!("Constructing independent SyntaxSets...");
|
||||
let independent_syntax_sets = build_independent_syntax_sets(syntax_set_builder);
|
||||
|
||||
println!("Independent SyntaxSets:");
|
||||
for syntax_set in independent_syntax_sets {
|
||||
let names = syntax_set
|
||||
.syntaxes()
|
||||
.iter()
|
||||
.map(|syntax| &syntax.name)
|
||||
.collect::<Vec<_>>();
|
||||
println!("{:?}", names);
|
||||
}
|
||||
}
|
||||
|
||||
/// Analyzes dependencies between syntaxes in a [SyntaxSetBuilder].
|
||||
/// From that, it builds independent [SyntaxSet]s.
|
||||
fn build_independent_syntax_sets(
|
||||
syntax_set_builder: &'_ SyntaxSetBuilder,
|
||||
) -> impl Iterator<Item = SyntaxSet> + '_ {
|
||||
let syntaxes = syntax_set_builder.syntaxes();
|
||||
|
||||
// Build the data structures we need for dependency resolution
|
||||
let (syntax_to_dependencies, dependency_to_syntax) = generate_maps(syntaxes);
|
||||
|
||||
// Create one independent SyntaxSet from each (non-hidden) SyntaxDefinition
|
||||
syntaxes.iter().filter_map(move |syntax| {
|
||||
if syntax.hidden {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut builder = SyntaxSetDependencyBuilder::new();
|
||||
builder.add_with_dependencies(syntax, &syntax_to_dependencies, &dependency_to_syntax);
|
||||
Some(builder.build())
|
||||
})
|
||||
}
|
||||
|
||||
/// In order to analyze dependencies, we need two key pieces of data.
|
||||
/// First, when we have a [Dependency], we need to know what [SyntaxDefinition] that
|
||||
/// corresponds to. Second, when we have a [SyntaxDefinition], we need to know
|
||||
/// what dependencies it has. This functions generates that data for each syntax.
|
||||
fn generate_maps(syntaxes: &[SyntaxDefinition]) -> (SyntaxToDependencies, DependencyToSyntax) {
|
||||
let mut syntax_to_dependencies = HashMap::new();
|
||||
let mut dependency_to_syntax = HashMap::new();
|
||||
|
||||
for syntax in syntaxes {
|
||||
syntax_to_dependencies.insert(syntax.name.clone(), dependencies_for_syntax(syntax));
|
||||
|
||||
dependency_to_syntax.insert(Dependency::ByName(syntax.name.clone()), syntax);
|
||||
dependency_to_syntax.insert(Dependency::ByScope(syntax.scope), syntax);
|
||||
}
|
||||
|
||||
(syntax_to_dependencies, dependency_to_syntax)
|
||||
}
|
||||
|
||||
/// Gets what external dependencies a given [SyntaxDefinition] has.
|
||||
/// An external dependency is another `.sublime-syntax` file.
|
||||
/// It does that by looking for variants of the following YAML patterns:
|
||||
/// - `include: C.sublime-syntax`
|
||||
/// - `embed: scope:source.c`
|
||||
fn dependencies_for_syntax(syntax: &SyntaxDefinition) -> Vec<Dependency> {
|
||||
let mut dependencies: Vec<Dependency> = syntax
|
||||
.contexts
|
||||
.values()
|
||||
.flat_map(|context| &context.patterns)
|
||||
.flat_map(dependencies_from_pattern)
|
||||
.collect();
|
||||
|
||||
// No need to track a dependency more than once
|
||||
dependencies.dedup();
|
||||
|
||||
dependencies
|
||||
}
|
||||
|
||||
fn dependencies_from_pattern(pattern: &Pattern) -> Vec<Dependency> {
|
||||
match *pattern {
|
||||
Pattern::Match(MatchPattern {
|
||||
operation: MatchOperation::Push(ref context_references),
|
||||
..
|
||||
}) => context_references
|
||||
.iter()
|
||||
.map(dependency_from_context_reference)
|
||||
.collect(),
|
||||
Pattern::Include(ref context_reference) => {
|
||||
vec![dependency_from_context_reference(context_reference)]
|
||||
}
|
||||
_ => vec![],
|
||||
}
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn dependency_from_context_reference(context_reference: &ContextReference) -> Option<Dependency> {
|
||||
match &context_reference {
|
||||
ContextReference::File { ref name, .. } => Some(Dependency::ByName(name.clone())),
|
||||
ContextReference::ByScope { ref scope, .. } => Some(Dependency::ByScope(*scope)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper to construct a [SyntaxSetBuilder] that contains only [SyntaxDefinition]s
|
||||
/// that have dependencies among them.
|
||||
struct SyntaxSetDependencyBuilder {
|
||||
syntax_set_builder: SyntaxSetBuilder,
|
||||
}
|
||||
|
||||
impl SyntaxSetDependencyBuilder {
|
||||
fn new() -> Self {
|
||||
SyntaxSetDependencyBuilder {
|
||||
syntax_set_builder: SyntaxSetBuilder::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Add a [SyntaxDefinition] to the underlying [SyntaxSetBuilder].
|
||||
/// Also resolve any dependencies it has and add those [SyntaxDefinition]s too.
|
||||
/// This is a recursive process.
|
||||
fn add_with_dependencies(
|
||||
&mut self,
|
||||
syntax: &SyntaxDefinition,
|
||||
syntax_to_dependencies: &SyntaxToDependencies,
|
||||
dependency_to_syntax: &DependencyToSyntax,
|
||||
) {
|
||||
let name = &syntax.name;
|
||||
if self.is_syntax_already_added(name) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.syntax_set_builder.add(syntax.clone());
|
||||
|
||||
let dependencies = syntax_to_dependencies.get(name);
|
||||
if dependencies.is_none() {
|
||||
eprintln!("ERROR: Unknown dependencies for {}", name);
|
||||
return;
|
||||
}
|
||||
|
||||
for dependency in dependencies.unwrap() {
|
||||
if let Some(syntax_definition_dependency) = dependency_to_syntax.get(dependency) {
|
||||
self.add_with_dependencies(
|
||||
syntax_definition_dependency,
|
||||
syntax_to_dependencies,
|
||||
dependency_to_syntax,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_syntax_already_added(&self, name: &str) -> bool {
|
||||
self.syntax_set_builder
|
||||
.syntaxes()
|
||||
.iter()
|
||||
.any(|syntax| syntax.name == name)
|
||||
}
|
||||
|
||||
fn build(self) -> SyntaxSet {
|
||||
self.syntax_set_builder.build()
|
||||
}
|
||||
}
|
@@ -1,18 +1,36 @@
|
||||
use std::path::Path;
|
||||
|
||||
use crate::error::Result;
|
||||
use ignored_suffixes::IgnoredSuffixes;
|
||||
|
||||
use globset::{Candidate, GlobBuilder, GlobMatcher};
|
||||
|
||||
pub mod ignored_suffixes;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum MappingTarget<'a> {
|
||||
/// For mapping a path to a specific syntax.
|
||||
MapTo(&'a str),
|
||||
|
||||
/// For mapping a path (typically an extension-less file name) to an unknown
|
||||
/// syntax. This typically means later using the contents of the first line
|
||||
/// of the file to determine what syntax to use.
|
||||
MapToUnknown,
|
||||
|
||||
/// For mapping a file extension (e.g. `*.conf`) to an unknown syntax. This
|
||||
/// typically means later using the contents of the first line of the file
|
||||
/// to determine what syntax to use. However, if a syntax handles a file
|
||||
/// name that happens to have the given file extension (e.g. `resolv.conf`),
|
||||
/// then that association will have higher precedence, and the mapping will
|
||||
/// be ignored.
|
||||
MapExtensionToUnknown,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct SyntaxMapping<'a> {
|
||||
mappings: Vec<(GlobMatcher, MappingTarget<'a>)>,
|
||||
pub(crate) ignored_suffixes: IgnoredSuffixes<'a>,
|
||||
}
|
||||
|
||||
impl<'a> SyntaxMapping<'a> {
|
||||
@@ -54,12 +72,7 @@ impl<'a> SyntaxMapping<'a> {
|
||||
// Nginx and Apache syntax files both want to style all ".conf" files
|
||||
// see #1131 and #1137
|
||||
mapping
|
||||
.insert("*.conf", MappingTarget::MapToUnknown)
|
||||
.unwrap();
|
||||
|
||||
// Re-insert a mapping for resolv.conf, see #1510
|
||||
mapping
|
||||
.insert("resolv.conf", MappingTarget::MapTo("resolv"))
|
||||
.insert("*.conf", MappingTarget::MapExtensionToUnknown)
|
||||
.unwrap();
|
||||
|
||||
for glob in &[
|
||||
@@ -81,7 +94,7 @@ impl<'a> SyntaxMapping<'a> {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
for glob in [
|
||||
for glob in &[
|
||||
"**/systemd/**/*.conf",
|
||||
"**/systemd/**/*.example",
|
||||
"*.automount",
|
||||
@@ -100,9 +113,7 @@ impl<'a> SyntaxMapping<'a> {
|
||||
"*.swap",
|
||||
"*.target",
|
||||
"*.timer",
|
||||
]
|
||||
.iter()
|
||||
{
|
||||
] {
|
||||
mapping.insert(glob, MappingTarget::MapTo("INI")).unwrap();
|
||||
}
|
||||
|
||||
@@ -153,7 +164,7 @@ impl<'a> SyntaxMapping<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn get_syntax_for(&self, path: impl AsRef<Path>) -> Option<MappingTarget<'a>> {
|
||||
let candidate = Candidate::new(path.as_ref());
|
||||
let candidate = Candidate::new(&path);
|
||||
let candidate_filename = path.as_ref().file_name().map(Candidate::new);
|
||||
for (ref glob, ref syntax) in self.mappings.iter().rev() {
|
||||
if glob.is_match_candidate(&candidate)
|
||||
@@ -166,6 +177,10 @@ impl<'a> SyntaxMapping<'a> {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn insert_ignored_suffix(&mut self, suffix: &'a str) {
|
||||
self.ignored_suffixes.add_suffix(suffix);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
107
src/syntax_mapping/ignored_suffixes.rs
Normal file
107
src/syntax_mapping/ignored_suffixes.rs
Normal file
@@ -0,0 +1,107 @@
|
||||
use std::ffi::OsStr;
|
||||
use std::fmt::Debug;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::error::*;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct IgnoredSuffixes<'a> {
|
||||
values: Vec<&'a str>,
|
||||
}
|
||||
|
||||
impl Default for IgnoredSuffixes<'_> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
values: vec![
|
||||
// Editor etc backups
|
||||
"~",
|
||||
".bak",
|
||||
".old",
|
||||
".orig",
|
||||
// Debian and derivatives apt/dpkg/ucf backups
|
||||
".dpkg-dist",
|
||||
".dpkg-old",
|
||||
".ucf-dist",
|
||||
".ucf-new",
|
||||
".ucf-old",
|
||||
// Red Hat and derivatives rpm backups
|
||||
".rpmnew",
|
||||
".rpmorig",
|
||||
".rpmsave",
|
||||
// Build system input/template files
|
||||
".in",
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IgnoredSuffixes<'a> {
|
||||
pub fn add_suffix(&mut self, suffix: &'a str) {
|
||||
self.values.push(suffix)
|
||||
}
|
||||
|
||||
pub fn strip_suffix(&self, file_name: &'a str) -> Option<&'a str> {
|
||||
for suffix in self.values.iter() {
|
||||
if let Some(stripped_file_name) = file_name.strip_suffix(suffix) {
|
||||
return Some(stripped_file_name);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// If we find an ignored suffix on the file name, e.g. '~', we strip it and
|
||||
/// then try again without it.
|
||||
pub fn try_with_stripped_suffix<T, F>(&self, file_name: &'a OsStr, func: F) -> Result<Option<T>>
|
||||
where
|
||||
F: Fn(&'a OsStr) -> Result<Option<T>>,
|
||||
{
|
||||
if let Some(file_str) = Path::new(file_name).to_str() {
|
||||
if let Some(stripped_file_name) = self.strip_suffix(file_str) {
|
||||
return func(OsStr::new(stripped_file_name));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn internal_suffixes() {
|
||||
let ignored_suffixes = IgnoredSuffixes::default();
|
||||
|
||||
let file_names = ignored_suffixes
|
||||
.values
|
||||
.iter()
|
||||
.map(|suffix| format!("test.json{}", suffix));
|
||||
for file_name_str in file_names {
|
||||
let file_name = OsStr::new(&file_name_str);
|
||||
let expected_stripped_file_name = OsStr::new("test.json");
|
||||
let stripped_file_name = ignored_suffixes
|
||||
.try_with_stripped_suffix(file_name, |stripped_file_name| Ok(Some(stripped_file_name)));
|
||||
assert_eq!(
|
||||
expected_stripped_file_name,
|
||||
stripped_file_name.unwrap().unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn external_suffixes() {
|
||||
let mut ignored_suffixes = IgnoredSuffixes::default();
|
||||
ignored_suffixes.add_suffix(".development");
|
||||
ignored_suffixes.add_suffix(".production");
|
||||
|
||||
let file_names = ignored_suffixes
|
||||
.values
|
||||
.iter()
|
||||
.map(|suffix| format!("test.json{}", suffix));
|
||||
for file_name_str in file_names {
|
||||
let file_name = OsStr::new(&file_name_str);
|
||||
let expected_stripped_file_name = OsStr::new("test.json");
|
||||
let stripped_file_name = ignored_suffixes
|
||||
.try_with_stripped_suffix(file_name, |stripped_file_name| Ok(Some(stripped_file_name)));
|
||||
assert_eq!(
|
||||
expected_stripped_file_name,
|
||||
stripped_file_name.unwrap().unwrap()
|
||||
);
|
||||
}
|
||||
}
|
212
src/vscreen.rs
Normal file
212
src/vscreen.rs
Normal file
@@ -0,0 +1,212 @@
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
// Wrapper to avoid unnecessary branching when input doesn't have ANSI escape sequences.
|
||||
pub struct AnsiStyle {
|
||||
attributes: Option<Attributes>,
|
||||
}
|
||||
|
||||
impl AnsiStyle {
|
||||
pub fn new() -> Self {
|
||||
AnsiStyle { attributes: None }
|
||||
}
|
||||
|
||||
pub fn update(&mut self, sequence: &str) -> bool {
|
||||
match &mut self.attributes {
|
||||
Some(a) => a.update(sequence),
|
||||
None => {
|
||||
self.attributes = Some(Attributes::new());
|
||||
self.attributes.as_mut().unwrap().update(sequence)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for AnsiStyle {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self.attributes {
|
||||
Some(ref a) => a.fmt(f),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Attributes {
|
||||
foreground: String,
|
||||
background: String,
|
||||
underlined: String,
|
||||
|
||||
/// The character set to use.
|
||||
/// REGEX: `\^[()][AB0-3]`
|
||||
charset: String,
|
||||
|
||||
/// A buffer for unknown sequences.
|
||||
unknown_buffer: String,
|
||||
|
||||
/// ON: ^[1m
|
||||
/// OFF: ^[22m
|
||||
bold: String,
|
||||
|
||||
/// ON: ^[2m
|
||||
/// OFF: ^[22m
|
||||
dim: String,
|
||||
|
||||
/// ON: ^[4m
|
||||
/// OFF: ^[24m
|
||||
underline: String,
|
||||
|
||||
/// ON: ^[3m
|
||||
/// OFF: ^[23m
|
||||
italic: String,
|
||||
|
||||
/// ON: ^[9m
|
||||
/// OFF: ^[29m
|
||||
strike: String,
|
||||
}
|
||||
|
||||
impl Attributes {
|
||||
pub fn new() -> Self {
|
||||
Attributes {
|
||||
foreground: "".to_owned(),
|
||||
background: "".to_owned(),
|
||||
underlined: "".to_owned(),
|
||||
charset: "".to_owned(),
|
||||
unknown_buffer: "".to_owned(),
|
||||
bold: "".to_owned(),
|
||||
dim: "".to_owned(),
|
||||
underline: "".to_owned(),
|
||||
italic: "".to_owned(),
|
||||
strike: "".to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the attributes with an escape sequence.
|
||||
/// Returns `false` if the sequence is unsupported.
|
||||
pub fn update(&mut self, sequence: &str) -> bool {
|
||||
let mut chars = sequence.char_indices().skip(1);
|
||||
|
||||
if let Some((_, t)) = chars.next() {
|
||||
match t {
|
||||
'(' => self.update_with_charset('(', chars.map(|(_, c)| c)),
|
||||
')' => self.update_with_charset(')', chars.map(|(_, c)| c)),
|
||||
'[' => {
|
||||
if let Some((i, last)) = chars.last() {
|
||||
// SAFETY: Always starts with ^[ and ends with m.
|
||||
self.update_with_csi(last, &sequence[2..i])
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
_ => self.update_with_unsupported(sequence),
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn sgr_reset(&mut self) {
|
||||
self.foreground.clear();
|
||||
self.background.clear();
|
||||
self.underlined.clear();
|
||||
self.bold.clear();
|
||||
self.dim.clear();
|
||||
self.underline.clear();
|
||||
self.italic.clear();
|
||||
self.strike.clear();
|
||||
}
|
||||
|
||||
fn update_with_sgr(&mut self, parameters: &str) -> bool {
|
||||
let mut iter = parameters
|
||||
.split(';')
|
||||
.map(|p| if p.is_empty() { "0" } else { p })
|
||||
.map(|p| p.parse::<u16>())
|
||||
.map(|p| p.unwrap_or(0)); // Treat errors as 0.
|
||||
|
||||
while let Some(p) = iter.next() {
|
||||
match p {
|
||||
0 => self.sgr_reset(),
|
||||
1 => self.bold = format!("\x1B[{}m", parameters),
|
||||
2 => self.dim = format!("\x1B[{}m", parameters),
|
||||
3 => self.italic = format!("\x1B[{}m", parameters),
|
||||
4 => self.underline = format!("\x1B[{}m", parameters),
|
||||
23 => self.italic.clear(),
|
||||
24 => self.underline.clear(),
|
||||
22 => {
|
||||
self.bold.clear();
|
||||
self.dim.clear();
|
||||
}
|
||||
30..=39 => self.foreground = Self::parse_color(p, &mut iter),
|
||||
40..=49 => self.background = Self::parse_color(p, &mut iter),
|
||||
58..=59 => self.underlined = Self::parse_color(p, &mut iter),
|
||||
90..=97 => self.foreground = Self::parse_color(p, &mut iter),
|
||||
100..=107 => self.foreground = Self::parse_color(p, &mut iter),
|
||||
_ => {
|
||||
// Unsupported SGR sequence.
|
||||
// Be compatible and pretend one just wasn't was provided.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
fn update_with_csi(&mut self, finalizer: char, sequence: &str) -> bool {
|
||||
if finalizer == 'm' {
|
||||
self.update_with_sgr(sequence)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn update_with_unsupported(&mut self, sequence: &str) -> bool {
|
||||
self.unknown_buffer.push_str(sequence);
|
||||
false
|
||||
}
|
||||
|
||||
fn update_with_charset(&mut self, kind: char, set: impl Iterator<Item = char>) -> bool {
|
||||
self.charset = format!("\x1B{}{}", kind, set.take(1).collect::<String>());
|
||||
true
|
||||
}
|
||||
|
||||
fn parse_color(color: u16, parameters: &mut dyn Iterator<Item = u16>) -> String {
|
||||
match color % 10 {
|
||||
8 => match parameters.next() {
|
||||
Some(5) /* 256-color */ => format!("\x1B[{};5;{}m", color, join(";", 1, parameters)),
|
||||
Some(2) /* 24-bit color */ => format!("\x1B[{};2;{}m", color, join(";", 3, parameters)),
|
||||
Some(c) => format!("\x1B[{};{}m", color, c),
|
||||
_ => "".to_owned(),
|
||||
},
|
||||
9 => "".to_owned(),
|
||||
_ => format!("\x1B[{}m", color),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Attributes {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}{}{}{}{}{}{}{}{}",
|
||||
self.foreground,
|
||||
self.background,
|
||||
self.underlined,
|
||||
self.charset,
|
||||
self.bold,
|
||||
self.dim,
|
||||
self.underline,
|
||||
self.italic,
|
||||
self.strike,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn join(
|
||||
delimiter: &str,
|
||||
limit: usize,
|
||||
iterator: &mut dyn Iterator<Item = impl ToString>,
|
||||
) -> String {
|
||||
iterator
|
||||
.take(limit)
|
||||
.map(|i| i.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(delimiter)
|
||||
}
|
1
tests/benchmarks/.gitignore
vendored
Normal file
1
tests/benchmarks/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/benchmark-results
|
33
tests/benchmarks/comparison.sh
vendored
33
tests/benchmarks/comparison.sh
vendored
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
|
||||
|
||||
if ! command -v hyperfine > /dev/null 2>&1; then
|
||||
echo "'hyperfine' does not seem to be installed."
|
||||
echo "You can get it here: https://github.com/sharkdp/hyperfine"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SRC="test-src/jquery-3.3.1.js"
|
||||
|
||||
|
||||
cmd_bat="bat --style=full --color=always --paging=never '$SRC'"
|
||||
cmd_bat_simple="bat --plain --wrap=never --tabs=0 --color=always --paging=never '$SRC'"
|
||||
cmd_pygmentize="pygmentize -g '$SRC'"
|
||||
cmd_highlight="highlight -O truecolor '$SRC'"
|
||||
cmd_ccat="ccat --color=always '$SRC'"
|
||||
cmd_source_highlight="source-highlight --failsafe --infer-lang -f esc -i '$SRC'"
|
||||
cmd_hicat="hicat '$SRC'"
|
||||
cmd_coderay="coderay '$SRC'"
|
||||
cmd_rouge="rougify '$SRC'"
|
||||
|
||||
hyperfine --warmup 3 \
|
||||
"$cmd_bat" \
|
||||
"$cmd_bat_simple" \
|
||||
"$cmd_pygmentize" \
|
||||
"$cmd_highlight" \
|
||||
"$cmd_ccat" \
|
||||
"$cmd_source_highlight" \
|
||||
"$cmd_hicat" \
|
||||
"$cmd_coderay" \
|
||||
"$cmd_rouge" \
|
2272
tests/benchmarks/highlighting-speed-src/grep-output-ansi-sequences.txt
vendored
Normal file
2272
tests/benchmarks/highlighting-speed-src/grep-output-ansi-sequences.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
8471
tests/benchmarks/highlighting-speed-src/numpy_test_multiarray.py
vendored
Normal file
8471
tests/benchmarks/highlighting-speed-src/numpy_test_multiarray.py
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/benchmarks/many-small-files/small-file-0.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-0.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 0
|
1
tests/benchmarks/many-small-files/small-file-1.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-1.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 1
|
1
tests/benchmarks/many-small-files/small-file-10.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-10.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 10
|
1
tests/benchmarks/many-small-files/small-file-100.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-100.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 100
|
1
tests/benchmarks/many-small-files/small-file-11.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-11.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 11
|
1
tests/benchmarks/many-small-files/small-file-12.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-12.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 12
|
1
tests/benchmarks/many-small-files/small-file-13.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-13.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 13
|
1
tests/benchmarks/many-small-files/small-file-14.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-14.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 14
|
1
tests/benchmarks/many-small-files/small-file-15.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-15.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 15
|
1
tests/benchmarks/many-small-files/small-file-16.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-16.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 16
|
1
tests/benchmarks/many-small-files/small-file-17.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-17.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 17
|
1
tests/benchmarks/many-small-files/small-file-18.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-18.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 18
|
1
tests/benchmarks/many-small-files/small-file-19.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-19.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 19
|
1
tests/benchmarks/many-small-files/small-file-2.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-2.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 2
|
1
tests/benchmarks/many-small-files/small-file-20.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-20.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 20
|
1
tests/benchmarks/many-small-files/small-file-21.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-21.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 21
|
1
tests/benchmarks/many-small-files/small-file-22.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-22.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 22
|
1
tests/benchmarks/many-small-files/small-file-23.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-23.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 23
|
1
tests/benchmarks/many-small-files/small-file-24.txt
vendored
Normal file
1
tests/benchmarks/many-small-files/small-file-24.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
I am small file 24
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user