ayamir / nvimdots

A well configured and structured Neovim.
BSD 3-Clause "New" or "Revised" License
2.82k stars 450 forks source link

feat(cmp): more completion candidates from opened buffers. #1219

Closed mjkx5 closed 2 months ago

mjkx5 commented 2 months ago

using that, buffer completion include all buffer, not only one buffer.

https://github.com/hrsh7th/cmp-buffer

get_bufnrs (type: fun(): number[]) Default: function() return { vim.api.nvim_get_current_buf() } end

A function that specifies the buffer numbers to complete.

ayamir commented 2 months ago

What's the effect? I can't see my desired effect.

mjkx5 commented 2 months ago

Screenshot_06-Apr_16-55-40_kitty Screenshot_06-Apr_16-59-30_kitty It is the first picture which is add this config. It is the second picture which is not add the config.

Default: vim.api.nvim_get_current_buf() -> only read current buffer to completion

the modified config -> reading all buffer to completion.

ayamir commented 2 months ago

Understood. Useful feature and thanks for your contribution!

Jint-lzxy commented 2 months ago

Hmm, but wouldn't this potentially lead to some inappropriate suggestions, especially when buffers are open for different file formats? [e.g., cmp-buffer might suggest @autoreleasepool in a buffer containing C source code (which is invalid) because the project also includes Objective-C files.] Plus, there could be performance implications when too many buffers are open 🤔

EDIT: Was thinking maybe having language servers handle file interactions would be better?

ayamir commented 2 months ago

IMO the range of candidates will decrease during the input process. This function can be seen as a supliment of lsp suggestion, specically for the text input situation like markdown.