roxma / nvim-completion-manager

:warning: PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
MIT License
917 stars 49 forks source link

Add new completion source for words in other buffers #153

Closed fgrsnau closed 6 years ago

fgrsnau commented 6 years ago

Hi,

I was missing the functionality to complete a word which is present in any other open buffer. Hence I have implemented a new completion source. This is basically cm_bufkeyword for all buffers but the current one. I think a second completion source is good, as we can have a separate priority and the user is able to easily disable the whole thing. Additionally, I don’t use the same word-pattern as cm_bufkeyword but a very generic one (the scope might change when moving between buffers). Naming this beast is a little bit complicated though. I am definitely willing to change it to something less clunky.

Are you generally interested in such a new completion source? When I find the time I might add additional functionality like:

Feel free to provide feedback.

roxma commented 6 years ago

Hi, I don't want to add new builtin source into NCM.

Keyword from other buffers may also be expensive for performance. It's better to keep it a standalone plugin. I'll add it to the source list so that users can find it.

Don’t include the same suggestions as the cm_bufkeyword source (maybe ncm handles this already?)

Vim/Nvim will automatically remove duplicate suggestions. Refer to the dup field at :help complete-items.

// cc @numbcoder #152

numbcoder commented 6 years ago

Why not merge this pr and disable it by default?

fgrsnau commented 6 years ago

Ah, I haven’t found this issue before. I’m fine with a separate plugin.

I considered it as a core plugin as (n)vim by default will complete words from other buffers. Even if the plugin is slower than others this should not be an issue with the async callbacks. Rescanning a buffer would happen rarely and words could be maintained in a prefix tree (but then only the prefix matcher could be used).

I will look into separating the plugin and implementing the points from the initial post. Afterwards you can add it to the list of 3rd-party source plugins.

fgrsnau commented 6 years ago

I created a separate repository for this plugin. You can add it to the source overview list: fgrsnau/ncm-otherbuf