Files

26 lines
921 B
Lua

-- ======================================================================
-- utils.lua — Helper functions
-- ======================================================================
local M = {}
-- Show filename aligned to the right
function M.show_filename_right()
local filename = vim.fn.expand("%:p")
local columns = vim.o.columns
local space = columns - #filename - 2
if space < 0 then space = 0 end
vim.api.nvim_echo({{string.rep(" ", space) .. filename, "None"}}, false, {})
end
-- Send cell to slime (delimited by pattern, e.g., "^#%%")
function M.send_cell(pattern)
local start_line = vim.fn.search(pattern, "bnW")
if start_line ~= 0 then start_line = start_line + 1 else start_line = 1 end
local stop_line = vim.fn.search(pattern, "nW")
if stop_line ~= 0 then stop_line = stop_line - 1 else stop_line = vim.fn.line("$") end
vim.fn["slime#send_range"](start_line, stop_line)
end
return M