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

use a script instead of submodules for grammars #1560

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
25 changes: 17 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true

- name: Fetch grammars
run: ./scripts/grammars sync

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -53,8 +54,14 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true

- name: Fetch grammars (Windows)
if: startsWith(matrix.os, 'windows')
run: scripts/grammars.cmd sync

- name: Fetch grammars (Unix)
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
run: scripts/grammars sync

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -97,8 +104,9 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true

- name: Fetch grammars
run: ./scripts/grammars sync

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -144,8 +152,9 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true

- name: Fetch grammars
run: ./scripts/grammars sync

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: true

- name: Fetch grammars (Windows)
if: startsWith(matrix.os, 'windows')
run: scripts/grammars.cmd sync

- name: Fetch grammars (Unix)
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
run: scripts/grammars sync

- name: Install ${{ matrix.rust }} toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -114,8 +120,9 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: false

- name: Fetch grammars
uses: ./scripts/grammars sync

- uses: actions/download-artifact@v2
# with:
Expand Down
216 changes: 0 additions & 216 deletions .gitmodules

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ We provide packaging for various distributions, but here's a quick method to
build from source.

```
git clone --recurse-submodules --shallow-submodules -j8 https://github.com/helix-editor/helix
git clone https://github.com/helix-editor/helix
cd helix
./scripts/grammars sync
cargo install --path helix-term
```

Expand Down
31 changes: 12 additions & 19 deletions book/src/guides/adding_languages.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
# Adding languages

## Submodules
## Grammars manifest

To add a new language, add a new line to `scripts/revisions.txt` with the
name of the remote and the revision. Then run

To add a new language, you should first add a tree-sitter submodule. To do this,
you can run the command
```sh
git submodule add -f <repository> helix-syntax/languages/tree-sitter-<name>
```
For example, to add tree-sitter-ocaml you would run
```sh
git submodule add -f https://github.com/tree-sitter/tree-sitter-ocaml helix-syntax/languages/tree-sitter-ocaml
```
Make sure the submodule is shallow by doing
```sh
git config -f .gitmodules submodule.helix-syntax/languages/tree-sitter-<name>.shallow true
./scripts/grammars sync
```

or you can manually add `shallow = true` to `.gitmodules`.
To download the new grammar.

## languages.toml

Expand Down Expand Up @@ -56,14 +49,14 @@ the last matching query supercedes the ones before it. See

## Common Issues

- If you get errors when building after switching branches, you may have to remove or update tree-sitter submodules. You can update submodules by running
- If you get errors when building after switching branches, you may have to sync your grammars. You can sync grammars by running
```sh
git submodule sync; git submodule update --init
./scripts/grammars sync
```
- If a parser is segfaulting or you want to remove the parser, make sure to remove the grammar repository *and* the compiled parser in `runtime/grammar/<name>.so`. You can remove the grammar repository by running
```sh
./scripts/grammars clean
```
- Make sure to not use the `--remote` flag. To remove submodules look inside the `.gitmodules` and remove directories that are not present inside of it.

- If a parser is segfaulting or you want to remove the parser, make sure to remove the submodule *and* the compiled parser in `runtime/grammar/<name>.so`

- The indents query is `indents.toml`, *not* `indents.scm`. See [this](https://github.com/helix-editor/helix/issues/114) issue for more information.

[treesitter-language-injection]: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection
Expand Down
3 changes: 2 additions & 1 deletion book/src/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ sudo dnf install helix
## Build from source

```
git clone --recurse-submodules --shallow-submodules -j8 https://github.com/helix-editor/helix
git clone https://github.com/helix-editor/helix
./scripts/grammars sync
cd helix
cargo install --path helix-term
```
Expand Down
3 changes: 1 addition & 2 deletions helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ impl LanguageConfiguration {
&highlights_query,
&injections_query,
&locals_query,
)
.unwrap(); // TODO: avoid panic
).unwrap_or_else(|query_error| panic!("Could not parse queries for language {:?}. This can happen if your grammars are out of sync - try running './scripts/grammars sync'. This query could not be parsed: {:?}", self.language_id, query_error));

config.configure(scopes);
Some(Arc::new(config))
Expand Down
1 change: 0 additions & 1 deletion helix-syntax/languages/tree-sitter-agda
Submodule tree-sitter-agda deleted from ca69cd
1 change: 0 additions & 1 deletion helix-syntax/languages/tree-sitter-bash
Submodule tree-sitter-bash deleted from a8eb5c
1 change: 0 additions & 1 deletion helix-syntax/languages/tree-sitter-c
Submodule tree-sitter-c deleted from f05e27
1 change: 0 additions & 1 deletion helix-syntax/languages/tree-sitter-c-sharp
Submodule tree-sitter-c-sharp deleted from 53a65a
1 change: 0 additions & 1 deletion helix-syntax/languages/tree-sitter-cmake
Submodule tree-sitter-cmake deleted from f6616f
1 change: 0 additions & 1 deletion helix-syntax/languages/tree-sitter-comment
Submodule tree-sitter-comment deleted from 5dd3c6
1 change: 0 additions & 1 deletion helix-syntax/languages/tree-sitter-cpp
Submodule tree-sitter-cpp deleted from e8dcc9
1 change: 0 additions & 1 deletion helix-syntax/languages/tree-sitter-css
Submodule tree-sitter-css deleted from 94e102
1 change: 0 additions & 1 deletion helix-syntax/languages/tree-sitter-dart
Submodule tree-sitter-dart deleted from 6a2537
1 change: 0 additions & 1 deletion helix-syntax/languages/tree-sitter-dockerfile
Submodule tree-sitter-dockerfile deleted from 7af32b
Loading