Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions custom-completions/uv/uv-completions.nu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# nu-version: 0.102.0
# nu-version: 0.106.0

# This script was created by dumping the output of `uv generate-shell-completion` and adding more completers.

Expand Down Expand Up @@ -92,7 +92,7 @@ module completions {

def get-groups []: nothing -> list<string> {
let file = (find-pyproject-file)
try { open $file | get -i dependency-groups | columns } catch { [] }
try { open $file | get -o dependency-groups | columns } catch { [] }
}

# Groups completer for subcommands
Expand All @@ -115,20 +115,20 @@ module completions {
# Get packages from "project.dependencies"
def get-main-packages [] {
let file = (find-pyproject-file)
try { open $file | get -i project.dependencies | parse-package-names } catch { [] }
try { open $file | get -o project.dependencies | parse-package-names } catch { [] }
}

# Get packages from "project.optional-dependencies"
def get-optional-packages [] {
let file = (find-pyproject-file)
try { open $file | get -i project.optional-dependencies | parse-package-names } catch { [] }
try { open $file | get -o project.optional-dependencies | parse-package-names } catch { [] }
}

# Get packages from "dependency-groups".
# Ref: https://packaging.python.org/en/latest/specifications/dependency-groups/#dependency-groups
def get-dependency-group-packages [only_group?: string] {
let file = (find-pyproject-file)
let dg = try { open $file | get -i dependency-groups } catch { [] }
let dg = try { open $file | get -o dependency-groups } catch { [] }
# One group can include other groups, like:
# dev = ['click', { include-group = "docs" }, { include-group = "linting" }, { include-group = "test" }]
let handle_line = {|p| if (($p | describe) == 'string') { $p } else { $dg | get ($p.include-group) } }
Expand All @@ -147,8 +147,8 @@ module completions {
let preceding = $context | str substring ..$position
let prev_tokens = $preceding | str trim | args-split
# Check if "--group" is specified
let go = $prev_tokens | enumerate | find '--group' | get -i index.0
let group = if ($go | is-not-empty) { $prev_tokens | get -i ($go + 1)}
let go = $prev_tokens | enumerate | find '--group' | get -o index.0
let group = if ($go | is-not-empty) { $prev_tokens | get -o ($go + 1)}
if ($group | is-empty ) {
get-all-dependencies
} else {
Expand Down