Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

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

Open
mcmillion opened this issue Jun 21, 2021 · 3 comments
Open

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

mcmillion opened this issue Jun 21, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@mcmillion
Copy link

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)?

@ful1e5
Copy link
Owner

ful1e5 commented Jun 22, 2021

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

git = {change = "#e0af68", add = "#109868", delete = "#9A353D", conflict = "#bb7a61"},

colors.git.ignore = colors.fg_gutter

@mcmillion
Copy link
Author

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...

@ful1e5 ful1e5 added the bug Something isn't working label Jun 23, 2021
@ful1e5 ful1e5 closed this as completed in 5335310 Jun 23, 2021
ful1e5 added a commit that referenced this issue Jun 23, 2021
🔧 (fix #6) Parse lua table inside `colors` config
@mawkler
Copy link
Contributor

mawkler commented Jun 10, 2022

@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)

@ful1e5 ful1e5 reopened this Jun 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants