Skip to content

Migration from contexts to functions #1206

@ruicsh

Description

@ruicsh

hi, are there any general guidelines on how to migrate code from old contexts configs to the new functions?

Example, I have a custom buffer context with an integration with snacks.picker.

contexts = {
    buffer = {
      description = "Pick a buffer to include in chat context.",
      input = function(callback)
          local chat_winid = vim.api.nvim_get_current_win()
          Snacks.picker.buffers({
              confirm = function(picker, item)
                  picker:close()
                  -- Return focus to the chat window
                  if vim.api.nvim_win_is_valid(chat_winid) then
                      vim.api.nvim_set_current_win(chat_winid)
                      vim.cmd("normal! a")
                  end
                  vim.schedule(function()
                      callback(item.buf)
                  end)
              end,
          })
       end,
    },
}

How do I migrate this to functions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions