A Neovim plugin enabling you to solve LeetCode problems.
feat(theme): `ColorScheme` autocmd
17 files changed, +143 -83
+1-1lua/leetcode-ui/component/button.lua
| @@ -32,7 +32,7 @@ function button:init(text, sc, on_press, expandable) | ||
| 32 | 32 | local line = NuiLine() |
| 33 | 33 | line:append(txt) |
| 34 | 34 | line:append(padding) |
| 35 | - line:append(sc, "LeetCodeInfo") | |
| 35 | + line:append(sc, "leetcode_info") | |
| 36 | 36 | |
| 37 | 37 | local obj = setmetatable({ |
| 38 | 38 | opts = opts, |
+9-20lua/leetcode.lua
| @@ -16,26 +16,15 @@ local function should_start() | ||
| 16 | 16 | end |
| 17 | 17 | |
| 18 | 18 | local function setup_highlights() |
| 19 | - vim.api.nvim_set_hl(0, "LeetCodeEasy", { fg = "#46c6c2" }) | |
| 20 | - vim.api.nvim_set_hl(0, "LeetCodeMedium", { fg = "#fac31d" }) | |
| 21 | - vim.api.nvim_set_hl(0, "LeetCodeHard", { fg = "#f8615c" }) | |
| 22 | - | |
| 23 | - vim.api.nvim_set_hl(0, "LeetCodeInfo", { link = "DiagnosticInfo" }) | |
| 24 | - vim.api.nvim_set_hl(0, "LeetCodeHint", { link = "DiagnosticHint" }) | |
| 25 | - vim.api.nvim_set_hl(0, "LeetCodeError", { link = "DiagnosticError" }) | |
| 26 | - vim.api.nvim_set_hl(0, "LeetCodeOk", { link = "DiagnosticOk" }) | |
| 27 | - | |
| 28 | - local normal = vim.api.nvim_get_hl(0, { name = "FloatTitle" }) | |
| 29 | - vim.api.nvim_set_hl(0, "LeetCodeNormal", normal) | |
| 30 | - vim.api.nvim_set_hl(0, "LeetCodeItalic", vim.tbl_extend("force", normal, { italic = true })) | |
| 31 | - vim.api.nvim_set_hl(0, "LeetCodeBold", { bold = true }) | |
| 32 | - | |
| 33 | - vim.api.nvim_set_hl(0, "LeetCodeCode", { link = "Type" }) | |
| 34 | - vim.api.nvim_set_hl(0, "LeetCodeExample", { link = "LeetCodeHint" }) | |
| 35 | - vim.api.nvim_set_hl(0, "LeetCodeConstraints", { link = "LeetCodeInfo" }) | |
| 36 | - vim.api.nvim_set_hl(0, "LeetCodeIndent", { link = "Comment" }) | |
| 37 | - vim.api.nvim_set_hl(0, "LeetCodeList", { link = "Tag" }) | |
| 38 | - vim.api.nvim_set_hl(0, "LeetCodeLink", { link = "Function" }) | |
| 19 | + local theme = require("leetcode.theme") | |
| 20 | + | |
| 21 | + vim.api.nvim_create_autocmd("ColorScheme", { | |
| 22 | + desc = "Colorscheme Synchronizer", | |
| 23 | + group = vim.api.nvim_create_augroup("lc.colorscheme_sync", {}), | |
| 24 | + callback = function() theme.load() end, | |
| 25 | + }) | |
| 26 | + | |
| 27 | + theme.load() | |
| 39 | 28 | end |
| 40 | 29 | |
| 41 | 30 | local function setup_cmds() |
+8-8lua/leetcode/parser/init.lua
| @@ -135,14 +135,14 @@ function parser:handle_list(tags) | ||
| 135 | 135 | text = string.format("%s%d. ", leftpad, self.ol_count[ol_c]) |
| 136 | 136 | end |
| 137 | 137 | |
| 138 | - self.line:append(text, "LeetCodeList") | |
| 138 | + self.line:append(text, "leetcode_list") | |
| 139 | 139 | end |
| 140 | 140 | |
| 141 | 141 | ---@param text string |
| 142 | 142 | function parser:handle_indent(text) |
| 143 | 143 | if self.line:content() ~= "" then return text end |
| 144 | 144 | |
| 145 | - self.line:append("\t▎\t", "LeetCodeIndent") | |
| 145 | + self.line:append("\t▎\t", "leetcode_indent") | |
| 146 | 146 | end |
| 147 | 147 | |
| 148 | 148 | ---@private |
| @@ -160,9 +160,9 @@ function parser:handle_link(text, tag_data) | ||
| 160 | 160 | end |
| 161 | 161 | if not href then return line end |
| 162 | 162 | |
| 163 | - line:append("[", "LeetCodeIndent") | |
| 164 | - line:append(text, "LeetCodeLink") | |
| 165 | - line:append(string.format("](%s)", href), "LeetCodeIndent") | |
| 163 | + line:append("[", "leetcode_indent") | |
| 164 | + line:append(text, "leetcode_link") | |
| 165 | + line:append(string.format("](%s)", href), "leetcode_indent") | |
| 166 | 166 | |
| 167 | 167 | return line |
| 168 | 168 | end |
| @@ -180,9 +180,9 @@ function parser:handle_img(tag_data) | ||
| 180 | 180 | if not src then return end |
| 181 | 181 | alt = alt or "" |
| 182 | 182 | |
| 183 | - line:append(string.format("[%s](", alt ~= "" and alt or "img"), "LeetCodeIndent") | |
| 184 | - line:append(src, "LeetCodeLink") | |
| 185 | - line:append(")", "LeetCodeIndent") | |
| 183 | + line:append(string.format("[%s](", alt ~= "" and alt or "img"), "leetcode_indent") | |
| 184 | + line:append(src, "leetcode_link") | |
| 185 | + line:append(")", "leetcode_indent") | |
| 186 | 186 | |
| 187 | 187 | self.text:append(line) |
| 188 | 188 | end |
+8-8lua/leetcode/parser/utils.lua
| @@ -36,14 +36,14 @@ local entities = { | ||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | local highlights = { |
| 39 | - [""] = "LeetCodeNormal", | |
| 40 | - ["strong"] = "LeetCodeBold", | |
| 41 | - ["b"] = "LeetCodeBold", | |
| 42 | - ["em"] = "LeetCodeItalic", | |
| 43 | - ["i"] = "LeetCodeItalic", | |
| 44 | - ["code"] = "LeetCodeCode", | |
| 45 | - ["example"] = "LeetCodeExample", | |
| 46 | - ["constraints"] = "LeetCodeConstraints", | |
| 39 | + [""] = "leetcode_normal", | |
| 40 | + ["strong"] = "leetcode_bold", | |
| 41 | + ["b"] = "leetcode_bold", | |
| 42 | + ["em"] = "leetcode_italic", | |
| 43 | + ["i"] = "leetcode_italic", | |
| 44 | + ["code"] = "leetcode_code", | |
| 45 | + ["example"] = "leetcode_example", | |
| 46 | + ["constraints"] = "leetcode_constraints", | |
| 47 | 47 | |
| 48 | 48 | ["pre"] = "Inherit", |
| 49 | 49 | ["span"] = "Inherit", |
+1-1lua/leetcode/pickers/language.lua
| @@ -21,7 +21,7 @@ local function lang_formatter(snippet) return string.format("%s %s", snippet.t.l | ||
| 21 | 21 | |
| 22 | 22 | ---@param snippet lc.QuestionCodeSnippet |
| 23 | 23 | local function dislay_icon(snippet) |
| 24 | - local hl = "LeetCodeLang_" .. snippet.t.slug | |
| 24 | + local hl = "leetcode_lang_" .. snippet.t.slug | |
| 25 | 25 | vim.api.nvim_set_hl(0, hl, { fg = snippet.t.color }) |
| 26 | 26 | |
| 27 | 27 | return { snippet.t.icon, hl } |
+8-2lua/leetcode/pickers/question-tabs.lua
| @@ -24,13 +24,19 @@ local function display_current(entry) | ||
| 24 | 24 | end |
| 25 | 25 | |
| 26 | 26 | local function display_difficulty(q) |
| 27 | + local hl = { | |
| 28 | + ["Easy"] = "leetcode_easy", | |
| 29 | + ["Medium"] = "leetcode_medium", | |
| 30 | + ["Hard"] = "leetcode_hard", | |
| 31 | + } | |
| 32 | + | |
| 27 | 33 | local lang = utils.get_lang(q.lang) |
| 28 | - return { lang.short, "LeetCode" .. q.q.difficulty } | |
| 34 | + return { lang.short, hl[q.q.difficulty] } | |
| 29 | 35 | end |
| 30 | 36 | |
| 31 | 37 | ---@param question lc.Cache.Question |
| 32 | 38 | local function display_question(question) |
| 33 | - local index = { question.frontend_id .. ".", "LeetCodeNormal" } | |
| 39 | + local index = { question.frontend_id .. ".", "leetcode_normal" } | |
| 34 | 40 | local title = { question.title } |
| 35 | 41 | |
| 36 | 42 | return unpack({ index, title }) |
+11-9lua/leetcode/pickers/question.lua
| @@ -20,22 +20,24 @@ end | ||
| 20 | 20 | |
| 21 | 21 | ---@param question lc.Cache.Question |
| 22 | 22 | local function display_difficulty(question) |
| 23 | - local hi = { | |
| 24 | - ["Easy"] = { "E", "LeetCodeEasy" }, | |
| 25 | - ["Medium"] = { "M", "LeetCodeMedium" }, | |
| 26 | - ["Hard"] = { "H", "LeetCodeHard" }, | |
| 23 | + local hl = { | |
| 24 | + ["Easy"] = "leetcode_easy", | |
| 25 | + ["Medium"] = "leetcode_medium", | |
| 26 | + ["Hard"] = "leetcode_hard", | |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return { "", "LeetCode" .. question.difficulty } | |
| 29 | + return { "", hl[question.difficulty] } | |
| 30 | 30 | end |
| 31 | 31 | |
| 32 | 32 | ---@param question lc.Cache.Question |
| 33 | 33 | local function display_user_status(question) |
| 34 | - if question.paid_only and not config.auth.is_premium then return { "", "LeetCodeMedium" } end | |
| 34 | + if question.paid_only and not config.auth.is_premium then | |
| 35 | + return { "", "leetcode_medium" } | |
| 36 | + end | |
| 35 | 37 | |
| 36 | 38 | local user_status = { |
| 37 | - ac = { "", "LeetCodeEasy" }, | |
| 38 | - notac = { "", "LeetCodeMedium" }, | |
| 39 | + ac = { "", "leetcode_easy" }, | |
| 40 | + notac = { "", "leetcode_medium" }, | |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | 43 | if question.status == vim.NIL then return { "" } end |
| @@ -44,7 +46,7 @@ end | ||
| 44 | 46 | |
| 45 | 47 | ---@param question lc.Cache.Question |
| 46 | 48 | local function display_question(question) |
| 47 | - local index = { question.frontend_id .. ".", "LeetCodeNormal" } | |
| 49 | + local index = { question.frontend_id .. ".", "leetcode_normal" } | |
| 48 | 50 | local title = { question.title } |
| 49 | 51 | |
| 50 | 52 | return unpack({ index, title }) |
+44-0lua/leetcode/theme/default.lua
| @@ -0,0 +1,44 @@ | ||
| 1 | +---Get highlight group value by name. | |
| 2 | +--- | |
| 3 | +---@param name string String for looking up highlight group. | |
| 4 | +---@return table | |
| 5 | +local function hl(name) | |
| 6 | + local highlight = vim.api.nvim_get_hl(0, { name = name, link = true }) | |
| 7 | + setmetatable(highlight, { | |
| 8 | + __index = function(self, key) | |
| 9 | + if key == "bg" then return self.background end | |
| 10 | + if key == "fg" then return self.foreground end | |
| 11 | + | |
| 12 | + return nil | |
| 13 | + end, | |
| 14 | + }) | |
| 15 | + | |
| 16 | + return highlight | |
| 17 | +end | |
| 18 | + | |
| 19 | +---@alias lc.Themes table<string, table> | |
| 20 | +---@type lc.Themes | |
| 21 | +return function() | |
| 22 | + return { | |
| 23 | + easy = { fg = "#46c6c2" }, | |
| 24 | + medium = { fg = "#fac31d" }, | |
| 25 | + hard = { fg = "#f8615c" }, | |
| 26 | + | |
| 27 | + ok = { fg = hl("DiagnosticOk").fg }, | |
| 28 | + info = { fg = hl("DiagnosticInfo").fg }, | |
| 29 | + hint = { fg = hl("DiagnosticHint").fg }, | |
| 30 | + error = { fg = hl("DiagnosticError").fg }, | |
| 31 | + | |
| 32 | + bold = { bold = true }, | |
| 33 | + italic = { fg = hl("FloatTitle").fg, italic = true }, | |
| 34 | + | |
| 35 | + normal = { fg = hl("FloatTitle").fg }, | |
| 36 | + alt = { fg = hl("Comment").fg }, | |
| 37 | + code = { fg = hl("Type").fg }, | |
| 38 | + example = { fg = hl("DiagnosticHint").fg }, | |
| 39 | + constraints = { fg = hl("DiagnosticInfo").fg }, | |
| 40 | + indent = { fg = hl("Comment").fg }, | |
| 41 | + link = { fg = hl("Function").fg }, | |
| 42 | + list = { fg = hl("Tag").fg }, | |
| 43 | + } | |
| 44 | +end |
+12-0lua/leetcode/theme/init.lua
| @@ -0,0 +1,12 @@ | ||
| 1 | +---@class lc.Theme | |
| 2 | +local theme = {} | |
| 3 | + | |
| 4 | +function theme.load() | |
| 5 | + local default = require("leetcode.theme.default")() | |
| 6 | + for key, t in pairs(default) do | |
| 7 | + key = "leetcode_" .. key | |
| 8 | + vim.api.nvim_set_hl(0, key, t) | |
| 9 | + end | |
| 10 | +end | |
| 11 | + | |
| 12 | +return theme |
+4-4lua/leetcode/ui/console/components/case.lua
| @@ -18,22 +18,22 @@ function case:init(index, input, output, expected, passed) | ||
| 18 | 18 | |
| 19 | 19 | local match = passed or (output == expected) |
| 20 | 20 | local icon = match and "" or "" |
| 21 | - local hi = match and "LeetCodeOk" or "LeetCodeError" | |
| 21 | + local hi = match and "leetcode_ok" or "leetcode_error" | |
| 22 | 22 | local title_line = NuiLine():append(icon .. " Case " .. index, hi) |
| 23 | 23 | |
| 24 | 24 | local input_line = NuiLine() |
| 25 | 25 | input_line:append("Input: ") |
| 26 | - input_line:append(input, "Comment") | |
| 26 | + input_line:append(input, "leetcode_alt") | |
| 27 | 27 | table.insert(t, input_line) |
| 28 | 28 | |
| 29 | 29 | local output_line = NuiLine() |
| 30 | 30 | output_line:append("Output: ") |
| 31 | - output_line:append(output, "Comment") | |
| 31 | + output_line:append(output, "leetcode_alt") | |
| 32 | 32 | table.insert(t, output_line) |
| 33 | 33 | |
| 34 | 34 | local expected_line = NuiLine() |
| 35 | 35 | expected_line:append("Expected: ") |
| 36 | - expected_line:append(expected, "Comment") | |
| 36 | + expected_line:append(expected, "leetcode_alt") | |
| 37 | 37 | table.insert(t, expected_line) |
| 38 | 38 | |
| 39 | 39 | return Pre:init(title_line, t) |
+2-2lua/leetcode/ui/console/components/pre.lua
| @@ -17,7 +17,7 @@ function pre:init(title, lines) | ||
| 17 | 17 | local text = Text:init({ lines = { title, NuiLine() } }) |
| 18 | 18 | |
| 19 | 19 | for _, line in ipairs(lines) do |
| 20 | - local new_line = NuiLine({ NuiText("\t▎\t", "LeetCodeIndent") }) | |
| 20 | + local new_line = NuiLine({ NuiText("\t▎\t", "leetcode_indent") }) | |
| 21 | 21 | new_line:append(line) |
| 22 | 22 | text:append(new_line) |
| 23 | 23 | end |
| @@ -33,7 +33,7 @@ function pre:init(title, lines) | ||
| 33 | 33 | -- table.insert(t, NuiLine()) |
| 34 | 34 | -- local match = output == expected |
| 35 | 35 | -- local icon = match and "" or "" |
| 36 | - -- local hi = match and "LeetCodeOk" or "LeetCodeError" | |
| 36 | + -- local hi = match and "leetcode_ok" or "leetcode_error" | |
| 37 | 37 | -- local index_line = NuiLine():append(icon .. " Case " .. index, hi) |
| 38 | 38 | -- table.insert(t, index_line) |
| 39 | 39 | -- |
+1-1lua/leetcode/ui/console/components/stdout.lua
| @@ -19,7 +19,7 @@ function stdout:init(output) | ||
| 19 | 19 | table.insert(t, NuiLine():append(output_list[i])) |
| 20 | 20 | end |
| 21 | 21 | |
| 22 | - return Pre:init(NuiLine():append(" Stdout", "Comment"), t) | |
| 22 | + return Pre:init(NuiLine():append(" Stdout", "leetcode_alt"), t) | |
| 23 | 23 | end |
| 24 | 24 | |
| 25 | 25 | return stdout |
+16-16lua/leetcode/ui/console/result.lua
| @@ -29,7 +29,7 @@ end | ||
| 29 | 29 | function result:set_popup_border_hi(hi) self.popup.border:set_highlight(hi) end |
| 30 | 30 | |
| 31 | 31 | function result:handle_accepted(item) |
| 32 | - local function perc_hi(perc) return perc >= 50 and "LeetCodeOk" or "LeetCodeError" end | |
| 32 | + local function perc_hi(perc) return perc >= 50 and "leetcode_ok" or "leetcode_error" end | |
| 33 | 33 | local group = Group:init({ opts = { spacing = 2 } }) |
| 34 | 34 | |
| 35 | 35 | local header = Text:init() |
| @@ -40,7 +40,7 @@ function result:handle_accepted(item) | ||
| 40 | 40 | local status_runtime = NuiLine() |
| 41 | 41 | local runtime_ms = item.display_runtime or vim.split(item.status_runtime, " ")[1] or "NIL" |
| 42 | 42 | status_runtime:append(runtime_ms) |
| 43 | - status_runtime:append(" ms", "Comment") | |
| 43 | + status_runtime:append(" ms", "leetcode_alt") | |
| 44 | 44 | |
| 45 | 45 | local perc_runtime = NuiLine() |
| 46 | 46 | perc_runtime:append( |
| @@ -49,7 +49,7 @@ function result:handle_accepted(item) | ||
| 49 | 49 | ) |
| 50 | 50 | perc_runtime:append("of users with " .. item.pretty_lang) |
| 51 | 51 | |
| 52 | - local runtime = Pre:init(NuiText(" Runtime", "LeetCodeNormal"), { | |
| 52 | + local runtime = Pre:init(NuiText(" Runtime", "leetcode_normal"), { | |
| 53 | 53 | status_runtime, |
| 54 | 54 | perc_runtime, |
| 55 | 55 | }) |
| @@ -60,7 +60,7 @@ function result:handle_accepted(item) | ||
| 60 | 60 | if item.status_memory == "0B" then item.status_memory = "0 MB" end |
| 61 | 61 | local s_mem = vim.split(item.status_memory, " ") |
| 62 | 62 | status_memory:append(s_mem[1] .. " ") |
| 63 | - status_memory:append(s_mem[2], "Comment") | |
| 63 | + status_memory:append(s_mem[2], "leetcode_alt") | |
| 64 | 64 | |
| 65 | 65 | local perc_mem = NuiLine() |
| 66 | 66 | perc_mem:append( |
| @@ -69,7 +69,7 @@ function result:handle_accepted(item) | ||
| 69 | 69 | ) |
| 70 | 70 | perc_mem:append("of users with " .. item.pretty_lang) |
| 71 | 71 | |
| 72 | - local memory = Pre:init(NuiText(" Memory", "LeetCodeNormal"), { | |
| 72 | + local memory = Pre:init(NuiText(" Memory", "leetcode_normal"), { | |
| 73 | 73 | status_memory, |
| 74 | 74 | perc_mem, |
| 75 | 75 | }) |
| @@ -90,7 +90,7 @@ function result:handle_runtime(item) -- status code = 10 | ||
| 90 | 90 | local h = NuiLine() |
| 91 | 91 | h:append(item._.title, item._.hl) |
| 92 | 92 | h:append(" | ") |
| 93 | - h:append("Runtime: " .. item.status_runtime, "Comment") | |
| 93 | + h:append("Runtime: " .. item.status_runtime, "leetcode_alt") | |
| 94 | 94 | header:append(h) |
| 95 | 95 | group:append(header) |
| 96 | 96 | |
| @@ -122,7 +122,7 @@ function result:handle_submission_error(item) -- status code = 11 | ||
| 122 | 122 | local header = NuiLine() |
| 123 | 123 | header:append(item._.title, item._.hl) |
| 124 | 124 | header:append(" | ") |
| 125 | - header:append(passed_testcases(item), "Comment") | |
| 125 | + header:append(passed_testcases(item), "leetcode_alt") | |
| 126 | 126 | group:append(Text:init({ lines = { header } })) |
| 127 | 127 | |
| 128 | 128 | local text = Case:init( |
| @@ -153,10 +153,10 @@ function result:handle_limit_exceeded(item) -- status code = 14 | ||
| 153 | 153 | |
| 154 | 154 | if item._.submission then |
| 155 | 155 | local last_testcase = NuiLine() |
| 156 | - last_testcase:append(item.last_testcase:gsub("\n", " "), "LeetCodeIndent") | |
| 156 | + last_testcase:append(item.last_testcase:gsub("\n", " "), "leetcode_indent") | |
| 157 | 157 | |
| 158 | 158 | local pre_header = NuiLine() |
| 159 | - pre_header:append(" Last Executed Input", "LeetCodeNormal") | |
| 159 | + pre_header:append(" Last Executed Input", "leetcode_normal") | |
| 160 | 160 | |
| 161 | 161 | local last_exec = Pre:init(pre_header, { last_testcase }) |
| 162 | 162 | group:append(last_exec) |
| @@ -184,21 +184,21 @@ function result:handle_runtime_error(item) -- status code = 15 | ||
| 184 | 184 | |
| 185 | 185 | if item._.submission then |
| 186 | 186 | header:append(" | ") |
| 187 | - header:append(passed_testcases(item), "Comment") | |
| 187 | + header:append(passed_testcases(item), "leetcode_alt") | |
| 188 | 188 | end |
| 189 | 189 | |
| 190 | 190 | local t = {} |
| 191 | 191 | for line in vim.gsplit(item.full_runtime_error, "\n") do |
| 192 | - table.insert(t, NuiLine():append(line, "LeetCodeError")) | |
| 192 | + table.insert(t, NuiLine():append(line, "leetcode_error")) | |
| 193 | 193 | end |
| 194 | 194 | group:append(Pre:init(header, t)) |
| 195 | 195 | |
| 196 | 196 | if item._.submission then |
| 197 | 197 | local pre_header = NuiLine() |
| 198 | - pre_header:append(" Last Executed Input", "LeetCodeNormal") | |
| 198 | + pre_header:append(" Last Executed Input", "leetcode_normal") | |
| 199 | 199 | |
| 200 | 200 | local last_testcase = NuiLine() |
| 201 | - last_testcase:append(item.last_testcase:gsub("\n", " "), "LeetCodeIndent") | |
| 201 | + last_testcase:append(item.last_testcase:gsub("\n", " "), "leetcode_indent") | |
| 202 | 202 | |
| 203 | 203 | local last_exec = Pre:init(pre_header, { last_testcase }) |
| 204 | 204 | group:append(last_exec) |
| @@ -228,12 +228,12 @@ function result:handle_compile_error(item) -- status code = 20 | ||
| 228 | 228 | header:append(item._.title, item._.hl) |
| 229 | 229 | if item._.submission then |
| 230 | 230 | header:append(" | ") |
| 231 | - header:append(passed_testcases(item), "Comment") | |
| 231 | + header:append(passed_testcases(item), "leetcode_alt") | |
| 232 | 232 | end |
| 233 | 233 | |
| 234 | 234 | local t = {} |
| 235 | 235 | for line in vim.gsplit(item.full_compile_error, "\n") do |
| 236 | - table.insert(t, NuiLine():append(line, "LeetCodeError")) | |
| 236 | + table.insert(t, NuiLine():append(line, "leetcode_error")) | |
| 237 | 237 | end |
| 238 | 238 | |
| 239 | 239 | group:append(Pre:init(header, t)) |
| @@ -254,7 +254,7 @@ function result:handle_item(item) | ||
| 254 | 254 | if item.submission_id then |
| 255 | 255 | submission = not item.submission_id:find("runcode") and true or false |
| 256 | 256 | end |
| 257 | - local hl = success and "LeetCodeOk" or "LeetCodeError" | |
| 257 | + local hl = success and "leetcode_ok" or "leetcode_error" | |
| 258 | 258 | |
| 259 | 259 | item._ = { |
| 260 | 260 | title = " " .. item.status_msg, |
+14-7lua/leetcode/ui/description.lua
| @@ -88,7 +88,7 @@ function description:populate() | ||
| 88 | 88 | local q = self.parent.q |
| 89 | 89 | |
| 90 | 90 | local linkline = NuiLine() |
| 91 | - linkline:append("https://leetcode.com/problems/" .. q.title_slug .. "/", "Comment") | |
| 91 | + linkline:append("https://leetcode.com/problems/" .. q.title_slug .. "/", "leetcode_alt") | |
| 92 | 92 | |
| 93 | 93 | local titleline = NuiLine() |
| 94 | 94 | titleline:append(" " .. q.frontend_id .. ". " .. q.title .. " ", "") |
| @@ -97,18 +97,25 @@ function description:populate() | ||
| 97 | 97 | statsline:append( |
| 98 | 98 | q.difficulty, |
| 99 | 99 | ({ |
| 100 | - ["Easy"] = "LeetCodeEasy", | |
| 101 | - ["Medium"] = "LeetCodeMedium", | |
| 102 | - ["Hard"] = "LeetCodeHard", | |
| 100 | + ["Easy"] = "leetcode_easy", | |
| 101 | + ["Medium"] = "leetcode_medium", | |
| 102 | + ["Hard"] = "leetcode_hard", | |
| 103 | 103 | })[q.difficulty] |
| 104 | 104 | ) |
| 105 | 105 | statsline:append(" | ") |
| 106 | 106 | |
| 107 | - statsline:append(q.likes .. " ", "Comment") | |
| 108 | - statsline:append(q.dislikes .. " ", "Comment") | |
| 107 | + statsline:append(q.likes .. " ", "leetcode_alt") | |
| 108 | + statsline:append(q.dislikes .. " ", "leetcode_alt") | |
| 109 | 109 | statsline:append(" | ") |
| 110 | 110 | |
| 111 | - statsline:append(string.format("%s of %s", q.stats.acRate, q.stats.totalSubmission), "Comment") | |
| 111 | + statsline:append( | |
| 112 | + string.format("%s of %s", q.stats.acRate, q.stats.totalSubmission), | |
| 113 | + "leetcode_alt" | |
| 114 | + ) | |
| 115 | + if not vim.tbl_isempty(q.hints) then | |
| 116 | + statsline:append(" | ") | |
| 117 | + statsline:append("Hints", "leetcode_alt") | |
| 118 | + end | |
| 112 | 119 | |
| 113 | 120 | local titlecomp = Text:init({ |
| 114 | 121 | lines = { titleline }, |
+2-2lua/leetcode/ui/hints.lua
| @@ -21,7 +21,7 @@ function Hints:mount() | ||
| 21 | 21 | local nodes = {} |
| 22 | 22 | for i, hint in ipairs(self.hints) do |
| 23 | 23 | local node = NuiTree.Node( |
| 24 | - { text = NuiText(" Hint " .. i, "LeetCodeHint") }, | |
| 24 | + { text = NuiText(" Hint " .. i, "leetcode_hint") }, | |
| 25 | 25 | { NuiTree.Node({ text = hint }) } |
| 26 | 26 | ) |
| 27 | 27 | |
| @@ -30,7 +30,7 @@ function Hints:mount() | ||
| 30 | 30 | if vim.tbl_isempty(nodes) then |
| 31 | 31 | table.insert( |
| 32 | 32 | nodes, |
| 33 | - NuiTree.Node({ text = NuiText(" No hints available", "LeetCodeError") }) | |
| 33 | + NuiTree.Node({ text = NuiText(" No hints available", "leetcode_error") }) | |
| 34 | 34 | ) |
| 35 | 35 | end |
| 36 | 36 |