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...
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

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

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.

Parse BNF grammar definitions

bnf A library for parsing Backus–Naur form context-free grammars. What does a parsable BNF grammar look like? The following grammar from the Wikipedia

Interface definitions for the [email protected] platform in witx.

🔗 compute-at-edge-abi This repository contains witx definitions for the [email protected] platform ABI. About witx The witx file format is an experimental

The Safe Network Core. API message definitions, routing and nodes, client core api.

safe_network The Safe Network Core. API message definitions, routing and nodes, client core api. License This Safe Network repository is licensed unde

Experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code

Diplomat is an experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code. With Diplomat, you can simply define Rust APIs to be exposed over FFI and get high-level C, C++, and JavaScript bindings automatically!

AVR device definitions

avrd AVR device definitons in Rust. Documentation This crate exposes information about different AVR microcontrollers so it can be used pragmatically.

Rust definitions corresponding to jni.h.

jni-sys Documentation Rust definitions corresponding to jni.h. License Licensed under either of Apache License, Version 2.0, (LICENSE-APACHE or http:/

A library for generating TypeScript definitions from rust code.

Tsify is a library for generating TypeScript definitions from rust code. Using this with wasm-bindgen will automatically output the types to .d.

A CLI tool for fetching Urban Dictionary definitions
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

Merge multiple Juniper object definitions into a single object type.

juniper-compose Merge multiple Juniper object definitions into a single object type. crates.io | docs | github Motivation You are building a GraphQL s

Generated Ryst of Apache Arrow spec

Arrow generated IPC format The generated flatbuffers code for Rust. Note that these files suffered modifications because flatbuffers is unable to comp

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
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
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
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
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

null 4 Feb 16, 2023
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

null 294 Dec 23, 2022
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

Dmitrii - Demenev 0 Feb 17, 2022
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

Max Brown 7 Jan 8, 2023
"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

null 42 Oct 23, 2022