Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add per-problem Cargo.toml and subdir structure for Rust LSP support #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Antonio-Bennett wants to merge 10 commits into clearloop:master
base: master
Choose a base branch
Loading
from Antonio-Bennett:rust-lsp-support

Conversation

Copy link

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

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!

clearloop reacted with heart emoji
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
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Feature Request: Add LSP Support for Rust
1 participant

AltStyle によって変換されたページ (->オリジナル) /