0

I am new to using plugins with Vim. I mostly work with rails, ruby, latex and html code. I have already installed UltiSnips and vim-snippets plugins using pathogen. I would like corresponding snippets files to be available while I work with these file types. I have tried :UltiSnipsAddFiletypes rails which works perfectly, and would like to place :UltiSnipsAddFiletypes rails.ruby.latex.html in ftplugin/rails.vim as ultisnips documentation mentions

The UltiSnipsAddFiletypes command allows for explicit merging of other snippet filetypes for the current buffer. For example, if you edit a .rst file but also want the Lua snippets to be available you can issue the command >

   :UltiSnipsAddFiletypes rst.lua

using the dotted filetype syntax. Order is important, the first filetype in this list will be the one used for UltiSnipsEdit and the list is ordered by evaluation priority. Consequently, you might add this to your ftplugin/rails.vim >

   :UltiSnipsAddFiletypes rails.ruby

The problem is that I cannot find any file named rails.vim.
Update: Since only some snippets are expanding while other are not I think the problem is with how I have setup plugins on my system. Here is how vim and vimrc have been setup:

call pathogen#infect()
set runtimepath+=~/.vim/bundle/ultisnips
set nocompatible
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsListSnippets="<s-tab>"
let g:UltiSnipsJumpForwardTrigger="<s-j>"
let g:UltiSnipsJumpBackwardTrigger="<s-k>"
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsSnippetDirectories=["vim-snippets", "Ultisnips"]  

.vim/bundle folder contains the cloned git repos ultisnips and vim-snippets.

I have also symlinked ftdetect as suggested in the installation section of ultisnips documentation. I am using vim 7.4. I would be grateful to the community for their help.

1 Answer 1

1

UltiSnipsAddFiletypes is not creating any files. It just informs UltiSnips that when you edit for example a rails file, you also want snippets from file type html and/or ruby and/or javascript and so on.

If you run command :UltiSnipsAddFiletypes rails.ruby.html.javascript then it's important what file type is first (rails in this example) - this will be used in UltiSnipsEdit command as a file type.

If you can't find any file named rails.vim, that's because UltiSnips creates and uses files with .snippets file extension - check out what's inside UltiSnip folder of vim-snippets plugin

Update after OP edit

Since you're using Pathogen, you don't need line:

set runtimepath+=~/.vim/bundle/ultisnips

as well as that ftdetect symlink.

let g:UltiSnipsSnippetDirectories=["vim-snippets", "Ultisnips"] 

This may be the problem. As described in :h UltiSnips-snippet-search-path, this variable is used for subfolders that are contained in direcotries in runtimepath, so vim-snippets is actually a folder in runtimepath that contains snippets and UltiSnips subfolders which have snippet files. I think that you can remove that line, as it defaults to ["UltiSnips"] (please also note the capital S letter).

7
  • I am actually quite confused the way ultisnips is behaving at the moment, html snippets are expanding without any problem, others (latex, rails) do not expand at all.
    – Imran Ali
    May 11, 2017 at 9:41
  • I have updated the vimrc file to reflect your suggestions, but tex snippets are not expanding, is there any command that can be run to test what is causing the problem
    – Imran Ali
    May 11, 2017 at 12:56
  • Is file type for LaTeX files tex or latex? If tex, than you wrote originally that you added 4 file types to ftplugin/rails.vim that contains latex, not tex
    – grodzik
    May 11, 2017 at 13:00
  • latex files have .tex extension, the corresponding snippets are in tex.snippets. I wrote that I wanted to add but actually did not find the suggested file ftplugin/rails.vim
    – Imran Ali
    May 11, 2017 at 13:21
  • So you manually insert this command every time? -> :UltiSnipsAddFiletypes rails.ruby.latex.html - which has latex, not tex. You can add that in ~/.vim/ftplugin/rails.vim - create if doesn't exist
    – grodzik
    May 11, 2017 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.