mawkler / modicator.nvim

Cursor line number mode indicator plugin for Neovim
MIT License
298 stars 6 forks source link

feat: add option for bold/italic formatting #3

Closed itzaeon closed 1 year ago

itzaeon commented 1 year ago

I added the option to format line numbers with bold or italics. I changed the name of your function M.set_highlight to M.set_highlight_and_format with a new parameter format.

Note: I haven't seen the syntax ---@param color string before, so you might have to update that for the new format parameter.

mawkler commented 1 year ago

@itzaeon Thank you very much for your PR! I have just a couple of minor things to comment on.

I think I might prefer if the configuration API looked like this:

{
  highlights = {
    modes = {
      ['i']  = {
        color = colors.insert,
        bold = false,
        italic = false,
      },
      ['v']  = {
        color = colors.visual,
        bold = false,
        italic = false,
      },
      ['V']  = {
        color = colors.visual,
        bold = false,
        italic = false,
      },
      [''] = {
        color = colors.visual,
        bold = false,
        italic = false,
      },
      ['s']  = {
        color = colors.select,
        bold = false,
        italic = false,
      },
      ['S']  = {
        color = colors.select,
        bold = false,
        italic = false,
      },
      ['R']  = {
        color = colors.replace,
        bold = false,
        italic = false,
      },
      ['c']  = {
        color = colors.command,
        bold = false,
        italic = false,
      },
    }
  }
}

since in Neovim, the "highlght" includes italic/bold. Or what do you think? Or do you think that would make it more confusing the user to include italic/bold under the highlights table?

itzaeon commented 1 year ago

A quick summary of my changes:

I also added the updated options keys to config, as well as how to install with lazy.nvim.

mawkler commented 1 year ago

@itzaeon Nice! However, now there's no highlight except for in normal mode for me. If I go to insert/visual/replace/etc. mode the line number indicator gets the foreground color of Nomal (white for me). Do you have the same issue?

itzaeon commented 1 year ago

I believe I know why you experience this behavior. The two colorschemes I use are zephyr and oxocarbon. This plugin works "as designed" when I use zephyr as my scheme, but not when I use oxocarbon.

Highlights with zephyr:

And with oxocarbon:

Note that with oxocarbon, both CursorLineNr and Question have the same value. I see the same behavior that you do. With zephyr, since CursorLineNr/Question/Type are all different, the plugin works as intended.

I see two options to fix this. 1) We can define highlight groups specifically for modicator (ie ModicatorNormalHighlight, ModicatorInsertHighlight) or 2) a new function can be added that finds different highlights for each mode.

mawkler commented 1 year ago

@itzaeon I'm not sure that's the issue I'm seeing since I explicitly set the colors in my config. I get the same problem with the following test config on your branch:

use { 'melkster/modicator.nvim',
  config = function()
    require('modicator').setup({
      highlights = {
        modes = {
          ['i']  = 'red',
          ['v']  = 'green',
          ['V']  = 'blue',
          [''] = 'blue',
          ['s']  = 'yellow',
          ['S']  = 'brown',
          ['R']  = 'pink',
          ['c']  = 'orange',
        }
      },
    })
  end
}
itzaeon commented 1 year ago

@mawkler That config won't work because it was changed here. I get the same behavior using that config, but because the config options have changed in accordance with your comment, something like this should work:

use { 'melkster/modicator.nvim',
  config = function()
    require('modicator').setup({
      highlights = {
        modes = {
          ['n'] = { color = 'orange' },
          ['i']  = { color = 'red' },
          ['v']  = { color = 'green' },
          ['V']  = { color = 'blue' },
          ['�'] = { color = 'blue' },
          ['s']  = { color = 'yellow' },
          ['S']  = { color = 'brown' },
          ['R']  = { color = 'pink' },
          ['c']  = { color = 'orange' },
        }
      },
    })
  end
}
mawkler commented 1 year ago

@itzaeon Of course! You're right, that's my bad.

itzaeon commented 1 year ago

Those should work.

itzaeon commented 1 year ago

Done!

mawkler commented 1 year ago

Awesome! Thank you very much for your contributing! 😄

mawkler commented 1 year ago

@itzaeon Note that I just changed the name of the option color to foreground in 26338f79329e0659b5c4bd7909816f95a715b6ca to make it more coherent with Neovim's vim.api.nvim_set_hl(). I also added a background option.