Skip to content

Unified Completions - #18791

Merged
kronberger-droid merged 40 commits into
nushell:mainfrom
philocalyst:unified
Sep 9, 2026
Merged

kronberger-droid merged 40 commits into
nushell:mainfrom
philocalyst:unified

Conversation

@philocalyst

@philocalyst philocalyst commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Completion inputs, output contracts, and interactive completers

This PR unifies how parameter completers, command-wide completers, external completers, and menu sources receive completion state and return suggestions !!!

It also adds an explicit @interactive attribute for completers that need the terminal, such as fzf or input list.

What changes

Previously, custom completion entry points used incompatible calling conventions:

Where Previous input
Parameter completer [context, offset]
Command-wide completer [spans]
External completer {|spans| ...}
Menu source {|buffer, position| ...}

Each completer had to decide how to interpret its input, reconstruct context when it needed more information, and often call commandline to retrieve editor state.

Now all custom completion entry points use the same named inputs:

  • token: the token at the cursor.
  • place: the resolved completion site and replacement range.
  • buffer: the original command line up to the cursor.

This applies to:

  • Parameter completers: arg: string@completer
  • Command-wide completers: @complete completer
  • External completers: $env.config.completions.external.completer
  • Menu sources: source: {|token| ...}

Completion inputs

A completer declares the information it needs by naming positional parameters. This is not record destructuring: the completion engine binds the declared names directly.

def complete-file [token: record] {
  $token.text
}

def complete-at-place [place: record] {
  if $place.kind == "flag-value" {
    [main dev release]
  }
}

def complete-from-buffer [buffer: string] {
  $buffer | split row " "
}

The recognized input names are token, place, and buffer. They may be declared in any order. An unrecognized positional name receives nothing and emits a diagnostic in the completion log.

token

token is the semantic token being completed:

{
  text: "mai"
  kind: "value"
  span: {start: 3, end: 6}
}

Its fields are:

Field Type Meaning
text string Text of the current token, or "" for a fresh empty argument slot.
kind string head, flag, value, or block.
span {start: int, end: int} or nothing Byte range of the token in buffer. Alias-expanded tokens do not have a source span.

A cursor after a space still has a token: an empty value token whose span starts and ends at the cursor. This means normal completion still works for a fresh argument slot.

place

place describes what Nushell is completing and what text a selected suggestion replaces:

{
  cursor: 11
  target: {start: 9, end: 11}
  kind: "positional"
  index: 0
  shape: "string"
}

Its common fields are:

Field Type Meaning
cursor int Byte offset of the cursor in buffer.
target {start: int, end: int} Byte range that a suggestion replaces.
kind string Resolved completion site: command, flag-name, flag-value, or positional, when applicable.
flag string Present for a flag value.
index int Present for a positional argument.
shape string Declared syntax shape of the value being completed, when known.

Use place.target rather than token.span when returning a custom span. They differ for completion sites that cover more than one token, such as a multi-word command head or a cell path.

buffer

buffer is the exact command-line text from the beginning of the line through the cursor:

"git checkout mai"

It includes text before pipes, inside closures, and after control-flow separators. It intentionally preserves what the user typed rather than reconstructing text from parser output.

This is the input for completers that need the whole line, such as Carapace:

$env.config.completions.external.completer = {|buffer|
  let words = $buffer | split row " "
  carapace ($words | first) nushell ...$words | from json
}

Use buffer instead of calling commandline from inside a completer. buffer always represents the line currently being completed; commandline can be empty in some editor states, including after ;.

For completers that want a normalized parser view, std structure converts a buffer into {text, kind, span} rows while removing duplicate parser spans:

use std/util

def complete-from-structure [buffer: string] {
  util structure $buffer
}

std structure is useful for completion logic, but it remains a parsed view. Use buffer whenever exact source text matters.

Inspecting completion state

commandline complete --input returns all three inputs without running a custom completer:

'git checkout mai' | commandline complete --input
{
  token: {text: mai, kind: value, span: {start: 13, end: 16}}
  place: {
    cursor: 16
    target: {start: 13, end: 16}
    kind: positional
    index: 0
    shape: string
  }
  buffer: "git checkout mai"
}

This is the supported way to develop and debug a completer. It also works for an @interactive completer, which cannot run outside the line editor.

commandline complete additionally gains:

  • --detailed: return suggestions in the custom-completer output format.
  • --type directory|path|glob|command|variable|env-var: run one built-in source, useful when composing built-in and custom completions.
  • --input: inspect completion inputs instead of producing suggestions. It cannot be combined with --detailed or --type.

For example, a command completer can add its own result beside Nushell’s command-name completion:

def complete-command [token: record] {
  [my-shortcut] ++ ($token.text | commandline complete --type command)
}

Attaching completers

A parameter completer is attached to a signature parameter:

def complete-branch [token: record] {
  git branch --format '%(refname:short)' | lines
}

def checkout [branch: string@complete-branch] {
  git checkout $branch
}

A command-wide completer covers every argument and flag position of a command:

def complete-foo [token: record] {
  [bar baz qux] | where $it != $token.text
}

@complete complete-foo
def foo [...args] {}

An internal wrapper can opt into the configured external completer:

@complete external
def --wrapped jc [...args] {
  ^jc ...$args | from json
}

Aliases resolve through to their completion command, including whether that command is interactive.

Completer output

A completer may return:

  • null to decline and let the next completion source run;
  • a list of strings;
  • a list of suggestion records;
  • one suggestion record;
  • an envelope record with completions, options, and fallback.

The smallest useful completer returns strings:

def complete-colour [token: record] {
  [red green blue]
}

A suggestion record can control insertion and display:

def complete-branch [token: record] {
  [
    {
      value: main
      description: "default branch"
      kind: "value"
      append_whitespace: true
    }
    {
      value: release
      description: "release branch"
      style: "yellow"
    }
  ]
}

Supported suggestion fields are:

Field Meaning
value Text inserted into the command line.
display_override Text shown in the menu instead of value.
description Secondary menu text.
kind value, command, cell-path, directory, file, flag, module, operator, or variable.
style A colour name or Nushell colour record.
span Optional {start, end} replacement override. Either end may be omitted.
extra Extra menu columns.
append_whitespace Whether to add a trailing space.
match_indices Character indices to highlight.

The envelope form controls filtering and source chaining:

def complete-preset [token: record] {
  {
    completions: [
      {value: main, description: "default branch"}
      {value: release, description: "release branch"}
    ]
    options: {
      filter: true
      completion_algorithm: "substring"
      match_description: true
    }
    fallback: true
  }
}

options supports:

  • filter
  • sort
  • case_sensitive
  • match_description
  • completion_algorithm
  • deprecated positional

Parameter completers are filtered by default. Command-wide and external completers are not, because they commonly perform their own filtering. Set options.filter explicitly when a completer needs the other behavior.

fallback: true keeps this completer’s results and continues to the next source, allowing custom results to appear beside built-in file completion or another completer.

Malformed output is isolated where possible. A malformed suggestion, style, span, or option is reported in the completion log without discarding unrelated valid suggestions.

Interactive completers

Ordinary completers run on a background worker. They are non-blocking and have stdin suppressed, which is correct for normal completion but prevents terminal-owning commands from working.

Use @interactive for a completer that needs the terminal:

@interactive
def pick-file [token: record] {
  ls | get name | to text | ^fzf --query $token.text | lines
}

def open-file [path: string@pick-file] {
  open $path
}

When completing open-file <Tab>, pick-file runs inline on the line-editor thread with stdin and the terminal available. The picker blocks the editor while it is open, then returns its selection as normal suggestions.

@interactive changes execution placement only. It does not attach a completer to a command, and calling pick-file directly is not the intended test because a completer receives its input from the completion engine.

External completers are closures and cannot carry an attribute themselves. To make one interactive, have the closure call an @interactive command:

@interactive
def carapace-fzf [buffer: string] {
  let words = $buffer | split row ' '
  carapace ($words | first) nushell ...$words | from json | ^fzf | lines
}

