aboutsummaryrefslogtreecommitdiff
path: root/core/themes.lua
blob: 1a4282840c739c23f7bfd7e719cc0d6d77396c0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
local utils = require('utils')

local M = {}

-- Theme to directory name mapping, because theme repo name is not necessarily
-- the same as the theme name itself.
M.theme2dir = {
  gruvbox8 = "vim-gruvbox8",
  onedark = 'onedark.nvim',
  edge = 'edge',
  sonokai = 'sonokai',
  gruvbox_material = 'gruvbox-material',
  nord = 'nord.nvim',
  doom_one = 'doom-one.nvim',
  everforest = 'everforest',
  nightfox = 'nightfox.nvim',
  kanagawa = 'kanagawa.nvim',
  catppuccin = 'catppuccin'
}

M.gruvbox8 = function()
  -- Italic options should be put before colorscheme setting,
  -- see https://github.com/morhetz/gruvbox/wiki/Terminal-specific#1-italics-is-disabled
  vim.g.gruvbox_italics = 1
  vim.g.gruvbox_italicize_strings = 1
  vim.g.gruvbox_filetype_hi_groups = 1
  vim.g.gruvbox_plugin_hi_groups = 1

  vim.cmd [[colorscheme gruvbox8_hard]]
end

M.onedark = function()
  vim.cmd [[colorscheme onedark]]
end

M.edge = function()
  vim.g.edge_enable_italic = 1
  vim.g.edge_better_performance = 1

  vim.cmd [[colorscheme edge]]
end

M.sonokai = function()
  vim.g.sonokai_enable_italic = 1
  vim.g.sonokai_better_performance = 1

  vim.cmd [[colorscheme sonokai]]
end

M.gruvbox_material = function()
  vim.g.gruvbox_material_enable_italic = 1
  vim.g.gruvbox_material_better_performance = 1

  vim.cmd [[colorscheme gruvbox-material]]
end

M.nord = function()
  vim.cmd [[colorscheme nord]]
end

M.doom_one = function()

  vim.cmd [[colorscheme doom-one]]
end

M.everforest = function()
  vim.g.everforest_enable_italic = 1
  vim.g.everforest_better_performance = 1

  vim.cmd [[colorscheme everforest]]
end

M.nightfox = function()
  vim.cmd [[colorscheme nordfox]]
end


M.kanagawa = function()
  vim.cmd [[colorscheme kanagawa]]
end

M.catppuccin = function()
  -- available option: latte, frappe, macchiato, mocha
  vim.g.catppuccin_flavour = "frappe"

  require("catppuccin").setup()

  vim.cmd [[colorscheme catppuccin]]
end


--- Use a random theme from the pre-defined list of themes.
M.rand_theme = function ()
  local theme = utils.rand_element(vim.tbl_keys(M.theme2dir))

  if not vim.tbl_contains(vim.tbl_keys(M), theme) then
    local msg = "Invalid theme: " .. theme
    vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })

    return
  end

  -- Load the theme, because all the themes are declared as opt plugins, the theme isn't loaded yet.
  local status = utils.add_pack(M.theme2dir[theme])

  if not status then
    local msg = string.format("Theme %s is not installed. Run PackerSync to install.", theme)
    vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })

    return
  end

  -- Set the theme.
  M[theme]()

  if vim.g.logging_level == 'debug' then
    local msg = "Colorscheme: " .. theme

    vim.notify(msg, vim.log.levels.DEBUG, { title = 'nvim-config' })
  end
end

M.rand_theme()