Skip to content

Commit 9d4d11e

Browse files
authored
feat: add italics option (#57)
1 parent 277e4f4 commit 9d4d11e

File tree

7 files changed

+616
-590
lines changed

7 files changed

+616
-590
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ require("one_monokai").setup({
5454
| `transparent` | enable transparent background | `boolean` | N/A |
5555
| `colors` | custom colors | `table<string, string>` | N/A |
5656
| `themes` | custom highlight groups | `function(colors): tables` | `:h nvim_set_hl` |
57+
| `italics` | enable italics | `boolean` | N/A |
5758

5859
#### Default
5960

@@ -64,6 +65,7 @@ require("one_monokai").setup({
6465
themes = function(colors)
6566
return {}
6667
end,
68+
italics = true,
6769
}
6870
```
6971

@@ -88,6 +90,7 @@ require("one_monokai").setup({
8890
["@lsp.type.keyword"] = { link = "@keyword" }
8991
}
9092
end,
93+
italics = false, -- disable italics
9194
})
9295
```
9396

lua/one_monokai/colors.lua

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local logs = require "one_monokai.logs"
21
local config = require "one_monokai.config"
2+
local logs = require "one_monokai.logs"
33

44
local colors = {}
55

@@ -56,20 +56,18 @@ local function is_valid_color(name, value)
5656
return true
5757
end
5858

59-
function colors:get()
60-
local user_colors = config.colors
59+
local user_colors = config.colors
6160

62-
if vim.tbl_isempty(user_colors) then
63-
return self.default
64-
end
61+
if vim.tbl_isempty(user_colors) then
62+
return colors.default
63+
end
6564

66-
for name, value in pairs(user_colors) do
67-
if not is_valid_color(name, value) then
68-
return self.default
69-
end
65+
for name, value in pairs(user_colors) do
66+
if not is_valid_color(name, value) then
67+
return colors.default
7068
end
71-
72-
return vim.tbl_extend("force", self.default, user_colors)
7369
end
7470

75-
return colors:get()
71+
colors.extended = vim.tbl_extend("force", colors.default, user_colors)
72+
73+
return colors.extended

lua/one_monokai/config.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ config.options = {
1111
themes = function(_)
1212
return {}
1313
end,
14+
---@type boolean #whether to italicize some highlight groups
15+
italics = true,
1416
}
1517

1618
---Extend default with user config

0 commit comments

Comments
 (0)