$env.config.completions.external.completer = {|buffer|
  carapace-fzf $buffer
}

The completion engine recognizes that dispatch and runs it inline. A plain external-completer closure remains on the background worker.

Behaviour changes

  • The experimental global background-completions option is removed. @interactive is the per-completer replacement.
  • Parameter completers that fail return no suggestions instead of unexpectedly falling back to the working directory.
  • Command-wide and external completers may decline with null, allowing file completion or another source to answer.
  • Completion state is resolved at the cursor, including nested closures, aliases, multi-word command heads, flag values, and empty argument slots.
  • Completion input and output handling is shared by parameter completers, command-wide completers, external completers, and menu sources.
  • Completion work avoids cloning the full engine and stack for every keystroke.

Migration

Previous form New form
def comp [input pos] { ... } def comp [token: record] { $token.text | ... }
def comp [spans] { ... } def comp [buffer: string] { $buffer | split row " " | ... } when whole-line input is needed
{ |spans| ... } external completer { |buffer: string| ... }
{ |buffer position| ... } menu source { |token: record| ... }, { |place: record| ... }, or { |buffer: string| ... }
Global background-completion opt-out @interactive on the terminal-owning completion command

User-facing changes (Release notes)

::: warning
This needs a proper changelog entry.
:::

@github-actions github-actions Bot added the A:LSP Language Server Protocol (nu-lsp) label Aug 5, 2026
Comment thread crates/nu-lsp/src/completion.rs Resolved
@kronberger-droid

Copy link
Copy Markdown
Contributor

@philocalyst
Can you ping me if this is worth taking a closer look, I think that one is really important now.

Also how much work on completions do you think we will have to do in reedline still? Just out of interest. Do you have any plans?

@philocalyst

Copy link
Copy Markdown
Contributor Author

Hey! Yeah, I just need to update the description here, but this is basically ready for review.

My thoughts on where to go with completions needs more thought on what people/core-team think the scope of nushell should be, so I'll try to file an issue on the landscape as I see it, and then we can work from there!

@kronberger-droid

Copy link
Copy Markdown
Contributor

Sounds good, thanks!

@fdncred

fdncred commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

it would be great to have a green ci

@fdncred

fdncred commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Does #18879 still work?

@philocalyst

philocalyst commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor Author

CI Should be green and the description is updated!

Basically I removed the opt out and just replaced it with an attr, and did some kind of low-key overloading so you can easily opt-in to full context if you're say, carapace. Idk if overloading is common, but I wanted to avoid @interactive AND @full or whatever it could have been

@philocalyst
philocalyst marked this pull request as ready for review August 24, 2026 19:50
@philocalyst

Copy link
Copy Markdown
Contributor Author

@blindFS I'd love your thoughts honestly

@blindFS

blindFS commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@blindFS I'd love your thoughts honestly

TBH, I think what you wrote in the description looks good. But so many new stuff that I have trouble understanding the code. I can't give you any suggestion about the implementation details. Maybe AI agents can help.

Hopefully you can keep maintaining this part in the future. Thanks in advance and wish you good luck.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Unifies custom completer inputs, output validation, menu integration, and interactive execution.

Changes:

  • Adds unified {token, place} / {contexts, place} inputs.
  • Adds @interactive and removes the global background option.
  • Expands validation, documentation, and completion tests.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
