vim-clang icon indicating copy to clipboard operation
vim-clang copied to clipboard

work with neocomplete

Open syswow opened this issue 10 years ago • 19 comments

在Windows 8.1下装了vim-clang和neocomplete,出现一个小问题。 输入std::, 就会自动补齐成std::std. 但当vim-clang运行完成,有cache之后,重新输入std::, 补齐就正常了。 :confused:

设置如下:

" disable auto completion for vim-clang
let g:clang_auto = 0
" default 'longest' can not work with neocomplete
let g:clang_c_completeopt = 'menuone'
let g:clang_cpp_completeopt = 'menuone'
let g:clang_debug = 5 
let g:clang_exec = 'clang.exe'
let g:clang_c_options = '-std=gnu11'
let g:clang_cpp_options = '-std=c++11 -stdlib=libc++'
if !exists('g:neocomplete#force_omni_input_patterns')
        let g:neocomplete#force_omni_input_patterns = {}
endif
" for c and c++
let g:neocomplete#force_omni_input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)\w*'
let g:neocomplete#force_omni_input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*'

syswow avatar May 23 '15 06:05 syswow

I'm not familiar with neocomplete. A few days ago I also tried it, but can't work well with it. I had this issue when change force_omni_input_patterns to .*, but I don't know how to make it work well with neocomplete. Another problems is the longest option, neocomplete can't work with it, but will always select the 1st item if is completed by vim-clang.

Any ideas ?

justmao945 avatar May 23 '15 07:05 justmao945

Hi, I'm neocomplete author.

I had this issue when change force_omni_input_patterns to .*, but I don't know how to make it work well with neocomplete.

You should not use the pattern. It calls the omnifunc in every input pattern.

Another problems is the longest option, neocomplete can't work with it, but will always select the 1st item if is completed by vim-clang.

You should not use "longest" option in auto completion. It conflicts with auto completion behavior. You can use neocomplete#complete_common_string() mapping.

Shougo avatar May 24 '15 01:05 Shougo

If you want to complete the 1st item, you should enable g:neocomplete#enable_auto_select.

Shougo avatar May 24 '15 01:05 Shougo

@Shougo I'm glad to have your answer, the author of neocomplete. :smile:

You should not use the pattern. It calls the omnifunc in every input pattern.

The auto popup completion feature from neocomplete is very impressive, but I want use vim-clang to make a precise completion. So what should I do if I want to use clang to complete all things, including variables and types that don't start with ::, . or -> in pattern [^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w* ?

e.g.

#include <algorithm>
using namespace std;

