olimorris / onedarkpro.nvim

🎨 Atom's iconic One Dark theme. Cacheable, fully customisable, Tree-sitter and LSP semantic token support. Comes with variants
MIT License
802 stars 44 forks source link

Highlight DiffChange #186

Closed olimorris closed 1 year ago

olimorris commented 1 year ago

I think it would be a good idea to set it, as leaving it unset (at least on neovim) leaves the default magenta bg for changed lines when doing a diff is quite jarring and doesn't match. I see that there used to be a DiffChange variable in the colors object but it's commented out?

Originally posted by @bertin0 in https://github.com/olimorris/onedarkpro.nvim/discussions/185

mmirus commented 1 year ago

FWIW I do this:

DiffChange = { bg = nil }, -- Changed lines

But that's in combination with a number of other changes to git/diff highltighting. Full context:

return {
  {
    "olimorris/onedarkpro.nvim",
    priority = 1000,
    config = function()
      local variant = "onedark_vivid"
      local helpers = require("onedarkpro.helpers")
      local Color = require("onedarkpro.lib.color")
      local colors = helpers.get_preloaded_colors(variant)
      local git_hunk_add = helpers.darken("#43554d", 10)
      -- local git_hunk_add_inline = helpers.lighten(git_hunk_add, 15)
      local git_hunk_add_inline = helpers.lighten(git_hunk_add, 5)
      local git_hunk_delete = helpers.darken("#502d30", 3)

      require("onedarkpro").setup({
        colors = {
          git_add = colors.green,
          git_change = colors.yellow,
          git_delete = colors.red,

          git_hunk_add = git_hunk_add,
          git_hunk_delete = git_hunk_delete,
          git_hunk_add_inline = git_hunk_add_inline,
          git_hunk_change_inline = "#41483d",
          git_hunk_delete_inline = helpers.lighten(git_hunk_delete, 15),

          diff_add = git_hunk_add,
          diff_text = git_hunk_add_inline,
        },
        styles = {
          comments = "italic",
          parameters = "italic",
          methods = "bold",
          functions = "bold",
        },
        options = {
          cursorline = true,
        },
        highlights = {
          -- DiffChange = { link = "DiffAdd" }, -- Changed lines
          DiffChange = { bg = nil }, -- Changed lines
          DiffviewDiffDelete = { fg = "${line_number}" }, -- Diff filler lines in diffview when enhanced_diff_hl is enabled

          -- Telescope
          TelescopePreviewTitle = { bg = "${green}", fg = "${float_bg}" },
          TelescopeResultsTitle = { bg = "${blue}", fg = "${float_bg}" },
          TelescopePromptTitle = { bg = "${purple}", fg = "${float_bg}" },
          TelescopeBorder = { bg = "${float_bg}", fg = "${float_bg}" },

          -- hl_match_area.nvim
          MatchArea = { bg = Color.from_hex(colors.blue):blend(Color.from_hex(colors.bg), 0.9):to_css() },

          -- Markdown
          CodeBlock = { bg = helpers.darken(colors.bg, 1) },

          -- ufo (folding)
          Folded = { bg = "${float_bg}" },
        },
      })

      if vim.o.background == "light" then
        vim.cmd([[colorscheme onelight]])
      else
        vim.cmd("colorscheme " .. variant)
      end
    end,
  },
}

And here's a diff example with a changed line:

image

vs the stock:

image