lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.4k stars 388 forks source link

Umlaut autocompletion with vimtex and neocomplete #969

Closed bo5o closed 6 years ago

bo5o commented 6 years ago

Explain the issue

I added umlauts to the neocomplete keyword_patterns like so:

let g:neocomplete#enable_multibyte_completion = 1
if !exists('g:neocomplete#keyword_patterns')
    let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns._ = '[A-Za-zÄÖÜäöüß_][0-9A-ZÄÖÜäöüß_]*'

Now neocomplete suggests words with umlauts as well. However this does not work in any of my tex files. Whenever neocomplete popup shows suggestions in a tex file, the umlauts are not included (only the parts of the word before or after the umlaut).

Minimal vimrc file

My neocomplete and vimtex settings:

set nocompatible

" vimtex
let g:vimtex_view_method = 'zathura'
let g:tex_flavor = 'latex'

" neocomplete
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1

let g:neocomplete#enable_multibyte_completion = 1
if !exists('g:neocomplete#keyword_patterns')
    let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns._ = '[A-Za-zÄÖÜäöüß_][0-9A-ZÄÖÜäöüß_]*'

if !exists('g:neocomplete#sources#omni#input_patterns')
    let g:neocomplete#sources#omni#input_patterns = {}
endif
let g:neocomplete#sources#omni#input_patterns.tex =
    \ g:vimtex#re#neocomplete
Shougo commented 6 years ago

I think vimtex source (omnifunc?) does not support Umlaut autocompletion. g:neocomplete#keyword_patterns only works for buffer source.

lervag commented 6 years ago

No, I think this is because of the g:vimtex#re#neocomplete, which should probably also include the umlauts. But I'm not quite sure; it seems you are specifically talking about keywords, which I take as "normal" words in the text. The omnifunc from vimtex supports a lot of different LaTeX related stuff, such as commands, bibliography, references, etc, but not keywords.

As always, it would be very helpful if you could provide a specific and explicit example (as suggested by the issue template). An example with what you do, what you expect, and what happens is a minimum.

Note: You could always copy the g:vimtex#re#neocomplete regex and modify it to allow umlauts. I've mostly used the \a atom to match characters, which only allows [A-Za-z]. Thus you could try to copy the variable and change these \as to your [] form.

bo5o commented 6 years ago

Thank you for your comments. I was worried that a minimal working example would be too minimal and therefore redundant. But I will give it a try.

I open up a file test.txt (or really any other filetype except .tex) and type the following:

Aufzählungen

Au

The neocomplete popup suggests the full word Aufzählungen as expected since it's the only match.

I open up a file test.tex and type the following (this is just filetype related so I can leave out the preamble etc):

Aufzählungen

Au

The neocomplete popup suggests only Aufz which is not my desired behaviour. I can always press <c-x><c-n> and the full word appears.

And this is really the only use case for me since I never put umlauts in labels, bibkeys, commands and so on. So you were exactly right, I'm only concerned about "normal" words.

lervag commented 6 years ago

Ok. What is the output of :echo g:neocomplete#keyword_patterns['tex']?

lervag commented 6 years ago

I find this strange, though. One should think that setting the g:neocomplete#sources#omni#input_patterns.tex would not conflict with the keyword completion. Do you have a comment on this, @Shougo?

bo5o commented 6 years ago

For this specific minimal example the output of :echo g:neocomplete#keyword_patterns['tex'] is

\\\a{\a\{1,2}}\|\\[[:alpha:]@][[:alnum:]@]*\%({\%([[:alnum:]:_]\+\*\?}\?\)\?\)\?\|\a[[:alnum:]:_]*\*\?
Shougo commented 6 years ago

I get it.

@cbows You must overwrite tex pattern in g:neocomplete#keyword_patterns. It does not includes Umlauts.

let g:neocomplete#keyword_patterns.tex = '[A-Za-zÄÖÜäöüß_][0-9A-ZÄÖÜäöüß_]*'
lervag commented 6 years ago

That was also my suspicion. Thanks, @Shougo.

bo5o commented 6 years ago

Thank you it works. This was very helpful.