int main() {
   find
        ^  I want use vim-clang to complete this with auto popup completion provided by neocomplete

You should not use "longest" option in auto completion. It conflicts with auto completion behavior. You can use neocomplete#complete_common_string() mapping.

Oh yes, I'm sorry that vim-clang can work with neocomplete as what I expected when I type .. neocomplete won't select the 1st item automatically, which is what I want.

But when I type <C-X><C-O> manually, vim always selects the 1st item when lacks of longest, which is really what I don't want... So I think it would be better if I can use omnifunc to complete all things.

justmao945 avatar May 24 '15 02:05 justmao945

@syswow I'll have a try with neocomplete on Windows

justmao945 avatar May 24 '15 02:05 justmao945

I've tried on Windows 7 with this version of Vim https://github.com/Shougo/neocomplete.vim#vim-builds-for-windows.

I use same settings both on Windows and Mac OS X. I also have this issue on Windows, but not on Mac OS X with Vim 7.4.712

namespace std {
  struct TestA{};
  struct TestB{};
  struct Test{};
}

int main() {
  std::std
         ^ completed by neocomplete  automatically
}

So I guess this problems is caused by different version of Vim, and I don't know how to fix it yet.

justmao945 avatar May 24 '15 03:05 justmao945

But when I type <C-X><C-O> manually, vim always selects the 1st item when lacks of longest, which is really what I don't want... So I think it would be better if I can use omnifunc to complete all things.

Yes, I think so too. And it conflicts in auto completion plugin behavior. So I posted the patch.

https://groups.google.com/forum/#!searchin/vim_dev/completeopt/vim_dev/tVsk0pdOGvs/fCzBbPkA4w0J

So I guess this problems is caused by different version of Vim, and I don't know how to fix it yet.

Hmmm.. It is strange. I think you should use latest version of Vim.

Shougo avatar May 24 '15 13:05 Shougo

I have the same issue (autocompletes std::std) on Windows with vim 7.4.769

beojan avatar Jul 10 '15 09:07 beojan

I have the same issue on Win7 Vim 7.4 with neocomplete, when force omnifunc to ClangComplete it always selects the first candidate, even though I set

let g:neocomplete#enable_auto_select = 0

Anyone knows how to deal with it?

j5shi avatar Jul 18 '15 00:07 j5shi

@j5shi Please describe your Vim version. Please upload your .vimrc configuration.

Shougo avatar Jul 18 '15 06:07 Shougo

@j5shi You should update your Vim to 7.4.775 or above.

Shougo avatar Jul 18 '15 06:07 Shougo

I've done this, and now get no completions from vim-clang at all

beojan avatar Jul 18 '15 09:07 beojan

I don't know the minor version of my Vim

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 25 2014 04:24:56)
MS-Windows 32-bit GUI version with OLE support
Included patches: 1-417
Compiled by Haroogan <[email protected]>
Huge version with GUI.  Features included (+) or not (-):
+acl                +cryptv             +file_in_path       +listcmds           +persistent_undo    +statusline         +visual
+arabic             +cscope             +find_in_path       +localmap           -postscript         -sun_workshop       +visualextra
+autocmd            +cursorbind         +float              +lua/dyn            +printer            +syntax             +viminfo
+balloon_eval       +cursorshape        +folding            +menu               +profile            +tag_binary         +vreplace
+browse             +dialog_con_gui     -footer             +mksession          +python/dyn         +tag_old_static     +wildignore
++builtin_terms     +diff               +gettext/dyn        +modify_fname       +python3/dyn        -tag_any_white      +wildmenu
+byte_offset        +digraphs           -hangul_input       +mouse              +quickfix           -tcl                +windows
+cindent            -directx            +iconv/dyn          +mouseshape         +reltime            -tgetent            +writebackup
+clientserver       -dnd                +insert_expand      +multi_byte_ime/dyn +rightleft          -termresponse       -xfontset
+clipboard          -ebcdic             +jumplist           +multi_lang         +ruby/dyn           +textobjects        -xim
+cmdline_compl      +emacs_tags         +keymap             -mzscheme           +scrollbind         +title              -xterm_save
+cmdline_hist       +eval               +langmap            +netbeans_intg      +signs              +toolbar            +xpm_w32
+cmdline_info       +ex_extra           +libcall            +ole                +smartindent        +user_commands
+comments           +extra_search       +linebreak          +path_extra         -sniff              +vertsplit
+conceal            +farsi              +lispindent         +perl/dyn           +startuptime        +virtualedit
   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
  system gvimrc file: "$VIM\gvimrc"
    user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
3rd user gvimrc file: "$VIM\_gvimrc"
    system menu file: "$VIMRUNTIME\menu.vim"
Dependency: python27.dll, python34.dll, msvcrt-ruby200.dll, lua52.dll, perl518.dll, libintl.dll, libiconv.dll, iconv.dll   

Partial of my _vimrc

