Skip to content
Discussion options

You must be logged in to vote

I think the most straightforward and robust way here would be to use function that returns array of regions. So something like this:

local custom_block = function(ai_type, _, _)
  local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
  local title_start_lines, res = {}, {}

  local process_line = function(i, l)
    -- If line is for "begin", document it and move on until its "end" part
    local start_title = l:match('^=begin (.*)$')
    if start_title ~= nil then
      title_start_lines[start_title] = i
      return
    end

    -- Use only "end" lines that have same title as some previous "begin"
    local end_title = l:match('^=end (.*)$')
    if end_title == nil or title_start_lines[

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by echasnovski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested mini.ai
2 participants