typos.toml Ignores intentional test misspellings.
tests/repl/test_commandline.rs Tests unified input inspection.
tests/fixtures/lsp/completion/custom.nu Updates LSP fixture API.
tests/fixtures/lsp/completion/command.nu Updates command-wide fixture.
crates/nu-lsp/src/completion.rs Uses borrowed completion state.
crates/nu-explore/src/explore_config/example_data.rs Migrates menu examples.
crates/nu-experimental/src/options/mod.rs Removes background option registration.
crates/nu-experimental/src/options/background_completions.rs Removes obsolete option.
crates/nu-config/default_files/doc_config.nu Documents unified completers.
crates/nu-cmd-lang/src/default_context.rs Registers @interactive.
crates/nu-cmd-lang/src/core_commands/attr/mod.rs Exports interactive attribute.
crates/nu-cmd-lang/src/core_commands/attr/interactive.rs Implements @interactive.
crates/nu-cmd-lang/src/core_commands/attr/complete.rs Updates completion example.
crates/nu-cli/tests/completions/mod.rs Expands completion coverage.
crates/nu-cli/src/util.rs Removes terminal guard.
crates/nu-cli/src/repl.rs Uses cache-backed completer.
crates/nu-cli/src/menus/menu_completions.rs Unifies menu completion handling.
crates/nu-cli/src/completions/mod.rs Exports new completion components.
crates/nu-cli/src/completions/custom_completions/output.rs Parses and validates outputs.
crates/nu-cli/src/completions/custom_completions/mod.rs Implements shared user completers.
crates/nu-cli/src/completions/custom_completions/input.rs Builds unified input records.
crates/nu-cli/src/completions/custom_completions.rs Removes legacy implementation.
crates/nu-cli/src/completions/completion_common.rs Prevents subtraction underflow.
crates/nu-cli/src/completions/completer.rs Refactors dispatch, caching, and threading.
crates/nu-cli/src/completions/arg_value_completion.rs Reuses unified context.
crates/nu-cli/src/commands/commandline/complete.rs Adds input inspection flags.
Suppressed comments (7)

crates/nu-explore/src/explore_config/example_data.rs:723

  • input is not a recognized unified-input field name, so it is bound to nothing and $input.text errors. Rename this positional to token and read its text field.
      "source": "{|input|\n        let buffer = $input.text\n        open $nu.history-path | get history.command_line | to text\n        | fzf -f $buffer\n        | lines\n        | each {|v| {value: ($v | str trim)} }\n      }"

crates/nu-explore/src/explore_config/example_data.rs:741

  • input is not a recognized unified-input field name, so it is bound to nothing and $input.text errors. Rename this positional to token and read its text field.
      "source": "{|input|\n        let buffer = $input.text\n        ls $env.PWD | where type == dir\n        | sort-by name | get name | to text\n        | fzf -f $buffer\n        | each {|v| {value: ($v | str trim)} }\n      }"

crates/nu-explore/src/explore_config/example_data.rs:758

  • input is not a recognized unified-input field name, so it is bound to nothing and $input.text errors. Rename this positional to token and read its text field.
      "source": "{|input|\n        let buffer = $input.text\n        scope commands\n        | where name =~ $buffer\n        | each {|it| {value: $it.name description: $it.usage} }\n      }"

crates/nu-explore/src/explore_config/example_data.rs:773

  • input is not a recognized unified-input field name, so it is bound to nothing and $input.text errors. Rename this positional to token and read its text field.
      "source": "{|input|\n        let buffer = $input.text\n        scope variables\n        | where name =~ $buffer\n        | sort-by name\n        | each {|it| {value: $it.name description: $it.type} }\n      }"

crates/nu-explore/src/explore_config/example_data.rs:792

  • input is not a recognized unified-input field name, so it is bound to nothing and $input.text errors. Rename this positional to token and read its text field.
      "source": "{|input|\n        let buffer = $input.text\n        scope commands\n        | where name =~ $buffer\n        | each {|it| {value: $it.name description: $it.usage} }\n      }"

crates/nu-explore/src/explore_config/example_data.rs:809

  • input is not a recognized unified-input field name, so it is bound to nothing and $input.text errors. Rename this positional to token and read its text field.
      "source": "{|input|\n        let buffer = $input.text\n        scope aliases\n        | where name == $buffer\n        | each {|it| {value: $it.expansion} }\n      }"

crates/nu-explore/src/explore_config/example_data.rs:824

  • input is not a recognized unified-input field name, so it is bound to nothing and $input.text errors. Rename this positional to token and read its text field.
      "source": "{|input|\n        let buffer = $input.text\n        history -l\n        | where session_id == (history session)\n        | select command\n        | where command =~ $buffer\n        | each {|it| {value: $it.command} }\n        | reverse\n        | uniq\n      }"

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown

