Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Yesterday I came across jedi-vim plugin which provides auto-completion for python. I installed the plugin using pathogen by placing it in bundle directory and it is working fine.

Now, as I have mentioned that this plugin is only for filetype: python so I want to load it only when I open files with .py extensions and not when I open other files like .java, .perl, .sh.

So, how can this be achieved.

I am a vim beginner/noob but I googled before asking and found that this can be achieved using vim ftplugin but I have no idea whatsoever where to place which file.

share|improve this question

migrated from stackoverflow.com Oct 21 '12 at 9:40

This question came from our site for professional and enthusiast programmers.

    
As the writer of jedi and jedi-vim I ask you: why do you want to do this? –  David Halter Oct 19 '12 at 19:09

1 Answer 1

Especially for complex plugins, the plugin must be written in a way that minimizes its effects on other filetypes. You didn't state why you want to limit the plugin's application to Python files (as long as it doesn't install global mappings that interfere with other mappings, you'd normally not care), but after finding an issue about slow loading time, I suspect it's that.

Until the plugin author provides a fix, you can try moving the plugin/jedi.vim file (and the corresponding jedi_vim.py) one directory up, so that it isn't sourced automatically when Vim starts. When you want to use the plugin, load it via :runtime jedi.vim. Maybe you can even move the files into the ftplugin/ folder; they would then be automatically sourced when a Python file is edited; try it out.

Alternatively, you could completely separate the .vim directories for Python and other development, and use two different aliases to start vim-with-python vs. plain vim:

alias vim-with-python='vim --cmd "set rtp^=~/.vim-with-python" --cmd "set rtp+=~/.vim-with-python/after"'
share|improve this answer
    
By one directory up you mean moving it from bundle/jedi-vim/plugin to bundle/jedi-vim b'coz this didn't worked. it showed some errors saying undefined variable ... –  ronnie Oct 18 '12 at 7:58
    
Yes, actually, any directory outside plugin/ is fine, because only those are sourced on startup. But as I said, for complex plugins spread over many files, this may not be so easy; you'd have to reverse-engineer the dependency structure and calling sequence. –  Ingo Karkat Oct 18 '12 at 9:27
    
Try: stackoverflow.com/questions/18581218/… –  Richard Oct 5 '13 at 5:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.