Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syslog error highlighting fix #3205

Merged
merged 4 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
- Add syntax mapping for `paru` configuration files #3182 (@cyqsimon)
- Add support for [Idris 2 programming language](https://www.idris-lang.org/) #3150 (@buzden)
- Add syntax mapping for `nix`'s '`flake.lock` lockfiles #3196 (@odilf)
- Improvements to CSV/TSV highlighting, with autodetection of delimiter and support for TSV files, see #3186 (@keith-hall)
- Improvements to CSV/TSV highlighting, with autodetection of delimiter and support for TSV files, see #3186 (@keith-
- Improve (Sys)log error highlighting, see #3205 (@keith-hall)

## Themes

Expand Down
19 changes: 17 additions & 2 deletions assets/patches/Monokai-Extended.tmTheme.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,26 @@ index 9c2aa3e..180cbbf 100644
<string>Invalid</string>
<key>scope</key>
- <string>invalid</string>
+ <string>invalid, markup.error</string>
+ <string>invalid, meta.annotation.error-line</string>
<key>settings</key>
<dict>
<key>background</key>
@@ -1042,7 +1042,7 @@
@@ -1038,11 +1038,22 @@
<string>#f8f8f0</string>
</dict>
</dict>
+ <dict>
+ <key>name</key>
+ <string>Error</string>
+ <key>scope</key>
+ <string>markup.error</string>
+ <key>settings</key>
+ <dict>
+ <key>foreground</key>
+ <string>#dd2020</string>
+ </dict>
+ </dict>
<dict>
<key>name</key>
<string>Invalid deprecated</string>
<key>scope</key>
Expand Down
24 changes: 12 additions & 12 deletions assets/syntaxes/02_Extra/log.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ contexts:
scope: markup.underline.link.scheme.log
push: url-host
log_level_lines:
- match: ^(?=.*{{error}})
- match: (?=.*{{error}})
push:
- error_line
- error_line_meta
- main_pop_at_eol
- match: ^(?=.*{{warning}})
- match: (?=.*{{warning}})
push:
- warning_line
- warning_line_meta
- main_pop_at_eol
- match: ^(?=.*{{info}})
- match: (?=.*{{info}})
push:
- info_line
- info_line_meta
- main_pop_at_eol
- match: ^(?=.*{{debug}})
- match: (?=.*{{debug}})
push:
- debug_line
- debug_line_meta
- main_pop_at_eol
log_levels:
- match: '{{error}}'
Expand All @@ -63,16 +63,16 @@ contexts:
scope: markup.info.log
- match: '{{debug}}'
scope: markup.info.log
error_line:
error_line_meta:
- meta_scope: meta.annotation.error-line.log
- include: immediately_pop
warning_line:
warning_line_meta:
- meta_scope: meta.annotation.warning-line.log
- include: immediately_pop
info_line:
info_line_meta:
- meta_scope: meta.annotation.info-line.log
- include: immediately_pop
debug_line:
debug_line_meta:
- meta_scope: meta.annotation.debug-line.log
- include: immediately_pop
immediately_pop:
Expand Down
36 changes: 19 additions & 17 deletions assets/syntaxes/02_Extra/syslog.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ scope: text.log.syslog
contexts:
main:
- match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2})
scope: meta.datetime.syslog constant.numeric.syslog
scope: meta.datetime.syslog
captures:
1: meta.date.syslog
2: meta.time.syslog
1: meta.date.syslog constant.numeric.syslog
2: meta.time.syslog constant.numeric.syslog
push: loghost
- match: ^
push: text
Expand All @@ -31,22 +31,24 @@ contexts:
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
push: structured-data-contents
- match: (?=\S)
set: text
structured-data-contents:
- match: \]
scope: punctuation.section.mapping.end.syslog
pop: true
- match: \w+
scope: variable.parameter.syslog
- match: =
scope: keyword.operator.assignment.syslog
push: structured-data-assignment
structured-data-assignment:
- match: '[^\s\]]+'
scope: constant.other.syslog
pop: true
- match: (?=\])
pop: true
text:
- match: $
pop: true
Expand Down
2 changes: 1 addition & 1 deletion doc/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ in the `.sublime-syntax` format.
4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
`bat` binary.

5. Use `bat --list-languages` to check if the new languages are available.
5. Use `bat --list-languages` to check if the new languages are available. You may want to do something like `export PATH="`pwd`/target/debug:$PATH"` to ensure the locally compiled version is the one being used.

6. Add a syntax test for the new language. See [below](#Syntax-tests) for details.

Expand Down
2 changes: 1 addition & 1 deletion tests/syntax-tests/highlighted/Log/example.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
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
2022-03-16T17:41:02.519 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /home/zeta/dev/raytracer/Cargo.toml, cargo 1.61.0-nightly (65c8266 2022-03-09): Failed to run `\"cargo\" \"metadata\" \"--format-version\" \"1\" \"--manifest-path\" \"/home/zeta/dev/raytracer/Cargo.toml\" \"--filter-platform\" \"wasm32-unknown-unknown\"`: `cargo metadata` exited with an error: Updating crates.io index\nerror: failed to select a version for `parking_lot`.\n ... required by package `raytracer v0.1.0 (/home/zeta/dev/raytracer)`\nversions that meet the requirements `^0.12.0` are: 0.12.0\n\nthe package `raytracer` depends on `parking_lot`, with features: `wasm-bindgen` but `parking_lot` does not have these features.\n\n\nfailed to select a version for `parking_lot` which could resolve this conflict\n" }
2022-03-16T17:41:02.519 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /home/zeta/dev/raytracer/Cargo.toml, cargo 1.61.0-nightly (65c8266 2022-03-09): Failed to run `\"cargo\" \"metadata\" \"--format-version\" \"1\" \"--manifest-path\" \"/home/zeta/dev/raytracer/Cargo.toml\" \"--filter-platform\" \"wasm32-unknown-unknown\"`: `cargo metadata` exited with an error: Updating crates.io index\nerror: failed to select a version for `parking_lot`.\n ... required by package `raytracer v0.1.0 (/home/zeta/dev/raytracer)`\nversions that meet the requirements `^0.12.0` are: 0.12.0\n\nthe package `raytracer` depends on `parking_lot`, with features: `wasm-bindgen` but `parking_lot` does not have these features.\n\n\nfailed to select a version for `parking_lot` which could resolve this conflict\n" }
Loading