Skip to content

Commit

Permalink
Remove included colour overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
jotaen committed Apr 1, 2022
1 parent 0b30abb commit 77fc3eb
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 97 deletions.
39 changes: 0 additions & 39 deletions Mariana.sublime-color-scheme

This file was deleted.

39 changes: 0 additions & 39 deletions Monokai.sublime-color-scheme

This file was deleted.

30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
# klog for Sublime Text

This package provides support for working with [klog time tracking](https://klog.jotaen.net) files in the Sublime Text editor:
This package provides support for working with [klog time tracking](https://klog.jotaen.net) files in the Sublime Text editor.

![A klog file with sample data](resources/example.png)

- Syntax highlighting
+ If you use the Mariana or Monokai theme, it also assigns meaningful colouring.
- Smart completion for inserting the current date or time. For example:
+ Typing `today` completes to the current date
+ Typing `now` completes to the current time
- A few sensible default settings for the `.klg` file format

![A klog file with sample data](resources/example.png)
## Configuration

### Colour overrides

The pre-defined syntax highlighting should look meaningful in most available colour schemes.

For klog-specific customisations, you can specify the following colour overrides:

- `markup.other.date.klog` For the date, e.g. `2022-03-15`
- `markup.other.should_total.klog` For the should total, e.g. `(8h!)`
- `markup.other.summary.klog` For summary text
- `markup.other.summary.tag.klog` For tags inside summaries, e.g. `#work`
- `markup.other.duration_positive.klog` For positive durations, e.g. `5h25m`
- `markup.other.duration_negative.klog` For negative durations, e.g. `-15m`
- `markup.other.range.klog` For ranges, e.g. `8:00 - 9:20`
- `markup.other.open_range.klog` For open ranges, e.g. `14:30 - ?`

You can achieve this by adding entries ([see Sublime docs](https://www.sublimetext.com/docs/color_schemes.html)) to the `rules` list of your scheme’s customisation file:

```
"rules": [
{"scope": "markup.other.range.klog", "foreground": "#76c7ff"},
]
```
41 changes: 27 additions & 14 deletions klog.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,27 @@ variables:
indentation: '(\t| | | )'

contexts:

# For every scope, there must be two values assigned:
# - One klog-specific scope, that’s unused by this
# package, but that allows the user to setup overrides
# conveniently.
# - One generic fallback scope, that will likely work
# out of the box for most color schemes.

main:
- include: record

record:
# A record must start with a date.
- match: '^({{date}})'
scope: constant.language.klog entity.other.date.klog
scope: markup.underline.klog markup.other.date.klog
push:

# Then, there may follow a should total on the same line.
- match: '(\s+{{should_total}})?\s*'
scope: variable.function.klog entity.other.should_total.klog
- match: '(\s+({{should_total}}))?\s*'
captures:
2: constant.numeric.klog markup.other.should_total.klog

# End of headline.
- match: '$'
Expand All @@ -44,7 +53,7 @@ contexts:
# A record summary line cannot start with whitespace.
- match: '^(?=[^\s])'
push:
- meta_scope: comment.klog entity.other.summary.text.klog
- meta_scope: comment.klog markup.other.summary.klog
- include: tag
- match: '^(?=\s)'
pop: 1
Expand All @@ -65,17 +74,21 @@ contexts:
pop: 99999

# When the line is indented, it’s an entry.
- match: '^{{indentation}}{{duration_positive}}(?=\s|$)'
scope: constant.numeric.klog entity.other.duration.positive.klog
- match: '^{{indentation}}({{duration_positive}})(?=\s|$)'
captures:
2: markup.inserted.klog markup.other.duration_positive.klog
push: entry_summary
- match: '^{{indentation}}{{duration_negative}}(?=\s|$)'
scope: keyword.control.klog entity.other.duration.negative.klog
- match: '^{{indentation}}({{duration_negative}})(?=\s|$)'
captures:
2: markup.deleted.klog markup.other.duration_negative.klog
push: entry_summary
- match: '^{{indentation}}{{range}}(?=\s|$)'
scope: string.quoted.klog entity.other.range.closed.klog
- match: '^{{indentation}}({{range}})(?=\s|$)'
captures:
2: variable.function.klog markup.other.range.klog
push: entry_summary
- match: '^{{indentation}}{{open_range}}(?=\s|$)'
scope: string.quoted.klog entity.other.range.open.klog
- match: '^{{indentation}}({{open_range}})(?=\s|$)'
captures:
2: variable.function.klog markup.other.open_range.klog
push: entry_summary

# Error if next line doesn’t start with whitespace.
Expand All @@ -85,7 +98,7 @@ contexts:

entry_summary:
# Parse the remainder of the first line, and continue on the next.
- meta_scope: comment.klog entity.other.summary.text.klog
- meta_scope: comment.klog markup.other.summary.klog
- include: tag

# Exit on blank line.
Expand All @@ -106,4 +119,4 @@ contexts:

tag:
- match: '\#[\p{L}\d_]+'
scope: comment.klog entity.other.summary.tag.klog
scope: string.quoted markup.other.summary.tag.klog
4 changes: 2 additions & 2 deletions resources/test.klg
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ This is an all-valid record. It’s indented with tabs.
-1h20m
-1h Test
0:00 - 1:00
04:00-17:00 asdf #foo_bar
<4:00 - 17:00> asdf #foo #bar
04:00-17:00 asdf #foo_bar?
<4:00 - 17:00> asdf #foo: #bar!
4:00am - 5:00pm 1:00 - 2:00
4:00am-5:00pm>
15:00>-? Foo
Expand Down

0 comments on commit 77fc3eb

Please sign in to comment.