Snippets doesn't expanded with tex file format.
vim 8, vim-plug
I am trying to add custom snippets; here is my .vimrc excerpt (without extra snippets collection plugins):
set guioptions-=T
set guioptions -=m
set gfn=Ubuntu\ Mono\ 12
imap jj <Esc>
set nocompatible
syntax on
filetype plugin indent on
set background=light
set noswapfile
set colorcolumn=80
set nowrap
set autoindent
set softtabstop=2
set tabstop=2
set shiftwidth=2
set expandtab
set backspace=indent,eol,start
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-commentary'
Plug 'SirVer/ultisnips'
Plug 'easymotion/vim-easymotion'
Plug 'ctrlpvim/ctrlp.vim'
call plug#end()
let g:EasyMotion_do_mapping = 0 " Disable default mappings
nmap <Space><Space> <Plug>(easymotion-overwin-f2)
" Turn on case insensitive feature
let g:EasyMotion_smartcase = 1
" JK motions: Line motions
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
let g:UltiSnipsSnippetDirectories=$HOME.'/.vim/snippets'
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
ultisnips starts works only after execution UltiSnipsAddFiletypes tex. With other file types it works ok.
I had also check this with honzo plugin.
Command :UltiSnipsEdit opens plaintext.snippet.
@lx93uv The same thing happened for me until my tex file actually had a preamble, at which point :UltiSnipsEdit opened the appropriate tex.snippet
@chrisrytting in my case it creates $PROJECT/UltiSnips/plaintext.snippets (per project) file.
in my case it creates $PROJECT/UltiSnips/plaintext.snippets (per project) file.
That's because
let g:UltiSnipsSnippetDirectories=$HOME.'/.vim/snippets'
is defined wrong in your vim config. First of all snippets directory name is reserved for snipMate snippets. Second, it should be list:
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/UltiSnips']
Command :UltiSnipsEdit opens plaintext.snippet.
Correct me if I'm wrong, but it opens plaintex.snippets, not plaintext.snippets. Plaintex is selected when file is empty on open, but contains .tex extension. However if tex file contains preamble, vim deduces it as tex filetype. Therefore snippets will work, because, they are defined for tex filetype.
The same situation occurs if you will open empty file script.txt in vim. It will be opened with text filetype. But if you add #!/bin/bash to the begining of this file, save it, and reopen, Vim will detect header, and switch to sh filetype, despite the fact that file has .txt extension. That's useful because most of files in linux are not containing extensions, and because vim need to know what type of file it opens, to use filetype indent and other ft features, it deduces fyletype from file contents.
I'm closing it, since it is not a bug.
As a workaround I can suggest creating an plaintex.snippets file, which contains standard Ultisnips facility - extends tex. Maybe it should be suggested to https://github.com/honza/vim-snippets as PR. I'm not LaTeX vim expert, so i don't know, maybe plaintex and tex are very different, and should use different snippets.
Most helpful comment
@lx93uv The same thing happened for me until my tex file actually had a preamble, at which point
:UltiSnipsEditopened the appropriatetex.snippet