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

Line numbers are now configurable via the gutters setting but apparently can't be changed with the :set command #2206

Closed
groovy9 opened this issue Apr 21, 2022 · 6 comments
Labels
A-core Area: Helix core improvements A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@groovy9
Copy link

groovy9 commented Apr 21, 2022

I'd like to be able to toggle line numbers on and off while editing. #1967 added a gutters setting that allows disabling line numbers by simply not including "line-numbers" in the gutters array, which is great. But :set throws an error if I try to set gutters to the referenced values:

:set gutters ["diagnostics"]
Bad arguments. Usage: ':set key field'

@groovy9 groovy9 added the C-enhancement Category: Improvements label Apr 21, 2022
@CptPotato
Copy link
Contributor

CptPotato commented Apr 21, 2022

:set gutters ["diagnostics"] doesn't error for me. If it does for you, you might be using the latest release which doesn't include that functionality, yet.

Apart from that, there seem to be two things happening here:

  1. :set fails to parse the list, if it contains spaces
    • i.e. ["diagnostics", "line-numbers"] fails, but ["diagnostics","line-numbers"] works
  2. the gutter is only updated when the window is created
    • opening a split will update it (closing one sometimes updates it?)

@the-mikedavis the-mikedavis added the A-helix-term Area: Helix term improvements label Aug 6, 2022
@the-mikedavis
Copy link
Member

the-mikedavis commented Aug 6, 2022

I can reproduce this. The error comes from this line:

if args.len() != 2 {
anyhow::bail!("Bad arguments. Usage: `:set key field`");
}

It looks like we're parsing the arguments :set gutters ["diagnostics"] as ["gutters", "[", "diagnostics", "]"].

:set gutters "[\"diagnostics\"]" is parsed correctly as a workaround but ideally we should be fixing the argument parser

@the-mikedavis the-mikedavis added A-core Area: Helix core improvements and removed A-helix-term Area: Helix term improvements labels Aug 6, 2022
@the-mikedavis
Copy link
Member

Hmm actually on further investigation this looks like the intended behavior of helix_core::shellwords based on the tests. You should escape quotes with \". Tuning that behavior could be discussed though.

:set gutters on its own doesn't refresh the gutters as CptPotato says. The helix_view::editor::Editor::refresh_config function (or maybe something in Application) will need some extra handling for gutters

@jcalabro
Copy link

jcalabro commented Mar 8, 2024

Hi there! Sorry to dig up an old issue, but I believe this is the way to do it in 23.10 at least? This is working for me

:set gutters.layout ["line-numbers"]

@phlippieb
Copy link

Hi there! Sorry to dig up an old issue, but I believe this is the way to do it in 23.10 at least? This is working for me

:set gutters.layout ["line-numbers"]

This seems to work, but only if the list contains exactly zero or one elements. Not sure how to set multiple elements. `:set gutters.layout ["line-numbers", "spacer"] still errors with the "Bad arguments" message.

@pascalkuthe
Copy link
Member

pascalkuthe commented May 18, 2024

This doesn't work because we parse the command input as json but have our own parsing/word splitting. You can use set like this you just need to comeup with the right way to escape it as Mike showed above.
This will be covered by the config factor refsctor and moving away from implementing :set using serde_json.

Closing in favor of #8853

@pascalkuthe pascalkuthe closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Helix core improvements A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

6 participants