Skip to content

Commit 7226eee

Browse files
committed
feat: QuartoSendBelow and QuartoSendRange
1 parent f03913a commit 7226eee

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lua/quarto/init.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,18 @@ M.quartoSendAbove = function()
208208
end
209209

210210

211+
M.quartoSendBelow = function()
212+
local lines = otterkeeper.get_language_lines_from_cursor()
213+
if lines == nil then
214+
print(
215+
'No code chunks found for the current language, which is detected based on the current code block. Is your cursor in a code block?')
216+
return
217+
end
218+
lines = concat(lines)
219+
vim.fn['slime#send'](lines)
220+
end
221+
222+
211223
M.quartoSendAll = function()
212224
local lines = otterkeeper.get_language_lines()
213225
if lines == nil then
@@ -219,6 +231,17 @@ M.quartoSendAll = function()
219231
vim.fn['slime#send'](lines)
220232
end
221233

234+
M.quartoSendRange = function()
235+
local lines = otterkeeper.get_language_lines_in_visual_selection()
236+
if lines == nil then
237+
print(
238+
'No code chunks found for the current language, which is detected based on the current code block. Is your cursor in a code block?')
239+
return
240+
end
241+
lines = concat(lines)
242+
vim.fn['slime#send'](lines)
243+
end
244+
222245

223246

224247
return M

plugin/quarto.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ api.nvim_create_user_command('QuartoActivate', quarto.activate, {})
2323
api.nvim_create_user_command('QuartoHelp', quarto.searchHelp, { nargs = 1 })
2424
api.nvim_create_user_command('QuartoHover', quarto.quartoHover, {})
2525
api.nvim_create_user_command('QuartoSendAbove', quarto.quartoSendAbove, {})
26+
api.nvim_create_user_command('QuartoSendBelow', quarto.quartoSendBelow, {})
2627
api.nvim_create_user_command('QuartoSendAll', quarto.quartoSendAll, {})
28+
api.nvim_create_user_command('QuartoSendRange', quarto.quartoSendRange, {range = 2})
2729

2830
vim.treesitter.language.register('markdown', 'quarto')
2931

0 commit comments

Comments
 (0)