Compare commits

..

1 commit

Author SHA1 Message Date
ea6727db40 chore: make public api consistent
Some checks failed
CI / Luacheck (pull_request) Successful in 1m2s
Conventional Tools Commitlint / Commitlint (pull_request) Successful in 35s
CI / Cargo Format (pull_request) Successful in 18s
CI / StyLua (pull_request) Failing after 4s
CI / Build and test (pull_request) Successful in 2m2s
Summary:

Right now we have two ways to access the public api we have `require('ivy')`
and `vim.ivy. Each way has a different api that will cause some confusion.

Now both apis are the same so anyone that wants to integrate with ivy can do so
without having to figure out what one they need to use.

Test Plan:

The unit tests cover most of the work, I have also been using this locally for
quite some time now with now issues.
2024-07-24 22:19:35 +01:00

View file

@ -21,7 +21,6 @@ git clone https://github.com/AdeAttwood/ivy.nvim ~/.config/nvim/pack/bundle/star
### Plugin managers ### Plugin managers
Using [lazy.nvim](https://github.com/folke/lazy.nvim) Using [lazy.nvim](https://github.com/folke/lazy.nvim)
```lua ```lua
{ {
"AdeAttwood/ivy.nvim", "AdeAttwood/ivy.nvim",
@ -29,31 +28,6 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim)
}, },
``` ```
Using [mini.deps](https://github.com/echasnovski/mini.deps)
```lua
local deps = require "mini.deps"
deps.later(function() -- Or `deps.now` if you want this to be loaded immediately
local build = function(args)
local obj = vim
.system(
{ "cargo", "build", "--release", string.format("%s%s%s", "--manifest-path=", args.path, "/Cargo.toml") },
{ text = true }
)
:wait()
vim.print(vim.inspect(obj))
end
deps.add {
source = "AdeAttwood/ivy.nvim",
hooks = {
post_install = build,
post_checkout = build,
},
}
end)
```
TODO: Add more plugin managers TODO: Add more plugin managers
### Setup / Configuration ### Setup / Configuration
@ -62,19 +36,19 @@ Ivy can be configured with minimal config that will give you all the defaults
provided by Ivy. provided by Ivy.
```lua ```lua
require("ivy").setup() require('ivy').setup()
``` ```
With Ivy you can configure your own backends. With Ivy you can configure your own backends.
```lua ```lua
require("ivy").setup { require('ivy').setup {
backends = { backends = {
-- A backend module that will be registered -- A backend module that will be registered
"ivy.backends.buffers", "ivy.backends.buffers",
-- Using a table so you can configure a custom keymap overriding the -- Using a table so you can configure a custom keymap overriding the
-- default one. -- default one.
{ "ivy.backends.files", { keymap = "<C-p>" } }, { "ivy.backends.files", { keymap = "<C-p>" } }
}, },
} }
``` ```
@ -85,7 +59,7 @@ function, this can be used to load backends before or after the setup function
is called. is called.
```lua ```lua
require("ivy").register_backend "ivy.backends.files" require('ivy').register_backend("ivy.backends.files")
``` ```
### Compiling ### Compiling
@ -143,7 +117,7 @@ customized when you register it.
Action can be run on selected candidates provide functionality Action can be run on selected candidates provide functionality
| Action | Key Map | Description | | Action | Key Map | Description |
| ------------------- | --------- | ---------------------------------------------------------------- | | -------------- | ----------- | ------------------------------------------------------------------------------ |
| Complete | \<CR\> |Run the completion function, usually this will be opening a file | | Complete | \<CR\> |Run the completion function, usually this will be opening a file |
| Vertical Split | \<C-v\> |Run the completion function in a new vertical split | | Vertical Split | \<C-v\> |Run the completion function in a new vertical split |
| Split | \<C-s\> |Run the completion function in a new split | | Split | \<C-s\> |Run the completion function in a new split |
@ -159,14 +133,10 @@ Add your own keymaps for an action by adding a `ftplugin/ivy.lua` file in your c
Just add a simple keymap like this: Just add a simple keymap like this:
```lua ```lua
vim.api.nvim_set_keymap( vim.api.nvim_set_keymap( "n", "<esc>", "<cmd>lua vim.ivy.destroy()<CR>", { noremap = true, silent = true, nowait = true })
"n",
"<esc>",
"<cmd>lua vim.ivy.destroy()<CR>",
{ noremap = true, silent = true, nowait = true }
)
``` ```
## API ## API
### ivy.run ### ivy.run
@ -220,9 +190,7 @@ vertical split action it will open the buffer in a new `vsplit`
end, end,
-- Action callback that will be called on the completion or checkpoint actions. -- Action callback that will be called on the completion or checkpoint actions.
-- The currently selected item is passed in as the result. -- The currently selected item is passed in as the result.
function(result) function(result) vim.cmd("edit " .. result) end
vim.cmd("edit " .. result)
end
) )
``` ```