Skip to content

Commit

Permalink
feat: QuartoSendBelow and QuartoSendRange
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuhr committed May 6, 2023
1 parent f03913a commit 7226eee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lua/quarto/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ M.quartoSendAbove = function()
end


M.quartoSendBelow = function()
local lines = otterkeeper.get_language_lines_from_cursor()
if lines == nil then
print(
'No code chunks found for the current language, which is detected based on the current code block. Is your cursor in a code block?')
return
end
lines = concat(lines)
vim.fn['slime#send'](lines)
end


M.quartoSendAll = function()
local lines = otterkeeper.get_language_lines()
if lines == nil then
Expand All @@ -219,6 +231,17 @@ M.quartoSendAll = function()
vim.fn['slime#send'](lines)
end

M.quartoSendRange = function()
local lines = otterkeeper.get_language_lines_in_visual_selection()
if lines == nil then
print(
'No code chunks found for the current language, which is detected based on the current code block. Is your cursor in a code block?')
return
end
lines = concat(lines)
vim.fn['slime#send'](lines)
end



return M
2 changes: 2 additions & 0 deletions plugin/quarto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ api.nvim_create_user_command('QuartoActivate', quarto.activate, {})
api.nvim_create_user_command('QuartoHelp', quarto.searchHelp, { nargs = 1 })
api.nvim_create_user_command('QuartoHover', quarto.quartoHover, {})
api.nvim_create_user_command('QuartoSendAbove', quarto.quartoSendAbove, {})
api.nvim_create_user_command('QuartoSendBelow', quarto.quartoSendBelow, {})
api.nvim_create_user_command('QuartoSendAll', quarto.quartoSendAll, {})
api.nvim_create_user_command('QuartoSendRange', quarto.quartoSendRange, {range = 2})

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

0 comments on commit 7226eee

Please sign in to comment.