irongit

A Neovim plugin enabling you to solve LeetCode problems.

33 lines811 BLua
1local Lines = require("leetcode-ui.lines")
2local t = require("leetcode.translator")
3
4---@class lc.ui.menu.Title : lc.ui.Lines
5---@field text lc.ui.Lines
6local Title = Lines:extend("LeetMenuTitle")
7
8---@param history string[]
9---@param str string
10---@param opts? any
11function Title:init(history, str, opts)
12 history = vim.tbl_map(t, history)
13 str = t(str)
14
15 opts = vim.tbl_deep_extend("force", {
16 padding = {
17 top = 1,
18 },
19 }, opts or {})
20
21 Title.super.init(self, {}, opts)
22
23 for _, hist in ipairs(history) do
24 self:append(hist, "leetcode_alt")
25 self:append("", "leetcode_list")
26 end
27 self:append(str, "Function")
28end
29
30---@type fun(history: string[], str: string, opts?: any): lc.ui.menu.Title
31local LeetMenuTitle = Title
32
33return LeetMenuTitle