Skip to content

Conversation

Antonio-Bennett
Copy link

@Antonio-Bennett Antonio-Bennett commented Sep 23, 2025

Summary

  • For lang = 'rust', generates subdir crates (e.g., code/1-two_sum/src/lib.rs, Cargo.toml with prob-1-two_sum package, tests.dat).
  • Enables full rust-analyzer LSP in editors (autocomplete, diagnostics) without breaking LeetCode API submissions (still extracts code snippet).
  • New config: [code] enable_rust_crates = true (default; set false for flat files).
  • Backward compatible: Legacy configs load with default true; notes existing flat files.
  • Enhancements: Sanitized names, commented deps in Cargo.toml, error handling.

Changes

  • Updated paths in helper.rs (conditional subdirs).
  • Added dir/Cargo.toml creation in cmds/edit.rs.
  • Configurable via new field in config/code.rs.
  • Docs: New README section on Rust setup.

Testing

  • Manual: leetcode edit 1 creates structure; test 1/exec 1 work.
  • LSP: Open dir in Helix/VS Code—full features.
  • Flat fallback: Set enable_rust_crates = false and edit another problem.

Closes #204 . Ready for review!

Antonio Bennett added 10 commits September 23, 2025 14:03
 • For lang='rust', generate code at code/{fid}-{slug}/src/lib.rs and tests.dat.
 • Create Cargo.toml with basic config on first edit.
 • Preserves flat structure for other languages.
 • Enables rust-analyzer integration without breaking API submissions.
- Cleans up compilation warning from file module.
- Lowercase slugs and prefix with 'prob-' (e.g., 'prob-1_two_sum').
- Prevents Cargo.toml errors; applied to paths and package names.
- Ensures cross-file consistency.
- Includes examples for common LeetCode crates (itertools, regex).
- Allows easy extension without editing boilerplate.
- Detects old flat paths and suggests migration without auto-moving.
- Helps users with pre-existing problems.
- Allows importing suffix in cmds/edit.rs for flat path calculation.
- Add [code] enable_rust_crates = true (default) in config.
- Allows opting out of subdir structure for Rust.
- Updates paths and creation logic accordingly.
- Fix serde attribute for the new field.
- Focus on Rust LSP support with subdir/Cargo.toml details, config option, and usage.
- Positions Rust first; extensible for other languages.
- Ensures missing field in old leetcode.toml defaults to true without error.
- Improves backward compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add LSP Support for Rust
1 participant