Nushell "extern" definitions for tab completion generated from Fish's

Overview

Nushell completions pack

This is a system for generating extern defs (tab-completion) in nu.

Background

The fish shell project has a long, complicated script for parsing man pages to gather completions definitions. Fortunately for us, Fish completions are defined in simple command line arguments, which we parse here and use to generate completions for Nu.

Installation and basic usage

  1. Download and optionally install this script. For a prebuilt binary, use cargo-binstall...

    cargo binstall nu-completion-script

    ...or if you don't have cargo-binstall, download the release from the releases page on Github.

    You may also build from source using cargo install, or cloning the repository and building with cargo install. See Development Process for instructions.

  2. Have fish installed.

  3. From a fish shell, run

    fish_update_completions
  4. Generate the nu definitions.

    nu-completions ~/.local/share/fish/generated_completions/*.fish
  5. Source the definitions

    nu-completions --install

Reporting bugs

If an error occurs, please run your command again with -vvvv, save the logs, and include them when submitting a Github Issue. For example, if an error occurs while running the above command to generate the definitions, run this command instead:

nu-completions -vvvv ~/.local/share/fish/generated_completions/*.fish | save log.json

And include the contents of log.json within a preformatted block, like this:

```json
{"level":30,"time":1677171831187,"msg":"beginning translation phase"}
{"level":30,"time":1677171831187,"msg":"processing file or directory","file":"../../../.local/share/fish/generated_completions/7z.fish"}
{"level":30,"time":1677171831187,"msg":"processing file","file":"../../../.local/share/fish/generated_completions/7z.fish"}
{"level":10,"time":1677171831187,"msg":"opened file for processing","file":"\"../../../.local/share/fish/generated_completions/7z.fish\""}

...

{"level":10,"time":1677171833182,"msg":"opened file for processing","file":"\"../../../.local/share/fish/generated_completions/java-openjdk8.fish\""}
{"level":50,"time":1677171833182,"msg":"error parsing shell words","line":"complete -c java-openjdk8 -o 'disablesystemassertions"}
{"level":50,"time":1677171833182,"msg":"failed to process completions at \"../../../.local/share/fish/generated_completions/java-openjdk8.fish\": missing closing quote"}
```

Development state

Since these definitions are auto-generated and incomplete, we need to modify the auto-generated output to provide additional application-specific functions to each definition. In order to provide a consistent workflow which smoothly (we hope) handles upstream man-page updates, these application-specific modifications take the form of a set of patches which are a part of this repository.

Development process

Note: These directions assume you're using Linux, and have git and cargo installed)

  1. Fork this repository
  2. Clone your fork and enter the directory
    git clone https://github.com/YOUR-GITHUB-USER/nu-completions.git
    cd nu-completions
  3. Compile the binary
    cargo build --release
    Alternatively, install the latest release's prebuilt binary (requires cargo-binstall)...
    cargo binstall nu-completion-script
    ...or if you don't have cargo-binstall, download the release from the releases page on Github.
  4. Have fish installed.
  5. From a fish shell, run
    fish_update_completions
  6. Generate the nu definitions.
    nu-completions ~/.local/share/fish/generated_completions/*.fish
  7. Make the changes you want to whichever of the generated files you want.
  8. Generate a patch (or patches) from your changes
    nu-completions --patch-dir=./patches patches generate ~/.local/share/fish/generated_completions/*.fish
  9. Commit your changes, push them to your fork, and follow the link in your console to submit a pull request for the changes.
You might also like...
Blazingly fast Rust CLI app to sync data from a folder of excel workbooks into generated c# code for unity usage
Blazingly fast Rust CLI app to sync data from a folder of excel workbooks into generated c# code for unity usage

Extensions supported ( .xls, .xlsx, .xlsm, .xlsb, .xla, .xlam, .ods ) Speed Test Image shows the results of 5000defs synced from 2 workbooks and 5 she

Evaluate LLM-generated COBOL

COBOLEval: LLM Evaluation for COBOL COBOLEval is a dataset to evaluate the code generation abilities of Large Language Models on the COBOL programming

Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

A library for extracting #[no_mangle] pub extern "C" functions (https://docs.rust-embedded.org/book/interoperability/rust-with-c.html#no_mangle)

A library for extracting #[no_mangle] pub extern "C" functions In order to expose a function with C binary interface for interoperability with other p

"Better" tab and stack navigation for Sway WM.

sway_bfocus "Better" tab and stack navigation for Sway WM. Proof of concept. This program lets you create one set of keybinds exclusively for cycling

Browser tab search provider for GNOME
Browser tab search provider for GNOME

What is this ? This is repository provides browser tab search provider for GNOME Screenshot Installation Installl all 3 components for tab search to w

Bioinformatics plugin for nushell.

Nushell bio A bioinformatics plugin for nushell. The aim initially is to create a bunch of parsers for all of the common bioinformatics file formats a

An i3/Sway utility to switch focus to your last focused window. Alt+Tab in i3

i3-back An i3/Sway utility to switch focus to your last focused window. Allows for behavior similar to Alt+Tab on other desktop environments. Features

🌈 A nushell plugin for syntax highlighting.

nu-plugin-highlight A nushell plugin for syntax highlighting. About nu-plugin-highlight is a plugin for Nushell that provides syntax highlighting for

A nushell plugin for scanning ports on a target.

nu_plugin_port_scan A nushell plugin for scanning ports on a target Similar to nc -vz {ip} {port} -w {timeout} the parameters are mapped to port scan

Rust Code Completion utility
Rust Code Completion utility

Racer - code completion for Rust RACER = Rust Auto-Complete-er. A utility intended to provide Rust code completion for editors and IDEs. Maybe one day

Rust On the FLY completion for neovim

rofl.nvim Rust On the FLy completion engine for Neovim. Why Rust? It's 2021. I think the question you should be asking yourself is "Why NOT Rust?!?? (

Auto-Complete is an intelligent auto-completion extension for Emacs.
Auto-Complete is an intelligent auto-completion extension for Emacs.

Auto-Complete is an intelligent auto-completion extension for Emacs. It extends the standard Emacs completion interface and provides an environment that allows users to concentrate more on their own work.

Emacs client for ycmd, the code completion system.

This package is currently unmaintained! If you want to take over maintenance, let me know in an issue. emacs-ycmd emacs-ycmd is a client for ycmd, the

A code-completion engine for Vim
A code-completion engine for Vim

YouCompleteMe: a code-completion engine for Vim Help, Advice, Support Looking for help, advice or support? Having problems getting YCM to work? First

call-me-maybe is a small CLI tool to notify you of the completion of a command

call-me-maybe call-me-maybe is a small CLI tool to notify you of the completion of a command By default, the tools consumes stdin for a message's cont

AskBend: SQL-based Knowledge Base Search and Completion using Databend

AskBend: SQL-based Knowledge Base Search and Completion using Databend AskBend is a Rust project that utilizes the power of Databend and OpenAI to cre

Easy protocol definitions in Rust

protocol Documentation Easy protocol definitions in Rust. This crate adds a custom derive that can be added to types, allowing structured data to be s

syntect is a syntax highlighting library for Rust that uses Sublime Text syntax definitions.
syntect is a syntax highlighting library for Rust that uses Sublime Text syntax definitions.

syntect is a syntax highlighting library for Rust that uses Sublime Text syntax definitions. It aims to be a good solution for any Rust project that needs syntax highlighting, including deep integration with text editors written in Rust.

Comments
  • by request, json log

    by request, json log

    From Discord conversation. I ran nu-completion-script -vvvv --no-convert | save log.json and this is the output.

    {"level":20,"time":1677508474347,"msg":"starting new connection: https://api.github.com/"}
    {"level":10,"time":1677508474426,"msg":"registering event source with poller: token=Token(0), interests=READABLE | WRITABLE"}
    {"level":10,"time":1677508474573,"msg":"signal: Want"}
    {"level":10,"time":1677508474573,"msg":"signal found waiting giver, notifying"}
    {"level":10,"time":1677508474573,"msg":"poll_want: taker wants!"}
    {"level":10,"time":1677508474781,"msg":"signal: Want"}
    {"level":10,"time":1677508474781,"msg":"signal found waiting giver, notifying"}
    {"level":10,"time":1677508474781,"msg":"signal: Want"}
    {"level":10,"time":1677508474781,"msg":"poll_want: taker wants!"}
    {"level":10,"time":1677508474781,"msg":"signal: Want"}
    {"level":20,"time":1677508474800,"msg":"starting new connection: https://github.com/"}
    {"level":10,"time":1677508474881,"msg":"registering event source with poller: token=Token(1), interests=READABLE | WRITABLE"}
    {"level":10,"time":1677508475026,"msg":"signal: Want"}
    {"level":10,"time":1677508475026,"msg":"signal found waiting giver, notifying"}
    {"level":10,"time":1677508475026,"msg":"poll_want: taker wants!"}
    {"level":10,"time":1677508475282,"msg":"signal: Want"}
    {"level":10,"time":1677508475282,"msg":"signal: Want"}
    {"level":20,"time":1677508475282,"msg":"redirecting 'https://github.com/dscottboggs/nu-completions/releases/download/v0.1.1/patches.tar.gz' to 'https://objects.githubusercontent.com/github-production-release-asset-2e65be/606793084/9c17e2df-ebc0-4201-86b4-15fed255f03d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230227%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230227T143435Z&X-Amz-Expires=300&X-Amz-Signature=cf228a7b1b809a564edf54db902df4202e97deca0cb6f5e24a9a241780b95130&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=606793084&response-content-disposition=attachment%3B%20filename%3Dpatches.tar.gz&response-content-type=application%2Foctet-stream'"}
    {"level":20,"time":1677508475282,"msg":"starting new connection: https://objects.githubusercontent.com/"}
    {"level":10,"time":1677508475351,"msg":"registering event source with poller: token=Token(2), interests=READABLE | WRITABLE"}
    {"level":10,"time":1677508475472,"msg":"signal: Want"}
    {"level":10,"time":1677508475472,"msg":"signal found waiting giver, notifying"}
    {"level":10,"time":1677508475472,"msg":"poll_want: taker wants!"}
    {"level":10,"time":1677508475791,"msg":"deregistering event source from poller"}
    {"level":10,"time":1677508475791,"msg":"signal: Closed"}
    {"level":10,"time":1677508475795,"msg":"signal: Want"}
    {"level":10,"time":1677508475795,"msg":"signal found waiting giver, notifying"}
    {"level":10,"time":1677508475795,"msg":"signal: Want"}
    {"level":10,"time":1677508475795,"msg":"poll_want: taker wants!"}
    {"level":10,"time":1677508475795,"msg":"deregistering event source from poller"}
    {"level":10,"time":1677508475796,"msg":"signal: Closed"}
    {"level":30,"time":1677508475798,"msg":"beginning patch phase"}
    {"level":30,"time":1677508475798,"msg":"finished patching"}
    {"level":10,"time":1677508475798,"msg":"deregistering event source from poller"}
    {"level":10,"time":1677508475799,"msg":"signal: Closed"}
    
    opened by fdncred 5
  • new issue / old issue

    new issue / old issue

    Seems to be failing

    nu-completion-script ~/.local/share/fish/generated_completions/*.fish                                                           18446  02:38:35 PM
    {"level":50,"time":1677616732945,"msg":"error parsing shell words","line":"complete -c aptitude-curses -l 'show-summary"}
    {"level":50,"time":1677616732945,"msg":"failed to process completions at \"../../.local/share/fish/generated_completions/aptitude-curses.fish\": missing closing quote"}
    {"level":50,"time":1677616732946,"msg":"error parsing shell words","line":"complete -c aptitude -l 'show-summary"}
    {"level":50,"time":1677616732946,"msg":"failed to process completions at \"../../.local/share/fish/generated_completions/aptitude.fish\": missing closing quote"}
    {"level":50,"time":1677616735843,"msg":"error patching","source":"/home/fdncred/.config/nushell/completions/definitions/capsh.nu","patch":"/home/fdncred/.config/nushell/completions/patches/capsh.patch","patch_output":"patching file /home/fdncred/.config/nushell/completions/definitions/capsh.nu\nHunk #1 FAILED at 39.\n1 out of 1 hunk FAILED -- saving rejects to file /home/fdncred/.config/nushell/completions/definitions/capsh.nu.rej\n","status":1}
    Error: process exited unsuccessfully: exit status: 1
    
    opened by fdncred 3
Releases(v0.1.3)
Owner
Scott Boggs
Scott Boggs
An i3/Sway utility to switch focus to your last focused window. Alt+Tab in i3

i3-back An i3/Sway utility to switch focus to your last focused window. Allows for behavior similar to Alt+Tab on other desktop environments. Features

Charles C 17 Mar 13, 2023
🌈 A nushell plugin for syntax highlighting.

nu-plugin-highlight A nushell plugin for syntax highlighting. About nu-plugin-highlight is a plugin for Nushell that provides syntax highlighting for

Piepmatz 4 Jun 29, 2023
Emacs client for ycmd, the code completion system.

This package is currently unmaintained! If you want to take over maintenance, let me know in an issue. emacs-ycmd emacs-ycmd is a client for ycmd, the

Austin Bingham 381 Dec 22, 2022
A code-completion engine for Vim

YouCompleteMe: a code-completion engine for Vim Help, Advice, Support Looking for help, advice or support? Having problems getting YCM to work? First

null 24.5k Dec 31, 2022
call-me-maybe is a small CLI tool to notify you of the completion of a command

call-me-maybe call-me-maybe is a small CLI tool to notify you of the completion of a command By default, the tools consumes stdin for a message's cont

Samuel Yvon 4 Sep 16, 2022
AskBend: SQL-based Knowledge Base Search and Completion using Databend

AskBend: SQL-based Knowledge Base Search and Completion using Databend AskBend is a Rust project that utilizes the power of Databend and OpenAI to cre

Databend Labs 87 Apr 7, 2023
A CLI tool for fetching Urban Dictionary definitions

udict - Urban Dictionary CLI A CLI tool for fetching Urban Dictionary definitions. Installation cargo cargo install udict Arch Linux Using an AUR pack

null 15 Nov 14, 2022
Code-shape is a tool for extracting definitions from source code files

Code-shape Code-shape is a tool that uses Tree-sitter to extract a shape of code definitions from a source code file. The tool uses the same language

Andrew Hlynskyi 3 Apr 21, 2023
Definitions from the Virtual I/O Device (VIRTIO) specification.

virtio-spec-rs This crate contains the Rust equivalents of the definitions from the Virtual I/O Device (VIRTIO) Specification. This crate aims to be u

Rust OSDev 12 Oct 13, 2024
A CLI tool to rename files to randomly generated strings.

rng-rename A CLI tool to rename files to randomly generated strings. Why? Suppose you downloaded a few hundred images to use as your desktop wallpaper

null 2 Feb 24, 2022