Skip to content

Commit

Permalink
docs: syntax highlighting in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
viddrobnic committed Jul 7, 2024
1 parent ea7993b commit a56e3e1
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ Advent of Code 2024.
For the language to be almost operational it should have:

- [x] an interpreter,
- [ ] syntax highlighting,
- [x] syntax highlighting,
- [ ] basic LSP.

## Usage

### Interpreter setup

Rust is required to build the interpreter.

1. Clone this repository:
```sh
git clone https://github.com/viddrobnic/aoc-lang.git
Expand All @@ -26,6 +30,43 @@ For the language to be almost operational it should have:
aoc-lang examples/hello_world.aoc
```

### Syntax highlighting

Syntax highlighting is implemented with [tree sitter](https://tree-sitter.github.io/tree-sitter/).
I am using neovim as my editor (btw) and this is the standard way of doing it.
If you are using some other editor, you are on your own...

1. Add the aoc tree sitter parser to your config:
```lua
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
parser_config.aoc = {
install_info = {
url = 'https://github.com/viddrobnic/aoc-lang.git',
files = { 'tree-sitter-aoc/src/parser.c' },
},
filetype = 'aoc',
}
```
2. Open neovim and install the parser
```
:TSInstall aoc
```
3. Configure automatic aoc file type detection:
```lua
vim.filetype.add({
extension = {
aoc = 'aoc',
},
})
```
4. Add highlighting queries by copying
[this file](https://github.com/viddrobnic/aoc-lang/blob/master/tree-sitter-aoc/queries/highlights.scm)
from [the repo](https://github.com/viddrobnic/aoc-lang) to
```
~/.config/nvim/queries/aoc/
```
5. Restart neovim and open a `.aoc` file :)
## Language features
AoC language supports the following features:
Expand Down Expand Up @@ -59,15 +100,6 @@ which contains examples of code with comments.
## Wishlist:
### Syntax highlighting

Since I am using neovim as my editor, the easiest way to get syntax highlighting
is with treesitter:

- [ ] define treesitter grammar
- [ ] write highlighting queries
- [ ] update neovim config

### LSP
I didn't look into how LSP implementation is done yet, so I don't know how hard
Expand Down

0 comments on commit a56e3e1

Please sign in to comment.