Skip to content

Commit

Permalink
feat: add italics option (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpea2506 authored Jun 1, 2023
1 parent 277e4f4 commit 9d4d11e
Show file tree
Hide file tree
Showing 7 changed files with 616 additions and 590 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ require("one_monokai").setup({
| `transparent` | enable transparent background | `boolean` | N/A |
| `colors` | custom colors | `table<string, string>` | N/A |
| `themes` | custom highlight groups | `function(colors): tables` | `:h nvim_set_hl` |
| `italics` | enable italics | `boolean` | N/A |

#### Default

Expand All @@ -64,6 +65,7 @@ require("one_monokai").setup({
themes = function(colors)
return {}
end,
italics = true,
}
```

Expand All @@ -88,6 +90,7 @@ require("one_monokai").setup({
["@lsp.type.keyword"] = { link = "@keyword" }
}
end,
italics = false, -- disable italics
})
```

Expand Down
24 changes: 11 additions & 13 deletions lua/one_monokai/colors.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local logs = require "one_monokai.logs"
local config = require "one_monokai.config"
local logs = require "one_monokai.logs"

local colors = {}

Expand Down Expand Up @@ -56,20 +56,18 @@ local function is_valid_color(name, value)
return true
end

function colors:get()
local user_colors = config.colors
local user_colors = config.colors

if vim.tbl_isempty(user_colors) then
return self.default
end
if vim.tbl_isempty(user_colors) then
return colors.default
end

for name, value in pairs(user_colors) do
if not is_valid_color(name, value) then
return self.default
end
for name, value in pairs(user_colors) do
if not is_valid_color(name, value) then
return colors.default
end

return vim.tbl_extend("force", self.default, user_colors)
end

return colors:get()
colors.extended = vim.tbl_extend("force", colors.default, user_colors)

return colors.extended
2 changes: 2 additions & 0 deletions lua/one_monokai/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ config.options = {
themes = function(_)
return {}
end,
---@type boolean #whether to italicize some highlight groups
italics = true,
}

---Extend default with user config
Expand Down
Loading

0 comments on commit 9d4d11e

Please sign in to comment.