Skip to content

Commit

Permalink
📝 Update readme example (#21)
Browse files Browse the repository at this point in the history
* chore: add uuid, file patterns and line match

* docs: update readme and examples
  • Loading branch information
nefrob authored Jun 23, 2024
1 parent 287ef2f commit 39fa89b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## [Unreleased]

### Added

- `HEX` constants

### Changed

- Updated tests

## [0.3.0] - 2024-06015

### Added
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ Contents:

## Features

Basic syntax highlighting for just files:
Basic syntax highlighting for `just` files:

- Comments
- Variable assignment and settings
- Strings & escaped blocks
- Strings & interpolation blocks
- Recipes: recipe attributes, names, params and dependencies
- Some keywords, constants and operators
- Keywords, constants and operators
- Some embedded languages

Note: Unlike previous iterations of this extension, this extension does not provide command running capabilities from VSCode.
Note: Unlike previous iterations of VSCode `just` extensions, this extension does not provide command running capabilities from VSCode.

<img src="./assets/example.png" />
<img src="./assets/example.png" style="max-width: 75%;" />

## Known Issues

This extension does simple and/or best effort syntax highlighting. It is not intended to be 100% comprehensive, but rather provide a good enough experience for most users. An LSP solution would be an alternative future approach. That being said, if you find a bug or missing feature, please open an issue or a pull request.
This extension does simple and/or best effort syntax highlighting. It is not intended to be 100% comprehensive, but rather provide a good enough experience for most users. That being said, if you find a bug or missing feature, please open an issue or a pull request.

- Escaping within a string, e.g. `"{{ variable }}"`, colors all non-match content as a string. Ideally non-match content should look like plain text and allow for "nested" strings within the escaped block, but this isn't easily (if at all) supported by regex grammars. For consistency, this extension opts to always have escaped content colored as a string, whether the block is within a string or not.
- Interpolation blocks, e.g. `{{ variable }}`, color all content as a string. Ideally it should match base `just` language highlighting, however limitations of regexs make comprehensive highlighting here complex or impossible for certain scenarios.

- Extension is not available on open source marketplaces. If you are using an open source build of VSCode, you might need to install the extension manually. To do so:
- This extension is not available on open source marketplaces (for now). If you are using an open source build of VSCode, you might need to install the extension manually. To do so:

1. Navigate to the latest [release](https://github.com/nefrob/vscode-just/releases) and download the `.vsix` file.
2. Copy the file to your `.vscode/extensions` directory.
Expand All @@ -53,7 +53,6 @@ See [CHANGELOG.md](CHANGELOG.md).
Outstanding:

- [ ] Update to match [just grammar](https://github.com/casey/just/blob/43d88f50e02057e5d91602ef4ffdd0ddfc094099/GRAMMAR.md) more accurately
- [ ] Add snapshot testing
- [ ] Fix escaping within strings
- [ ] Publish to [open source marketplaces](https://open-vsx.org/)

Expand All @@ -62,14 +61,16 @@ Completed:
- [x] Initial release
- [x] Update with new `just` releases
- [x] Migrate to `yaml` grammar for composability and readability
- [x] Add snapshot testing


### Beyond

- Semantic highlighting / LSP

To avoid implementing a parser for files, it would be ideal for `just` to expose the AST or other APIs for editor extensions to leverage. This would allow for more advanced features like semantic highlighting, code folding, and more.

If VSCode works to support tree-sitter, that would be a possible alternative.
If VSCode works to support tree-sitter, [that](https://github.com/IndianBoy42/tree-sitter-just) would be a possible alternative.

## Contributing

Expand Down
13 changes: 13 additions & 0 deletions assets/example.just
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Demo

set tempdir := "/tmp"

export MY_VAR := `./my_script.sh`

[confirm: "Continue?"]
@foo PARAM_1="hello" PARAM_2="world" +ARGS:
echo {{ PARAM_1 }} {{ PARAM_2 }} {{ ARGS }}

python:
#!/usr/bin/env python3
print('Hello from python!')
Binary file modified assets/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions syntaxes/just.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Just",
"scopeName": "source.just",
"fileTypes": ["just", "justfile", "Justfile"],
"firstLineMatch": "#![\\s\\t]*\\/.*\\just\\b",
"uuid": "8b0cfae0-229f-4688-a4b7-8b5c3db82855",
"patterns": [
{
"include": "#assignment"
Expand Down
3 changes: 3 additions & 0 deletions syntaxes/just.tmLanguage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
$schema: https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json
name: Just
scopeName: source.just
fileTypes: [just, justfile, Justfile]
firstLineMatch: "#![\\s\\t]*\\/.*\\just\\b"
uuid: 8b0cfae0-229f-4688-a4b7-8b5c3db82855

patterns:
- include: '#assignment'
Expand Down

0 comments on commit 39fa89b

Please sign in to comment.