diff --git a/modules/coloring/24bit-1.nu b/modules/coloring/24bit-1.nu index b99a8ad0c..a4d598e7e 100644 --- a/modules/coloring/24bit-1.nu +++ b/modules/coloring/24bit-1.nu @@ -34,4 +34,4 @@ def build-colorstr [ # sleep 10ms | ignore } -draw \ No newline at end of file +# draw \ No newline at end of file diff --git a/modules/coloring/short_list.nu b/modules/coloring/short_list.nu index 42a8dab51..23cb86e03 100644 --- a/modules/coloring/short_list.nu +++ b/modules/coloring/short_list.nu @@ -1,4 +1,4 @@ -source ../stdlib_candidate/nu_style.nu +source ../../stdlib-candidate-archive/stdlib-candidate-older/std-rfc/nu_style.nu # # Regular Colors $" Regular Colors (char newline) (char newline)" diff --git a/modules/gitv2/mod.nu b/modules/gitv2/mod.nu index e73462b10..a0fb30fde 100644 --- a/modules/gitv2/mod.nu +++ b/modules/gitv2/mod.nu @@ -1,4 +1,4 @@ -use argx +use ../argx def agree [ prompt diff --git a/modules/history-utils/mod.nu b/modules/history-utils/mod.nu index ed0b2c80f..bdb21f2ed 100644 --- a/modules/history-utils/mod.nu +++ b/modules/history-utils/mod.nu @@ -80,7 +80,7 @@ export def 'history top' [ num=10 --before (-b): duration --dir (-d) - --path(-p): list + --path(-p): list ] { open $nu.history-path | query db (sql { from: history diff --git a/modules/kubernetes/complete.nu b/modules/kubernetes/complete.nu index 03ab17143..c411217d6 100644 --- a/modules/kubernetes/complete.nu +++ b/modules/kubernetes/complete.nu @@ -1,4 +1,4 @@ -use argx +use ../argx use utils.nu * export def "nu-complete kube ctx" [] { diff --git a/modules/kubernetes/helm.nu b/modules/kubernetes/helm.nu index 9e5a8b111..5d9f3cb03 100644 --- a/modules/kubernetes/helm.nu +++ b/modules/kubernetes/helm.nu @@ -1,6 +1,6 @@ use complete.nu * use utils.nu * -use argx +use ../argx export def record-to-set-json [value] { $value | transpose k v diff --git a/modules/kubernetes/resources.nu b/modules/kubernetes/resources.nu index bdb8f4701..af88bbd85 100644 --- a/modules/kubernetes/resources.nu +++ b/modules/kubernetes/resources.nu @@ -1,11 +1,11 @@ -use complete * +use complete.nu * ### refine kubernetes resources export def kube-refine [ ...namespace: string@"nu-complete kube ns" --kind(-k): list@"nu-complete kube kind" ] { - use lg + use ../lg let config = $env.KUBERNETES_REFINE let nsf = if ($namespace | is-empty) { diff --git a/modules/language/playground.nu b/modules/language/playground.nu deleted file mode 100644 index 656bc73c1..000000000 --- a/modules/language/playground.nu +++ /dev/null @@ -1 +0,0 @@ -source language/playground/lib.nu \ No newline at end of file diff --git a/modules/language/std.nu b/modules/language/std.nu deleted file mode 100644 index 4f3cd151c..000000000 --- a/modules/language/std.nu +++ /dev/null @@ -1 +0,0 @@ -source language/std/date.nu diff --git a/modules/ls_mods/ls-hidden.nu b/modules/ls_mods/ls-hidden.nu index dfef3abf0..b52b94b28 100644 --- a/modules/ls_mods/ls-hidden.nu +++ b/modules/ls_mods/ls-hidden.nu @@ -1,5 +1,5 @@ -export def ls-hidden [ +export def main [ --dir(-d):any # The directory you want to list ] { let dir = if ($dir | is-empty) { "." } else { $dir } diff --git a/modules/ls_mods/ls-less.nu b/modules/ls_mods/ls-less.nu index 9b4cea15c..4bdfe91c0 100644 --- a/modules/ls_mods/ls-less.nu +++ b/modules/ls_mods/ls-less.nu @@ -1,5 +1,5 @@ # An attempt at trying to put ls into a paging mode -export def ls-less [ +export def main [ --dir(-d):any # The directory you want to list ] { let is_empty = ($dir | is-empty) diff --git a/modules/ls_mods/ls-wide.nu b/modules/ls_mods/ls-wide.nu index 45b157f06..f5aa92379 100644 --- a/modules/ls_mods/ls-wide.nu +++ b/modules/ls_mods/ls-wide.nu @@ -1,5 +1,5 @@ # A ls command that approximates the ls -sh command in bash -export def ls-wide [ +export def main [ --path(-p):string # The path you want to list --columns(-c):int # The number of columns in your output ] { diff --git a/modules/maths/math_functions.nu b/modules/maths/math_functions.nu index 26e881d33..3a30da696 100644 --- a/modules/maths/math_functions.nu +++ b/modules/maths/math_functions.nu @@ -155,7 +155,7 @@ export def scale-minmax-table [a, b,input?] { 0..($n_cols - 1) | each {|i| ($x | column2 $i) | scale-minmax $a $b | wrap ($name_cols | get $i) - } | reduce {|it, acc| $acc | merge {$it}} + } | reduce {|it, acc| $acc | merge $it} } diff --git a/modules/prompt/async_git_prompt/async-git-prompt.nu b/modules/prompt/async_git_prompt/async-git-prompt.nu index c713bc86e..fb4f651a4 100644 --- a/modules/prompt/async_git_prompt/async-git-prompt.nu +++ b/modules/prompt/async_git_prompt/async-git-prompt.nu @@ -43,7 +43,7 @@ export def async-git-prompt-compute-sync [] { { staged: $symbol} } # Execute the two slow git commands in parallel and merge the results into a single record - let symbols = ([ $unstaged $staged ] | par-each { |it| do $it } | reduce {|a b| $a | merge {$b}}) + let symbols = ([ $unstaged $staged ] | par-each { |it| do $it } | reduce {|a b| $a | merge $b}) $"($symbols | get 'unstaged') ($symbols | get 'staged')" | str trim } diff --git a/modules/prompt/jalon-git.nu b/modules/prompt/jalon-git.nu index 32a393a2a..5d18138de 100644 --- a/modules/prompt/jalon-git.nu +++ b/modules/prompt/jalon-git.nu @@ -162,7 +162,7 @@ def duration-style [] { def fast-git-style [] { let s = get-styles - let b_info = (do -p { git --no-optional-locks branch -v } | str trim) + let b_info = (do -i { git --no-optional-locks branch -v } | str trim) if ($b_info | is-empty) { '' } else { @@ -190,7 +190,7 @@ def fast-git-style [] { def full-git-style [] { let s = get-styles - let info_lines = (do -p { git --no-optional-locks status --porcelain=2 --branch } | str trim | lines) + let info_lines = (do -i { git --no-optional-locks status --porcelain=2 --branch } | str trim | lines) if ($info_lines | is-empty) { '' } else { diff --git a/modules/prompt/shell_space.nu b/modules/prompt/shell_space.nu index 816502a38..5350e4c7d 100644 --- a/modules/prompt/shell_space.nu +++ b/modules/prompt/shell_space.nu @@ -1,10 +1,10 @@ # use shells to to show workspaces def workspaces [] { - shells | each {|item index| - if $item.active { - $"(ansi green)($index) " + shells | enumerate | each {|it| + if $it.item.active { + $"(ansi green)($it.index) " } else { - $"(ansi blue)($index) " + $"(ansi blue)($it.index) " } }| str join } diff --git a/modules/virtual_environments/auto-venv/venv_helpers.nu b/modules/virtual_environments/auto-venv/venv_helpers.nu index 45bacc1d3..832a86d61 100644 --- a/modules/virtual_environments/auto-venv/venv_helpers.nu +++ b/modules/virtual_environments/auto-venv/venv_helpers.nu @@ -20,7 +20,7 @@ def get-env [ } export def venv-is-active [] { - '__auto_venv' in (overlay list) + '__auto_venv' in (overlay list | get name) } # Creates a virtual environment under the current directory diff --git a/nu-hooks/nu-hooks/dynamic-load/dynamic-load.nu b/nu-hooks/nu-hooks/dynamic-load/dynamic-load.nu index 550a87486..b9cc6c359 100644 --- a/nu-hooks/nu-hooks/dynamic-load/dynamic-load.nu +++ b/nu-hooks/nu-hooks/dynamic-load/dynamic-load.nu @@ -1,7 +1,7 @@ def dynamic_load [] { [ { - condition: {|before, after| (not ('.nu' in (overlay list))) and ('~/.nu' | path exists) } + condition: {|before, after| (not ('.nu' in (overlay list).name)) and ('~/.nu' | path exists) } code: "overlay use ~/.nu as .nu" } ] diff --git a/sourced/todo.nu b/sourced/todo.nu index 9e72d4e68..32717d54c 100644 --- a/sourced/todo.nu +++ b/sourced/todo.nu @@ -10,7 +10,8 @@ def --env printer [] { open $env.TODO | split row "\n" | take (($in | length) - 1) - | each {|$it, n| $"($n + 1) (ansi red)->(ansi reset) ($it)"} + | enumerate + | each {|it| $"($it.index + 1) (ansi red)->(ansi reset) ($it.item)"} | str join "\n" ) diff --git a/themes/src/make.nu b/themes/src/make.nu index 6122bc22f..f6d828423 100755 --- a/themes/src/make.nu +++ b/themes/src/make.nu @@ -1,5 +1,33 @@ #!/usr/bin/env nu -use .../stdlib-candidate/std-rfc str + +def dedent []: string -> string { + let input = $in + if ($input | is-empty) { return "" } + let lines = ($input | lines) + if ($lines | is-empty) { return "" } + + # Calculate common indentation + # Find all leading whitespace for non-empty lines + let leading_spaces = ($lines + | where ($it | str trim | is-empty) == false + | each { |line| + # Get the leading spaces + let trimmed = ($line | str trim -l) + ($line | str length) - ($trimmed | str length) + } + ) + + if ($leading_spaces | is-empty) { return ($lines | str join "\n") } + let min_indent = ($leading_spaces | math min) + + $lines | each { |line| + if ($line | str trim | is-empty) { + "" + } else { + $line | str substring $min_indent.. + } + } | str join "\n" +} let current_dir = ($env.CURRENT_FILE | path dirname) @@ -163,7 +191,7 @@ def make_color_config [ name: string, source: string = "lemnos" ] { def make_theme [ name: string, origin: string = "lemnos" ] { # Generate the theme depending on what type/origin it is - let main_command = ((make_color_config $name $origin) | str dedent) + let main_command = ((make_color_config $name $origin) | dedent) let update_terminal_command = $" # Update terminal colors @@ -187,7 +215,7 @@ def make_theme [ name: string, origin: string = "lemnos" ] { | print -n $\"\($in)\\r\" } " - | str dedent + | dedent let set_color_config_command = $" # Update the Nushell configuration @@ -195,7 +223,7 @@ def make_theme [ name: string, origin: string = "lemnos" ] { $env.config.color_config = \(main) } " - | str dedent + | dedent let activate_command = $" export module activate { @@ -208,7 +236,7 @@ def make_theme [ name: string, origin: string = "lemnos" ] { # Activate the theme when sourced use activate " - | str dedent + | dedent # Combine into the final theme file [ diff --git a/themes/src/preview-generate-screenshots.nu b/themes/src/preview-generate-screenshots.nu index 62afaabce..609e37d9d 100644 --- a/themes/src/preview-generate-screenshots.nu +++ b/themes/src/preview-generate-screenshots.nu @@ -10,7 +10,35 @@ # background to reduce artifacts def save_screenshot [ method, theme_name ] { - use .../stdlib-candidate/std-rfc/str + +def dedent []: string -> string { + let input = $in + if ($input | is-empty) { return "" } + let lines = ($input | lines) + if ($lines | is-empty) { return "" } + + # Calculate common indentation + # Find all leading whitespace for non-empty lines + let leading_spaces = ($lines + | where ($it | str trim | is-empty) == false + | each { |line| + # Get the leading spaces + let trimmed = ($line | str trim -l) + ($line | str length) - ($trimmed | str length) + } + ) + + if ($leading_spaces | is-empty) { return ($lines | str join "\n") } + let min_indent = ($leading_spaces | math min) + + $lines | each { |line| + if ($line | str trim | is-empty) { + "" + } else { + $line | str substring $min_indent.. + } + } | str join "\n" +} match $method { # This method for generating terminal screenshots uses # a pure-PowerShell script. The caveat is that Windows @@ -24,7 +52,7 @@ def save_screenshot [ method, theme_name ] { "powershell" => { let ps_script = $" use .. * - source ($name) + source ../nu-themes/($theme_name).nu clear sleep 100ms print `Theme name: '($theme_name)'` @@ -39,7 +67,7 @@ def save_screenshot [ method, theme_name ] { sleep 1 [Windows.Forms.Clipboard]::GetImage\().Save\('($theme_name).png', [System.Drawing.Imaging.ImageFormat]::Png) " - | str dedent + | dedent $"powershell.exe -c \" ($ps_script) @@ -50,7 +78,7 @@ def save_screenshot [ method, theme_name ] { "minicap" => { $' use .. * - source ($name) + source ../nu-themes/($theme_name).nu clear sleep 100ms print `Theme name: '($theme_name)'` @@ -130,7 +158,6 @@ def save_screenshot [ method, theme_name ] { } def "preview generate screenshots" [screenshot_method, theme_count = 10_000] { - use .../stdlib-candidate/std-rfc str let themes = ( "../nu-themes/" @@ -168,7 +195,6 @@ def "preview generate screenshots" [screenshot_method, theme_count = 10_000] { } def "preview generate readme" [] { - use .../stdlib-candidate/std-rfc str # README Title "# Screenshots of Theme Previews\n\n" @@ -197,14 +223,13 @@ def "preview generate readme" [] { ![($theme_name)]\(($screenshot_file)) " - | str dedent + | dedent | save -a "../screenshots/README.md" } | ignore } def main [screenshot_method] { - use .../stdlib-candidate/std-rfc/str if $env.PWD != $env.FILE_PWD { " @@ -212,7 +237,7 @@ def main [screenshot_method] { nu preview-screenshot-script.nu " - | str dedent + | dedent | print -e $in return diff --git a/toolkit.nu b/toolkit.nu index 83707c8f6..73daf72cd 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -73,7 +73,7 @@ def "with files" [ } } -def "lint check" []: path -> int { +export def "lint check" [--only-errors]: path -> int { let file = $in let test_methodology = $env.TEST_METHOD? | default "import-or-source" @@ -113,7 +113,9 @@ def "lint check" []: path -> int { } let error_count = $diagnostics | length if $error_count == 0 { - print $"lint: ✔ ($file) is ok" + if not $only_errors { + print $"lint: ✔ ($file) is ok" + } } else { print $"lint: ❌ ($file) has errors:\n($diagnostics | table)" } @@ -127,8 +129,9 @@ def "lint check" []: path -> int { export def lint [ --full # Check all files instead of input --and-exit # Exit with error count + --only-errors # Only print files with errors ]: [list -> int, nothing -> int] { with files --full=$full --and-exit=$and_exit { - par-each { lint check } + par-each { lint check --only-errors=$only_errors } } }