-
Notifications
You must be signed in to change notification settings - Fork 43
[RFC] allow combining matchers #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
That's neat! Matching on the title seems to work quite nicely (although I think I personally would prefer
This should match on Or is it currently by design that only the last field is considered? I should add that this is also a great improvement for another omnifun completion in vimtex, |
The author field passed by vimtex is in
|
Oh, I see! Then it makes sense. Using
matches everything correctly (and a few things that are a nuisance like the Out of curiosity, how can I output the string in your last comment for other omnifun completions? Then I can check this for |
After the item gets completed, press |
Thanks, that's helpful. For the record, here's an example of omnifun's
and an example for command completion:
EDIT By the way, I looked at |
A question: How are the matches sorted if multiple matchers match (heh)? I.e., if I have
there are three items with
and I try to match |
This is kind of hard to solve. But current See https://github.com/ncm2/ncm2/blob/master/pythonx/ncm2_sorter/abbrfuzzy.py#L25 The sort priority is
|
So the But even in its current form, this is already a big improvement in functionality for me, and I'd be happy to see it merged! |
Regarding different configurations for different |
I'm not sure what you want. You should open an issue and elaborate the expecting behavior. |
@roxma Sorry, I should have been clearer. Briefly, depending on the context, vimtex's omnifun can return different completed items such as
and
(note the different 'kind' fields). I would like to (for simplicity say) match the former But I think I can get most of what I want by modifying things on the vimtex side; if that's not enough (or you think that it might be useful for others), I'll open a new issue. From my side, this PR is good as is. |
I just want to add that I like how this is progressing. I will definately look closer into ncm2 and might swap out deoplete if I'm properly convinced! |
Since this issue is linked from the wiki, here's the full ncm2-vimtex config as in au InsertEnter * call ncm2#enable_for_buffer()
au Filetype tex call ncm2#register_source({
\ 'name' : 'vimtex-cmds',
\ 'priority': 8,
\ 'complete_length': -1,
\ 'scope': ['tex'],
\ 'matcher': {'name': 'prefix', 'key': 'word'},
\ 'word_pattern': '\w+',
\ 'complete_pattern': g:vimtex#re#ncm2#cmds,
\ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
\ })
au Filetype tex call ncm2#register_source({
\ 'name' : 'vimtex-labels',
\ 'priority': 8,
\ 'complete_length': -1,
\ 'scope': ['tex'],
\ 'matcher': {'name': 'combine',
\ 'matchers': [
\ {'name': 'substr', 'key': 'word'},
\ {'name': 'substr', 'key': 'menu'},
\ ]},
\ 'word_pattern': '\w+',
\ 'complete_pattern': g:vimtex#re#ncm2#labels,
\ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
\ })
au Filetype tex call ncm2#register_source({
\ 'name' : 'vimtex-files',
\ 'priority': 8,
\ 'complete_length': -1,
\ 'scope': ['tex'],
\ 'matcher': {'name': 'combine',
\ 'matchers': [
\ {'name': 'abbrfuzzy', 'key': 'word'},
\ {'name': 'abbrfuzzy', 'key': 'abbr'},
\ ]},
\ 'word_pattern': '\w+',
\ 'complete_pattern': g:vimtex#re#ncm2#files,
\ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
\ })
au Filetype tex call ncm2#register_source({
\ 'name' : 'bibtex',
\ 'priority': 8,
\ 'complete_length': -1,
\ 'scope': ['tex'],
\ 'matcher': {'name': 'combine',
\ 'matchers': [
\ {'name': 'prefix', 'key': 'word'},
\ {'name': 'abbrfuzzy', 'key': 'abbr'},
\ {'name': 'abbrfuzzy', 'key': 'menu'},
\ ]},
\ 'word_pattern': '\w+',
\ 'complete_pattern': g:vimtex#re#ncm2#bibtex,
\ 'on_complete': ['ncm2#on_complete#omni', 'vimtex#complete#omnifunc'],
\ }) |
The key is
Demo:
test files from #22 (comment)
minimal vimrc:
Comments? @clason @balta2ar