jeffkreeftmeijer / vim-numbertoggle

Toggles between hybrid and absolute line numbers automatically
https://jeffkreeftmeijer.com/vim-number/#automatic-toggling-between-line-number-modes
MIT License
682 stars 49 forks source link

Implement new feature: g:numbertoggle_min_cols #12

Closed farmergreg closed 11 years ago

farmergreg commented 11 years ago

When g:numbertoggle_min_cols is set, show line numbers if there are at least g:numbertoggle_min_cols available for displaying content. By default this is set to zero and has no impact on existing users.

Setting g:numbertoggle_min_cols=80 for example causes line numbering to be turned off if the window is not able to display 80 characters of text along side the line numbers. When the window becomes larger, the line numbering will automatically appear.

Signed-off-by: Greg Dietsche Gregory.Dietsche@cuw.edu

jeffkreeftmeijer commented 11 years ago

Hey Greg,

I'm not sure this fixes an issue with vim-numbertoggle specifically, as it seems to be concerned with vim line numbers in general. If I don't misunderstand your change, it seems like this would be better as a separate plugin, as it doesn't really have anything to do with switching between relative and absolute line numbers.

But, please tell me If you think I'm wrong or I'm misunderstanding something, I'm quite new to the whole vim plugin thing myself.

farmergreg commented 11 years ago

Thanks Jeff, I don't see a clean way (perhaps there is something obvious that I've missed?) to separate the new functionality from the numbertoggle plugin. For example, how would it know to turn on relative/absolute numbering in a way that is compatible with your plugin when the window is resized? I'll probably keep my fork since it works well for me. Wanted to push it upstream in case it seemed useful to include for folks.

Thanks! Greg

farmergreg commented 11 years ago

p.s. I'm not much of a vim script expert myself p.p.s. f3ed5b3 fixes a bug in your plugin... i guess i should have put that into a separate request.

jeffkreeftmeijer commented 11 years ago

Hey Greg,

If I understand correctly, your change makes sure that no line numbers (relative or absolute) are shown if there's not enough room, so that could be built into a plugin that makes sure that the line numbers still fit whenever the available columns changes. Right?

-- Jeff

On Mar 6, 2013, at 6:30 AM, Greg notifications@github.com wrote:

Thanks Jeff, I don't see a clean way (perhaps there is something obvious that I've missed?) to separate the new functionality from the numbertoggle plugin. For example, how would it know to turn on relative or absolute numbering in a way compatible with your plugin your plugin? I'll probably just keep my fork since it works well for me. Wanted to push it upstream in case it seemed useful to include for folks.

Thanks! Greg

— Reply to this email directly or view it on GitHub.

jeffkreeftmeijer commented 11 years ago

That's right. Could you open up a new pull request for it?

On Mar 6, 2013, at 6:49 AM, Greg notifications@github.com wrote:

p.s. I'm not much of a vim script expert myself p.p.s. f3ed5b3 fixes a bug in your plugin... i guess i should have put that into a separate request.

— Reply to this email directly or view it on GitHub.

farmergreg commented 11 years ago

Thanks Jeff, I think you've properly understood what it does. In short, I wanted the relative/absolute line numbers to be turned off in a small console window, but automatically appear in larger windows that are not constrained for space.

As a separate plugin, there would be a race condition between this hypothetical new plugin that turns off numbering and your plugin which would likely try and turn the numbering back on. So I think the two plugin's would have to "know" about one another in order to function properly. That's why I patched your code instead of creating a new plugin.

In any case, thanks for the work you've put into your plugin. Together with the changes I've made it works very nicely for me. I would have never thought to combine relative and absolute numbering into a plugin the way you did. Nice job.