Skip to content

wvhulle/nushell

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11,027 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Nushell - Diagnostics Edition

Fork of Nushell with a generic LSP client for showing real-time diagnostics. Intended to use with nu-lint but could be used with any other LSP server.

Disclaimer: This fork was made to make it easier for people to experiment with inline diagnostics in the terminal for Nushell. As far as I know this is not too common yet. For the most-up-to date mainline Nushell features and development, please refer to the original repository. Otherwise, go ahead and play around with this fork.

Features:

  • Multiple underlined spans
  • Inline hints under spans
  • Colors for warning / info / error level
  • Automatic fixes (for most rules)
  • User / workspace ignore action (for noisy rules)

Screenshot of inline diagnostics with multiple labels:

Screenshot of inline diagnostics

Screenshot of the code action menu being active and suggesting fixes:

Screenshot of code action menu active

Architecture

flowchart LR
    subgraph Terminal
        Nu[nu binary]
        Reedline[reedline fork]
    end
    subgraph LSP Server
        NuLint[nu-lint]
    end

    Nu -->|line editing| Reedline
    Reedline <-->|LSP protocol| NuLint
    NuLint -->|diagnostics, fixes| Reedline
Loading

The forked reedline adds an LSP client that communicates with any language server specified via $env.REEDLINE_LS. The LSP server analyzes input and returns diagnostics and code actions displayed inline.

Installation

Install a language protocol server (LSP server). I recommend nu-lint:

cargo install nu-lint

Build the main binary nu with a Rust compiler toolchain:

  • For Nix users: nix run . (or add this repo's flake to your system dependencies)
  • Otherwise, if you are on a more mainstream machine, install rustup and:
cargo install --git https://github.com/wvhulle/nushell

Keep in mind this will overwrite any other nu binary you have there (such as the official one).

Usage

Set the environment variable with the startup command for the language server:

$env.REEDLINE_LS = "nu-lint --lsp"
# Or any other LSP server command you like
# $env.REEDLINE_LS = "nu --lsp"

Run the shell: ~/.cargo/bin/nu (or add to your path)

Key bindings:

  • Open fix/ignore menu when a violation is detected with ctrl+..
  • Navigate between fixes and ignore actions: tab
  • Apply fix directly in the prompt: enter

You can file issues related to incorrect lints and fixes at nu-lint.

About

Nushell with an LSP client

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 97.2%
  • Nushell 2.6%
  • Nix 0.1%
  • Python 0.1%
  • JavaScript 0.0%
  • Dockerfile 0.0%