Skip to content

Commit

Permalink
docs: improve buffer completion from all open buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Jan 11, 2025
1 parent ffa26a9 commit 5b84196
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions docs/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,25 @@ completion = {

### Buffer completion from all open buffers

The default behavior is to only show completions from **visible** "normal" buffers (i.e. it woudldn't include neo-tree). This will instead show completions from all buffers, even if they're not visible on screen. Note that the performance impact of this has not been tested.

```lua
providers = {
buffer = {
name = "Buffer",
module = "blink.cmp.sources.buffer",
opts = {
get_bufnrs = function()
return vim.api.nvim_list_bufs()
end,
},
},
},
sources = {
providers = {
buffer = {
opts = {
-- get all buffers, even ones like neo-tree
get_bufnrs = vim.api.nvim_list_bufs
-- or (recommended) filter to only "normal" buffers
get_bufnrs = function()
return vim.tbl_filter(function(bufnr)
return vim.bo[bufnr].buftype == ''
end, vim.api.nvim_list_bufs())
end
}
}
}
}
```

### Don't show completion menu automatically in cmdline mode
Expand Down

0 comments on commit 5b84196

Please sign in to comment.