Skip to content

Commit 795133e

Browse files
committed
fix: slime-sending.
and prepare for yarepl
1 parent 2d3a334 commit 795133e

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

lua/quarto/init.lua

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ M.setup = function(opt)
155155
end
156156

157157
local function concat(ls)
158+
if not (type(ls) == "table") then return ls .. '\n\n' end
158159
local s = ''
159160
for _, l in ipairs(ls) do
160161
if l ~= '' then
@@ -165,17 +166,27 @@ local function concat(ls)
165166
end
166167

167168
local function send(lines)
168-
local yarepl = require 'yarepl'
169169
lines = concat(lines)
170-
171-
if yarepl ~= nil then
172-
yarepl._send_strings(0, 'ipython')
170+
local success, yarepl = pcall(require, 'yarepl')
171+
if success then
172+
yarepl._send_strings(0)
173173
else
174-
local success, error = pcall(vim.fn[vim.fn['slime#send'](lines)])
175-
if not success then
174+
vim.fn['slime#send'](lines)
175+
if success then
176176
vim.fn.notify('Install a REPL code sending plugin to use this feature. Options are yarepl.nvim and vim-slim.')
177177
end
178178
end
179+
180+
end
181+
182+
M.quartoSend = function()
183+
local lines = otterkeeper.get_language_lines_around_cursor()
184+
if lines == nil then
185+
print(
186+
'No code chunk detected around cursor')
187+
return
188+
end
189+
send(lines)
179190
end
180191

181192
M.quartoSendAbove = function()

plugin/quarto.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ api.nvim_create_user_command('QuartoClosePreview', quarto.quartoClosePreview, {}
2121
api.nvim_create_user_command('QuartoActivate', quarto.activate, {})
2222
api.nvim_create_user_command('QuartoHelp', quarto.searchHelp, { nargs = 1 })
2323
api.nvim_create_user_command('QuartoHover', ':require"otter".ask_hover()<cr>', {})
24+
api.nvim_create_user_command('QuartoSend', quarto.quartoSend, {})
2425
api.nvim_create_user_command('QuartoSendAbove', quarto.quartoSendAbove, {})
2526
api.nvim_create_user_command('QuartoSendBelow', quarto.quartoSendBelow, {})
2627
api.nvim_create_user_command('QuartoSendAll', quarto.quartoSendAll, {})

0 commit comments

Comments
 (0)