neovim / neovim

Vim-fork focused on extensibility and usability
https://neovim.io
Other
83.3k stars 5.7k forks source link

`statuscolumn` shows room for line numbers but no actual line numbers #29461

Closed andrewferrier closed 4 months ago

andrewferrier commented 4 months ago

Problem

Since pull request https://github.com/neovim/neovim/pull/29357 was merged into nightly, line numbers seem to have been interacting very strangely with statuscolumn and the number option and additional whitespace is getting inserted. Explained through recreation below.

Steps to reproduce

Expected behavior

No additional whitespace shown to the left of the file.

Neovim version (nvim -v)

NVIM v0.11.0-dev-301+g6c3f7e7e2

Vim (not Nvim) behaves the same?

No statuscolumn option in Vim

Operating system/version

Arch Linux

Terminal name/version

kitty 0.35.1

$TERM environment variable

xterm-kitty

Installation

nvenv

luukvbaal commented 4 months ago

Error - four columns of whitespace are shown to the left of the file, but this doesn't make much sense.

'statuscolumn' follows the 'numberwidth' option. This is doucmented and did not change in #29357.

andrewferrier commented 4 months ago

Error - four columns of whitespace are shown to the left of the file, but this doesn't make much sense.

'statuscolumn' follows the 'numberwidth' option. This is doucmented and did not change in #29357.

OK, it's possible that I got confused about the pull req having changed something; nevertheless, I don't think this behaviour makes much sense. Isn't the idea that statuscolumn will override the complete drawing of the status column? In this case, the fact that %l isn't part of the statuscolumn should surely mean that nothing is shown for line numbers, either them or whitespace for them?

In case I'm not being clear, I'm not talking about extra whitespace being shown next to line numbers, I'm talking about no line numbers being shown at all. I've attached an image in case it's not clear what I meant...

andrewferrier commented 4 months ago

2024-06-23T14:25:24+01:00

luukvbaal commented 4 months ago

If you set '(relative)number', it is just assumed that the statuscolumn will contain line numbers, and thus follows 'numberwidth'. Nvim cannot reasonably determine whether that is the case, so if it is not, you must unset '(relative)number' if you don't want the extra padding for 'numberwidth'.

lewis6991 commented 4 months ago

Can't we make %l be empty (zero length) if both nu and rnu are unset?

luukvbaal commented 4 months ago

It already is. But then if '(r)nu' is enabled the statuscolumn itself is padded to 'numberwidth', even if it doesn't contain %l. This is what @andrewferrier finds unexpected but it is done deliberately because the statuscolumn may contain line numbers despite that through vim.v.(re)lnum.

lewis6991 commented 4 months ago

Ah ok, makes sense. This should be closed as intended then.

andrewferrier commented 4 months ago

@luukvbaal so to summarize, I think what you're saying is that if number or relativenumber is set (or both), statuscolumn will always pad by numberwidth, even if %l is missing, because the assumption is that any custom logic called from statuscolumn will want to render numbers/relnumbers instead. I re-read the docs and whilst I don't think it's stated there quite that explicitly, all of this is kind of covered by the statuscolumn description.

So that all makes some sense to me. I think you can close this, agreed. Thanks for your patience and all your hard work on NeoVim :)