roxma / nvim-completion-manager

:warning: PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
MIT License
916 stars 49 forks source link

Add support for .tex // Doesn't work for snippets in .tex files #202

Closed qazip closed 6 years ago

qazip commented 6 years ago

Hello,

I'm trying to use nvim-completion-manager with .tex but it doesn't seem to work for snippets in .tex files, or is there some problem in my config?

This is my minimum vim file:

call plug#begin('~/.vim/plugged')

Plug 'roxma/nvim-completion-manager'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'

call plug#end()

imap <expr> <tab>  (pumvisible() ?  "\<c-y>\<Plug>(expand_or_nl)" : "\<tab>")
imap <expr> <Plug>(expand_or_nl) (cm#completed_is_snippet() ? "\<C-j>":"\<tab>")
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"

let g:UltiSnipsExpandTrigger = '<C-j>'
let g:UltiSnipsJumpForwardTrigger = '<C-j>'
let g:UltiSnipsJumpBackwardTrigger = '<C-k>'
qazip commented 6 years ago

It works for .latex but not for .tex

kiryph commented 6 years ago

You probably need to add to your vimrc:

let g:tex_flavor='latex'

Please read :h ft-tex-plugin:

If the first line of a *.tex file has the form >
    %&<format>
then this determined the file type:  plaintex (for plain TeX), context (for
ConTeXt), or tex (for LaTeX).  Otherwise, the file is searched for keywords to
choose context or tex.  If no keywords are found, it defaults to plaintex.
You can change the default by defining the variable g:tex_flavor to the format
(not the file type) you use most.  Use one of these: >
    let g:tex_flavor = "plain"
    let g:tex_flavor = "context"
    let g:tex_flavor = "latex"
Currently no other formats are recognized.

This typically affects empty tex files (you start a new manuscript) or chapter tex files which do not have the line \documentclass.

qazip commented 6 years ago

Oh, it seems to work fine on a non-empty tex file. My bad! Thank you @kiryph