Skip to content

Commit

Permalink
README: Add get_bufnrs function for buffers under current git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
rish987 committed Oct 20, 2023
1 parent 3022dbc commit bd90f30
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,32 @@ cmp.setup {

```

##### Git repository buffers

```lua
cmp.setup {
sources = {
{
name = 'buffer',
option = {
-- all buffers for files in the current git repository
get_bufnrs = function()
local bufs = {}
for _, buf in pairs(vim.api.nvim_list_bufs()) do
local rootdir = string.sub(vim.fn.system("git rev-parse --show-toplevel"), 1, -2)
local filename = vim.api.nvim_buf_get_name(buf)
if filename:find(rootdir, 1, true) == 1 then
table.insert(bufs, buf)
end
end
return bufs
end
}
}
}
}

```

### indexing_interval (type: number)

Expand Down

0 comments on commit bd90f30

Please sign in to comment.