LaTeX-Box-Team / LaTeX-Box

Lightweight Toolbox for LaTeX - New Official repository
http://www.vim.org/scripts/script.php?script_id=3109
GNU General Public License v3.0
396 stars 66 forks source link

YouCompleteMe Support #172

Open perrin4869 opened 10 years ago

perrin4869 commented 10 years ago

First of all I must say that LaTeX-Box OmniCompletion works almost perfect with YouCompleteMe out of the box. The only complaint that I have is when it comes to command completion. I have set YouCompleteMe to pop up autocompletion whenever '{' and '\' are pressed. The former, as mentioned before, works as you'd expect - it brings up a menu with the available environments. The latter, however, brings up a list of commands, only when one is selected, it gets added with an additional backslash '\' in front of it. For example, if I press '\' and then select '\begin', I end up getting '\begin{'. Of course, the expected output is '\begin{'. I should also mention that ref completion works exactly as expected out of the box as well. Thanks!

felixjung commented 10 years ago

I am interested in your setup, can you post the YCM config bit?

perrin4869 commented 10 years ago

Sure! In my .vimrc I have:

"youcompleteme options
let g:ycm_global_ycm_extra_conf='~/.vim/youcompleteme/.ycm_extra_conf.py'
" let g:ycm_path_to_python_interpreter='/usr/bin/python/'

"use omnicomplete whenever there's no completion engine in youcompleteme (for
"example, in the case of PHP)
set omnifunc=syntaxcomplete#Complete

" let g:ycm_key_invoke_completion = '<C-s>' " Ctrl-suggest - doesn't work
" because C-s freezes the command line
let g:ycm_key_invoke_completion = '<C-h>'
" let g:ycm_key_list_select_completion = ['<C-j>']
" let g:ycm_key_list_previous_completion = ['<C-k>']
let g:ycm_key_list_select_completion = ['<Tab>']
let g:ycm_key_list_previous_completion = ['<S-Tab>']

" Ultisnips
" let g:UltiSnipsExpandTrigger="<Tab>"
" let g:UltiSnipsJumpForwardTrigger="<Tab>"
" let g:UltiSnipsJumpBackwardTrigger="<S-Tab>"
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"

I also have the following in vim/ftplugin/tex.vim

" Add triggers to ycm for LaTeX-Box autocompletion
let g:ycm_semantic_triggers = {
\  'tex'  : ['{'],
\ }
qiemem commented 9 years ago

I'm having this problem as well. I have a pretty minimal ycm setup. It pretty much just sets up the semantic trigger on { and \. I've noticed that when I type something starting with \ and the completions appear, if I hit the shortcut for semantic completion (C- by default I believe), I can then select a completion without ending up with \\ at the beginning of the word.

Karel-van-de-Plassche commented 7 years ago

This issue still exists. It's because the LatexBox_completion_commands include a preceding backslash. You can work around this by changing in ~/.vim/bundle/LaTeX-Box/ftplugin/latex-box/complete.vim

if !exists('g:LatexBox_completion_commands')
    let g:LatexBox_completion_commands = [
        \ {'word': '\begin{' },
        \ {'word': '\end{' },
        \ {'word': '\item' },
        \ {'word': '\label{' },
        \ {'word': '\ref{' },
        \ {'word': '\eqref{eq:' },
        \ {'word': '\cite{' },
        \ {'word': '\chapter{' },
        \ {'word': '\section{' },
        \ {'word': '\subsection{' },
        \ {'word': '\subsubsection{' },
        \ {'word': '\paragraph{' },
        \ {'word': '\nonumber' },
        \ {'word': '\bibliography' },
        \ {'word': '\bibliographystyle' },
\ ]

to

if !exists('g:LatexBox_completion_commands')
    let g:LatexBox_completion_commands = [
        \ {'word': 'begin{' },
        \ {'word': 'end{' },
        \ {'word': 'item' },
        \ {'word': 'label{' },
        \ {'word': 'ref{' },
        \ {'word': 'eqref{eq:' },
        \ {'word': 'cite{' },
        \ {'word': 'chapter{' },
        \ {'word': 'section{' },
        \ {'word': 'subsection{' },
        \ {'word': 'subsubsection{' },
        \ {'word': 'paragraph{' },
        \ {'word': 'nonumber' },
        \ {'word': 'bibliography' },
        \ {'word': 'bibliographystyle' },
\ ]