summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Peter <sharkdp@users.noreply.github.com>2021-05-12 22:28:10 +0200
committerGitHub <noreply@github.com>2021-05-12 22:28:10 +0200
commitbfa9c3bef60d97238b6d9e1495b58b8a8c8151d8 (patch)
tree6bca8b70b2b958dc68bc532d24594ee96efb4b11
parentaa442b57954144dda697d063e4c43b9ccbc93101 (diff)
parent2904f24ea803ce3fd51cb4080949c8d53e14d06e (diff)
Merge branch 'master' into feature/dark_plus_theme
-rw-r--r--.gitmodules9
-rw-r--r--CHANGELOG.md1
-rw-r--r--assets/patches/Monokai-Extended.tmTheme.patch18
m---------assets/syntaxes/02_Extra/SublimeEthereum0
m---------assets/syntaxes/02_Extra/Syslog0
-rw-r--r--assets/syntaxes/02_Extra/log.sublime-syntax116
-rw-r--r--assets/syntaxes/02_Extra/syslog.sublime-syntax63
-rw-r--r--src/less.rs15
-rw-r--r--tests/syntax-tests/highlighted/Log/example.log2
-rw-r--r--tests/syntax-tests/highlighted/Solidity/ERC721.sol376
-rw-r--r--tests/syntax-tests/highlighted/Syslog/example.syslog11
-rw-r--r--tests/syntax-tests/highlighted/Vyper/crowdsale.vy89
-rw-r--r--tests/syntax-tests/source/Log/example.log2
-rw-r--r--tests/syntax-tests/source/Solidity/ERC721.sol376
-rw-r--r--tests/syntax-tests/source/Solidity/LICENSE.md27
-rw-r--r--tests/syntax-tests/source/Syslog/example.syslog11
-rw-r--r--tests/syntax-tests/source/Vyper/LICENSE.md205
-rw-r--r--tests/syntax-tests/source/Vyper/crowdsale.vy89
18 files changed, 1404 insertions, 6 deletions
diff --git a/.gitmodules b/.gitmodules
index 993123b0..7cea6c76 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -94,10 +94,6 @@
[submodule "assets/syntaxes/Assembly (ARM)"]
path = assets/syntaxes/02_Extra/Assembly (ARM)
url = https://github.com/tvi/Sublime-ARM-Assembly
-[submodule "assets/syntaxes/syslog-syntax"]
- path = assets/syntaxes/02_Extra/Syslog
- url = https://github.com/caos21/syslog-syntax.git
- branch = master
[submodule "assets/syntaxes/protobuf-syntax-highlighting"]
path = assets/syntaxes/02_Extra/Protobuf
url = https://github.com/VcamX/protobuf-syntax-highlighting.git
@@ -218,4 +214,7 @@
url = https://github.com/TheClams/SystemVerilog.git
[submodule "assets/themes/visual-studio-dark-plus"]
path = assets/themes/visual-studio-dark-plus
- url = https://github.com/vidann1/visual-studio-dark-plus.git \ No newline at end of file
+ url = https://github.com/vidann1/visual-studio-dark-plus.git
+[submodule "assets/syntaxes/02_Extra/SublimeEthereum"]
+ path = assets/syntaxes/02_Extra/SublimeEthereum
+ url = https://github.com/davidhq/SublimeEthereum.git \ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d3341148..617f19b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@
## Syntaxes
+- Improved the Syslog syntax highlighting, see #1606 (@keith-hall)
- Replaced "Advanced CSV" with a custom CSV syntax definition written especially for `bat`; see #1574 (@keith-hall)
## New themes
diff --git a/assets/patches/Monokai-Extended.tmTheme.patch b/assets/patches/Monokai-Extended.tmTheme.patch
index 16624d5f..106b584d 100644
--- a/assets/patches/Monokai-Extended.tmTheme.patch
+++ b/assets/patches/Monokai-Extended.tmTheme.patch
@@ -16,3 +16,21 @@ index 9c2aa3e..180cbbf 100644
</dict>
</dict>
<dict>
+@@ -1027,7 +1027,7 @@
+ <key>name</key>
+ <string>Invalid</string>
+ <key>scope</key>
+- <string>invalid</string>
++ <string>invalid, markup.error</string>
+ <key>settings</key>
+ <dict>
+ <key>background</key>
+@@ -1042,7 +1042,7 @@
+ <key>name</key>
+ <string>Invalid deprecated</string>
+ <key>scope</key>
+- <string>invalid.deprecated</string>
++ <string>invalid.deprecated, markup.warning</string>
+ <key>settings</key>
+ <dict>
+ <key>background</key>
diff --git a/assets/syntaxes/02_Extra/SublimeEthereum b/assets/syntaxes/02_Extra/SublimeEthereum
new file mode 160000
+Subproject b60e0a3e00e68263fcf35ba1a2e0bd0f6e3544f
diff --git a/assets/syntaxes/02_Extra/Syslog b/assets/syntaxes/02_Extra/Syslog
deleted file mode 160000
-Subproject 7628d4e0b89d3b4f0dcc014bfb4a3e3433f5133
diff --git a/assets/syntaxes/02_Extra/log.sublime-syntax b/assets/syntaxes/02_Extra/log.sublime-syntax
new file mode 100644
index 00000000..3c699d2e
--- /dev/null
+++ b/assets/syntaxes/02_Extra/log.sublime-syntax
@@ -0,0 +1,116 @@
+%YAML 1.2
+---
+# See http://www.sublimetext.com/docs/3/syntax.html
+file_extensions:
+ - log
+scope: text.log
+variables:
+ ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
+contexts:
+ main:
+ - match: (\w+)(=)
+ captures:
+ 1: variable.parameter.log
+ 2: keyword.operator.assignment.log
+ - match: (')([^']*)(')
+ scope: string.quoted.single.log
+ captures:
+ 1: punctuation.definition.string.begin.log
+ 3: punctuation.definition.string.end.log
+ - match: (")([^"]*)(")
+ scope: string.quoted.double.log
+ captures:
+ 1: punctuation.definition.string.begin.log
+ 3: punctuation.definition.string.end.log
+ - include: dates
+ - include: ip_addresses
+ - include: numbers
+ - match: \b(?i:fail(?:ure|ed)?|error|exception)\b
+ scope: markup.error.log
+ - match: \b(?i:warn(?:ing)?)\b
+ scope: markup.warning.log
+ #- include: scope:text.html.markdown#autolink-inet
+ - match: \b\w+:/{2,3}
+ scope: markup.underline.link.scheme.log
+ push: url-host
+ dates:
+ - match: \b\d{4}-\d{2}-\d{2}\b
+ scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
+ - match: \b\d{4}/\d{2}/\d{2}\b
+ scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
+ - match: \b(?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d)(?:(\.)\d{3})?\b
+ scope: meta.time.log meta.number.integer.decimal.log constant.numeric.value.log
+ captures:
+ 1: punctuation.separator.decimal.log
+ ip_addresses:
+ - match: \b(?=(?:{{ipv4_part}}\.){3}{{ipv4_part}}\b)
+ push:
+ - meta_scope: meta.ipaddress.v4.log meta.number.integer.decimal.log
+ - match: \d+
+ scope: constant.numeric.value.log
+ - match: \.
+ scope: punctuation.separator.sequence.log
+ - match: ''
+ pop: true
+ - match: (?=(?:\h{0,4}:){2,6}\h{1,4}\b)
+ push:
+ - meta_scope: meta.ipaddress.v6.log meta.number.integer.hexadecimal.log
+ - match: \h{1,4}
+ scope: constant.numeric.value.log
+ - match: ':'
+ scope: punctuation.separator.sequence.log
+ - match: ''
+ pop: true
+ numbers:
+ - match: \b(0x)(\h+)(?:(\.)(\h+))?\b
+ scope: meta.number.float.hexadecimal.log
+ captures:
+ 1: constant.numeric.base.log
+ 2: constant.numeric.value.log
+ 3: constant.numeric.value.log punctuation.separator.decimal.log
+ 4: constant.numeric.value.log
+ - match: \b\d+(\.)\d+\b
+ scope: meta.number.float.log constant.numeric.value.log
+ captures:
+ 1: punctuation.separator.decimal.log
+ - match: \b\d+\b
+ scope: meta.number.integer.log constant.numeric.value.log
+ url-host:
+ - meta_content_scope: markup.underline.link.host.log
+ - match: \[
+ scope: punctuation.section.brackets.begin.log
+ push:
+ - match: \]
+ scope: punctuation.section.brackets.end.log
+ pop: true
+ - include: ip_addresses
+ - match: '[^:/\s]+'
+ - match: ''
+ set: url-after-host
+ url-after-host:
+ - match: (:)(\d+)
+ scope: markup.underline.link.port.log
+ captures:
+ 1: punctuation.separator.mapping.port.log
+ 2: constant.numeric.value.log
+ #- include: scope:text.html.markdown#url-escaped-chars
+ - match: (%)\h{2}
+ scope: markup.underline.link.path.log constant.character.escape.url.log
+ captures:
+ 1: punctuation.definition.escape.log
+ # After a valid domain, zero or more non-space non-< characters may follow
+ - match: (?=[?!.,:*_~]*[\s<]) # Trailing punctuation (specifically, ?, !, ., ,, :, *, _, and ~) will not be considered part of the autolink, though they may be included in the interior of the link
+ pop: true
+ - match: \( # When an autolink ends in ), we scan the entire autolink for the total number of parentheses. If there is a greater number of closing parentheses than opening ones, we don’t consider the last character part of the autolink, in order to facilitate including an autolink inside a parenthesis
+ push:
+ - meta_scope: markup.underline.link.path.log
+ - match: (?=[?!.,:*_~]*[\s<])
+ pop: true
+ - match: \)
+ pop: true
+ - match: (?=\)[?!.,:*_~]*[\s<])
+ pop: true
+ - match: '[^?!.,:*_~\s<&()%]+|\S'
+ scope: markup.underline.link.path.log
+ - match: ''
+ pop: true
diff --git a/assets/syntaxes/02_Extra/syslog.sublime-syntax b/assets/syntaxes/02_Extra/syslog.sublime-syntax
new file mode 100644
index 00000000..ce782e50
--- /dev/null
+++ b/assets/syntaxes/02_Extra/syslog.sublime-syntax
@@ -0,0 +1,63 @@
+%YAML 1.2
+---
+# http://www.sublimetext.com/docs/3/syntax.html
+name: syslog
+file_extensions:
+ - syslog
+scope: text.log.syslog
+contexts:
+ main:
+ - match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2})
+ scope: meta.datetime.syslog constant.numeric.syslog
+ captures:
+ 1: meta.date.syslog
+ 2: meta.time.syslog
+ push: loghost
+ - match: ^
+ push: text
+ loghost:
+ - match: '[\w-]+'
+ scope: entity.other.attribute-name.loghost.syslog
+ set: process
+ process:
+ - match: ([\w-]+)(?:(\[)(\d+)(\]))?(:)
+ captures:
+ 1: support.function.process.syslog
+ 2: punctuation.separator.pid.begin.syslog
+ 3: meta.pid.syslog meta.number.integer.syslog constant.numeric.value.syslog
+ 4: punctuation.separator.pid.end.syslog
+ 5: punctuation.separator.mapping.syslog
+ set: structured-data
+ structured-data:
+ - match: '\['
+ scope: punctuation.section.mapping.begin.syslog
+ push:
+ - match: \]
+ scope: punctuation.section.mapping.end.syslog
+ pop: true
+ - match: \w+
+ scope: variable.parameter.syslog
+ - match: =
+ scope: keyword.operator.assignment.syslog
+ push:
+ - match: '[^\s\]]+'
+ scope: constant.other.syslog
+ pop: true
+ - match: (?=\])
+ pop: true
+ - match: (?=\S)
+ set: text
+ text:
+ - match: $
+ pop: true
+ - match: '<\w+>'
+ scope: constant.language.syslog
+ - match: \b(CMD)\b\s+(\()
+ captures:
+ 1: entity.name.label.syslog
+ 2: punctuation.section.block.begin.syslog
+ embed: scope:source.shell.bash
+ escape: \)$
+ escape_captures:
+ 0: punctuation.section.block.end.syslog
+ - include: scope:text.log
diff --git a/src/less.rs b/src/less.rs
index 34b57549..f1adca81 100644
--- a/src/less.rs
+++ b/src/less.rs
@@ -11,7 +11,7 @@ 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(' ')?;
+ let end = version.find(|c: char| !c.is_ascii_digit())?;
version[..end].parse::<usize>().ok()
} else {
None
@@ -58,6 +58,19 @@ Home page: http://www.greenwoodsoftware.com/less";
}
#[test]
+fn test_parse_less_version_581_2() {
+ let output = b"less 581.2 (PCRE2 regular expressions)
+Copyright (C) 1984-2021 Mark Nudelman
+
+less comes with NO WARRANTY, to the extent permitted by law.
+For information about the terms of redistribution,
+see the file named README in the less distribution.
+Home page: https://greenwoodsoftware.com/less";
+
+ assert_eq!(Some(581), parse_less_version(output));
+}
+
+#[test]
fn test_parse_less_version_wrong_program() {
let output = b"more from util-linux 2.34";
diff --git a/tests/syntax-tests/highlighted/Log/example.log b/tests/syntax-tests/highlighted/Log/example.log
new file mode 100644
index 00000000..8387670c
--- /dev/null
+++ b/tests/syntax-tests/highlighted/Log/example.log
@@ -0,0 +1,2 @@
+2021-03-06 23:22:21.392 https://[2001:db8:4006:812::200e]:8080/path/the%20page.html
+2021-03-06 23:22:21 https://example.com:8080/path/the%20page(with_parens).html
diff --git a/tests/syntax-tests/highlighted/Solidity/ERC721.sol b/tests/syntax-tests/highlighted/Solidity/ERC721.sol
new file mode 100644
index 00000000..7a30e357
--- /dev/null
+++ b/tests/syntax-tests/highlighted/Solidity/ERC721.sol
@@ -0,0 +1,376 @@
+// SPDX-License-Identifier: MIT
+
+pragma solidity ^0.8.0;
+
+import "./IERC721.sol";
+import "./IERC721Receiver.sol";
+import "./extensions/IERC721Metadata.sol";
+import "../../utils/Address.sol";
+import "../../utils/Context.sol";
+import "../../utils/Strings.sol";
+import "../../utils/introspection/ERC165.sol";
+
+/**
+ * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
+ * the Metadata extension, but not including the Enumerable extension, which is available separately as
+ * {ERC721Enumerable}.
+ */
+contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
+ using Address for address;
+ using Strings for uint256;
+
+ // Token name
+ string private _name;
+
+ // Token symbol
+ string private _symbol;
+
+ // Mapping from token ID to owner address
+ mapping (uint256 => address) private _owners;
+
+ // Mapping owner address to token count
+ mapping (address => uint256) private _balances;
+
+ // Mapping from token ID to approved address
+ mapping (uint256 => address) private _tokenApprovals;
+
+ // Mapping from owner to operator approvals
+ mapping (address => mapping (address => bool)) private _operatorApprovals;
+
+ /**
+ * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
+ */
+ constructor (string memory name_, string memory symbol_) {
+ _name = name_;
+ _symbol = symbol_;
+ }
+
+ /**
+ * @dev See {IERC165-supportsInterface}.
+ */
+ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
+ return interfaceId == type(IERC721).interfaceId
+ || interfaceId == type(IERC721Metadata).interfaceId
+ || super.supportsInterface(interfaceId);
+ }
+
+ /**
+ * @dev See {IERC721-balanceOf}.
+ */
+ function balanceOf(address owner) public view virtual override returns (uint256) {
+ require(owner != address(0), "ERC721: balance query for the zero address");
+ return _balances[owner];
+ }
+
+ /**
+ * @dev See {IERC721-ownerOf}.
+ */
+ function ownerOf(uint256 tokenId) public view virtual override returns (address) {
+ address owner = _owners[tokenId];
+ require(owner != address(0), "ERC721: owner query for nonexistent token");
+ [38;2