Skip to content

Commit

Permalink
docs: multi buffer completion snippet (#978)
Browse files Browse the repository at this point in the history
* chore(docs) Update recipes.md with multi buffer completion snippet

* docs: improve buffer completion from all open buffers

---------

Co-authored-by: Liam Dyer <[email protected]>
  • Loading branch information
joshzcold and Saghen authored Jan 11, 2025
1 parent 1ddd01b commit 0fe891f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ 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
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

```lua
Expand Down

0 comments on commit 0fe891f

Please sign in to comment.