Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filetype detection not working #159

Closed
SirVer opened this issue Feb 15, 2014 · 20 comments
Closed

filetype detection not working #159

SirVer opened this issue Feb 15, 2014 · 20 comments

Comments

@SirVer
Copy link
Owner

SirVer commented Feb 15, 2014

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]

Launchpad Details: #LP1067416 Frank Schwach - 2012-10-16 18:15:45 +0200

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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

Launchpad Details: #LPC SirVer - 2012-10-17 10:13:15 +0200

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

I just tried that but it didn't solve my problem.
I unpacked Ultisnips in
$HOME/.vim/UltiSnips-2.2

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.

Launchpad Details: #LPC Frank Schwach - 2012-10-17 11:34:31 +0200

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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

Launchpad Details: #LPC SirVer - 2012-10-17 23:03:50 +0200

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

Thanks for your help SirVer, much appreciated!
Unfortunately, adding
~/.vim/UltiSnips-2.2/after/plugin
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)

Thanks!

Launchpad Details: #LPC Frank Schwach - 2012-10-18 11:22:44 +0200

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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.

Launchpad Details: #LPC SirVer - 2012-10-19 08:20:31 +0200

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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

Launchpad Details: #LPC Frank Schwach - 2012-10-23 10:48:40 +0200

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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.

Launchpad Details: #LPC SirVer - 2012-10-23 14:19:07 +0200

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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

Launchpad Details: #LPC Frank Schwach - 2012-10-23 14:37:57 +0200

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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

Launchpad Details: #LPC SirVer - 2012-10-23 19:14:53 +0200

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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

Launchpad Details: #LPC Flavius Aspra - 2012-12-14 16:15:05 +0100

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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.

Launchpad Details: #LPC SirVer - 2012-12-17 10:49:10 +0100

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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?

Launchpad Details: #LPC Gregor Müllegger - 2013-02-02 02:33:08 +0100

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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

Launchpad Details: #LPC SirVer - 2013-02-02 09:08:25 +0100

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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

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

I.e.

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.

Cheers!

Launchpad Details: #LPC Lemming - 2013-02-27 22:41:40 +0100

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

I am using vundle with ultisnips and have zero issues. I guess you have vundle wrongly installed . see VundleVim/Vundle.vim#16

Launchpad Details: #LPC SirVer - 2013-02-27 23:30:31 +0100

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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!

Launchpad Details: #LPC Anton Melser - 2013-11-05 12:44:52 +0100

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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

Launchpad Details: #LPC SirVer - 2013-11-05 20:24:59 +0100

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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!

Launchpad Details: #LPC Zapata - 2013-12-30 16:53:49 +0100

@SirVer
Copy link
Owner Author

SirVer commented Feb 15, 2014

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

Launchpad Details: #LPC mMontu - 2014-02-04 17:19:08 +0100

@SirVer SirVer closed this as completed Feb 15, 2014
@wilmoore
Copy link

The comment above has a typo (i.e. ftdetext), here is the corrected version:

% 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants