irongit

A Neovim plugin enabling you to solve LeetCode problems.

docs(readme): `cn` section

kawreauthored
parent 4380497commit a77edb214bb6d52e1c047b7b28427c38777d4aecBrowse files

8 files changed, +58 -55

+17-8README.md
@@ -72,21 +72,27 @@ To see full configuration types see [template.lua](./lua/leetcode/config/templat
7272
7373 ```lua
7474 {
75- ---@type lc.domain
76- domain = "com", -- For now "com" is the only one supported
77-
7875 ---@type string
7976 arg = "leetcode.nvim",
8077
8178 ---@type lc.lang
8279 lang = "cpp",
8380
81+ cn = { -- leetcode.cn
82+ enabled = false, ---@type boolean
83+ translate_problems = true, ---@type boolean
84+ },
85+
8486 ---@type string
8587 directory = vim.fn.stdpath("data") .. "/leetcode/",
8688
8789 ---@type boolean
8890 logging = true,
8991
92+ cache = {
93+ update_interval = 60 * 60 * 24 * 7, ---@type integer 7 days
94+ },
95+
9096 console = {
9197 open_on_runcode = true, ---@type boolean
9298
@@ -147,13 +153,15 @@ Language to start your session with
147153 lang = "cpp"
148154 ```
149155
150-### domain
156+### cn
151157
152-[LeetCode] domain.
158+Use [leetcode.cn] instead of [leetcode.com][leetcode]
153159
154160 ```lua
155----@type lc.domain
156-domain = "com" -- For now "com" is the only one supported
161+cn = { -- leetcode.cn
162+ enabled = false, ---@type boolean
163+ translate_problems = true, ---@type boolean
164+},
157165 ```
158166
159167 ### directory
@@ -242,7 +250,7 @@ image_support = false, -- setting this to `true` will disable question descripti
242250 Can take optional arguments. To stack argument values separate them by a `,`
243251
244252 ```
245-Leet list status=<status> topics=<topic1,...,topicN> difficulty=<difficulty>
253+Leet list status=<status> difficulty=<difficulty>
246254 ```
247255
248256 ## 🚀 Usage
@@ -303,6 +311,7 @@ return {
303311 [image.nvim]: https://github.com/3rd/image.nvim
304312 [lazy.nvim]: https://github.com/folke/lazy.nvim
305313 [leetcode]: https://leetcode.com
314+[leetcode.cn]: https://leetcode.cn
306315 [leetcode.nvim]: https://github.com/kawre/leetcode.nvim
307316 [neovim]: https://github.com/neovim/neovim
308317 [nerd-font]: https://www.nerdfonts.com
+14-7README.zh.md
@@ -76,21 +76,27 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/309088c9-4ff7-4dff-ab61-a
7676
7777 ```lua
7878 {
79- ---@type lc.domain
80- domain = "com", -- 目前仅支持 "com"
81-
8279 ---@type string
8380 arg = "leetcode.nvim",
8481
8582 ---@type lc.lang
8683 lang = "cpp",
8784
85+ cn = { -- leetcode.cn
86+ enabled = false, ---@type boolean
87+ translate_problems = true, ---@type boolean
88+ },
89+
8890 ---@type string
8991 directory = vim.fn.stdpath("data") .. "/leetcode/",
9092
9193 ---@type boolean
9294 logging = true,
9395
96+ cache = {
97+ update_interval = 60 * 60 * 24 * 7, ---@type integer 7 days
98+ },
99+
94100 console = {
95101 open_on_runcode = true, ---@type boolean
96102
@@ -127,7 +133,7 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/309088c9-4ff7-4dff-ab61-a
127133 },
128134
129135 ---@type boolean
130- image_support = false, -- 将此设置为 `true` 将禁用问题描述的换行
136+ image_support = false, -- setting this to `true` will disable question description wrap
131137 }
132138 ```
133139
@@ -151,9 +157,9 @@ arg = "leetcode.nvim"
151157 lang = "cpp"
152158 ```
153159
154-### domain
160+### cn
155161
156-[LeetCode] 领域
162+将 [leetcode.com][leetcode] 替换为 [leetcode.cn]
157163
158164 ```lua
159165 ---@type lc.domain
@@ -246,7 +252,7 @@ image_support = false, -- 将此设置为 `true` 将禁用问题描述的换行
246252 可以带有可选参数。要堆叠参数值,请使用 , 将它们分隔开
247253
248254 ```
249-Leet list status=<status> topics=<topic1,...,topicN> difficulty=<difficulty>
255+Leet list status=<status> difficulty=<difficulty>
250256 ```
251257
252258 ## 🚀 使用方法
@@ -301,6 +307,7 @@ return {
301307 [image.nvim]: https://github.com/3rd/image.nvim
302308 [lazy.nvim]: https://github.com/folke/lazy.nvim
303309 [leetcode]: https://leetcode.com
310+[leetcode.cn]: https://leetcode.cn
304311 [leetcode.nvim]: https://github.com/kawre/leetcode.nvim
305312 [neovim]: https://github.com/neovim/neovim
306313 [nerd-font]: https://www.nerdfonts.com
+2-2lua/leetcode-menu/components/calendar.lua
@@ -174,9 +174,9 @@ function Calendar:fetch()
174174 end
175175
176176 function Calendar:update()
177- local spinner = Spinner:init("updating...")
177+ local spinner = Spinner:init("updating calendar")
178178 statistics.calendar(function(res, err)
179- spinner:stop(nil, true, { timeout = 200 })
179+ spinner:stop("calendar updated", true, { timeout = 200 })
180180 self:handle_res(res, err)
181181 end)
182182 end
+1-1lua/leetcode/command/arguments.lua
@@ -79,7 +79,7 @@ arguments.list = {
7979 -- orderBy = { "desc", "asc" },
8080 difficulty = { "Easy", "Medium", "Hard" },
8181 status = { "ac", "notac", "todo" },
82- topics = topics,
82+ -- topics = topics,
8383 }
8484
8585 return arguments
+1-1lua/leetcode/config/init.lua
@@ -39,7 +39,7 @@ end
3939 function config.load_plugins()
4040 local plugins = {}
4141
42- if config.user.plugins.cn.enabled then table.insert(plugins, "cn") end
42+ if config.user.cn.enabled then table.insert(plugins, "cn") end
4343
4444 for _, plugin in ipairs(plugins) do
4545 local ok, plug = pcall(require, "leetcode-plugins." .. plugin)
+8-21lua/leetcode/config/template.lua
@@ -24,18 +24,16 @@
2424 ---| "react"
2525 ---| "vanillajs"
2626
27----@alias lc.domain
28----| "com"
29----| "cn"
30-
3127 ---@alias lc.hook
3228 ---| "LeetEnter"
3329 ---| "LeetQuestionNew"
3430
3531 ---@class lc.UserConfig
3632 local M = {
37- ---@type lc.domain
38- domain = "com", -- For now "com" is the only one supported
33+ cn = { -- leetcode.cn
34+ enabled = false, ---@type boolean
35+ translate_problems = true, ---@type boolean
36+ },
3937
4038 ---@type string
4139 arg = "leetcode.nvim",
@@ -49,6 +47,10 @@ local M = {
4947 ---@type boolean
5048 logging = true,
5149
50+ cache = {
51+ update_interval = 60 * 60 * 24 * 7, ---@type integer 7 days
52+ },
53+
5254 console = {
5355 open_on_runcode = true, ---@type boolean
5456
@@ -86,21 +88,6 @@ local M = {
8688
8789 ---@type boolean
8890 image_support = false, -- setting this to `true` will disable question description wrap
89-
90- cache = {
91- ---@type integer
92- update_interval = 60 * 60 * 24 * 7, -- 7 days
93- },
94-
95- plugins = {
96- cn = {
97- enabled = true,
98- translate_problems = true, ---@type boolean
99- },
100- },
101- -- cn = {
102- -- translate = true, ---@type boolean
103- -- },
10491 }
10592
10693 return M
+14-14lua/leetcode/pickers/question.lua
@@ -108,20 +108,20 @@ local function filter_questions(questions, opts)
108108
109109 ---@param q lc.Cache.Question
110110 return vim.tbl_filter(function(q)
111- if opts.topics then
112- for _, topic in ipairs(opts.topics) do
113- local flag = false
114-
115- for _, tag in ipairs(q.topic_tags) do
116- if tag.slug == topic then
117- flag = true
118- break
119- end
120- end
121-
122- if not flag then return false end
123- end
124- end
111+ -- if opts.topics then
112+ -- for _, topic in ipairs(opts.topics) do
113+ -- local flag = false
114+ --
115+ -- for _, tag in ipairs(q.topic_tags) do
116+ -- if tag.slug == topic then
117+ -- flag = true
118+ -- break
119+ -- end
120+ -- end
121+ --
122+ -- if not flag then return false end
123+ -- end
124+ -- end
125125
126126 if opts.difficulty then
127127 if not vim.tbl_contains(opts.difficulty, q.difficulty) then return false end
+1-1lua/leetcode/utils.lua
@@ -145,7 +145,7 @@ end
145145 ---@param translated_content string
146146 function utils.translate(content, translated_content)
147147 if config.is_cn then
148- if config.user.plugins.cn.translate_problems then
148+ if config.user.cn.translate_problems then
149149 return translated_content or content
150150 else
151151 return content or translated_content