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

Helix support #27

Merged
merged 2 commits into from
Aug 17, 2023
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
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Tree-sitter grammar for Nushell

[**WIP**] [nushell](https://github.com/nushell/nushell) grammar for [tree-sitter](https://tree-sitter.github.io/tree-sitter/)

## goals (brainstorming)

- Ability to serve as a parser for a repl
- Ability to work in editors that support tree-sitter (`hx`, `nvim`, others)
- Ability to work in rust
- Fast
- Ability to be utilized for syntax highlighting
- ...

## installation guide
- for *neovim* users, please have a look at [`installation/neovim.md`](installation/neovim.md)

## contributing
see [instructions](./CONTRIBUTING.md)
# Tree-sitter grammar for Nushell

[**WIP**] [nushell](https://github.com/nushell/nushell) grammar for [tree-sitter](https://tree-sitter.github.io/tree-sitter/)

## goals (brainstorming)

- Ability to serve as a parser for a repl
- Ability to work in editors that support tree-sitter (`hx`, `nvim`, others)
- Ability to work in rust
- Fast
- Ability to be utilized for syntax highlighting
- ...

## installation guide
- for *neovim* users, please have a look at [`installation/neovim.md`](installation/neovim.md)
- for *helix* users, please have a look at [`installation/helix.md`](installation/helix.md)

## contributing
see [instructions](./CONTRIBUTING.md)
47 changes: 47 additions & 0 deletions installation/helix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Helix has built-in support for tree-sitter grammars and installations from
most sources have grammars for common languages (including nu!) built in.

### Using built-in helix grammars
Version from master branch of helix or any release after (not including) 23.05
will have this grammar and queries preinstalled. Hovewer due to rapid
development pace of nushell they might be severly out of date.

### Installing up to date grammar from this repo
Following [official guide](https://docs.helix-editor.com/languages.html#tree-sitter-grammar-configuration)
grammar may be updated to track specific revision (or main branch) of this
repo. In file `languages.toml` add
```toml
[[grammar]]
name = "nu"
source = { git = "https://github.com/nushell/tree-sitter-nu", rev = "<revision hash or main>" }
```

Then downaload and install up-to-date grammar:
```nu
hx -g fetch
hx -g build
```

These actions only install grammar. Queries are handled
[separately](https://docs.helix-editor.com/guides/adding_languages.html#queries).
To install queries copy them from `queries` directory of this repo to
`runtime/queries/nu` in [configuration directory](https://docs.helix-editor.com/configuration.html)
of helix (i.e. `~/.config/helix/runtime/queries/nu` on Linux and Mac,
`%AppData%\helix\runtime\queries\nu` on windows).

> **Warning**
> In helix there are several configuration (and thus `runtime`)
> [directories](https://docs.helix-editor.com/install.html#configuring-helixs-runtime-files).
> One of them is located in the directory with installation of binary and
> contains queries shipped with pre-built binary. For example when installing
> on windows with scoop it will be located in `~\scoop\apps\helix\current\runtime\`
>
> Before commit [1077630](https://github.com/helix-editor/helix/commit/107763083405868f3679d8e12476ed0688896f87)
> helix used [different grammar](https://github.com/LhKipp/tree-sitter-nu)
> which is incompatible with this one and contained some additional queries.
> These queries will not work correctly with new grammar and helix will error
> not applying correct queries either.
>
> To fix this issue users that are running helix versions 23.05 or older
> and in generally any users installing queries manually are advised to remove
> contents of `<helix install dir>/runtime/queries/nu`.
2 changes: 2 additions & 0 deletions queries/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))