roxma / nvim-completion-manager

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

[Question] Is there somewhere a list of sources defined? #204

Closed andreyorst closed 6 years ago

andreyorst commented 6 years ago

Hello. I'm trying to figure out how to configure your plugin. It is bit tricky.

The thing that I can't understand is where I can check for source names, that g:cm_sources_override will understand. For example, if I got it right, then this code:

let g:cm_sources_override = {
    \ 'cm-tags': {'enable':0}
    \ }

disables ctags completion source wich declared in this list: image

But it's not clear how would one find out, that ctags source and cm-tags basically refer to one thing. I mean, if I didn't saw that 'cm-tags': {'enable':0} I would never guessed that it will be named like so. And if someone would ask me to guess the name for the source, my first guess probably would be something like ncm_ctags, and if I would continue guessing I'll go for cm_ctags or cm-ctags but not the cm-tags. Maybe it's just me. I don't know. But back to the topic.

Is there a list of source names somewhere? I want to disable theese ~buf ~cwd and ~root sources, because they're useless for me. image _.sh script, kdeinit5__0 and builder (folder) are very useful completions, but I prefer not to see not C related completions, when I work with C code._

But I can't get how to define them in g:cm_sources_override. Or I'm missing something? I've looked through NCM-settings and cm#register_source() tags in :help NCM and read :help ncm-source-examples but that didn't clarify anything related to subject.

Shougo commented 6 years ago

You should specify scopes attribute in cm-filepath source.

If you want to complete filepath in .sh script only.

let g:cm_sources_override = {
    \ 'cm-filepath': {'scopes':['sh']}
    \ }
andreyorst commented 6 years ago

That's not quite what i'm asking for. IIUC you're provided a config that enables filepath completion only when editing .sh files, but i'm talking not about filepath. The problem that it's just filenames shown in completion popup when editing C code. Filepath completion usually is triggered when /such/sequence/of/slhashes/is/inserted/ and I would like to keep it when editing C, for sake of manual includes. But when I type variable name, I don't want to see buffer name, and names contained in the folder where nvim was started. That's what is shown on the screenshot.

Shougo commented 6 years ago

OK. I get it.

DonnieWest commented 6 years ago

@andreyorst this is an example of where the source is the documentation, unfortunately. You can find some of these sources here https://github.com/roxma/nvim-completion-manager/tree/master/autoload/cm/sources and the others here https://github.com/roxma/nvim-completion-manager/tree/master/pythonx/cm_sources

Each one has a register_source call that looks like you would expect and can be disabled in the same way as cm-tags. You're likely looking for cm-bufkeyword and cm-filepath :)

andreyorst commented 6 years ago

@DonnieWest I'll try it. Thanks.


I've tried it. Well... It kinda solves the problem, except that now completion is done by clang only, and therefore there is no filepath nor buffer keywords completion, surprise!.. But as I said - I'd like to disable searching for files when I'm not actually want it, and not disable filepath entirely. Look how Shougo's deoplete works with it: It doesn't show any file in the path until I manually start entering path itself. But with NCM (in my case) when I type in for keyword, I expect clang's for to be the top one, then buffer keyword (if exists), and nothing more at all (or other fuzzymatched *fo* keywords if one exists in any of buffers). But what I get instead is: image lost+found ~root? Seriously? And no clang's for at all. Yes I know that for is 3 keystrokes, and my settings force complete popup show on second keystroke, so even if forwould appear first in the list it will be still three keystrokes, but there are more situations with same behavior, and even though I can fuzzy match through it image I just dont expect such unnecessary completion items to appear in the list.


But I think I'll stick with those sources enabled, as mostly it works fine. Just not that sharp. Thanks again.

roxma commented 6 years ago

This seems to be a sorting issue。 NCM forces the matches of higher priority source shows before the lower ones. But it's hard to find a perfect solutions

A list of possible solutions:

andreyorst commented 6 years ago

This seems to be a sorting issue。

@roxma Actually, I don't think that this is sorting issue. The main issue here is that NCM is completing filenames, when it shouldn't do that. Like in sthe screenshoot at main comment to this issue: image There are certainly filenames in the list (which are not even opened in vim), yet i'm not in filepath completion mode.

I think that filenames should be completed when user have triggered filepath completion directly by typing /\w, ./ or ~/ (yet NCM toggles filepath completion with //).

Same thing with buffnames. I don't think that I ever need one in C file. Those may be shown with the lowest priority though.

roxma commented 6 years ago

In this case,try override the source’s cm_refresh_length,read the doc for more info