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

Allow disabling autosuggestions and syntax highlighting #8376

Merged
merged 4 commits into from
Nov 2, 2021

Conversation

faho
Copy link
Member

@faho faho commented Oct 22, 2021

Description

This allows essentially disabling autosuggestions and syntax highlighting.

For autosuggestions, it adds a variable $fish_autosuggestion_enabled. If set to 0, this will disable suggestions. If set to anything else (or unset), it will keep them enabled.

For highlighting, it adds a "none" theme that disables most colors. It keeps colors for the search match, selection, suggestions and pager descriptions, but sets them to either brblack or --reverse. Everything else is set to "normal". Especially the selection and pager need to have color or they aren't discernable at all.

The rationale here is that these features don't impact any scripting. They don't create a language dialect. They also aren't hard to implement, especially since the suggestions change is already implemented (to allow for interactive read).

So we should allow for simple matters of taste.

One issue here is that the git prompt colors currently can't be set via a theme file, so most likely the git branch will still show up as green (EDIT: This is incorrect, the branch isn't colored by default, please ignore the green in the below screenshots - it's left over from my config). This would either require us to rename the color variables to fish_color_git or similar, or allow __fish variables to be set in themes (this was quite locked down on purpose, so people don't try to put other things in).

Screenshots:

Screenshot_20211022_171321
Screenshot_20211022_171506
Screenshot_20211022_193324

(as a personal note, I absolutely hate using fish without suggestions - I feel like I have my arm tied behind my back!)

Fixes #1363.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

This adds a variable, $fish_autosuggestion_enabled.

When set to 0, it will turn off autosuggestions/highlighting.
Setting it to anything else will enable it (which also
means this remains enabled by default).
This basically disables syntax highlighting. That doesn't mean we use
absolutely no colors - the search match, suggestion, selection and the
pager have coloring, but only reverse or brblack.

The idea is that this disables anything that tells you about
the *syntax*, but it still tells you about the state of the
commandline. If we didn't highlight the selection it would be entirely
invisible, and if we didn't highlight the suggestion you would have no
idea where it begins.

So this basically brings colors on-par with bash, where the search
match is colored (in reverse) and suggestions aren't a thing.

An alternative is to add a $fish_highlighting_enabled variable like
the one for suggestions. That's still possible, but would require some
internal changes to avoid coloring some things with $fish_color_normal
and other things with the normal terminal color.

One thing this also does not do is set the git prompt colors. These
are currently disallowed from being set in theme files because they
start with `__fish` instead of just `fish`. We should probably rename
them.
Also add more mentions of `fish_config` in general.
@faho faho added this to the fish 3.4.0 milestone Oct 22, 2021
@faho
Copy link
Member Author

faho commented Oct 22, 2021

Note: A bunch of prompts will have their own coloring.

I think for coloring things like $PWD or user@host normally, we might want to move these to the common variables. That's excluding places where the prompts do their own thing - e.g. scales has that three-colored fish display, disco has a $PWD color derived from the hash.

@faho faho mentioned this pull request Oct 22, 2021
@faho
Copy link
Member Author

faho commented Oct 23, 2021

most likely the git branch will still show up as green

Turns out this is just if $__fish_git_prompt_showcolorhints is set, which by default it is not.

So here's a new screenshot:

Screenshot_20211023_113801

(that "check" highlight is the search match, the ^C is a cancel).

On a light background:

Screenshot_20211023_113910

@@ -0,0 +1,31 @@
# name: '(Almost) No Colors'
# preferred_background: 'black'
Copy link
Member

Choose a reason for hiding this comment

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

I love this theme - I like to read code on my grayscale e-ink screen, and I sometimes can't read text if the background and foreground are too similar. This fixes those issues, very nice!

Actually the one issue I have in mind is that search matches (fish_color_search_match) are combined with other syntax highlighting (instead of overriding them), which can make them hard to read, even on a screen that already supports colors.

So if I type echo Up and the matching echo is in command position, the default theme will give it dark blue foreground, and as a search match it has black background background (on a light-themed terminal).
If the search match is an argument, it's better because that's lighter by default.
I wonder if we can/should disable our semantic syntax highlighting inside search matches.
I want to try if this makes things better.

fish_pager_color_description brblack
fish_pager_color_prefix '--underline'
fish_pager_color_progress brblack
fish_pager_color_selected_background --background=brblack
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be

Suggested change
fish_pager_color_selected_background --background=brblack
fish_pager_color_selected_background -r

Otherwise I can't read the selected completion (+ description) in the pager

Copy link
Member

@krobelus krobelus Nov 1, 2021

Choose a reason for hiding this comment

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

I'm using gnome-terminal which likes to draw bright colors a little bit darker than other terminals 😕

image

with -r

image

to get rid of the inconsistency with the description, we could use set fish_pager_color_description normal on top of that. Sadly that removes the nice gray tone for descriptions.. so I'd leave it. nevermind, this screenshot looks fine to me

(technically introduced after this)
@faho faho merged commit d41b463 into fish-shell:master Nov 2, 2021
krobelus added a commit that referenced this pull request Nov 4, 2021
Otherwise, with a light-theme, the selected entry uses black text with
"bright black" background, which can be low contrast thus hard to read.

The description background is different, maybe we can fix that later.

See #8376
@faho faho deleted the disable-suggestions-highlighting branch November 4, 2021 19:40
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

improve the experience of using fish over mosh
2 participants