Hey, just a bot checking in! You edited files related to the configuration.
If you changed any of the default values or added a new config option, don't forget to update the doc_config.nu which documents the options for our users including the defaults provided by the Rust implementation.
If you didn't make a change here, you can just ignore me.

@philocalyst

Copy link
Copy Markdown
Contributor Author

Fixed all of the review comments, the files i modified related to configuration are fixes towards the new API

@fdncred fdncred added the notes:breaking-changes Noted in Breaking Changes section label Aug 25, 2026
@fdncred

fdncred commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

@philocalyst help me understand how to get your example working. I put it in a file and sourced it and it gives errors.

@interactive
def pick-file [token] { ls | get name | to text | ^fzf --query $token.text }
~/src/nushell> source f-test.nu
~/src/nushell> pick-file c
Error: nu::shell::incompatible_path_access

  × Data cannot be accessed with a cell path
   ╭─[/Users/fdncred/src/nushell/f-test.nu:2:71]
 1 │ @interactive
 2 │ def pick-file [token] { ls | get name | to text | ^fzf --query $token.text }
   ·                                                                       ──┬─
   ·                                                                         ╰── string doesn't support cell paths
 3 │
   ╰────

I then tried the demo.nu file from #18879 with @interactive added and can't get it to work either.

# launch with
# nu --no-config-file --execute 'source demo.nu'
#
@interactive
export def generate-candidates [--fuzzy(-f), tokens: list<string>, ] {
    let pattern = $tokens | skip 1 | last
    let candidates = ls | where name has $pattern | get name
    if ($candidates | length) <= 1 or not $fuzzy {
        $candidates
    } else {
      # $candidates | input list --fuzzy | default $pattern | [$in]
        $candidates | to text | ^fzf --reverse | lines | default --empty [$pattern]  # <--- FZF
    }
}

const fuzzy = true

$env.config.show_banner = false
$env.config.completions.external.completer = {|tokens|
    generate-candidates --fuzzy=$fuzzy $tokens
}

export def tokenize [buffer: string, cursor: number] {
    let prefix = $buffer | str substring ..<$cursor
    let parsed = ast --flatten $prefix
    if $parsed != [] and ($parsed | last).span.end < ($prefix | str length) {
        $parsed.content ++ ['']
    } else {
        $parsed.content
    }
}

$env.config.keybindings ++= [
    {
        name: demo-keybinding
        modifier: control
        keycode: char_t
        mode: [emacs vi_insert vi_normal]
        event: {
            until: [
                {send: Menu, name: demo-menu}
                {send: MenuNext}
                {edit: Complete}
            ]
        }
    }
]
$env.config.menus ++= [
    {
        name: demo-menu
        marker: '| '
        only_buffer_difference: false
        type: { layout: columnar }
        style: {}
        source: {|buffer, cursor|
            let tokens = tokenize $buffer $cursor
            let span = {start: ($cursor - ($tokens | last | str length)), end: $cursor}
            generate-candidates --fuzzy=$fuzzy $tokens
            | wrap value
            | insert span $span
        }
    }
]

I'd also like to get the nushell script working that is generated from fzf.

fzf --nushell | save -f ($nu.default-config-dir | path join "autoload" "_fzf_integration.nu")

@philocalyst

Copy link
Copy Markdown
Contributor Author

Should be solid, now?

@philocalyst

philocalyst commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Oh shoot wanted to clarify, it should look like below:

export def generate-candidates [--fuzzy(-f), tokens: list<string>] {
      let pattern = $tokens | skip 1 | last
      let candidates = ls | where name has $pattern | get name

      if ($candidates | length) <= 1 or not $fuzzy {
          $candidates
      } else {
          # $candidates | input list --fuzzy | default $pattern | [$in]
          $candidates | to text | ^fzf --reverse | lines | default --empty [$pattern]
      }
  }

  const fuzzy = true

  $env.config.show_banner = false

  $env.config.completions.external.completer = {
      closure: {|contexts|
          generate-candidates --fuzzy=$fuzzy ($contexts.tokens | get text)
      }
      interactive: true
  }

  export def tokenize [buffer: string, cursor: number] {
      let prefix = $buffer | str substring ..<$cursor
      let parsed = ast --flatten $prefix

      if $parsed != [] and ($parsed | last).span.end < ($prefix | str length) {
          $parsed.content ++ ['']
      } else {
          $parsed.content
      }
  }

  $env.config.keybindings ++= [
      {
          name: demo-keybinding
          modifier: control
          keycode: char_t
          mode: [emacs vi_insert vi_normal]
          event: {
              until: [
                  {send: Menu, name: demo-menu}
                  {send: MenuNext}
                  {edit: Complete}
              ]
          }
      }
  ]

  $env.config.menus ++= [
      {
          name: demo-menu
          marker: '| '
          only_buffer_difference: false
          type: { layout: columnar }
          style: {}
          source: {|buffer, cursor|
              let tokens = tokenize $buffer $cursor
              let span = {
                  start: ($cursor - ($tokens | last | str length))
                  end: $cursor
              }

              generate-candidates --fuzzy=$fuzzy $tokens
              | wrap value
              | insert span $span
          }
      }
  ]

@philocalyst

philocalyst commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor Author

And I see/recognize

$env.config.completions.external.completer = {
      closure: {|contexts|
          generate-candidates --fuzzy=$fuzzy ($contexts.tokens | get text)
      }
      interactive: true
  }

is a bit boilerplatey, the cleaner solution would be to have attribute support on closures, but that's not a reality right now. there are other approaches, as well, maybe external.interactive_completor = CLOSURE ?

@philocalyst philocalyst changed the title Unified Unified Completions Aug 26, 2026
@philocalyst
philocalyst force-pushed the unified branch 2 times, most recently from 1b2528e to 186fcc2 Compare August 27, 2026 13:45
@fdncred

fdncred commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Oh shoot wanted to clarify, it should look like below:

export def generate-candidates [--fuzzy(-f), tokens: list<string>] {
      let pattern = $tokens | skip 1 | last
      let candidates = ls | where name has $pattern | get name

      if ($candidates | length) <= 1 or not $fuzzy {
          $candidates
      } else {
          # $candidates | input list --fuzzy | default $pattern | [$in]
          $candidates | to text | ^fzf --reverse | lines | default --empty [$pattern]
      }
  }

  const fuzzy = true

  $env.config.show_banner = false

  $env.config.completions.external.completer = {
      closure: {|contexts|
          generate-candidates --fuzzy=$fuzzy ($contexts.tokens | get text)
      }
      interactive: true
  }

  export def tokenize [buffer: string, cursor: number] {
      let prefix = $buffer | str substring ..<$cursor
      let parsed = ast --flatten $prefix

      if $parsed != [] and ($parsed | last).span.end < ($prefix | str length) {
          $parsed.content ++ ['']
      } else {
          $parsed.content
      }
  }

  $env.config.keybindings ++= [
      {
          name: demo-keybinding
          modifier: control
          keycode: char_t
          mode: [emacs vi_insert vi_normal]
          event: {
              until: [
                  {send: Menu, name: demo-menu}
                  {send: MenuNext}
                  {edit: Complete}
              ]
          }
      }
  ]

  $env.config.menus ++= [
      {
          name: demo-menu
          marker: '| '
          only_buffer_difference: false
          type: { layout: columnar }
          style: {}
          source: {|buffer, cursor|
              let tokens = tokenize $buffer $cursor
              let span = {
                  start: ($cursor - ($tokens | last | str length))
                  end: $cursor
              }

              generate-candidates --fuzzy=$fuzzy $tokens
              | wrap value
              | insert span $span
          }
      }
  ]

I don't understand the point of @interactive if we don't use it in situations like this? From the descriptions, "A completer that needs to drive the TTY — fzf, input list, any picker — gets a new @Interactive attribute."

And I get this error message with it.

