demo.mp4
Caution
This plugin has been exclusively tested with Java.
If you encounter any errors while using other languages,
please open an issue to report them.
-
📌 an intuitive dashboard for effortless navigation within leetcode.nvim
-
😍 question description formatting for a better readability
-
🔀 support for daily and random questions
-
💾 caching for optimized performance
-
Neovim >= 0.9.0
-
nvim-treesitter (optional, but highly recommended) used for formatting the question description. Make sure to install the parser for
html. -
nvim-notify (optional)
-
Nerd Font & nvim-web-devicons (optional)
{
"kawre/leetcode.nvim",
build = ":TSUpdate html",
dependencies = {
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim", -- required by telescope
"MunifTanjim/nui.nvim",
-- optional
"nvim-treesitter/nvim-treesitter",
"rcarriga/nvim-notify",
"nvim-tree/nvim-web-devicons",
},
opts = {
-- configuration goes here
},
}To see full configuration types see template.lua
{
---@type string
arg = "leetcode.nvim",
---@type lc.lang
lang = "cpp",
cn = { -- leetcode.cn
enabled = false, ---@type boolean
translator = true, ---@type boolean
translate_problems = true, ---@type boolean
},
---@type lc.storage
storage = {
home = vim.fn.stdpath("data") .. "/leetcode",
cache = vim.fn.stdpath("cache") .. "/leetcode",
},
---@type boolean
logging = true,
injector = {}, ---@type table<lc.lang, lc.inject>
cache = {
update_interval = 60 * 60 * 24 * 7, ---@type integer 7 days
},
console = {
open_on_runcode = true, ---@type boolean
dir = "row", ---@type lc.direction
size = { ---@type lc.size
width = "90%",
height = "75%",
},
result = {
size = "60%", ---@type lc.size
},
testcase = {
virt_text = true, ---@type boolean
size = "40%", ---@type lc.size
},
},
description = {
position = "left", ---@type lc.position
width = "40%", ---@type lc.size
show_stats = true, ---@type boolean
},
hooks = {
---@type fun()[]
LeetEnter = {},
---@type fun(question: lc.ui.Question)[]
LeetQuestionNew = {},
},
keys = {
toggle = { "q", "<Esc>" }, ---@type string|string[]
confirm = { "<CR>" }, ---@type string|string[]
reset_testcases = "r", ---@type string
use_testcase = "U", ---@type string
focus_testcases = "H", ---@type string
focus_result = "L", ---@type string
},
---@type boolean
image_support = false,
}Argument for Neovim
---@type string
arg = "leetcode.nvim"See usage for more info
Language to start your session with
---@type lc.lang
lang = "cpp"available languages
| Language | lang |
|---|---|
| C++ | cpp |
| Java | java |
| Python | python |
| Python3 | python3 |
| C | c |
| C# | csharp |
| JavaScript | javascript |
| TypeScript | typescript |
| PHP | php |
| Swift | swift |
| Kotlin | kotlin |
| Dart | dart |
| Go | golang |
| Ruby | ruby |
| Scala | scala |
| Rust | rust |
| Racket | racket |
| Erlang | erlang |
| Elixir | elixir |
| Bash | bash |
Use leetcode.cn instead of leetcode.com
cn = { -- leetcode.cn
enabled = false, ---@type boolean
translator = true, ---@type boolean
translate_problems = true, ---@type boolean
},storage directories
---@type lc.storage
storage = {
home = vim.fn.stdpath("data") .. "/leetcode",
cache = vim.fn.stdpath("cache") .. "/leetcode",
},Whether to log leetcode.nvim status notifications
---@type boolean
logging = trueInject code before or after your solution, injected code won't be submitted or run.
injector = { ---@type table<lc.lang, lc.inject>
["cpp"] = {
before = { "#include <bits/stdc++.h>", "using namespace std;" },
after = "int main() {}",
},
["java"] = {
before = "import java.util.*;",
},
}List of functions that get executed on specified event
hooks = {
---@type fun()[]
LeetEnter = {},
---@type fun(question: lc.ui.Question)[]
LeetQuestionNew = {},
},Whether to render question description images using image.nvim
Warning
Enabling this will disable question description wrap, because of 3rd/image.nvim#62 (comment)
---@type boolean
image_support = false,-
menusame asLeet -
consoleopens console pop-up for currently opened question -
infoopens a pop-up containing information about the currently opened question -
tabsopens a picker with all currently opened question tabs -
yankyanks the current question solution -
langopens a picker to change the language of the current question -
runrun currently opened question -
testsame asLeet run -
submitsubmit currently opened question -
randomopens a random question -
dailyopens the question of today -
listopens a problemlist picker -
openopens the current question in a default browser -
resetreset current question to default code definition -
last_submitretrieve last submitted code for the current question -
desctoggle question description-
togglesame asLeet desc -
statstoggle description stats visibility
-
-
cookie-
updateopens a prompt to enter a new cookie -
deletesign-out
-
-
cacheupdateupdates cache
-
Leet listLeet list status=<status> difficulty=<difficulty> -
Leet randomLeet random status=<status> difficulty=<difficulty> tags=<tags>
This plugin can be initiated in two ways:
-
To start leetcode.nvim, simply pass
argas the first and only Neovim argumentnvim leetcode.nvim -
(Experimental) Alternatively, you can use
:Leetcommand to open leetcode.nvim within your preferred dashboard plugin. The only requirement is that Neovim must not have any listed buffers open.
To switch between questions, use Leet tabs
It is required to be signed-in to use leetcode.nvim
signin.mp4
💤 lazy loading with lazy.nvim
Warning
opting for either option makes the alternative launch method unavailable due to lazy loading
-
with
arglocal leet_arg = "leetcode.nvim"
{ "kawre/leetcode.nvim", lazy = leet_arg ~= vim.fn.argv()[1], opts = { arg = leet_arg }, } -
with
:Leet{ "kawre/leetcode.nvim", cmd = "Leet", }