leetcode-cli
leetcode-cli copied to clipboard
Feature Request: Add LSP Support for Rust
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).
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.rsfile 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!