cargo r -- --no-config-file --execute 'source demo2.nu'
    Finished [`dev` profile [unoptimized + debuginfo]](https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles) target(s) in 0.87s
     Running `target/debug/nu --no-config-file --execute 'source demo2.nu'`
Error: nu::shell::invalid_config

  × Encountered 1 error(s) when updating config

Error: nu::shell::type_mismatch

  × Type mismatch at $env.config.completions.external.completer
    ╭─[/Users/fdncred/src/nushell/demo2.nu:17:48]
 16 │
 17 │ ╭─▶   $env.config.completions.external.completer = {
 18 │ │         closure: {|contexts|
 19 │ │             generate-candidates --fuzzy=$fuzzy ($contexts.tokens | get text)
 20 │ │         }
 21 │ │         interactive: true
 22 │ ├─▶   }
    · ╰──── expected closure or nothing, but got record<closure: closure, interactive: bool>
 23 │
    ╰────
  help: Check the value assigned to $env.config.completions.external.completer. Expected type: closure or nothing, found: record<closure:
        closure, interactive: bool>.

I'm beginning to think that I'm doing something wrong. I can't get the pick-file example to work either.

❯ source f-test.nu
❯ pick-file c
Error: nu::shell::incompatible_path_access

  × Data cannot be accessed with a cell path
   ╭─[/Users/fdncred/src/nushell/f-test.nu:2:71]
 1 │ @interactive
 2 │ def pick-file [token] { ls | get name | to text | ^fzf --query $token.text }
   ·                                                                       ──┬─
   ·                                                                         ╰── string doesn't support cell paths
 3 │
   ╰────

I confirmed that I'm on 186fcc2 so I'm not sure what is going on.

@kronberger-droid

Copy link
Copy Markdown
Contributor

I will get some time to test it out now maybe i find out whats wrong.

@philocalyst

philocalyst commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor Author
Screen.Recording.2026-08-28.at.11.43.10.mov
  @interactive
  def fzf-files [token: record] {
      let query = $token.text
      let choices = ls | where name has $query | get name

      if ($choices | length) <= 1 {
          $choices
      } else {
          $choices | to text | ^fzf --reverse --query $query | lines
      }
  }

  $env.config.completions.external.completer = {|token| fzf-files $token }

Works exactly with that configuration!

@philocalyst

Copy link
Copy Markdown
Contributor Author

All resolved!

@fdncred

fdncred commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thanks @philocalyst !!

@kronberger-droid

Copy link
Copy Markdown
Contributor

Tested the 2,6,7 from the HackMD again, they now all work as expected now.

@kronberger-droid
kronberger-droid merged commit b263714 into nushell:main Sep 9, 2026
15 checks passed
@github-actions github-actions Bot added this to the v0.116.0 milestone Sep 9, 2026
@philocalyst

Copy link
Copy Markdown
Contributor Author

woot !

@fdncred

fdncred commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Nice job all who participated!

