onedark.nvim icon indicating copy to clipboard operation
onedark.nvim copied to clipboard

How to configure nested colors (e.g. diffs, etc)

Open mcmillion opened this issue 3 years ago • 3 comments

I see that we can override colors in the config via:

require("onedark").setup({
  colors = {hint = "orange", error = "#ff0000"}
})

Is there something similar for changing things like git diffs? Maybe I'm just messing up the syntax (I'm newer to lua in general)?

mcmillion avatar Jun 21 '21 22:06 mcmillion

Yes you can overide git diff colors using git lua table. Reference the lua/onedark/colors.lua for a other possible color override.

require("onedark").setup({
  colors = {
    git = {
      change = "#e0af68",
      add = "#109868",
      delete = "#9A353D",
      conflict = "#bb7a61",
      ignore = "#5c6370"
    }
  }
})

Permalinks

https://github.com/ful1e5/onedark.nvim/blob/38b637026326fec447a2faf5c5294bd0da94a5a5/lua/onedark/colors.lua#L35 https://github.com/ful1e5/onedark.nvim/blob/38b637026326fec447a2faf5c5294bd0da94a5a5/lua/onedark/colors.lua#L54

ful1e5 avatar Jun 22 '21 04:06 ful1e5

That's what I was trying, but I'm getting the following on current master:

E5113: Error while calling lua chunk: ...site/pack/packer/start/onedark.nvim/lua/onedark/util.lua:230: bad argument #1 to 'sub' (string expected, got table)

Which is why I was wondering if I'm doing something wrong or maybe I've got something not working with my plugin imports...

mcmillion avatar Jun 22 '21 15:06 mcmillion

@ful1e5 Configuring nested colors using names of a onedark color like 'orange1' doesn't seem to work:

require("onedark").setup({
  colors = {
    git = {
      add = 'green0',
      change = 'orange1',
      delete = 'red1',
      conflict = '#bb7a61',
      ignore = 'fg_gutter',
    }
  }
})

I get the error color "change" does not exist.

Here's a full config to reproduce:

Click to expand
-- Ignore default config and plugins
vim.opt.runtimepath:remove(vim.fn.expand('~/.config/nvim'))
vim.opt.packpath:remove(vim.fn.expand('~/.local/share/nvim/site'))

-- Append test directory
local test_dir = vim.fn.expand('~/code-other/nvim-test-config')
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))

-- Install packer
local install_path = test_dir .. '/pack/packer/start/packer.nvim'
local install_plugins = false

if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
  vim.cmd('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
  vim.cmd('packadd packer.nvim')
  install_plugins = true
end

local packer = require('packer')

packer.init({
  package_root = test_dir .. '/pack',
  compile_path = test_dir .. '/plugin/packer_compiled.lua'
})

packer.startup(function()
  function Use(module)
    use(require(string.format('configs.%s', module)))
  end

  -- Packer can manage itself
  packer.use 'wbthomason/packer.nvim'

  use { 'ful1e5/onedark.nvim', config = function()
    require("onedark").setup({
      colors = {
        git = {
          add = 'green0',
          change = 'orange1',
          delete = 'red1',
          conflict = '#bb7a61',
          ignore = 'fg_gutter',
        }
      }
    })
  end }

  if install_plugins then
    packer.sync()
  else
    -- load plugins at your earliest convenience
    vim.defer_fn(function()
      vim.cmd('doautocmd User LoadPlugins')
    end, 1)
  end
end)

mawkler avatar Jun 10 '22 14:06 mawkler