Feat: Filtering Problem List using local files. #145

Open
jessedoka wants to merge 2 commits from jessedoka/master into master
jessedoka commented 2024-11-20 16:15:50 -06:00 (Migrated from github.com)

Hey, just wanted to add this feature, which is basically able to filter the problem list using both text and JSON files.

For example:

list.json

# My LeetCode Study List
two-sum
4sum|arrays,hash-table
longest-palindromic-substring|dynamic-programming

list.txt

{
  "dynamic-programming": [
    "longest-palindromic-substring",
    "coin-change"
  ],
  "arrays": [
    "two-sum",
    "4sum"
  ]
}

Basic Use:

:Leet custom file=my_list.txt

With additional Filters

:Leet custom file=my_list.txt filter=difficulty difficulty=medium
:Leet custom file=my_list.txt filter=status status=notac

Proof that is works.
Screencast from 2024-11-20 22-10-27.webm

(copilot summary below)

New functionality for custom list filtering:

  • lua/leetcode/cache/problemlist.lua: Added parse_custom_list function to parse custom list files and filter_by_custom_list function to filter problems based on the custom list. Also added Problemlist.filter_by_file method to integrate these functions.

Command structure updates:

Hey, just wanted to add this feature, which is basically able to filter the problem list using both text and JSON files. For example: `list.json` ```txt # My LeetCode Study List two-sum 4sum|arrays,hash-table longest-palindromic-substring|dynamic-programming ``` `list.txt` ```json { "dynamic-programming": [ "longest-palindromic-substring", "coin-change" ], "arrays": [ "two-sum", "4sum" ] } ``` Basic Use: ```nvim :Leet custom file=my_list.txt ``` With additional Filters ```nvim :Leet custom file=my_list.txt filter=difficulty difficulty=medium :Leet custom file=my_list.txt filter=status status=notac ``` Proof that is works. [Screencast from 2024-11-20 22-10-27.webm](https://github.com/user-attachments/assets/da781407-c187-46d5-a2ce-0ed96d6d3eba) (copilot summary below) New functionality for custom list filtering: * [`lua/leetcode/cache/problemlist.lua`](diffhunk://#diff-2c2db1b14496d926a9dd476db8236af3721f538be213b9a3a5a5787bcad269d7R145-R271): Added `parse_custom_list` function to parse custom list files and `filter_by_custom_list` function to filter problems based on the custom list. Also added `Problemlist.filter_by_file` method to integrate these functions. Command structure updates: * [`lua/leetcode/command/arguments.lua`](diffhunk://#diff-42ecef13a41502fab42f10c563a204261a43b2cd2d0f97c19129452ccd4ce9aaR90-R94): Added `arguments.list_custom` to define the structure for custom list command arguments, including file and filter options. * [`lua/leetcode/command/init.lua`](diffhunk://#diff-ea78da1f3dbfedb840427d4eaeb5dfd5a61f4ec79edf4f161033e3c416826ecbR495-R517): Added `cmd.custom_list` function to handle the new custom list command and integrated it into the command list with `cmd.commands.custom`. [[1]](diffhunk://#diff-ea78da1f3dbfedb840427d4eaeb5dfd5a61f4ec79edf4f161033e3c416826ecbR495-R517) [[2]](diffhunk://#diff-ea78da1f3dbfedb840427d4eaeb5dfd5a61f4ec79edf4f161033e3c416826ecbR690-R693)
jessedoka commented 2024-11-20 16:52:23 -06:00 (Migrated from github.com)

Here is neetcode 150 if you want to test it yourself.
neetcode.txt

Here is neetcode 150 if you want to test it yourself. [neetcode.txt](https://github.com/user-attachments/files/17837606/neetcode.txt)
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin jessedoka/master:jessedoka/master
git switch jessedoka/master

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff jessedoka/master
git switch jessedoka/master
git rebase master
git switch master
git merge --ff-only jessedoka/master
git switch jessedoka/master
git rebase master
git switch master
git merge --no-ff jessedoka/master
git switch master
git merge --squash jessedoka/master
git switch master
git merge --ff-only jessedoka/master
git switch master
git merge jessedoka/master
git push origin master
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
arduinohatesme/leetcode.nvim!145
No description provided.