leetcode-cli icon indicating copy to clipboard operation
leetcode-cli copied to clipboard

Feature Request: Add LSP Support for Rust

Open Antonio-Bennett opened this issue 4 months ago • 1 comments

Motivation

Currently, when using lang = 'rust', the tool generates flat files (e.g., code/1.two-sum.rs) in ~/.leetcode/code/. This works for LeetCode submissions but lacks a proper crate structure, causing LSP tools like rust-analyzer (in editors such as Helix, VS Code, or Neovim) to have limited features (e.g., no full autocomplete, diagnostics, or go-to-definition).

Antonio-Bennett avatar Sep 23 '25 20:09 Antonio-Bennett

I've just started my journey today on LeetCode and decided to go with Rust.

I'm currently using Zed as an editor and I wasn't able to get rust-analyzer to work with the filenames generated by leetcode-cli. As a workaround, here's what I've done:

  • Work off a valid cargo workspace: cargo new leetcode
  • Create a basic main.rs file with:
#[path = "3512.minimum-operations-to-make-array-sum-divisible-by-k.rs"]
mod p3512;

fn main() {
    println!("Hello, LeetCode!");
}
  • Edit ~/.leetcode/leetcode.toml with:
[code]
editor = 'touch' # this is a hack to have the cmd only create the files and not open the editor
lang = 'rust'

[storage]
code = 'src'
root = '<project path to initialized leetcode project with cargo>'

Hope this helps!

daqnun avatar Nov 29 '25 23:11 daqnun