Skip to content

Inline-diagnostics for users typing a prompt #1003

@wvhulle

Description

@wvhulle

I am working on a patch that adds inline diagnostics to (partial) Nu prompt based on the linter I made for Nu (nu-lint).

The diagnostics would be shown in real-time as they type (with optional debounce of ~ 300 ms).

Users would have the ability to configure it with a bool or the nu-lint config as in:

$env.config.inline_diagnostics = true
$env.config.inline_diagnostics = {
  ignored: ["snake_case_variables"]
  rules: { trailing_whitespace: "error" }
  groups: { naming: "warning" }
  max_pipeline_length: 100
}

While typing they get something that looks like this (the violations displayed below are just examples)

❯ $env.config.inline_diagnostics = true
wvhulle ~/Code/nushell inline-diagnostics ≡
❯ ^head -20 ./README.md | lines
  ╰─ Unnecessary '^' prefix on external command 'head'
  ╰─ Nushell only checks the final external command's exit code in pipelines.
   ╰─ Use 'first N' to get the first N items

Is this something that might interest you?

I patched nu-cli (to depend on nu-lint optionally with a feature flag and connect its output with reedline) and reedline (for displaying diagnostics from a generic provider). I added an adapter in nu-lint to provide data in the right format to reedline. It is in early stages of development.

Users would be able to set a minimum lint level so they don't get spammed by eager lints.

Here is a screenshot of the above sample, so you can see the colors:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions