Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestion: added style #691

Merged
merged 3 commits into from
Jan 24, 2024
Merged

suggestion: added style #691

merged 3 commits into from
Jan 24, 2024

Conversation

rsteube
Copy link
Contributor

@rsteube rsteube commented Dec 29, 2023

image

Reverse highlighting with config "record" for reverse:

style: {
    text: white
    selected_text: {
        attr: r
    }
    description_text: white_dimmed
}

related nushell/nushell#5292
related carapace-sh/carapace#546

@fdncred
Copy link
Collaborator

fdncred commented Dec 29, 2023

Personally, I'd love to see "style" added. You can't get colorful enough for me.

@amtoine
Copy link
Member

amtoine commented Dec 29, 2023

@rsteube
the style would come from an external completer such as carapace?

@RusticCraftsman
Copy link

@rsteube the style would come from an external completer such as carapace?

i assume, rsteube is the owner of carapace and this pull request comes from a carapace issue relating nushell.

@rsteube
Copy link
Contributor Author

rsteube commented Dec 29, 2023

@rsteube the style would come from an external completer such as carapace?

Yes, An additional attribute in the results similar to the config should work:

https://github.com/nushell/nushell/blob/main/crates/nu-cli/src/reedline_config.rs#L162

let style = match text {
    Value::String { val, .. } => lookup_ansi_color_style(&val),
    Value::Record { .. } => color_record_to_nustyle(&text),
    _ => None
};

Copy link

codecov bot commented Dec 30, 2023

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (9ca229d) 47.59% compared to head (949bf1f) 49.28%.
Report is 8 commits behind head on main.

❗ Current head 949bf1f differs from pull request most recent head 3bef1b7. Consider uploading reports for the commit 3bef1b7 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #691      +/-   ##
==========================================
+ Coverage   47.59%   49.28%   +1.68%     
==========================================
  Files          47       46       -1     
  Lines        9312     8009    -1303     
==========================================
- Hits         4432     3947     -485     
+ Misses       4880     4062     -818     
Files Coverage Δ
src/completion/base.rs 29.16% <ø> (ø)
src/completion/default.rs 68.34% <100.00%> (+0.48%) ⬆️
src/menu/menu_functions.rs 95.87% <100.00%> (-0.07%) ⬇️
src/completion/history.rs 0.00% <0.00%> (ø)
src/engine.rs 4.97% <0.00%> (-0.09%) ⬇️
src/menu/columnar_menu.rs 32.97% <5.55%> (-0.06%) ⬇️

... and 16 files with indirect coverage changes

@rsteube rsteube force-pushed the suggestion-style branch 4 times, most recently from 7cfac29 to c2bf6c5 Compare December 30, 2023 00:55
@rsteube rsteube marked this pull request as ready for review December 30, 2023 00:56
@rsteube rsteube mentioned this pull request Dec 30, 2023
1 task
@rsteube
Copy link
Contributor Author

rsteube commented Dec 30, 2023

@fdncred @amtoine

You can test this with nushell/nushell#11442 and the current master branch of carapace-bin:

cd cmd/carapace
go generate ./...
go install

@stormasm
Copy link
Contributor

@rsteube I now have carapace installed and we are ready continue working on this PR....

The CI is reporting one failing check having to do with the spelling of "wheres" which should be "whereas"
in the file sqlite_backed.rs

Also you will probably need to update your code somewhat as the branch has conflicts...

Thank you !

supports reverse highlighting using nu.config

```nushell
style: {
    text: white
    selected_text: {
        attr: r
    }
    description_text: white_dimmed
}
```
@fdncred
Copy link
Collaborator

fdncred commented Jan 23, 2024

I think you just need to merge main because we added wheres a while back

wheres = "wheres"

@stormasm stormasm merged commit 7adffd5 into nushell:main Jan 24, 2024
6 checks passed
@stormasm
Copy link
Contributor

@rsteube thanks for getting this going so quickly today and being very patient for a long time...

Glad we were finally able to land this PR --- sorry it took so long 😄

@rsteube rsteube deleted the suggestion-style branch January 24, 2024 14:56
fdncred pushed a commit to nushell/nushell that referenced this pull request Jan 25, 2024
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description

Adds style support.

Reverse highlighting is recommended for the
[completion-menu](https://www.nushell.sh/book/line_editor.html#completion-menu):
```nushell
style: {
    text: white
    selected_text: {
        attr: r
    }
    description_text: white_dimmed
}
```

needs nushell/reedline#691
related #5292
fix carapace-sh/carapace#967

<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->

# User-Facing Changes

Style support for values during completion:


![image](https://github.com/nushell/nushell/assets/9090290/f5e4440e-61db-4eeb-87b3-f887b6918c50)


![image](https://github.com/nushell/nushell/assets/9090290/e59065a6-58c2-4f5f-82ea-e2b9c2464b9a)

<!-- 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 std testing; testing run-tests --path
crates/nu-std"` 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.
-->
stormasm pushed a commit that referenced this pull request Jan 26, 2024
* get correct cursor pos when menu indicator contains newline

* add tests

* fix cursor pos in multiline prompt

* make description mode enum public

* add doc comment

* respect windows newline in update_values

* Revert "respect windows newline in update_values"

This reverts commit 070d600.

* add complete_with_base_ranges to Completer

* add builder for correct_cursor_pos

* add config options to completion examples

* add style to ide menu

* run fmt

* start menu refactor

* Revert "start menu refactor"

This reverts commit 62726f2.
@maxomatic458 maxomatic458 mentioned this pull request Jan 28, 2024
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description

Adds style support.

Reverse highlighting is recommended for the
[completion-menu](https://www.nushell.sh/book/line_editor.html#completion-menu):
```nushell
style: {
    text: white
    selected_text: {
        attr: r
    }
    description_text: white_dimmed
}
```

needs nushell/reedline#691
related nushell#5292
fix carapace-sh/carapace#967

<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->

# User-Facing Changes

Style support for values during completion:


![image](https://github.com/nushell/nushell/assets/9090290/f5e4440e-61db-4eeb-87b3-f887b6918c50)


![image](https://github.com/nushell/nushell/assets/9090290/e59065a6-58c2-4f5f-82ea-e2b9c2464b9a)

<!-- 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 std testing; testing run-tests --path
crates/nu-std"` 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.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants