From 7226eeecd42182c0051a0959983e15e9a4e0b939 Mon Sep 17 00:00:00 2001 From: Jannik Buhr Date: Sat, 6 May 2023 13:57:37 +0200 Subject: [PATCH] feat: QuartoSendBelow and QuartoSendRange --- lua/quarto/init.lua | 23 +++++++++++++++++++++++ plugin/quarto.lua | 2 ++ 2 files changed, 25 insertions(+) diff --git a/lua/quarto/init.lua b/lua/quarto/init.lua index 5aea022..634fb4a 100644 --- a/lua/quarto/init.lua +++ b/lua/quarto/init.lua @@ -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 @@ -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 diff --git a/plugin/quarto.lua b/plugin/quarto.lua index 9ac7621..37512ac 100644 --- a/plugin/quarto.lua +++ b/plugin/quarto.lua @@ -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')