theme.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. vim.o.termguicolors = true
  2. vim.g.sonokai_transparent_background = true
  3. vim.g.sonokai_disable_terminal_colors = true
  4. vim.o.laststatus = 3
  5. -- neovim has a NormalNC highlight group that applies to inactive windows but
  6. -- we want to apply different styles to *active* windows. The Normal highlight
  7. -- group is special and setting a background there applies to everything and
  8. -- cannot be "unset" from other groups like NormalNC.
  9. --
  10. -- What we do here is create a new highlight namespace that we apply to active
  11. -- windows only. We have to copy all the original highlight groups and then
  12. -- apply our changes. We then change the window's highlight namespace on
  13. -- WinEnter/WinLeave.
  14. local active_ns = vim.api.nvim_create_namespace('active')
  15. function init_active_ns()
  16. local hls = vim.api.nvim_get_hl(0, {})
  17. for k,v in ipairs(hls) do
  18. vim.api.nvim_set_hl(active_ns, k, v)
  19. end
  20. local normal = vim.api.nvim_get_hl(0, { name = 'Normal' })
  21. normal.ctermbg = 235
  22. normal.bg = '#2c2c2c'
  23. vim.api.nvim_set_hl(active_ns, 'Normal', normal)
  24. vim.api.nvim_win_set_hl_ns(0, active_ns)
  25. end
  26. vim.api.nvim_create_autocmd('WinEnter', {
  27. callback = function()
  28. vim.api.nvim_win_set_hl_ns(0, active_ns)
  29. end
  30. })
  31. vim.api.nvim_create_autocmd('WinLeave', {
  32. callback = function()
  33. vim.api.nvim_win_set_hl_ns(0, 0)
  34. end
  35. })
  36. vim.api.nvim_create_autocmd('ColorScheme', {
  37. pattern = 'sonokai',
  38. callback = function()
  39. vim.api.nvim_set_hl(0, 'MiniIndentscopeSymbol', { link = 'Whitespace' })
  40. local configuration = vim.fn['sonokai#get_configuration']()
  41. local palette = vim.fn['sonokai#get_palette'](configuration.style, {[vim.type_idx]=vim.types.dictionary})
  42. vim.fn['sonokai#highlight']('MiniStatuslineModeNormal', palette.black, palette.blue)
  43. vim.fn['sonokai#highlight']('MiniStatuslineModeCommand', palette.black, palette.yellow)
  44. vim.fn['sonokai#highlight']('MiniStatuslineModeInsert', palette.black, palette.green)
  45. vim.fn['sonokai#highlight']('MiniStatuslineModeVisual', palette.black, palette.orange)
  46. vim.fn['sonokai#highlight']('MiniStatuslineModeReplace', palette.black, palette.red)
  47. vim.fn['sonokai#highlight']('MiniStatuslineModeOther', palette.black, palette.green)
  48. init_active_ns()
  49. end,
  50. })
  51. vim.cmd('colorscheme sonokai')