irongit

A Neovim plugin enabling you to solve LeetCode problems.

124 lines2.5 KBLua
1---@alias lc.lang
2---| "cpp"
3---| "java"
4---| "python"
5---| "python3"
6---| "c"
7---| "csharp"
8---| "javascript"
9---| "typescript"
10---| "php"
11---| "swift"
12---| "kotlin"
13---| "dart"
14---| "golang"
15---| "ruby"
16---| "scala"
17---| "rust"
18---| "racket"
19---| "erlang"
20---| "elixir"
21---| "bash"
22---| "html"
23---| "pythonml"
24---| "react"
25---| "vanillajs"
26
27---@alias lc.hook
28---| "LeetEnter"
29---| "LeetQuestionNew"
30
31---@alias lc.size
32---| string
33---| number
34---| { width: string | number, height: string | number }
35
36---@alias lc.position "top" | "right" | "bottom" | "left"
37
38---@alias lc.direction "col" | "row"
39
40---@alias lc.inject { before?: string|string[], after?: string|string[] }
41
42---@alias lc.storage table<"cache"|"home", string>
43
44---@class lc.UserConfig
45local M = {
46 ---@type string
47 arg = "leetcode.nvim",
48
49 ---@type lc.lang
50 lang = "cpp",
51
52 cn = { -- leetcode.cn
53 enabled = false, ---@type boolean
54 translator = true, ---@type boolean
55 translate_problems = true, ---@type boolean
56 },
57
58 ---@type lc.storage
59 storage = {
60 home = vim.fn.stdpath("data") .. "/leetcode/",
61 cache = vim.fn.stdpath("cache") .. "/leetcode/",
62 },
63
64 ---@type boolean
65 logging = true,
66
67 injector = {}, ---@type table<lc.lang, lc.inject>
68
69 cache = {
70 update_interval = 60 * 60 * 24 * 7, ---@type integer 7 days
71 },
72
73 console = {
74 open_on_runcode = true, ---@type boolean
75
76 dir = "row", ---@type lc.direction
77
78 size = { ---@type lc.size
79 width = "90%",
80 height = "75%",
81 },
82
83 result = {
84 size = "60%", ---@type lc.size
85 },
86
87 testcase = {
88 virt_text = true, ---@type boolean
89
90 size = "40%", ---@type lc.size
91 },
92 },
93
94 description = {
95 position = "left", ---@type lc.position
96
97 width = "40%", ---@type lc.size
98
99 show_stats = true, ---@type boolean
100 },
101
102 hooks = {
103 ---@type fun()[]
104 LeetEnter = {},
105
106 ---@type fun(question: lc.ui.Question)[]
107 LeetQuestionNew = {},
108 },
109
110 keys = {
111 toggle = { "q", "<Esc>" }, ---@type string|string[]
112 confirm = { "<CR>" }, ---@type string|string[]
113
114 reset_testcases = "r", ---@type string
115 use_testcase = "U", ---@type string
116 focus_testcases = "H", ---@type string
117 focus_result = "L", ---@type string
118 },
119
120 ---@type boolean
121 image_support = false, -- setting this to `true` will disable question description wrap
122}
123
124return M