Shougo / neocomplete.vim

Next generation completion framework after neocomplcache
2.74k stars 203 forks source link

Problem with buffer completion after recent commit #146

Closed petobens closed 10 years ago

petobens commented 10 years ago

Hi Shougo. Thanks to your help here and here I was able to complete references in tex files. Using the following settings

if !exists('g:neocomplete#keyword_patterns')
    let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns._ = '^\\\?\h\w*$'
let keyword_patterns = {}
let keyword_patterns = {'tex' : '\h\w*:\%(\w*_\w*\)\?'}
call neocomplete#custom#source('buffer', 'keyword_patterns',
            \ keyword_patterns)

if in a buffer I have something like this

\ref{sec:a_section}

If I type

\cref{sec:

it completes to

\cref{sec:a_section

This used to work great until this commit. Since that commit buffer completion stopped working.

I also noticed that before that commit if I ran the command echo neocomplete#get_keyword_pattern('tex', 'buffer') I would get as a result \h\w*:\%(\w*_\w*\)\? and after the problematic commit i get the following error:

Error detected while processing function neocomplete#get_keyword_pattern:
E712: Argument of get() must be a List or Dictionary
Shougo commented 10 years ago

I fixed the problem.

petobens commented 10 years ago

Thanks Shougo that indeed fixes the problem. I noticed another problem (that is maybe related to my regex but I'm pretty sure that it use to work before. Now if I type

\cref{sec:

It correctly completes to

\cref{sec:a_section}

But if I type

\cref{}

and then

\cref{sec:}

no completion happens. I don't know why this is happening. Thanks in advance and happy new year.

Shougo commented 10 years ago

You must disable next_keyword_patterns.

let next_keyword_patterns = {}
let next_keyword_patterns = {'tex' : ''}
call neocomplete#custom#source('buffer', 'next_keyword_patterns',
            \ next_keyword_patterns)
petobens commented 10 years ago

Thanks! That worked. What functionality does next_keyword_pattern add? I read from the documentation but I don't understand this part

    This dictionary records regular expression to recognize a
    keyword pattern of the next than a cursor.  The form is the ...

It recognizes keyword pattern of the word next to the cursor?

Shougo commented 10 years ago

It recognizes keyword pattern of the word next to the cursor?

Yes.

petobens commented 10 years ago

Okay thanks again for the help!

petobens commented 10 years ago

One last question. Do I need to set

if !exists('g:neocomplete#next_keyword_patterns')
    let g:neocomplete#next_keyword_patterns = {}
endif

before

let next_keyword_patterns = {}
let next_keyword_patterns = {'tex' : ''}
call neocomplete#custom#source('buffer', 'next_keyword_patterns',
            \ next_keyword_patterns)

?

Shougo commented 10 years ago

No. If you don't use global g:neocomplete#next_keyword_patterns, you don't have to initialize.

petobens commented 10 years ago

Thanks for the explanation.

petobens commented 10 years ago

Hello Shougo, I'm terribly sorry to bother you again. As you told me, I was using the following

let next_keyword_patterns = {}
let next_keyword_patterns = {'tex' : ''}
call neocomplete#custom#source('buffer', 'next_keyword_patterns',
            \ next_keyword_patterns)

However next_keyword_patterns is deprecated now. So once again I have the problem I used to have here. How can I fix it? I read the docs but I don't know how or if I should use converter_remove_overlap. Thanks in advance

Shougo commented 10 years ago

Yes, this feature is deprecated. You can disable "converter_remove_overlap".

:help neocomplete#custom#filters()

petobens commented 10 years ago

I tried doing:

call neocomplete#custom#source('buffer', 'converters',
            \ ['converter_delimiter', 'converter_case', 'converter_abbr'])

But my problem is not fixed. Additionally I would like to disable converter_remove_overlap only for buffer source in tex files and not every file. Is there a way to do that? Thanks

Shougo commented 10 years ago

Ok, I will try it. But your information is not enough. Please upload minimal .vimrc less than 50 lines and reproduce ways from Vim starting. You should upload sample tex file.

petobens commented 10 years ago

Here is the minimal vimrc:

set nocompatible

set runtimepath+=~/vimfiles/bundle/neocomplete/
set runtimepath+=~/vimfiles/bundle/vimproc/
let g:neocomplete#enable_at_startup = 1

if !exists('g:neocomplete#sources')
    let g:neocomplete#sources = {}
endif
let g:neocomplete#sources.tex = ['buffer']

if !exists('g:neocomplete#keyword_patterns')
    let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns._ = '^\\\?\h\w*$'
let keyword_patterns = {}
let keyword_patterns = {'tex' : '\h\w*:\%(\w*_\w*\)\?'}
call neocomplete#custom#source('buffer', 'keyword_patterns',
            \ keyword_patterns)

call neocomplete#custom#source('buffer', 'converters',
            \ ['converter_delimiter', 'converter_case', 'converter_abbr'])

setfiletype tex

To reproduce create a file foo.tex with the following contents

\section{A test}
\label{sec:a_test}

After doing :NeoCompleteClean and :NeoCompleteBufferMakeCache you will see that if you type \cref{sec: then vim will complete to \cref{sec:a_test but if you yank and paste \cref{sec:} and place the cursor before the last parenthesis i.e \cref{sec:CURSOR HERE}, then no completion happens.

Shougo commented 10 years ago

neocomplete

No. It is works in my environment. So, it is not neocomplete problem.

petobens commented 10 years ago

It doesn't work for me: when I place the cursor before the brace no completion happens.

output_yvcalo

Shougo commented 10 years ago

I cannot fix the problem. Because, it works in my envoriment. Can you fix the problem?

It doesn't work for me: when I place the cursor before the brace no completion happens.

You must input characters. Neocomplete does not complete on InsertEnter.

petobens commented 10 years ago

I believe thaat "You must input characters. Neocomplete does not complete on InsertEnter" is the solution to my problem! Thanks Shougo for the help and patience.