Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: Add get_bufnrs function for buffers under current git repo #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,38 @@ 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 = {}
local out = vim.fn.system("git rev-parse --show-toplevel")
if vim.v.shell_error ~= 0 then -- use only current buffer if not in git repo
table.insert(bufs, vim.api.nvim_get_current_buf())
else
local rootdir = string.sub(out, 1, -2)
for _, buf in pairs(vim.api.nvim_list_bufs()) do

local filename = vim.api.nvim_buf_get_name(buf)
if filename:find(rootdir, 1, true) == 1 then
table.insert(bufs, buf)
end
end
end
return bufs
end
}
}
}
}

```

### indexing_interval (type: number)

Expand Down