filetype detection not working

Bug #1067416 reported by Frank Schwach on 2012-10-16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Fix Committed

Bug Description

Just installed UltiSnips from the tarball, on vimscripts version 2.2. It works but I only get the "all" snippets in files which are otherwise correctly identified by the filetype plugin as Perl and BASH files (filetype is correctly showing up in the status line and syntax highlighting and indentation work as before).
Manually adding the filetype with, e.g.
:UltiSnipsAddFiletypes perl

loads the perl snippets and all works correctly.

I have installed UltiSnips as suggested by extracting the tarball into a directory which I then added to the path in my .vimrc

I have seen the same error reported in conjunction with Vundle but I'm not using Vundle, so not sure what the problem could be or how to investigate this further. Thanks for your help!

my vim version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Apr 16 2010 12:40:58)

:py import sys; print sys.version
2.6.5 (r265:79063, Oct 1 2012, 22:19:00)
[GCC 4.4.3]

You are right, there is a step missing in the documentation - it only
became necessary recently. I added this to the documentation and pushed
a new version, for your convenience, the paragraph is repeated here:

UltiSnips also needs that Vim sources files from the after/ directory.
Unfortunately, vim only allows this in the home directory. You therefore have
to symlink/copy the files from after: >
    mkdir -p ~/.vim/after/plugin/
    ln -s ~/.vim/ultisnips_rep/after/plugin/* ~/.vim/after/plugin/

  status fixcommitted
  importance medium

Changed in ultisnips:
importance: Undecided → Medium
status: New → Fix Committed
Frank Schwach (frankschwach) wrote :

I just tried that but it didn't solve my problem.
I unpacked Ultisnips in

in my vimrc I have

set runtimepath+=~/.vim/UltiSnips-2.2

I have created ths symlinks as you said, so I now have

 ~/.vim/after/plugin/UltiSnips_after.vim -> ~/.vim/UltiSnips-2.2/after/plugin/UltiSnips_after.vim

As before, Ultisnips works when I edit a perl or bash file but I only get the "all" snippets although the filetype has been determined correctly.

please try the following:

cd ~/.vim/after/plugin/
cat UltiSnips_after.vim

and see if this really prints something. Maybe the link is dead.

Second thing to try:
set runtimepath+=~/.vim/UltiSnips-2.2
set runtimepath+=~/.vim/UltiSnips-2.2/after/plugin

Does that solve your problem?

  status incomplete

SirVer (sirver) on 2012-10-17
Changed in ultisnips:
status: Fix Committed → Incomplete
Frank Schwach (frankschwach) wrote :

Thanks for your help SirVer, much appreciated!
Unfortunately, adding
to the runtimepath made no difference, the filetype is still not picked up by UltiSnips. And yes, the symlink actually works and points at the correct file. I also verified that the runtimepath variable has the correct paths including the one to UltiSnips-2.2/after/plugin.
What I would like to do is to make your plugin dump the filetype of the current buffer as it sees it. I guess this would have to be done somewhere in the __init__ python script. Could you help me out with this (I don't know vimscript at all and my Python is a bit rudimentary too I'm afraid)


SirVer (sirver) wrote :

>Thanks for your help SirVer, much appreciated!
np, it's kinda my job begin the author :)

Try to link the files from ftdetect/* also into ~/.vim/ftdetect (create
folder if non existing) and try again. I feel the autocomand FileType is
not installed.

If that works, let me know if you need both symlinks (after and
ftdetect) or if ftdetect is enough. I'll update the docs then.

Frank Schwach (frankschwach) wrote :

Done that but it hasn't changed anything.

My ftdetect folder now has:

UltiSnips.vim -> UltiSnips-2.2/ftdetect/UltiSnips.vim
snippets.vim -> UltiSnips-2.2/ftdetect/snippets.vim

SirVer (sirver) wrote :

Seems like the FileType autocommand is not installed. I do not know why.
please check :au FileType and post the output. The next step would be to
reduce your vim config to a minimal config and upload it for me to test.

Frank Schwach (frankschwach) wrote :

oh no, hang on my mistake - just realised that the paths in my ftdetect symlinks are not correct (missing ../). Corrected them and it now works!!! So, yes, that was the problem.
I have also removed the addition to the runtimepath of after/plugin as well as the symlinks, so all I have now are the symlinks in .vim/ftdetect and the line in .vimrc that adds the UltiSnips directory to the runtimepath and it all works fine now.
Thank you so much for helping me along with this

SirVer (sirver) wrote :

Glad that we found the solution. Sorry for taking so long with this. I
updated the documentation with the proper advice. Setting this to
fixcommitted now.

  status fixcommitted

Changed in ultisnips:
status: Incomplete → Fix Committed

Could you please add the instructions on how to install ultisnips properly using vundle, pathogen and VAM?

SirVer (sirver) wrote :

I use neither of these plugin managers, so I cannot really provide this information. Basically Ultisnips is just a regular Vim plugin, so there should be no need to do anything special. I also gladly accept patches and additions to the documentation.

I also just ran into this issue. I used the current version from vim-scripts where this thing is not documented yet. Maybe it's time for a new release?

SirVer (sirver) wrote :

Yes, you are right. It is about time to release a new version of Ultisnips.

Lemming (lemming123) wrote :

I'm using Vundle and ran into the same issue.

Adding the after/plugin and ftdetect symlinks did the trick.


mkdir -p ~/.vim/after/plugin
ln -s ~/.vim/bundle/ultisnip/after/plugin/* ~/.vim/after/plugin
mkdir ~/.vim/ftdetext
ln -s ~/.vim/bundle/ultisnip/ftdetect/* ~/.vim/ftdetect

I have to say though, it would be very nice, if ultisnip would work out of the box with vundle without all that trouble.
Also, please consider adding this install information on the github README page. Especially for vundle that is the main place I look for install instructions.


SirVer (sirver) wrote :

I am using vundle with ultisnips and have zero issues. I guess you have vundle wrongly installed . see

Anton Melser (melser-anton) wrote :

For those installing from vundle on 12.04 (with the vim 7.4 launchpad repo everyone seems to recommend), the following seems to fix the error:

mkdir -p ~/.vim/after/plugin
ln -s ~/.vim/bundle/UltiSnips/after/plugin/* ~/.vim/after/plugin
mkdir ~/.vim/ftdetect
ln -s ~/.vim/bundle/UltiSnips/ftdetect/* ~/.vim/ftdetect

This differs from the above with the /UltiSnips/ which is what is currently what vundle installs and fixes the typo in ftdetext!

SirVer (sirver) wrote :

Anton, could you elaborate what you are talking about? Which typo? Vundle works perfectly fine with Ultisnips (if you install vundle correctly).

Zapata (kaktuuus) wrote :

When installing it from github via vundle, the correct path is: ~/.vim/bundle/ultisnips/*. Above mentioned workaround is therefore:

mkdir -p ~/.vim/after/plugin
ln -s ~/.vim/bundle/ultisnips/after/plugin/* ~/.vim/after/plugin
mkdir ~/.vim/ftdetext
ln -s ~/.vim/bundle/ultisnips/ftdetect/* ~/.vim/ftdetect

Only for the record :) Should be obvious, but I had trouble with it myself, so I wanted to make things clear!

mMontu (mmontu) wrote :

This is also necessary for pathogen, but seems to be OS dependent -- same settings/plugins works fine on ms-windows without this fix.

Naseer Ahmed (naseer) wrote :

I'm running into the same issue with NeoBundle

Naseer Ahmed (naseer) wrote :

Never mind #20 - it was an issue with the filetype setting order

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers