Update README.md

This commit is contained in:
hrsh7th 2022-08-10 12:18:08 +09:00 committed by GitHub
parent 62fc67a2b0
commit 3022dbc916
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -91,21 +91,40 @@ You can use the following pre-defined recipes.
##### All buffers
```lua
get_bufnrs = function()
return vim.api.nvim_list_bufs()
end
cmp.setup {
sources = {
{
name = 'buffer',
option = {
get_bufnrs = function()
return vim.api.nvim_list_bufs()
end
}
}
}
}
```
##### Visible buffers
```lua
get_bufnrs = function()
local bufs = {}
for _, win in ipairs(vim.api.nvim_list_wins()) do
bufs[vim.api.nvim_win_get_buf(win)] = true
end
return vim.tbl_keys(bufs)
end
cmp.setup {
sources = {
{
name = 'buffer',
option = {
get_bufnrs = function()
local bufs = {}
for _, win in ipairs(vim.api.nvim_list_wins()) do
bufs[vim.api.nvim_win_get_buf(win)] = true
end
return vim.tbl_keys(bufs)
end
}
}
}
}
```