HomePhorge

feat: implement a setup function

Description

feat: implement a setup function

Summary:

Now when using ivy.nvim you will need to call the setup function. This will
need to register any backends you want to use. This is an example config, this
can be put into a plugin in ~/.config/nvim/plugin/ivy.lua for example.

require('ivy').setup {
  backends = {
    "ivy.backends.buffers",
    "ivy.backends.files",
  },
}

If you are using Lazy you can use the config directly to call the setup
function.

return {
  "AdeAttwood/ivy.nvim",
  build = "cargo build --release",
  config = {
    backends = {
      "ivy.backends.buffers",
      "ivy.backends.files",
    }
  }
}

The setup function can only be called once, if its called a second time any
backends or config will not be used. The module does expose the
register_backend function, this can be used to load backends before or after
the setup function is called.

require('ivy').register_backend("ivy.backends.files")

As well as the register_backend the core runfunction is exposed. With this
exposed we should be able to build anything we want.

vim.ivy.run(
  "Title",
  function(input)
    return {
      { content = "One" },
      { content = "Two" },
      { content = "Three" },
    }
  end,
  function(result) vim.cmd("edit " .. result) end
)

Test Plan:

Not much to test in this one, it has been tested locally on my config that does
not use any plugin managers, also a sandbox Lazy env using NVIM_APPNAME
NVIM_APPNAME

Details

Provenance
AdeAttwoodAuthored on Jun 24 2024, 7:07 PM
Parents
R1:91b6db9d76c6: feat: split out register backend so it can be used as an external API
Branches
Unknown
Tags
Unknown

Event Timeline