Skip to content

Adding RelLineAbove and RelLineBelow highlight groups#624

Closed
shaunbrady wants to merge 1 commit intovim:masterfrom
shaunbrady:add_relnum_highlight
Closed

Adding RelLineAbove and RelLineBelow highlight groups#624
shaunbrady wants to merge 1 commit intovim:masterfrom
shaunbrady:add_relnum_highlight

Conversation

@shaunbrady
Copy link

I wanted my relative line numbers to be colored differently above and below the
cursor line. I believe a highlight group applied conditionally is the correct
way to achieve this.

This is my first foray in to the vim sources, so please let me know if I missed
the mark or could do things differently/better.

src/screen.c Outdated
char_attr, hl_attr(HLF_RNA));

if (wp->w_p_rnu && (lnum > wp->w_cursor.lnum))
/* high light relative above (<) cursor */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is exactly the same as the above comment.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taryn,
Thank you. I have added another commit to fix this obvious issue. I
can leave things as they are, fixup the branch as it sits (rewriting
history), or submit a new PR. Let me know what the project prefers.

Thanks!

SB

On Thu, Feb 4, 2016 at 11:27 PM, Taryn Hill vim-dev-github@256bit.org
wrote:

In src/screen.c #624 (comment)
:

@@ -3724,6 +3724,16 @@ win_line(
if ((wp->w_p_cul || wp->w_p_rnu)
&& lnum == wp->w_cursor.lnum)
char_attr = hl_attr(HLF_CLN);
+

  •                if (wp->w_p_rnu && (lnum < wp->w_cursor.lnum))
    
  •                    /\* high light relative above (<) cursor */
    
  •                    char_attr = hl_combine_attr(
    
  •                            char_attr, hl_attr(HLF_RNA));
    
  •                if (wp->w_p_rnu && (lnum > wp->w_cursor.lnum))
    
  •                    /\* high light relative above (<) cursor */
    

This comment is exactly the same as the above comment.


Reply to this email directly or view it on GitHub
https://github.com/vim/vim/pull/624/files#r51976064.

You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to vim_dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

@chrisbra
Copy link
Member

chrisbra commented Feb 5, 2016

I think it is easier for Bram to apply if you squash it into a single commit, so there is only one single patch. BTW: could you please provide a screenshot?

@shaunbrady shaunbrady force-pushed the add_relnum_highlight branch 2 times, most recently from b3abac6 to 90e2775 Compare February 5, 2016 07:38
@shaunbrady
Copy link
Author

@chrisbra Thanks, I have squashed everything in to one commit, which hopefully should by typo free. Here is a screenshot of the syntax group in action. Please ignore my tortured and hacked .vimrc. The lines used to change the colors are highlighted in purple.
vim_rel_lines

@chrisbra
Copy link
Member

chrisbra commented Feb 5, 2016

Thanks. This looks useful. Can you please also add some documentation at syntax.txt below :h highlight-groups

RelLineAbove is applied to relative line numbers above the cursor line
(and Below below).  These are added in addition to LineNr so as to not
break backwards compatibility.

The idea behind these highlight groups is to color relative line numbers
above and below the cursor differently.
@shaunbrady shaunbrady force-pushed the add_relnum_highlight branch from 90e2775 to bbac91d Compare February 5, 2016 22:09
@shaunbrady
Copy link
Author

@chrisbra I have added some documentation for the new highlight groups. Thanks!

@shaunbrady
Copy link
Author

shaunbrady commented Apr 24, 2016

@chrisbra Is there any thing else that is needed? Github tells me no conflicts have crept up since I authored the PR. Thanks!

@brammool brammool closed this in efae76a Oct 27, 2019
@phrohdoh
Copy link

🎉

manuelschiller pushed a commit to manuelschiller/vim that referenced this pull request Nov 10, 2019
…ntly

Problem:    Cannot color number column above/below cursor differently.
Solution:   Add LineNrAbove and LineNrBelow. (Shaun Brady, closes vim#624)
justinmk pushed a commit to neovim/neovim that referenced this pull request Aug 27, 2021
Problem:    Cannot color number column above/below cursor differently.
Solution:   Add LineNrAbove and LineNrBelow. (Shaun Brady, closes vim/vim#624)
vim/vim@efae76a
muniter pushed a commit to muniter/neovim that referenced this pull request Sep 8, 2021
Problem:    Cannot color number column above/below cursor differently.
Solution:   Add LineNrAbove and LineNrBelow. (Shaun Brady, closes vim/vim#624)
vim/vim@efae76a
lewis6991 pushed a commit to lewis6991/neovim that referenced this pull request Dec 12, 2021
Problem:    Cannot color number column above/below cursor differently.
Solution:   Add LineNrAbove and LineNrBelow. (Shaun Brady, closes vim/vim#624)
vim/vim@efae76a
Konfekt pushed a commit to Konfekt/vim that referenced this pull request Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants