1

my current line number colors

1

I like to have a very visible line number coloring and I couldn't find a way to configure it in v0.8.2 of Neovim. I'm using tokionight-night as my color theme and would like to have more visible colors on the relative line numbers if possible i'd like to have the side above zero colored blue zero could be yellow/red and below zero pink. I'd like to change it to anything honestly I'm trying to move from vscode, where I changed my colors of line numbers to yellow and I enjoy the visibility very much.

I tried to make it work through this disscussion I've found https://stackoverflow.com/questions/237289/vim-configure-line-number-coloring, with no luck. I haven't found a way to do it in a .lua configuration file and pasting :highlight LineNr ctermfg=grey was no luck either.

4 Answers4

2

Solution: This is a solution that worked for me (Using relative numbers):

-- Sets colors to line numbers Above, Current and Below  in this order
function LineNumberColors()
    vim.api.nvim_set_hl(0, 'LineNrAbove', { fg='#51B3EC', bold=true })
    vim.api.nvim_set_hl(0, 'LineNr', { fg='white', bold=true })
    vim.api.nvim_set_hl(0, 'LineNrBelow', { fg='#FB508F', bold=true })
end

Calling this function in colors.lua right after a function for my neovim theme.

Like so:

SetTheme()
LineNumberColors()
1

You can use vim.api.nvim_set_hl() for this.

vim.api.nvim_set_hl(0, 'LineNrAbove', { fg='blue' })
vim.api.nvim_set_hl(0, 'LineNr', { fg='yellow' })
vim.api.nvim_set_hl(0, 'LineNrBelow', { fg='magenta' })

These need to be set after you set your colourscheme for them to not be immediately overwritten.

If you have cursorline enabled, LineNr should be replaced with CursorLineNr.

Holloway
  • 6,412
  • 1
  • 26
  • 33
1

If you are using tokyonight you can override colors for specific parts of interface. I've personally found success with setting fg_gutter (you can find all variables you can override here).

My after/plugin/theme.lua:

local tokyotheme = require("tokyonight")
tokyotheme.setup({
  on_colors = function (colors)
    colors.fg_gutter = "#b2b8cf"
  end
})

This changes all line numbers color to the one specified in snippet.

K Kafara
  • 656
  • 4
  • 5
0
  require("tokyonight").setup {
    on_highlights = function(hl, colors)
      hl.LineNr = {
        fg = "#fffb7b",
      }
      hl.CursorLineNr = {
        fg = colors.orange,
      }
    end,
  }

https://github.com/folke/tokyonight.nvim/issues/100

lonny
  • 11
  • 1
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 18 '23 at 08:33