Closed Roy-Orbison closed 6 years ago
If I'm not mistaken what you'd like to achieve is to have the phpcomplete#CompletePHP
set up as an omnifunc for php files and the syntaxcomplete#Complete
for every other filetypes.
Is that correct?
I think you can do this decision with the autocmd Filetype *
based on the filetype of the buffer. I'm thinking of something like this:
autocmd Filetype *
\ if &ft == "php" |
\ setlocal omnifunc=phpcomplete#CompletePHP |
\ else |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
However I might just set the omnifunc globally to the syntaxcomplete one and then have an autocommand for the php file type, this gonna get very unwieldy if you start adding extra languages. My vimrc looks something like this:
augroup ft_php
au!
autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP
autocmd FileType php setlocal iskeyword-=-
augroup END
augroup ft_css
au!
autocmd FileType css,less setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType css,less setlocal iskeyword+=_,$,@,%,#,-,.
autocmd FileType css,less syn sync minlines=200
augroup END
augroup ft_javascript
au!
au FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
au BufNewFile,BufRead *.jsx setlocal filetype=javascript
augroup END
and so on with more and more auto command groups.
Yes.
Currently I'm just listing omnifunc
s individually, like your latter solution, as a workaround.
Thanks for that.
I thought I'd report it in case your plugin was meant to override the inbuilt function in that situation.
Well, it is in a sense it will replace the built-in runtime version of the phpcomplete#CompletePHP
function with a different version.
When in doubt you can check the source of a function with: :function phpcomplete#CompletePHP
and the loaded script files with :scriptnames
to see if the plugin installation was picked up properly or not.
The trick is that it's only loaded when it first needed (hence the autoload parts), after triggering the completion once, I'd expect something like this on the scriptnames output:
178: ~/.vim/bundle/phpcomplete.vim/autoload/phpcomplete.vim
179: ~/.vim/bundle/phpcomplete.vim/misc/php_keywords.vim
180: ~/.vim/bundle/phpcomplete.vim/misc/builtin.vim
181: ~/.vim/bundle/phpcomplete.vim/misc/builtin_manual.vim
So now that I'm not using the inbuilt phpcomplete, function signatures no longer show in a preview window. Do you know if that's a related issue, or if I'm missing some config?
I believe I've seen something like that in a different ticket regarding php7 return type hinting... see the last comment here: #101 Does this sound familiar? Do you have any php7 in the codebase in question?
No, I noticed it with a static method on an old class.
I have had no luck, I think what I'm seeing is the inbuilt behaviour because completions of many native functions do not match the signatures your plugin provides.
Output of :scriptnames
:
1: /etc/vimrc
2: /usr/share/vim/vim74/syntax/syntax.vim
3: /usr/share/vim/vim74/syntax/synload.vim
4: /usr/share/vim/vim74/syntax/syncolor.vim
5: ~/.vim/after/syntax/syncolor.vim
6: /usr/share/vim/vim74/filetype.vim
7: /usr/share/vim/vim74/ftplugin.vim
8: ~/.vimrc
9: /usr/share/vim/vim74/indent.vim
10: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim
11: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim
12: ~/.vim/bundle/vim-airline/autoload/airline/section.vim
13: ~/.vim/bundle/vim-airline/autoload/airline/init.vim
14: ~/.vim/bundle/vim-airline/autoload/airline/parts.vim
15: ~/.vim/colors/molokai.vim
16: ~/.vim/bundle/vim-surround/plugin/surround.vim
17: ~/.vim/bundle/vdebug/plugin/vdebug.vim
18: ~/.vim/bundle/vim-autotag/plugin/autotag.vim
19: ~/.vim/bundle/HowMuch/plugin/HowMuch.vim
20: ~/.vim/bundle/vim-bookmarks/plugin/bookmark.vim
21: ~/.vim/bundle/vim-windowswap/plugin/WindowSwap.vim
22: ~/.vim/bundle/vim-diff-enhanced/plugin/EnhancedDiff.vim
23: ~/.vim/bundle/diffchar.vim/plugin/diffchar.vim
24: ~/.vim/bundle/ctrlp.vim/plugin/ctrlp.vim
25: ~/.vim/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim
26: ~/.vim/bundle/tagbar-phpctags.vim/plugin/tagbar-phpctags.vim
27: ~/.vim/bundle/tagbar/plugin/tagbar.vim
28: ~/.vim/bundle/vim-airline/plugin/airline.vim
29: ~/.vim/bundle/vim-airline/autoload/airline.vim
30: ~/.vim/bundle/vim-airline-themes/plugin/airline-themes.vim
31: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
32: /usr/share/vim/vim74/plugin/gzip.vim
33: /usr/share/vim/vim74/plugin/matchparen.vim
34: /usr/share/vim/vim74/plugin/netrwPlugin.vim
35: /usr/share/vim/vim74/plugin/rrhelper.vim
36: /usr/share/vim/vim74/plugin/spellfile.vim
37: /usr/share/vim/vim74/plugin/tarPlugin.vim
38: /usr/share/vim/vim74/plugin/tohtml.vim
39: /usr/share/vim/vim74/plugin/vimballPlugin.vim
40: /usr/share/vim/vim74/plugin/zipPlugin.vim
41: ~/.vim/bundle/vim-airline/autoload/airline/extensions.vim
42: ~/.vim/bundle/vim-airline/autoload/airline/extensions/quickfix.vim
43: ~/.vim/bundle/vim-airline/autoload/airline/extensions/netrw.vim
44: ~/.vim/bundle/vim-airline/autoload/airline/extensions/ctrlp.vim
45: ~/.vim/bundle/vim-airline/autoload/airline/extensions/tagbar.vim
46: ~/.vim/bundle/vim-airline/autoload/airline/extensions/po.vim
47: ~/.vim/bundle/vim-airline/autoload/airline/extensions/wordcount.vim
48: ~/.vim/bundle/vim-airline/autoload/airline/extensions/tabline.vim
49: ~/.vim/bundle/vim-airline/autoload/airline/extensions/tabline/autoshow.vim
50: ~/.vim/bundle/vim-airline/autoload/airline/extensions/tabline/tabs.vim
51: ~/.vim/bundle/vim-airline/autoload/airline/extensions/tabline/buffers.vim
52: ~/.vim/bundle/vim-airline/autoload/airline/extensions/keymap.vim
53: ~/.vim/bundle/vim-airline/autoload/airline/extensions/windowswap.vim
54: ~/.vim/bundle/vim-airline/autoload/airline/highlighter.vim
55: ~/.vim/bundle/vim-airline-themes/autoload/airline/themes/molokai.vim
56: ~/.vim/bundle/vim-airline/autoload/airline/themes.vim
Are they loading in the wrong order somehow?
So... I had somehow corrupted the loading of Vundle (but everything else was working as expected) so that was a bit of a red herring. Your plugin is working, it just won't show the preview window filled with the function signature when doing <c-x><c-o>
unless multiple options are available. I thought it was not finding the signature at all.
Nice work, thank you for getting back to me with this. I'll close the ticket unless you have something else related to the bindings.
Is there a way to always show the preview window, even when there's only one match?
That behaviour is controlled by vim's completeopt
settings, what you want to have there is the menuone
for that.
I swear I used to have that on. Maybe I turned it off before I had proper auto-completion.
I have this in my vimrc, and no matter what order I put the two
au
s in, PHP syntax completion always seems to be overridden by the the default version in/usr/share/vim/...
.The only thing that seems to allow your plugin to work is to comment out the default omnicomplete.