Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
๐ leetrs
A blazing-fast, Rust-powered CLI engine and TUI for solving LeetCode problems natively in Neovim.
Features โข Installation โข Quick Start โข CLI Reference โข TUI Keybindings
[!WARNING]
This is still a work in progress. Breaking changes to commands and configuration might happen.
๐ Table of Contents
- ๐ Overview
- โจ Features
- ๐ง Prerequisites
- ๐ ๏ธ Installation
- โ๏ธ Configuration
- โก Quick Start
- ๐ป CLI Command Reference
- โจ๏ธ TUI Keybindings
- ๐ Supported Languages
- โ Troubleshooting & FAQ
- ๐ค Contributing
- ๐ License
๐ Overview
leetrs is built for developers who live in the terminal and rely on Neovim. It strips away browser friction by providing a complete LeetCode workflow directly within your terminal:
- Browse & Search: Search problems using an interactive terminal interface (TUI) with fuzzy search, difficulty filters, and topic overlays.
- Fetch & Format: Instantly generate clean Markdown problem descriptions and language-specific code templates.
- Edit in Neovim: Launch Neovim automatically with a vertical split (
vsplit) placing the problem description and code template side-by-side. - Test & Submit: Asynchronously execute sample test cases or submit your solution for full judging, with colorized terminal feedback and runtime statistics.
https://github.com/user-attachments/assets/86783e7e-afc6-449a-828b-c29e34fa9dbb
โจ Features
-
๐ฅ๏ธ Interactive TUI Browser (
leetrs tui/leetrs)- Instant fuzzy search across thousands of LeetCode problems.
- Difficulty filters (Easy, Medium, Hard) and topic tag overlays.
- Visual status indicators for solved status (
ACCEPTANCE), subscription locks, and premium gates. - Quick keys to toggle help popups or open selected problems directly in your system browser.
-
๐ Intelligent Cookie Authentication (
leetrs auth)- Automatically extracts
LEETCODE_SESSIONandcsrftokencookies from active Chrome or Firefox sessions. - Includes a secure manual token fallback for containerized or custom browser profiles.
- Automatically extracts
-
๐ Frictionless Problem Fetching (
leetrs pick)- Fetch problems using URL slugs (e.g.,
two-sum) or numerical IDs (e.g.,1). - Converts raw LeetCode HTML into clean, wrapped terminal Markdown text.
- Generates idiomatic code files (e.g.,
two_sum.rs,two_sum.py,two_sum.sql) with pre-populated function stubs and metadata headers.
- Fetch problems using URL slugs (e.g.,
-
โก Native Neovim Integration
- Seamlessly launches Neovim and opens a side-by-side vertical split (
vsplit). - Problem description sits in the left pane; code solution sits in the right pane.
- Seamlessly launches Neovim and opens a side-by-side vertical split (
-
๐งช Async Testing & Submission Engine (
leetrs test/leetrs submit)- Run code against sample test cases locally without polluting your official submission history.
- Submit directly to LeetCode's judging servers and view real-time judge results, runtime/memory percentiles, and compiler error logs.
๐ง Prerequisites
| Requirement | Version | Notes |
|---|---|---|
| Neovim | 0.9+ | Must be available as nvim in your $PATH |
| LeetCode Account | โ | Required for authentication and submission |
| Google Chrome or Firefox | Any | Used for automatic browser cookie extraction |
| Rust Toolchain | 1.70+ | Required only if installing via Cargo or building from source |
๐ ๏ธ Installation
Choose the installation method that best fits your environment.
Option 1 โ Cargo Install (Recommended)
If you already have Rust and Cargo installed:
[!TIP] Ensure
~/.cargo/binis present in your system$PATH.
Option 2 โ Homebrew (macOS & Linux)
Install via Homebrew tap:
Option 3 โ curl Installer (Quickstart)
Download and install pre-compiled binaries for your platform directly without requiring a Rust installation:
|
Option 4 โ Build from Source
Build the latest release binary from source code:
# 1. Clone the repository
# 2. Build optimized release binary
# 3. Copy binary to executable PATH
# โ or โ
# 4. Verify installation
โ๏ธ Configuration
leetrs uses a TOML configuration file to customize editor launcher commands, default languages, and display settings.
Config File Location
The configuration file (config.toml) is stored in standard system directories:
| OS | Default Path |
|---|---|
| Linux / macOS | ~/.config/leetrs/config.toml |
| Windows | %APPDATA%\leetrs\config.toml |
[!NOTE] The configuration file and parent directories are automatically created on first execution if they do not exist.
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
editor |
string |
"nvim" |
Command executed when picking a problem. Use "nvim" or "vim" for terminal split, or "code" for VS Code. |
language |
string |
"python3" |
Default language for code stub generation ("rust", "python3", "pythondata", "mysql", "postgresql"). |
show_description |
boolean |
true |
When true, opens problem description alongside the code stub in split view. |
Example Configuration
# ~/.config/leetrs/config.toml
= "nvim"
= "rust"
= true
โก Quick Start
Follow these steps to get up and running:
# 1. Authenticate with LeetCode (extracts browser cookies automatically)
# 2. Check authentication status
# 3. Launch the interactive TUI problem browser
# 4. Alternatively, pick a problem directly by slug or numeric ID
# 5. Solve the problem in Neovim, then test against example testcases
# 6. Submit solution for full judging
๐ป CLI Command Reference
leetrs provides a suite of CLI subcommands:
| Subcommand | Arguments / Flags | Description |
|---|---|---|
auth |
โ | Interactively extracts cookies from Chrome/Firefox or accepts manual tokens. |
tui |
[language] |
Launches the interactive TUI problem browser. Optionally set temporary language override. |
pick |
<identifier> [language] [-p, --preview] |
Fetches problem, creates files, and opens editor. Identifier can be a slug (two-sum) or ID (1). --preview prints markdown to stdout. |
test |
<file> |
Tests local solution file against sample test cases without official submission. |
submit |
<file> |
Submits solution file to LeetCode for full judging and statistics. |
status |
โ | Displays active authentication state and token information. |
completion |
<shell> |
Generates shell autocomplete scripts (bash, zsh, fish). |
โจ๏ธ TUI Keybindings
When navigating the interactive TUI (leetrs tui), the following keybindings are available:
Navigation & Problem Selection
| Keybinding | Action |
|---|---|
j / Down |
Move selection down one item |
k / Up |
Move selection up one item |
g g |
Jump to top of problem list |
G |
Jump to bottom of problem list |
Ctrl+d |
Page down (problem list & topic filter) |
Ctrl+u |
Page up (problem list & topic filter) |
Enter |
Pick selected problem and open in configured editor |
o |
Open selected problem in default web browser |
Filtering & Modes
| Keybinding | Action |
|---|---|
/ |
Focus search bar (fuzzy search by title / ID) |
1 |
Easy Problems |
2 |
Medium Problems |
3 |
Hard Problems |
4 |
All difficulties |
t |
Open topic overlay filter modal (real-time topic search, Ctrl+j/Ctrl+k navigation, Enter/Space toggle) |
Tab |
Cycle focus between UI components |
? |
Toggle interactive Help overlay |
Esc |
Clear search filter / exit edit mode / dismiss popup |
q |
Quit TUI |
๐ Supported Languages
leetrs supports major LeetCode programming languages, automatically inferring extensions and comment formats:
| Language Name | LeetCode Slug | File Extension | Meta Header Comment Style |
|---|---|---|---|
| Rust | rust |
.rs |
// id=1 slug=two-sum lang=rust |
| Python 3 | python3 |
.py |
# id=1 slug=two-sum lang=python3 |
| Pandas | pythondata |
.py |
# id=1 slug=two-sum lang=pythondata |
| MySQL | mysql |
.sql |
# id=1 slug=two-sum lang=mysql |
| PostgreSQL | postgresql |
.sql |
-- id=1 slug=two-sum lang=postgresql |
โ Troubleshooting & FAQ
- Ensure you are logged into leetcode.com in your selected browser (Chrome or Firefox).
- If using containerized browser packages (such as Snap or Flatpak on Linux) or custom profile paths, select "Paste tokens manually" during
leetrs auth. - Tokens can be obtained from your browser's Developer Tools (
F12โ Application/Storage โ Cookies โleetcode.com): copyLEETCODE_SESSIONandcsrftoken.
- Verify that Neovim is installed and accessible as
nvimin your system$PATH: - If using another editor, set
editor = "code"or your preferred editor binary in~/.config/leetrs/config.toml.
leetrscaches problem metadata locally in your user data directory (~/.local/share/leetrs/or OS equivalent).- If problem cache becomes corrupted, delete the cache file to trigger a fresh sync on next run:
๐ค Contributing
Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct, development setup, and pull request workflow.
- Fork the Repository
- Create your Feature Branch (
git checkout -b feature/amazing-feature) - Commit your Changes (
git commit -m "feat: add amazing feature") - Push to the Branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
Distributed under the MIT License. See LICENSE for more details.
Developed with โค๏ธ by shadowmkj.