Skip to content

A tree-sitter grammar for nu-lang, the language of nushell

License

Notifications You must be signed in to change notification settings

jgollenz/tree-sitter-nu

 
 

Repository files navigation

tree-sitter-nu

This is an experiment to see if we can create a good parser for nu-lang.

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
  • ?

How-To - taken from here

  1. cargo install tree-sitter-cli
  2. make sure nodejs and npm is installed (you may have to do npm install - see docs above)
  3. tree-sitter generate
  4. tree-sitter parse example-file.nu

Examples with rust

  1. main.rs
  2. cargo run --example main

Testing

  1. Add a file to test/corpus/descriptive_test_name.txt
  2. Use the custom_command_1.txt as a guide
  3. run tree-sitter test -f 'custom command 1' and evaluate the results
  4. More information can be found here

Tips

  • A line in the grammar.js that begins with $._blah means that blah is anonymous and won't show up in the final syntax tree.
  • Most of the grammar how-to is found here

Further reading

About

A tree-sitter grammar for nu-lang, the language of nushell

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • C 94.4%
  • JavaScript 4.1%
  • Rust 1.1%
  • Other 0.4%