nushell/crates
Yash Thakur 9522052063
More specific errors for missing values in records (#11423)
# Description
Currently, when writing a record, if you don't give the value for a
field, the syntax error highlights the entire record instead of
pinpointing the issue. Here's some examples:

```nushell
> { a: 2, 3 } # Missing colon (and value)
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #2:1:1]
 1 │  { a: 2, 3 }
   ·  ─────┬─────
   ·       ╰── expected record
   ╰────

> { a: 2, 3: } # Missing value
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #3:1:1]
 1 │  { a: 2, 3: }
   ·  ──────┬─────
   ·        ╰── expected record
   ╰────

> { a: 2, 3 4 } # Missing colon
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #4:1:1]
 1 │  { a: 2, 3 4 }
   ·  ──────┬──────
   ·        ╰── expected record
   ╰────
```

In all of them, the entire record is highlighted red because an
`Expr::Garbage` is returned covering that whole span:


![image](https://github.com/nushell/nushell/assets/45539777/36660b50-23be-4353-b180-3f84eff3c220)

This PR is for highlighting only the part inside the record that could
not be parsed. If the record literal is big, an error message pointing
to the start of where the parser thinks things went wrong should help
people fix their code.

# User-Facing Changes
Below are screenshots of the new errors:

If there's a stray record key right before the record ends, it
highlights only that key and tells the user it expected a colon after
it:


![image](https://github.com/nushell/nushell/assets/45539777/94503256-8ea2-47dd-b69a-4b520c66f7b6)

If the record ends before the value for the last field was given, it
highlights the key and colon of that field and tells the user it
expected a value after the colon:


![image](https://github.com/nushell/nushell/assets/45539777/2f3837ec-3b35-4b81-8c57-706f8056ac04)

If there are two consecutive expressions without a colon between them,
it highlights everything from the second expression to the end of the
record and tells the user it expected a colon. I was tempted to add a
help message suggesting adding a colon in between, but that may not
always be the right thing to do.


![image](https://github.com/nushell/nushell/assets/45539777/1abaaaa8-1896-4909-bbb7-9a38cece5250)

# Tests + Formatting

# After Submitting
2023-12-27 10:15:12 +01:00
..
nu_plugin_custom_values Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu_plugin_example Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu_plugin_formats Bump ical from 0.8.0 to 0.9.0 (#11419) 2023-12-25 09:23:27 +08:00
nu_plugin_gstat Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu_plugin_inc Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu_plugin_python remove vectorize_over_list from python plugin (#9905) 2023-08-03 16:46:48 +02:00
nu_plugin_query Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu-cli fix: prevent greedy matching of directory names (#11403) 2023-12-23 00:06:00 -06:00
nu-cmd-base Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu-cmd-dataframe Make polars deps optional for cargo test --all (#11415) 2023-12-24 13:12:31 +01:00
nu-cmd-extra Bump fancy-regex to single 0.12.0 version (#11389) 2023-12-21 17:10:33 +01:00
nu-cmd-lang Bump fancy-regex to single 0.12.0 version (#11389) 2023-12-21 17:10:33 +01:00
nu-color-config Construct Records only through checked helpers (#11386) 2023-12-21 16:48:15 +01:00
nu-command Don't panic when http_client fails (#11422) 2023-12-25 23:09:37 +08:00
nu-engine Make Call::get_flag_expr return Expression by ref (#11388) 2023-12-21 16:42:07 +01:00
nu-explore Bump lscolors from 0.15.0 to 0.16.0 (#11359) 2023-12-21 16:08:19 +00:00
nu-glob Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu-json Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu-lsp Make hover equal to help command (#11320) 2023-12-15 11:39:19 -06:00
nu-parser More specific errors for missing values in records (#11423) 2023-12-27 10:15:12 +01:00
nu-path Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu-plugin Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu-pretty-hex Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu-protocol Remove unnecessary replace_in_variable (#11424) 2023-12-26 18:46:49 +01:00
nu-std disable directory submodule auto export (#11157) 2023-12-15 12:37:55 +01:00
nu-system Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu-table Bump fancy-regex to single 0.12.0 version (#11389) 2023-12-21 17:10:33 +01:00
nu-term-grid Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu-test-support Bump version to 0.88.2 (#11333) 2023-12-14 13:55:48 -06:00
nu-utils Bump lscolors from 0.15.0 to 0.16.0 (#11359) 2023-12-21 16:08:19 +00:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.