helix icon indicating copy to clipboard operation
helix copied to clipboard

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

Open groovy9 opened this issue 2 years ago • 3 comments

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 avatar Apr 21 '22 00:04 groovy9

: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?)

CptPotato avatar Apr 21 '22 09:04 CptPotato

I can reproduce this. The error comes from this line: https://github.com/helix-editor/helix/blob/24f5a47ceca5468ef22e21cdbb53e737782ff878/helix-term/src/commands/typed.rs#L1214-L1216

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 avatar Aug 06 '22 13:08 the-mikedavis

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

the-mikedavis avatar Aug 06 '22 13:08 the-mikedavis

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"]

jcalabro avatar Mar 08 '24 22:03 jcalabro