irongit

A Neovim plugin enabling you to solve LeetCode problems.

docs: lazy load examples

kawreauthored
parent efa3de4commit 0b3710fc23a496c605dbbd9543bbafcf42a8dbfeBrowse files

2 files changed, +165 -61

+83-31README.md
@@ -86,8 +86,11 @@ To see full configuration types see [template.lua](./lua/leetcode/config/templat
8686 translate_problems = true, ---@type boolean
8787 },
8888
89- ---@type string
90- directory = vim.fn.stdpath("data") .. "/leetcode/",
89+ ---@type lc.storage
90+ storage = {
91+ home = vim.fn.stdpath("data") .. "/leetcode",
92+ cache = vim.fn.stdpath("cache") .. "/leetcode",
93+ },
9194
9295 ---@type boolean
9396 logging = true,
@@ -146,7 +149,7 @@ To see full configuration types see [template.lua](./lua/leetcode/config/templat
146149 },
147150
148151 ---@type boolean
149- image_support = false, -- setting this to `true` will disable question description wrap
152+ image_support = false,
150153 }
151154 ```
152155
@@ -170,6 +173,34 @@ Language to start your session with
170173 lang = "cpp"
171174 ```
172175
176+<details>
177+ <summary>available languages</summary>
178+
179+| Language | lang |
180+| ---------- | ---------- |
181+| C++ | cpp |
182+| Java | java |
183+| Python | python |
184+| Python3 | python3 |
185+| C | c |
186+| C# | csharp |
187+| JavaScript | javascript |
188+| TypeScript | typescript |
189+| PHP | php |
190+| Swift | swift |
191+| Kotlin | kotlin |
192+| Dart | dart |
193+| Go | golang |
194+| Ruby | ruby |
195+| Scala | scala |
196+| Rust | rust |
197+| Racket | racket |
198+| Erlang | erlang |
199+| Elixir | elixir |
200+| Bash | bash |
201+
202+</details>
203+
173204 ### cn
174205
175206 Use [leetcode.cn] instead of [leetcode.com][leetcode]
@@ -182,13 +213,16 @@ cn = { -- leetcode.cn
182213 },
183214 ```
184215
185-### directory
216+### storage
186217
187-Where to store [leetcode.nvim] data
218+storage directories
188219
189220 ```lua
190----@type string
191-directory = vim.fn.stdpath("data") .. "/leetcode/"
221+---@type lc.storage
222+storage = {
223+ home = vim.fn.stdpath("data") .. "/leetcode",
224+ cache = vim.fn.stdpath("cache") .. "/leetcode",
225+},
192226 ```
193227
194228 ### logging
@@ -234,9 +268,12 @@ hooks = {
234268
235269 Whether to render question description images using [image.nvim]
236270
271+Enabling this will disable question description wrap,
272+because of https://github.com/3rd/image.nvim/issues/62#issuecomment-1778082534
273+
237274 ```lua
238275 ---@type boolean
239-image_support = false, -- setting this to `true` will disable question description wrap
276+image_support = false,
240277 ```
241278
242279 ## 📋 Commands
@@ -263,7 +300,7 @@ image_support = false, -- setting this to `true` will disable question descripti
263300
264301 - `daily` opens the question of today
265302
266-- [`list`](#leet-list) opens a problemlist picker
303+- `list` opens a problemlist picker
267304
268305 - `desc` toggle question description
269306
@@ -281,13 +318,19 @@ image_support = false, -- setting this to `true` will disable question descripti
281318
282319 - `update` updates cache
283320
284-#### `Leet list`
321+#### Some commands can take optional arguments. To stack argument values separate them by a `,`
285322
286-Can take optional arguments. To stack argument values separate them by a `,`
323+- `Leet list`
287324
288-```
289-Leet list status=<status> difficulty=<difficulty>
290-```
325+ ```
326+ Leet list status=<status> difficulty=<difficulty>
327+ ```
328+
329+- `Leet random`
330+
331+ ```
332+ Leet random status=<status> difficulty=<difficulty> tags=<tags>
333+ ```
291334
292335 ## 🚀 Usage
293336
@@ -296,9 +339,9 @@ This plugin can be initiated in two ways:
296339 - To start [leetcode.nvim], simply pass [`arg`](#arg)
297340 as the _first and **only**_ [Neovim] argument
298341
299-```
300-nvim leetcode.nvim
301-```
342+ ```
343+ nvim leetcode.nvim
344+ ```
302345
303346 - _**(Experimental)**_ Alternatively, you can use `:Leet` command to open [leetcode.nvim]
304347 within your preferred dashboard plugin. The only requirement is that [Neovim]
@@ -316,23 +359,32 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/b7be8b95-5e2c-4153-8845-4
316359
317360 ## 🍴 Recipes
318361
319-### lazy loading
362+### 💤 lazy loading with [lazy.nvim]
320363
321-- proper lazy loading with [lazy.nvim]
364+- with [`arg`](#arg)
322365
323-```lua
324-local leet_arg = "leetcode.nvim"
366+ ```lua
367+ local leet_arg = "leetcode.nvim"
325368
326-return {
327- "kawre/leetcode.nvim",
328- ...
329- lazy = leet_arg ~= vim.fn.argv()[1],
330- opts = {
331- arg = leet_arg,
332- },
333- ...
334-}
335-```
369+ return {
370+ "kawre/leetcode.nvim",
371+ ...
372+ lazy = leet_arg ~= vim.fn.argv()[1],
373+ opts = {
374+ arg = leet_arg,
375+ },
376+ ...
377+ }
378+ ```
379+
380+- with `:Leet`, this will make launching with [`arg`](#arg) not work
381+
382+ ```lua
383+ {
384+ "kawre/leetcode.nvim",
385+ cmd = "Leet",
386+ }
387+ ```
336388
337389 ## 🙌 Credits
338390
+82-30README.zh.md
@@ -89,8 +89,11 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/aee6584c-e099-4409-b114-1
8989 translate_problems = true, ---@type boolean
9090 },
9191
92- ---@type string
93- directory = vim.fn.stdpath("data") .. "/leetcode/",
92+ ---@type lc.storage
93+ storage = {
94+ home = vim.fn.stdpath("data") .. "/leetcode",
95+ cache = vim.fn.stdpath("cache") .. "/leetcode",
96+ },
9497
9598 ---@type boolean
9699 logging = true,
@@ -149,7 +152,7 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/aee6584c-e099-4409-b114-1
149152 },
150153
151154 ---@type boolean
152- image_support = false, -- setting this to `true` will disable question description wrap
155+ image_support = false,
153156 }
154157 ```
155158
@@ -173,6 +176,34 @@ arg = "leetcode.nvim"
173176 lang = "cpp"
174177 ```
175178
179+<details>
180+ <summary>可用编程语言</summary>
181+
182+| Language | lang |
183+| ---------- | ---------- |
184+| C++ | cpp |
185+| Java | java |
186+| Python | python |
187+| Python3 | python3 |
188+| C | c |
189+| C# | csharp |
190+| JavaScript | javascript |
191+| TypeScript | typescript |
192+| PHP | php |
193+| Swift | swift |
194+| Kotlin | kotlin |
195+| Dart | dart |
196+| Go | golang |
197+| Ruby | ruby |
198+| Scala | scala |
199+| Rust | rust |
200+| Racket | racket |
201+| Erlang | erlang |
202+| Elixir | elixir |
203+| Bash | bash |
204+
205+</details>
206+
176207 ### cn
177208
178209 将 [leetcode.com][leetcode] 替换为 [leetcode.cn]
@@ -185,13 +216,16 @@ cn = { -- leetcode.cn
185216 },
186217 ```
187218
188-### directory
219+### storage
189220
190-存储 [leetcode.nvim] 数据的位置
221+存储目录
191222
192223 ```lua
193----@type string
194-directory = vim.fn.stdpath("data") .. "/leetcode/"
224+---@type lc.storage
225+storage = {
226+ home = vim.fn.stdpath("data") .. "/leetcode",
227+ cache = vim.fn.stdpath("cache") .. "/leetcode",
228+},
195229 ```
196230
197231 ### logging
@@ -237,6 +271,9 @@ hooks = {
237271
238272 是否使用 [image.nvim] 渲染问题描述中的图片
239273
274+启用此选项将禁用问题描述的换行,因为
275+https://github.com/3rd/image.nvim/issues/62#issuecomment-1778082534
276+
240277 ```lua
241278 ---@type boolean
242279 image_support = false, -- 将此设置为 `true` 将禁用问题描述的换行
@@ -266,7 +303,7 @@ image_support = false, -- 将此设置为 `true` 将禁用问题描述的换行
266303
267304 - `daily` 打开今天的问题
268305
269-- [`list`](#leet-list) 打开问题列表选择器
306+- `list` 打开问题列表选择器
270307
271308 - `desc` 切换问题描述
272309
@@ -284,13 +321,19 @@ image_support = false, -- 将此设置为 `true` 将禁用问题描述的换行
284321
285322 - `update` 更新缓存
286323
287-#### `Leet list`
324+#### 可以带有可选参数。要堆叠参数值,请使用 `,` 将它们分隔开
288325
289-可以带有可选参数。要堆叠参数值,请使用 , 将它们分隔开
326+- `Leet list`
290327
291-```
292-Leet list status=<status> difficulty=<difficulty>
293-```
328+ ```
329+ Leet list status=<status> difficulty=<difficulty>
330+ ```
331+
332+- `Leet random`
333+
334+ ```
335+ Leet random status=<status> difficulty=<difficulty> tags=<tags>
336+ ```
294337
295338 ## 🚀 使用方法
296339
@@ -299,9 +342,9 @@ Leet list status=<status> difficulty=<difficulty>
299342 - 要启动 [leetcode.nvim],只需将 [`arg`](#arg)
300343 作为 第一个且唯一 [Neovim] 参数传递
301344
302-```
303-nvim leetcode.nvim
304-```
345+ ```
346+ nvim leetcode.nvim
347+ ```
305348
306349 - _**(实验性)**_ 另外,您可以使用 `:Leet` 命令在您喜欢的仪表板插件中打开
307350 [leetcode.nvim]。唯一的要求是 [Neovim] 不能有任何列出的缓冲区打开。
@@ -318,23 +361,32 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/b7be8b95-5e2c-4153-8845-4
318361
319362 ## 🍴 示例
320363
321-### 懒加载
364+### 💤 使用 [lazy.nvim] 进行延迟加载
322365
323-- 使用 [lazy.nvim] 实现正确的懒加载
366+- 使用 [`arg`](#arg)
324367
325-```lua
326-local leet_arg = "leetcode.nvim"
368+ ```lua
369+ local leet_arg = "leetcode.nvim"
327370
328-return {
329- "kawre/leetcode.nvim",
330- ...
331- lazy = leet_arg ~= vim.fn.argv()[1],
332- opts = {
333- arg = leet_arg,
334- },
335- ...
336-}
337-```
371+ return {
372+ "kawre/leetcode.nvim",
373+ ...
374+ lazy = leet_arg ~= vim.fn.argv()[1],
375+ opts = {
376+ arg = leet_arg,
377+ },
378+ ...
379+ }
380+ ```
381+
382+- 使用 `:Leet`,这将导致使用 [`arg`](#arg) 启动不起作用
383+
384+ ```lua
385+ {
386+ "kawre/leetcode.nvim",
387+ cmd = "Leet",
388+ }
389+ ```
338390
339391 ## 🙌 鸣谢
340392