fix(statuscolumn): %r deprecated in nightly and %l handles everything (#3719)

## What is this PR for?

Fix correctly showing relative numbers in `statuscolumn` after recent
breaking changes on
[nightly](https://github.com/neovim/neovim/pull/29357).

Please feel free to disregard this PR if a better solution is possible.
<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Does this PR fix an existing issue?
Fixes #3721 
<!--
  If this PR fixes any issues, please link to the issue here.
  Fixes #<issue_number>
-->

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
This commit is contained in:
Iordanis Petkakis 2024-06-18 19:42:34 +03:00 committed by GitHub
parent 8a89c0360e
commit 1a295c5ef8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -140,11 +140,15 @@ function M.statuscolumn()
local is_num = vim.wo[win].number local is_num = vim.wo[win].number
local is_relnum = vim.wo[win].relativenumber local is_relnum = vim.wo[win].relativenumber
if (is_num or is_relnum) and vim.v.virtnum == 0 then if (is_num or is_relnum) and vim.v.virtnum == 0 then
if vim.fn.has("nvim-0.11") == 1 then
components[2] = "%l" -- 0.11 handles both the current and other lines with %l
else
if vim.v.relnum == 0 then if vim.v.relnum == 0 then
components[2] = is_num and "%l" or "%r" -- the current line components[2] = is_num and "%l" or "%r" -- the current line
else else
components[2] = is_relnum and "%r" or "%l" -- other lines components[2] = is_relnum and "%r" or "%l" -- other lines
end end
end
components[2] = "%=" .. components[2] .. " " -- right align components[2] = "%=" .. components[2] .. " " -- right align
end end