GitHub - sidntrivedi/leetcode.nvim: Solve Leetcode problems in Neovim · GitHub
/" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
sidntrivedi
leetcode.nvim
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>8 Commits<br>8 Commits
lua/leetcode
lua/leetcode
plugin
plugin
tests
tests
.gitignore
.gitignore
README.md
README.md
package-lock.json
package-lock.json
package.json
package.json
View all files
Repository files navigation
leetcode.nvim
A small Neovim wrapper around the same LeetCode CLI used by the VS Code<br>extension. It supports login/logout, searching problems, generating solution<br>files with descriptions, running tests, and submitting the current file.
This plugin is inspired by<br>LeetCode-OpenSource/vscode-leetcode<br>and uses<br>vsc-leetcode-cli for the<br>LeetCode transport layer.
Prerequisites
Neovim 0.10 or newer.
Node.js available on your PATH.
Network access to leetcode.com for login, problem fetch, test, and submit.
A LeetCode browser session if you use the recommended cookie login flow. The<br>cookie string must include LEETCODE_SESSION and csrftoken.
vsc-leetcode-cli<br>available either from this plugin's local node_modules, from a leetcode<br>executable on PATH, or from cli.path in setup.
Installation
Native Packages
Use this section if you install plugins with Neovim's built-in package layout<br>(:h packages), sometimes called vim packages or vim-pack. Clone the plugin<br>into pack/plugins/start:
mkdir -p ~/.local/share/nvim/site/pack/plugins/start<br>git clone git@github.com:sidntrivedi/leetcode.nvim \<br>~/.local/share/nvim/site/pack/plugins/start/leetcode.nvim
If you do not already have a compatible leetcode binary on PATH, install the<br>local CLI dependency:
cd ~/.local/share/nvim/site/pack/plugins/start/leetcode.nvim<br>npm install
Other Plugin Managers
If you use a plugin manager such as lazy.nvim, packer.nvim, or vim-plug,<br>install sidntrivedi/leetcode.nvim using that manager's normal GitHub plugin<br>syntax. After the plugin is cloned, make sure vsc-leetcode-cli is available.<br>The simplest option is to run npm install inside the cloned plugin directory:
Example dependency install:
cd /path/to/leetcode.nvim<br>npm install
If you already have a compatible leetcode executable installed globally, you<br>can skip npm install; the plugin falls back to leetcode on PATH. You can<br>also point at a specific CLI executable:
require("leetcode").setup({<br>cli = {<br>path = "/path/to/leetcode",<br>},<br>})
Setup
Create ~/.config/nvim/lua/plugins/leetcode.lua:
require("leetcode").setup({<br>workspace = vim.fn.expand("~/Code/leetcode"),<br>})
Then load it from ~/.config/nvim/init.lua with your other plugin configs:
safe_require("plugins.leetcode")
Defaults:
require("leetcode").setup({<br>workspace = vim.fn.getcwd(),<br>lang = "golang",<br>file = {<br>folder = "",<br>filename = "${id}.${kebab-case-name}.${ext}",<br>overwrite = false,<br>ensure_go_package = true,<br>},<br>cli = {<br>node = "node",<br>path = nil,<br>},<br>})
Commands
:LeetCodeLogin logs in. Cookie login is the default and recommended flow.
:LeetCodeLogout logs out.
:LeetCodeUser shows the current user.
:LeetCodeSearch [query] searches problems and opens the selected problem.
:LeetCodeOpen opens one problem directly.
:LeetCodeTest [testcase] runs tests for the current file.
:LeetCodeSubmit submits the current file.
:LeetCodeHealth checks Node, CLI path, and basic configuration.
Cookie Login
Use :LeetCodeLogin, choose cookie login, then enter:
your LeetCode username or email
either a full copied cookie string, or the raw LEETCODE_SESSION value
the raw csrftoken value, only if you did not paste a full cookie string
The plugin builds the cookie string for you and saves it where<br>vsc-leetcode-cli reads its session: ~/.lc/leetcode/user.json.
Internally, the plugin formats those values as:
; csrftoken=;">LEETCODE_SESSION=; csrftoken=;
The cookie is redacted from output buffers.
About
Solve Leetcode problems in Neovim
Topics
neovim
leetcode
neovim-plugin
Resources
Readme
Uh oh!
There...