🌈 A nushell plugin for syntax highlighting.

Overview

nu-plugin-highlight

A nushell plugin for syntax highlighting.


Version License

About

nu-plugin-highlight is a plugin for Nushell that provides syntax highlighting for source code. It uses the syntect library for syntax highlighting and the bat library for easy access to its ready-to-use assets.

Usage

The highlight command can be used for syntax highlighting source code. Here are a few examples:

# Highlight a TOML file by its file extension
open Cargo.toml -r | highlight toml

# Highlight a Rust file by programming language name
open src/main.rs | highlight Rust

# Highlight a bash script by inferring the language (the file should start with a shebang)
open example.sh | highlight

# Highlight a TOML file with a different theme
open Cargo.toml -r | highlight toml -t ansi

# List all available themes
highlight --list-themes

Parameters

  • language <string>: This is an optional parameter that can be used to specify the language or file extension to aid language detection.

Flags

  • -h, --help: Display the help message for the highlight command.

  • -t, --theme <string>: The theme used for highlighting.

  • --list-themes: List all possible themes.

Configuration

The plugin can be configured using environment variables:

NU_PLUGIN_HIGHLIGHT_TRUE_COLORS

Enable or disable true colors (24-bit). By default, this is enabled.

let-env NU_PLUGIN_HIGHLIGHT_TRUE_COLORS = true

NU_PLUGIN_HIGHLIGHT_THEME

Set a theme to use. The default theme depends on the operating system. Use highlight --list-themes | where default == true to see your default theme. Setting this environment variable should allow highlight --list-themes | where id == $env.NU_PLUGIN_HIGHLIGHT_THEME to result in a single row with your selected theme. If you get no results, you have set an invalid theme.

let-env NU_PLUGIN_HIGHLIGHT_THEME = ansi

Plugin Installation

Installing and registering the nu-plugin-highlight is a straightforward process. Follow these steps:

  1. Install the plugin from crates.io using cargo:

    cargo install nu_plugin_highlight
  2. Restart your terminal session to ensure the newly installed plugin is recognized.

  3. Find path of your installation:

    which nu_plugin_highlight
  4. Register the plugin with Nushell:

    register path/to/the/plugin/binary

After registering, the plugin is available as part of your set of commands:

help commands | where command_type == "plugin"

License

nu_plugin_highlight is licensed under the MIT License. See LICENSE for more information.

You might also like...
A syntax highlighter for Node powered by Tree Sitter. Written in Rust.

tree-sitter-highlight A syntax highlighter for Node.js powered by Tree Sitter. Written in Rust. Usage The following will output HTML: const treeSitter

Valq - macros for querying and extracting value from structured data by JavaScript-like syntax

valq   valq provides a macro for querying and extracting value from structured data in very concise manner, like the JavaScript syntax. Look & Feel: u

Notes on learning the Rust programming language syntax.

notes-on-rust Notes on learning the Rust programming language syntax. Resources https://www.rust-lang.org/learn/get-started https://doc.rust-lang.org/

Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting
Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting

Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting

Fast, minimal, feature-rich, extended formatting syntax for Rust!

Formatting Tools Fast, minimal, feature-rich, extended formatting syntax for Rust! Features include: Arbitrary expressions inside the formatting brace

A superset of PHP with extended syntax and runtime capabilities.

PXP PXP is a superset of the PHP programming language that provides an extended set of syntax rules and language features to improve developer experie

Rust regex in ECMAScript regular expression syntax!

ecma_regex The goal of ecma_regex is to provide the same functionality as the regex crate in ECMAScript regular expression syntax. Reliable regex engi

*slaps roof of [programming language]* this bad boy can fit so much [syntax sugar] into it

An attempt to give myself a new Pareto-optimal choice for quick-and-dirty scripts, particularly when I'm not on a dev computer, and to practice writin

βš™οΈ Pre-commit hook for downgrading Python logger syntax

printf-log-formatter Automatically convert f-strings and str.format() syntax to printf-style strings. In other words, this syntax logger.error(f"{1}")

Comments
  • spaces/tabs are eaten?

    spaces/tabs are eaten?

    It looks like leading spaces or tabs are removed

    Regular Open

    image

    Open with highlight

    Notice the use crate:: { part is left aligned. The entire file is like this. image

    opened by fdncred 0
Releases(v1.0.1)
Owner
Piepmatz
CS Student at CvO University Oldenburg
Piepmatz
A syntax-highlighting pager for git, diff, and grep output

Get Started Install delta and add this to your ~/.gitconfig: [core] pager = delta [interactive] diffFilter = delta --color-only [delta]

Dan Davison 16k Dec 31, 2022
🌴 Syntax highlighting in Rust.

?? HL (WIP) Syntax highlighting written in Rust. The project is designed to generate html syntax highlighting for the given file. This software is ins

ahmadrosid 8 Jun 28, 2022
Simple calculator REPL, similar to bc(1), with syntax highlighting and persistent history

eva simple calculator REPL, similar to bc(1), with syntax highlighting and persistent history installation Homebrew $ brew install eva crates.io $ car

Akshay 632 Jan 4, 2023
A standalone code editor with syntax highlighting and themes.

CodeEditor A standalone code (and text) editor for people like me who write their own user interfaces utilizing crates like pixels. CodeEditor renders

Markus Moenig 8 Nov 25, 2022
🏭 Convert Markdown documents into themed HTML pages with support for code syntax highlighting, LaTeX and Mermaid diagrams.

Marky Markdown Magician ?? Features Hot reload previewing ?? Conversion to HTML / PDF ?? Themes! ✨ Extensions - Math, diagrams, syntax-highlighting ??

Vadim 12 Feb 19, 2023
Nushell "extern" definitions for tab completion generated from Fish's

Nushell completions pack This is a system for generating extern defs (tab-completion) in nu. Background The fish shell project has a long, complicated

Scott Boggs 7 Feb 28, 2023
Count your code by tokens, types of syntax tree nodes, and patterns in the syntax tree. A tokei/scc/cloc alternative.

tcount (pronounced "tee-count") Count your code by tokens, types of syntax tree nodes, and patterns in the syntax tree. Quick Start Simply run tcount

Adam P. Regasz-Rethy 48 Dec 7, 2022
WIP. Goals: Treesitter highlighting, snippets, and a smooth intergration with neovim.

typst.nvim WIP. Goals: Tree-sitter highlighting, snippets, and a smooth integration with neovim. For the past week, I've been thinking what I want for

SeniorMars 66 Apr 9, 2023
A prolog like syntax for egg

egglog Using the egg library with a file format and semantics similar to datalog. Explanatory blog posts: https://www.philipzucker.com/egglog-checkpoi

Philip Zucker 40 Dec 1, 2022
Rust syntax in Turkish

pas pas (Turkish for Rust) allows to write Rust programs in Turkish, using Turkish keywords and function names, adapted from the original French imple

Barış Ekim 19 Dec 15, 2022