A Neovim plugin enabling you to solve LeetCode problems.
docs: lazy load examples
2 files changed, +165 -61
+83-31README.md
| @@ -86,8 +86,11 @@ To see full configuration types see [template.lua](./lua/leetcode/config/templat | ||
| 86 | 86 | translate_problems = true, ---@type boolean |
| 87 | 87 | }, |
| 88 | 88 | |
| 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 | + }, | |
| 91 | 94 | |
| 92 | 95 | ---@type boolean |
| 93 | 96 | logging = true, |
| @@ -146,7 +149,7 @@ To see full configuration types see [template.lua](./lua/leetcode/config/templat | ||
| 146 | 149 | }, |
| 147 | 150 | |
| 148 | 151 | ---@type boolean |
| 149 | - image_support = false, -- setting this to `true` will disable question description wrap | |
| 152 | + image_support = false, | |
| 150 | 153 | } |
| 151 | 154 | ``` |
| 152 | 155 | |
| @@ -170,6 +173,34 @@ Language to start your session with | ||
| 170 | 173 | lang = "cpp" |
| 171 | 174 | ``` |
| 172 | 175 | |
| 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 | + | |
| 173 | 204 | ### cn |
| 174 | 205 | |
| 175 | 206 | Use [leetcode.cn] instead of [leetcode.com][leetcode] |
| @@ -182,13 +213,16 @@ cn = { -- leetcode.cn | ||
| 182 | 213 | }, |
| 183 | 214 | ``` |
| 184 | 215 | |
| 185 | -### directory | |
| 216 | +### storage | |
| 186 | 217 | |
| 187 | -Where to store [leetcode.nvim] data | |
| 218 | +storage directories | |
| 188 | 219 | |
| 189 | 220 | ```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 | +}, | |
| 192 | 226 | ``` |
| 193 | 227 | |
| 194 | 228 | ### logging |
| @@ -234,9 +268,12 @@ hooks = { | ||
| 234 | 268 | |
| 235 | 269 | Whether to render question description images using [image.nvim] |
| 236 | 270 | |
| 271 | +Enabling this will disable question description wrap, | |
| 272 | +because of https://github.com/3rd/image.nvim/issues/62#issuecomment-1778082534 | |
| 273 | + | |
| 237 | 274 | ```lua |
| 238 | 275 | ---@type boolean |
| 239 | -image_support = false, -- setting this to `true` will disable question description wrap | |
| 276 | +image_support = false, | |
| 240 | 277 | ``` |
| 241 | 278 | |
| 242 | 279 | ## 📋 Commands |
| @@ -263,7 +300,7 @@ image_support = false, -- setting this to `true` will disable question descripti | ||
| 263 | 300 | |
| 264 | 301 | - `daily` opens the question of today |
| 265 | 302 | |
| 266 | -- [`list`](#leet-list) opens a problemlist picker | |
| 303 | +- `list` opens a problemlist picker | |
| 267 | 304 | |
| 268 | 305 | - `desc` toggle question description |
| 269 | 306 | |
| @@ -281,13 +318,19 @@ image_support = false, -- setting this to `true` will disable question descripti | ||
| 281 | 318 | |
| 282 | 319 | - `update` updates cache |
| 283 | 320 | |
| 284 | -#### `Leet list` | |
| 321 | +#### Some commands can take optional arguments. To stack argument values separate them by a `,` | |
| 285 | 322 | |
| 286 | -Can take optional arguments. To stack argument values separate them by a `,` | |
| 323 | +- `Leet list` | |
| 287 | 324 | |
| 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 | + ``` | |
| 291 | 334 | |
| 292 | 335 | ## 🚀 Usage |
| 293 | 336 | |
| @@ -296,9 +339,9 @@ This plugin can be initiated in two ways: | ||
| 296 | 339 | - To start [leetcode.nvim], simply pass [`arg`](#arg) |
| 297 | 340 | as the _first and **only**_ [Neovim] argument |
| 298 | 341 | |
| 299 | -``` | |
| 300 | -nvim leetcode.nvim | |
| 301 | -``` | |
| 342 | + ``` | |
| 343 | + nvim leetcode.nvim | |
| 344 | + ``` | |
| 302 | 345 | |
| 303 | 346 | - _**(Experimental)**_ Alternatively, you can use `:Leet` command to open [leetcode.nvim] |
| 304 | 347 | 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 | ||
| 316 | 359 | |
| 317 | 360 | ## 🍴 Recipes |
| 318 | 361 | |
| 319 | -### lazy loading | |
| 362 | +### 💤 lazy loading with [lazy.nvim] | |
| 320 | 363 | |
| 321 | -- proper lazy loading with [lazy.nvim] | |
| 364 | +- with [`arg`](#arg) | |
| 322 | 365 | |
| 323 | -```lua | |
| 324 | -local leet_arg = "leetcode.nvim" | |
| 366 | + ```lua | |
| 367 | + local leet_arg = "leetcode.nvim" | |
| 325 | 368 | |
| 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 | + ``` | |
| 336 | 388 | |
| 337 | 389 | ## 🙌 Credits |
| 338 | 390 |
+82-30README.zh.md
| @@ -89,8 +89,11 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/aee6584c-e099-4409-b114-1 | ||
| 89 | 89 | translate_problems = true, ---@type boolean |
| 90 | 90 | }, |
| 91 | 91 | |
| 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 | + }, | |
| 94 | 97 | |
| 95 | 98 | ---@type boolean |
| 96 | 99 | logging = true, |
| @@ -149,7 +152,7 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/aee6584c-e099-4409-b114-1 | ||
| 149 | 152 | }, |
| 150 | 153 | |
| 151 | 154 | ---@type boolean |
| 152 | - image_support = false, -- setting this to `true` will disable question description wrap | |
| 155 | + image_support = false, | |
| 153 | 156 | } |
| 154 | 157 | ``` |
| 155 | 158 | |
| @@ -173,6 +176,34 @@ arg = "leetcode.nvim" | ||
| 173 | 176 | lang = "cpp" |
| 174 | 177 | ``` |
| 175 | 178 | |
| 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 | + | |
| 176 | 207 | ### cn |
| 177 | 208 | |
| 178 | 209 | 将 [leetcode.com][leetcode] 替换为 [leetcode.cn] |
| @@ -185,13 +216,16 @@ cn = { -- leetcode.cn | ||
| 185 | 216 | }, |
| 186 | 217 | ``` |
| 187 | 218 | |
| 188 | -### directory | |
| 219 | +### storage | |
| 189 | 220 | |
| 190 | -存储 [leetcode.nvim] 数据的位置 | |
| 221 | +存储目录 | |
| 191 | 222 | |
| 192 | 223 | ```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 | +}, | |
| 195 | 229 | ``` |
| 196 | 230 | |
| 197 | 231 | ### logging |
| @@ -237,6 +271,9 @@ hooks = { | ||
| 237 | 271 | |
| 238 | 272 | 是否使用 [image.nvim] 渲染问题描述中的图片 |
| 239 | 273 | |
| 274 | +启用此选项将禁用问题描述的换行,因为 | |
| 275 | +https://github.com/3rd/image.nvim/issues/62#issuecomment-1778082534 | |
| 276 | + | |
| 240 | 277 | ```lua |
| 241 | 278 | ---@type boolean |
| 242 | 279 | image_support = false, -- 将此设置为 `true` 将禁用问题描述的换行 |
| @@ -266,7 +303,7 @@ image_support = false, -- 将此设置为 `true` 将禁用问题描述的换行 | ||
| 266 | 303 | |
| 267 | 304 | - `daily` 打开今天的问题 |
| 268 | 305 | |
| 269 | -- [`list`](#leet-list) 打开问题列表选择器 | |
| 306 | +- `list` 打开问题列表选择器 | |
| 270 | 307 | |
| 271 | 308 | - `desc` 切换问题描述 |
| 272 | 309 | |
| @@ -284,13 +321,19 @@ image_support = false, -- 将此设置为 `true` 将禁用问题描述的换行 | ||
| 284 | 321 | |
| 285 | 322 | - `update` 更新缓存 |
| 286 | 323 | |
| 287 | -#### `Leet list` | |
| 324 | +#### 可以带有可选参数。要堆叠参数值,请使用 `,` 将它们分隔开 | |
| 288 | 325 | |
| 289 | -可以带有可选参数。要堆叠参数值,请使用 , 将它们分隔开 | |
| 326 | +- `Leet list` | |
| 290 | 327 | |
| 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 | + ``` | |
| 294 | 337 | |
| 295 | 338 | ## 🚀 使用方法 |
| 296 | 339 | |
| @@ -299,9 +342,9 @@ Leet list status=<status> difficulty=<difficulty> | ||
| 299 | 342 | - 要启动 [leetcode.nvim],只需将 [`arg`](#arg) |
| 300 | 343 | 作为 第一个且唯一 [Neovim] 参数传递 |
| 301 | 344 | |
| 302 | -``` | |
| 303 | -nvim leetcode.nvim | |
| 304 | -``` | |
| 345 | + ``` | |
| 346 | + nvim leetcode.nvim | |
| 347 | + ``` | |
| 305 | 348 | |
| 306 | 349 | - _**(实验性)**_ 另外,您可以使用 `:Leet` 命令在您喜欢的仪表板插件中打开 |
| 307 | 350 | [leetcode.nvim]。唯一的要求是 [Neovim] 不能有任何列出的缓冲区打开。 |
| @@ -318,23 +361,32 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/b7be8b95-5e2c-4153-8845-4 | ||
| 318 | 361 | |
| 319 | 362 | ## 🍴 示例 |
| 320 | 363 | |
| 321 | -### 懒加载 | |
| 364 | +### 💤 使用 [lazy.nvim] 进行延迟加载 | |
| 322 | 365 | |
| 323 | -- 使用 [lazy.nvim] 实现正确的懒加载 | |
| 366 | +- 使用 [`arg`](#arg) | |
| 324 | 367 | |
| 325 | -```lua | |
| 326 | -local leet_arg = "leetcode.nvim" | |
| 368 | + ```lua | |
| 369 | + local leet_arg = "leetcode.nvim" | |
| 327 | 370 | |
| 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 | + ``` | |
| 338 | 390 | |
| 339 | 391 | ## 🙌 鸣谢 |
| 340 | 392 |