max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Sep 27, 2026
…input is deprecated (#4297)

Nushell
[0.116.0](https://github.com/nushell/nushell/releases/tag/0.116.0)
(released 2026-09-26) binds custom completer inputs by parameter name
([nushell/nushell#18791](nushell/nushell#18791)).
Our completer's parameter is still named `spans`, the old name, so
sourcing the `wt` integration on 0.116 prints a multi-line
`nu::shell::deprecated` warning ("Positional completer input
deprecated") at every shell startup. Completions still work, but only
through a compatibility bridge that Nushell says will be removed in a
future release. After that, the completer would receive `nothing` and
`wt` tab completion would stop working.

This PR renames the parameter to `place`, the name Nushell's migration
table suggests. On 0.116, `place` is a record whose `command` field
holds the same token list `spans` used to. On older versions the
argument is still the plain spans list, because they pass it
positionally regardless of the parameter's name. The completer checks
which of the two it received, so a single template works on both.

Tested by generating the integration (`wt config shell init nu`) from
this branch and running `commandline complete` against it on Nushell
0.115.1 and 0.116.0:

- Neither version prints a warning. On main, 0.116.0 prints it.
- Both versions give identical results for `wt ` (subcommands), `wt
switch ` (branches), and `wt config sh` (→ `shell`, `show`). These match
what the `spans` version returns today.
- Integration tests matching `nu`/`completion`/`git_error_display` under
`--features shell-integration-tests` give the same results on both
versions. The only two failures are fish `config show` snapshots, which
fail identically on unmodified main in this sandbox.

The `init_nu` snapshot changes to match the template. The CI Nushell pin
bump to 0.116.0 is in a separate PR and doesn't depend on this one.

Co-authored-by: worktrunk-bot <[email protected]>
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Sep 27, 2026
Weekly CI pin bump: Nushell `0.115.1` → `0.116.0`, the latest
[`nushell/nushell`
release](https://github.com/nushell/nushell/releases/tag/0.116.0)
(published 2026-09-26).

Seven sites move together:

- the five `hustcer/setup-nu` inputs: `coverage.yaml`,
`benchmarks.yaml`, `nightly.yaml`, and
`.github/actions/{test,tend}-setup/action.yaml`
- `NU_VERSION` in `.codex/cloud.sh`, which the weekly checklist keeps
level with `test-setup`
- `NU_VERSION` in `Taskfile.yaml`'s `setup-web`

The `nu-0.116.0-x86_64-unknown-linux-gnu.tar.gz` asset that `cloud.sh`
and `setup-web` download is published on the release.

This is in its own PR because Nushell's version moves PTY snapshots
under `--all-features`, and this PR's CI is the only place the bump is
tested on macOS and Windows.

The release's one breaking change that touches this repo is the unified
completer input
([nushell/nushell#18791](nushell/nushell#18791)).
`templates/nushell.nu` already handles it: #4297 moved the completer to
the new `place` input, so 0.116 no longer warns when the integration is
sourced. Locally, with 0.116.0 on `PATH`, the `shell` integration-test
subset gives the same results as with 0.115.1: 193 passed, and the same
16 failures, which are sandbox-environment snapshot failures present on
main.

Co-authored-by: worktrunk-bot <[email protected]>
fdncred pushed a commit to nushell/nushell.github.io that referenced this pull request Sep 27, 2026
fdncred pushed a commit that referenced this pull request Oct 1, 2026
…close and reopen (#19129)

## Description

Since #18791 every completion menu closes as soon as the typed text
matches nothing, with `persistent_menus` on too (#19096).
`SourcedMenu::abandon_if_empty` closes on any settled empty answer, and
#18791 wrapped the default columnar and ide menus in it as well.
The abandon exists for cancelled pickers: an `@interactive` completer or
menu source cancelled with Esc answers empty, and an open empty menu
would relaunch it on the next keystroke.
A cancelled picker is always the first answer after activation though,
while typing past all matches comes after the menu has shown values.
So `SourcedMenu` now remembers whether it has shown values since the
last `Activate`, and only abandons when the first answer is empty.

Testing the picker path turned up two older bugs, both also on `main`:
- **Stray indicator.** With `quick` off, the opening
`can_partially_complete` probe is the first fetch, but the wrapper
skipped the abandon check there. The menu only closed on the next
repaint, after the prompt had drawn its indicator, so a `| ` stayed
until the next keypress. The probe now checks too; a probe that fetched
nothing is still covered by `is_awaiting_first_answer`.
- **Picker would not reopen.** `NuCompleter` kept the cancelled picker's
empty answer in `latest`, so Tab on the same line served it again
instead of running the picker. Interactive answers are now kept only
when non-empty, which still dedupes the repeated asks of one keystroke.

## User-facing changes (Release notes)
### Completion menus stay open when nothing matches

An open completion menu no longer closes when the typed text stops
matching.
It shows `NO RECORDS FOUND` and fills again once the text matches, as it
did before 0.116.
Cancelling an `@interactive` picker with Esc now closes its menu right
away, and Tab on the same line opens the picker again.

## Additional notes

fixes #19096
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:LSP Language Server Protocol (nu-lsp) notes:breaking-changes Noted in Breaking Changes section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants