Closed andreyorst closed 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']}
\ }
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.
OK. I get it.
@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
:)
@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:
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 for
would 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
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.
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:
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:
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.
In this case,try override the source’s cm_refresh_length,read the doc for more info
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:disables ctags completion source wich declared in this list:![image](https://user-images.githubusercontent.com/19470159/37480554-943a1f24-2890-11e8-9ce1-e57c24b4d8c5.png)
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 likencm_ctags
, and if I would continue guessing I'll go forcm_ctags
orcm-ctags
but not thecm-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..sh
script,kdeinit5__0
andbuilder
(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 throughNCM-settings
andcm#register_source()
tags in:help NCM
and read:help ncm-source-examples
but that didn't clarify anything related to subject.