plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


62ecfffPeter John 2026-07-19T17:43:01+05:30
fix: restore | operator spacing, add format_source_with_opts, reject --stdin --check
plum-cli/src/main.rs CHANGED
@@ -48,6 +48,9 @@ fn cmd_format(
48
48
  check: bool,
49
49
  use_stdin: bool,
50
50
  ) -> Result<()> {
51
+ if use_stdin && check {
52
+ anyhow::bail!("--check cannot be used with --stdin");
53
+ }
51
54
  if use_stdin {
52
55
  let mut source = String::new();
53
56
  io::stdin()
plum-core/src/formatter.rs CHANGED
@@ -34,6 +34,10 @@ impl From<topiary_core::FormatterError> for FormatterError {
34
34
  }
35
35
 
36
36
  pub fn format_source(source: &str) -> Result<String, FormatterError> {
37
+ format_source_with_opts(source, false)
38
+ }
39
+
40
+ pub fn format_source_with_opts(source: &str, skip_idempotence: bool) -> Result<String, FormatterError> {
37
41
  let ts_language: tree_sitter::Language = tree_sitter_plum::LANGUAGE.into();
38
42
  let facade_grammar: topiary_tree_sitter_facade::Language = ts_language.into();
39
43
  let query = TopiaryQuery::new(&facade_grammar, FORMAT_QUERY)?;
@@ -50,7 +54,7 @@ pub fn format_source(source: &str) -> Result<String, FormatterError> {
50
54
  &mut output,
51
55
  &language,
52
56
  Operation::Format {
53
- skip_idempotence: false,
57
+ skip_idempotence,
54
58
  tolerate_parsing_errors: false,
55
59
  },
56
60
  )?;
plum-core/src/lib.rs CHANGED
@@ -2,5 +2,5 @@ pub mod ast;
2
2
  pub mod parser;
3
3
  pub mod formatter;
4
4
 
5
- pub use formatter::{format_source, FormatterError};
5
+ pub use formatter::{format_source, format_source_with_opts, FormatterError};
6
6
  pub use parser::AstParser;
tooling/tree-sitter-plum/queries/plum/format.scm CHANGED
@@ -29,6 +29,7 @@
29
29
  "%"
30
30
  "^"
31
31
  "&"
32
+ "|"
32
33
  "<<"
33
34
  ">>"
34
35
  ".."