Skip to content

Commit

Permalink
Merge pull request #27 from NotLebedev/helix-support
Browse files Browse the repository at this point in the history
Helix support
  • Loading branch information
fdncred authored Aug 17, 2023
2 parents 4313519 + ab3bf89 commit 786689b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 18 deletions.
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"))

0 comments on commit 786689b

Please sign in to comment.