function! Neocomplete()
    " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    " https://github.com/Shougo/neocomplete.vim.git
    " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    let g:neocomplete#enable_at_startup                = 1
    let g:neocomplete#enable_smart_case                = 1
    let g:neocomplete#skip_auto_completion_time        = "0.3"
    let g:neocomplete#sources#buffer#disabled_pattern  = ".*log$"
    let g:neocomplete#ctags_command                    = ""   
    let g:neocomplete#sources#tags#cache_limit_size    = 500000
    let g:neocomplete#use_vimproc                      = 1
    let g:neocomplete#enable_auto_select               = 0

    if !exists('g:neocomplete#force_omni_input_patterns')
        let g:neocomplete#force_omni_input_patterns = {}
    endif
    let g:neocomplete#force_omni_input_patterns.python = '\%([^. \t]\.\|^\s*@\|^\s*from\s.\+import \|^\s*from \|^\s*import \)\w*'
    let g:neocomplete#force_omni_input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)\w*'
    let g:neocomplete#force_omni_input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*'

    inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
    inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<BS>"
    inoremap <expr><BS> pumvisible() ? "<ESC>:call neocomplete#close_popup()<CR>a<BS>" : "<BS>"
endfunction
execute Neocomplete()

And unfortunately I can't find my configuration of vim-clang because of this nasty auto-select-first-candidate issue, I changed to clang-complete this aftertoon and deleted the configuration...

j5shi avatar Jul 18 '15 13:07 j5shi

Luckily, I found it in my recycle bin.

function! VimClang() 
    " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    " https://github.com/justmao945/vim-clang.git
    " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    let g:clang_auto                 = 1
    let g:clang_debug                = 1
    let g:clang_c_options            = ""
    let g:clang_c_completeopt        = "menuone,preview"
    let g:clang_cpp_options          = ""
    let g:clang_cpp_completeopt      = "menuone,preview"
    let g:clang_diagsopt             = "rightbelow12"
    let g:clang_dotfile              = ".clang"
    let g:clang_exec                 = "c:/apps/llvm/bin/clang.exe"
    let g:clang_include_sysheaders   = 0
    let g:clang_pwheight             = 4
    let g:clang_syntax_check_on_save = 0
    nnoremap <Leader>c :ClangCloseWindow<CR>
    nnoremap <C-F9> :ClangSyntaxCheck<CR>
endfunction
execute VimClang()

j5shi avatar Jul 18 '15 13:07 j5shi

let g:clang_auto                 = 1

OK. I get it. Please disable vim-clang auto completion feature. It conflicts with neocomplete.

Please see above configuration.

" disable auto completion for vim-clang
let g:clang_auto = 0
" default 'longest' can not work with neocomplete
let g:clang_c_completeopt = 'menuone'
let g:clang_cpp_completeopt = 'menuone'
let g:clang_debug = 5 
let g:clang_exec = 'clang.exe'
let g:clang_c_options = '-std=gnu11'
let g:clang_cpp_options = '-std=c++11 -stdlib=libc++'
if !exists('g:neocomplete#force_omni_input_patterns')
        let g:neocomplete#force_omni_input_patterns = {}
endif
" for c and c++
let g:neocomplete#force_omni_input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)\w*'
let g:neocomplete#force_omni_input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*'

Shougo avatar Jul 19 '15 01:07 Shougo

@Shougo: Thank you :-] that works now!

j5shi avatar Jul 22 '15 00:07 j5shi

I think this issue should be closed.

Shougo avatar Jul 23 '15 09:07 Shougo

No, as I noted above, after updating vim, I no longer get any completions from vim-clang

Sincerely, Beojan Stanislaus On Jul 23, 2015 10:34 AM, "Shougo" [email protected] wrote:

This issue should be closed.

— Reply to this email directly or view it on GitHub https://github.com/justmao945/vim-clang/issues/53#issuecomment-124033806 .

beojan avatar Jul 23 '15 09:07 beojan

No, as I noted above, after updating vim, I no longer get any completions from vim-clang

Did you disable clang auto completion feature?

Please upload minimal .vimrc less than 50 lines and reproduce ways from Vim starting. The omni completion is works? If the omni completion does not work, it is another problem.

Shougo avatar Jul 23 '15 10:07 Shougo