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

Add keybinds for toggling common settings #3309

Closed

Conversation

the-mikedavis
Copy link
Member

hx.mp4

This adds a <space>t binding that can toggle a few select settings:

  • visible whitespace
  • indent guides
  • cursorline
  • a ruler at 80

It's has limitations:

  • it's not configurable what is toggled1
  • the value of the setting you had before toggling is not possible to restore in all cases without using :set

Closes #2849

Footnotes

  1. IMO this should wait for a more general purpose config language. It's possible to do it in TOML but it wouldn't be particularly elegant. It could be pretty elegant to do it if keymaps were written in something like lisp :P

@AlexanderBrevig
Copy link
Contributor

Cool! 👍
I would personally love line number relative toggles.

BTW I restored my config with a simple :config-reload. At first, I thought the toggle would modify my config. Glad that's not the case.

(a lisp for configuration would be awesome)

The toggle should disable the feature if it's enabled in any way
and should enable the feature to the hard-coded default if it's
disabled.
Copy link
Contributor

@AlexanderBrevig AlexanderBrevig left a comment

Choose a reason for hiding this comment

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

Very cool! I don't know if it's OK for me to do the review, but here I am anyway :)

@David-Else
Copy link
Contributor

David-Else commented Aug 3, 2022

@the-mikedavis Please can we toggle the line numbers on and off? I see this as much more important than line number relative toggles. A perfect solution would be to cycle through all three states with l, is this possible ?

If you are writing docs in markdown you never need line numbers, and even when coding I personally only use line numbers when some legacy linter only gives line numbers of errors, rather than an LSP that can take you right to the problem.

@AlexanderBrevig
Copy link
Contributor

AlexanderBrevig commented Aug 3, 2022

@the-mikedavis Please can we toggle the line numbers on and off? I see this as much more important than line number relative toggles. A perfect solution would be to cycle through all three states with l, is this possible ?

Kind of feels weird with a ternary toggle. Maybe L for on/off and l for absolute/relative?

PS: relative line numbers will make n<operation-that-shifts-vertically> much easier.
You can immediately see that you need to go nC to create n carets for modifying a config file or some such. We all do things differently of course, but this has been a productivity boost for me (yeah, we're measuring sub seconds here 😉)

@David-Else
Copy link
Contributor

Kind of feels weird with a ternary toggle. Maybe L for on/off and l for absolute/relative?

I think it would feel cool and easier to use than L and l, do you think it would be weird as it would be the only ternary and doesn't fit in, or just that toggles should be binary?

@AlexanderBrevig
Copy link
Contributor

Kind of feels weird with a ternary toggle. Maybe L for on/off and l for absolute/relative?

I think it would feel cool and easier to use than L and l, do you think it would be weird as it would be the only ternary and doesn't fit in, or just that toggles should be binary?

After thinking about it more, I think you're right. Probably cool and natural. I'll edit my comment with a strike through.

@the-mikedavis
Copy link
Member Author

I don't have any qualms about this command cycling between a list of options. IMO, if it were configurable then the options would be a list. If visible whitespace had the Selection variant implemented #2208, the toggle would include that. Similar with #3242.

Implementation-wise it's not very clean to disable/enable the line-number gutter because it's controlled by the gutters configuration and not helix_view::editor::LineNumber, so I'd prefer to not add a toggle for it. The use-case of "If you are writing docs in markdown you never need line numbers" sounds like it's somewhat better suited by #3207.

@kirawi kirawi added A-helix-term Area: Helix term improvements A-keymap Area: Keymap and keybindings S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 13, 2022
@the-mikedavis
Copy link
Member Author

Despite this working as a proof-of-concept I think it would be better to be able to accomplish this with custom keybinds once there is scripting support / better config.

In the meantime people can use this PR as a guide if they want to build something similar locally

@the-mikedavis the-mikedavis deleted the md-toggle-setting branch September 17, 2022 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements A-keymap Area: Keymap and keybindings S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Toggle features
4 participants