Skip to content

Commit 91f774c

Browse files
tenfyzhongianding1
authored andcommitted
Add an option named g:leetcode_problemset to select the problemset.
1 parent 93b1c98 commit 91f774c

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ Hide the companies section.
106106

107107
Default value is `0`
108108

109+
### `g:leetcode_problemset`
110+
111+
Set the problemset to get from leetcode.
112+
113+
Default value is `all`
114+
109115
## Updates
110116

111117
- 2019/12/20: Fix the login issue caused by reCAPTCHA.

autoload/leetcode.vim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,16 @@ function! s:ListProblemsOfCompany(company_slug, refresh) abort
367367
endfunction
368368

369369
function! leetcode#ListProblems(refresh) abort
370-
let buf_name = 'leetcode:///problems/all'
370+
let buf_name = 'leetcode:///problems/' . g:leetcode_problemset
371371
if s:CheckSignIn() == v:false
372372
return
373373
endif
374+
let problemset = printf('leetcode.get_problems(["%s"])', g:leetcode_problemset)
374375
if buflisted(buf_name)
375376
execute bufnr(buf_name) . 'buffer'
376377
let saved_view = winsaveview()
377378
if a:refresh ==# 'redownload'
378-
let expr = 'leetcode.get_problems(["all"])'
379+
let expr = problemset
379380
let b:leetcode_downloaded_problems = py3eval(expr)
380381
elseif a:refresh ==# 'norefresh'
381382
return
@@ -387,7 +388,7 @@ function! leetcode#ListProblems(refresh) abort
387388
execute 'rightbelow new ' . buf_name
388389
call s:SetupProblemListBuffer()
389390
let b:leetcode_buffer_type = 'all'
390-
let expr = 'leetcode.get_problems(["all"])'
391+
let expr = problemset
391392
let b:leetcode_downloaded_problems = py3eval(expr)
392393
let b:leetcode_difficulty = 'All'
393394
let b:leetcode_state = 'All'

doc/leetcode.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,10 @@ g:leetcode_hide_companies
9797

9898
Default: 0
9999

100+
*g:leetcode_problemset*
101+
g:leetcode_problemset
102+
Set the problemset to get from leetcode.
103+
104+
Default: 'all'
105+
100106
vim:tw=78:ts=8:et:ft=help:norl:

plugin/leetcode.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ if !exists('g:leetcode_hide_companies')
3232
let g:leetcode_hide_companies = 0
3333
endif
3434

35+
if !exists('g:leetcode_problemset')
36+
let g:leetcode_problemset = 'all'
37+
endif
38+
3539
command! -nargs=0 LeetCodeList call leetcode#ListProblems('redraw')
3640
command! -nargs=0 LeetCodeReset call leetcode#ResetSolution(0)
3741
command! -nargs=0 LeetCodeTest call leetcode#TestSolution()

0 commit comments

Comments
 (0)