nushell/crates
Darren Schroeder 0372e8c53c
add $nu.data-dir for completions and $nu.cache-dir for other uses (#13122)
# Description

This PR is an attempt to add a standard location for people to put
completions in. I saw this topic come up again recently and IIRC we
decided to create a standard location. I used the dirs-next crate to
dictate where these locations are. I know some people won't like that
but at least this gets the ball rolling in a direction that has a
standard directory.

This is what the default NU_LIB_DIRS looks like now in the
default_env.nu. It should also be like this when starting nushell with
`nu -n`
```nushell
$env.NU_LIB_DIRS = [
    ($nu.default-config-dir | path join 'scripts') # add <nushell-config-dir>/scripts
    ($nu.data-dir | path join 'completions') # default home for nushell completions
]
```

I also added these default folders to the `$nu` variable so now there is
`$nu.data-path` and `$nu.cache-path`.

## Data Dir Default

![image](https://github.com/nushell/nushell/assets/343840/aeeb7cd6-17b4-43e8-bb6f-986a0c7fce23)

While I was in there, I also decided to add a cache dir

## Cache Dir Default

![image](https://github.com/nushell/nushell/assets/343840/87dead66-4911-4f67-bfb2-acb16f386674)

### This is what the default looks like in Ubuntu.

![image](https://github.com/nushell/nushell/assets/343840/bca8eae8-8c18-47e8-b64f-3efe34f0004f)

### This is what it looks like with XDG_CACHE_HOME and XDG_DATA_HOME
overridden
```nushell
XDG_DATA_HOME=/tmp/data_home XDG_CACHE_HOME=/tmp/cache_home cargo r
```

![image](https://github.com/nushell/nushell/assets/343840/fae86d50-9821-41f1-868e-3814eca3730b)

### This is what the defaults look like in Windows (username scrubbed to
protect the innocent)

![image](https://github.com/nushell/nushell/assets/343840/3ebdb5cd-0150-448c-aff5-c57053e4788a)

How my NU_LIB_DIRS is set in the images above
```nushell
$env.NU_LIB_DIRS = [
    ($nu.default-config-dir | path join 'scripts') # add <nushell-config-dir>/scripts
    '/Users/fdncred/src/nu_scripts'
    ($nu.config-path | path dirname)
    ($nu.data-dir | path join 'completions') # default home for nushell completions
]
```

Let the debate begin.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2024-06-11 15:10:31 -04:00
..
nu_plugin_custom_values bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu_plugin_example bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu_plugin_formats bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu_plugin_gstat bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu_plugin_inc bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu_plugin_nu_example bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu_plugin_polars Allow the addition of an index column to be optional (#13097) 2024-06-10 10:45:25 +08:00
nu_plugin_python bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu_plugin_query Make query xml return nodes in document order (#13047) 2024-06-05 09:47:36 +08:00
nu_plugin_stress_internals bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-cli add $nu.data-dir for completions and $nu.cache-dir for other uses (#13122) 2024-06-11 15:10:31 -04:00
nu-cmd-base bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-cmd-extra Span ID Refactor (Step 2): Use SpanId of expressions in some places (#13102) 2024-06-09 12:15:53 +03:00
nu-cmd-lang Fix multiple issues with def --wrapped help example (#13123) 2024-06-10 19:12:54 -05:00
nu-cmd-plugin bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-color-config bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-command Remove deprecated --not flag on str contains (#13124) 2024-06-11 15:00:00 -04:00
nu-engine Span ID Refactor (Step 2): Use SpanId of expressions in some places (#13102) 2024-06-09 12:15:53 +03:00
nu-explore Overhaul explore config (#13075) 2024-06-06 08:46:43 -05:00
nu-glob bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-json bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-lsp bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-parser Span ID Refactor - Step 1 (#12960) 2024-06-05 09:57:14 +08:00
nu-path add $nu.data-dir for completions and $nu.cache-dir for other uses (#13122) 2024-06-11 15:10:31 -04:00
nu-plugin bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-plugin-core bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-plugin-engine bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-plugin-protocol bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-plugin-test-support bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-pretty-hex bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-protocol add $nu.data-dir for completions and $nu.cache-dir for other uses (#13122) 2024-06-11 15:10:31 -04:00
nu-std complete the type of --error-label in std assert commands (#12998) 2024-06-05 08:02:17 +08:00
nu-system bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-table bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-term-grid bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-test-support bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
nu-utils add $nu.data-dir for completions and $nu.cache-dir for other uses (#13122) 2024-06-11 15:10:31 -04:00
nuon Span ID Refactor - Step 1 (#12960) 2024-06-05 09:57:14 +08:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.