Skip to content

Commit 2bd34cb

Browse files
authored
cmd SCNvimReboot (reboot interpreter) (#253)
1 parent cb6a968 commit 2bd34cb

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

doc/SCNvim.txt

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Command Description
123123
`SCNvimStart` Start SuperCollider
124124
`SCNvimStop` Stop SuperCollider
125125
`SCNvimRecompile` Recompile SCClassLibrary
126+
`SCNvimReboot` Reboot sclang interpreter
126127
`SCNvimGenerateAssets` Generate syntax highlightning and snippets
127128
`SCNvimHelp` <subject> Open HelpBrowser or window split for <subject>
128129
`SCNvimStatusLine` Display server status in 'statusline' if configured.

lua/scnvim.lua

+5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ function scnvim.recompile()
9999
sclang.recompile()
100100
end
101101

102+
--- Reboot sclang.
103+
function scnvim.reboot()
104+
sclang.reboot()
105+
end
106+
102107
--- Determine if a sclang process is active.
103108
---@return True if sclang is running otherwise false.
104109
function scnvim.is_running()

lua/scnvim/commands.lua

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ return function()
1717
add_command('SCNvimStart', sclang.start, 'Start the sclang interpreter')
1818
add_command('SCNvimStop', sclang.stop, 'Stop the sclang interpreter')
1919
add_command('SCNvimRecompile', sclang.recompile, 'Recompile the sclang interpreter')
20+
add_command('SCNvimReboot', sclang.reboot, 'Reboot sclang interpreter')
2021
add_command('SCNvimStatusLine', sclang.poll_server_status, 'Display the server status')
2122
add_command('SCNvimGenerateAssets', function()
2223
local on_done = function()

lua/scnvim/sclang.lua

+11-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function M.start()
223223
end
224224

225225
--- Stop the sclang process.
226-
function M.stop()
226+
function M.stop(callback)
227227
if not M.is_running() then
228228
return
229229
end
@@ -235,15 +235,25 @@ function M.stop()
235235
local ret = M.proc:kill 'sigkill'
236236
if ret == 0 then
237237
timer:close()
238+
if callback then
239+
vim.schedule(callback)
240+
end
238241
M.proc = nil
239242
end
240243
else
241244
-- process exited during timer loop
242245
timer:close()
246+
if callback then
247+
vim.schedule(callback)
248+
end
243249
end
244250
end)
245251
end
246252

253+
function M.reboot()
254+
M.stop(M.start)
255+
end
256+
247257
--- Recompile the class library.
248258
function M.recompile()
249259
if not M.is_running() then

test/spec/automated/commands_spec.lua

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('commands', function()
88
'SCNvimGenerateAssets',
99
'SCNvimHelp',
1010
'SCNvimRecompile',
11+
'SCNvimReboot',
1112
'SCNvimStart',
1213
'SCNvimStatusLine',
1314
'SCNvimStop',

0 commit comments

Comments
 (0)