From 5b84196f1b211b1d36f1354b2cc4886f0ccd9ddb Mon Sep 17 00:00:00 2001 From: Liam Dyer Date: Sat, 11 Jan 2025 12:25:14 -0500 Subject: [PATCH] docs: improve buffer completion from all open buffers --- docs/recipes.md | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/docs/recipes.md b/docs/recipes.md index 066295c2..1071f6b9 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -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