File tree Expand file tree Collapse file tree 5 files changed +17
-31
lines changed
Expand file tree Collapse file tree 5 files changed +17
-31
lines changed Original file line number Diff line number Diff line change @@ -48,14 +48,10 @@ function Question:set_lines(code)
4848end
4949
5050function Question :reset_lines ()
51- if not self .reset then
52- return
53- end
54-
5551 local new_lines = self :snippet (true ) or " "
5652
5753 vim .schedule (function () --
58- log .info (" Previous code found and reseted \n To undo, simply press `u`" )
54+ log .info (" Previous code found and reset \n To undo, simply press `u`" )
5955 end )
6056
6157 self :set_lines (new_lines )
@@ -315,14 +311,12 @@ Question.change_lang = vim.schedule_wrap(function(self, lang)
315311end )
316312
317313--- @param problem lc.cache.Question
318- --- @param reset boolean
319- function Question :init (problem , reset )
314+ function Question :init (problem )
320315 self .cache = problem
321316 self .lang = config .lang
322- self .reset = reset and true or false
323317end
324318
325- --- @type fun ( question : lc.cache.Question , reset ?: boolean ): lc.ui.Question
319+ --- @type fun ( question : lc.cache.Question ): lc.ui.Question
326320local LeetQuestion = Question
327321
328322return LeetQuestion
Original file line number Diff line number Diff line change @@ -154,11 +154,11 @@ function Menu:unmount()
154154
155155 require (" leetcode.command" ).q_close_all ()
156156
157- if self .winid and vim .api .nvim_win_is_valid (self .winid ) then
158- vim .api .nvim_win_close (self .winid , true )
159- end
160-
161157 vim .schedule (function ()
158+ if self .winid and vim .api .nvim_win_is_valid (self .winid ) then
159+ vim .api .nvim_win_close (self .winid , true )
160+ end
161+
162162 if self .bufnr and vim .api .nvim_buf_is_valid (self .bufnr ) then
163163 vim .api .nvim_buf_delete (self .bufnr , { force = true })
164164 end
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ function cmd.qot()
140140 return log .err (err )
141141 end
142142 local problemlist = require (" leetcode.cache.problemlist" )
143- Question (problemlist .get_by_title_slug (qot .title_slug ), true ):mount ()
143+ Question (problemlist .get_by_title_slug (qot .title_slug )):mount ()
144144 end )
145145end
146146
@@ -168,7 +168,7 @@ function cmd.random_question(opts)
168168
169169 local item = problems .get_by_title_slug (q .title_slug ) or {}
170170 local Question = require (" leetcode-ui.question" )
171- Question (item , true ):mount ()
171+ Question (item ):mount ()
172172end
173173
174174function cmd .start_with_cmd ()
Original file line number Diff line number Diff line change 22local hooks = {}
33
44hooks [" question_enter" ] = {
5- vim . schedule_wrap ( function (q )
5+ function (q )
66 -- https://github.com/kawre/leetcode.nvim/issues/14
7- if q .lang ~= " rust" then
8- return
7+ if q .lang == " rust" then
8+ pcall (function ()
9+ require (" rust-tools.standalone" ).start_standalone_client ()
10+ end )
911 end
10- pcall (function ()
11- require (" rust-tools.standalone" ).start_standalone_client ()
12- end )
13- end ),
12+ end ,
1413}
1514
1615return hooks
Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ return {
128128 }),
129129 sorter = conf .generic_sorter (theme ),
130130 attach_mappings = function (prompt_bufnr , map )
131- local function mount_question ( reset )
131+ actions . select_default : replace ( function ( )
132132 local selection = action_state .get_selected_entry ()
133133 if not selection then
134134 return
@@ -140,14 +140,7 @@ return {
140140 end
141141
142142 actions .close (prompt_bufnr )
143- Question (q , reset ):mount ()
144- end
145-
146- actions .select_default :replace (function ()
147- mount_question ()
148- end )
149- map ({ " n" , " i" }, " <C-Enter>" , function ()
150- mount_question (true )
143+ Question (q ):mount ()
151144 end )
152145
153146 return true
You can’t perform that action at this time.
0 commit comments