Skip to content
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

cmd SCNvimReboot (reboot interpreter) #253

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/SCNvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Command Description
`SCNvimStart` Start SuperCollider
`SCNvimStop` Stop SuperCollider
`SCNvimRecompile` Recompile SCClassLibrary
`SCNvimReboot` Reboot sclang interpreter
`SCNvimGenerateAssets` Generate syntax highlightning and snippets
`SCNvimHelp` <subject> Open HelpBrowser or window split for <subject>
`SCNvimStatusLine` Display server status in 'statusline' if configured.
Expand Down
5 changes: 5 additions & 0 deletions lua/scnvim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ function scnvim.recompile()
sclang.recompile()
end

--- Reboot sclang.
function scnvim.reboot()
sclang.reboot()
end

--- Determine if a sclang process is active.
---@return True if sclang is running otherwise false.
function scnvim.is_running()
Expand Down
1 change: 1 addition & 0 deletions lua/scnvim/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ return function()
add_command('SCNvimStart', sclang.start, 'Start the sclang interpreter')
add_command('SCNvimStop', sclang.stop, 'Stop the sclang interpreter')
add_command('SCNvimRecompile', sclang.recompile, 'Recompile the sclang interpreter')
add_command('SCNvimReboot', sclang.reboot, 'Reboot sclang interpreter')
add_command('SCNvimStatusLine', sclang.poll_server_status, 'Display the server status')
add_command('SCNvimGenerateAssets', function()
local on_done = function()
Expand Down
12 changes: 11 additions & 1 deletion lua/scnvim/sclang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function M.start()
end

--- Stop the sclang process.
function M.stop()
function M.stop(callback)
if not M.is_running() then
return
end
Expand All @@ -235,15 +235,25 @@ function M.stop()
local ret = M.proc:kill 'sigkill'
if ret == 0 then
timer:close()
if callback then
vim.schedule(callback)
end
M.proc = nil
end
else
-- process exited during timer loop
timer:close()
if callback then
vim.schedule(callback)
end
end
end)
end

function M.reboot()
M.stop(M.start)
end

--- Recompile the class library.
function M.recompile()
if not M.is_running() then
Expand Down
1 change: 1 addition & 0 deletions test/spec/automated/commands_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('commands', function()
'SCNvimGenerateAssets',
'SCNvimHelp',
'SCNvimRecompile',
'SCNvimReboot',
'SCNvimStart',
'SCNvimStatusLine',
'SCNvimStop',
Expand Down
Loading