4

I have setup vundle to handle my packages in MacVim. It correctly sets the filetype for all my other files, e.g. ruby, perl, etc.

However, it is not setting the filetype when I open a .clj file. When I run :set filetype? it returns empty. So, vim isn't recognizing clojure files. I can :set filetype=clojure and immediately get code completion and syntax highlighting; so I know VimClojure is working correctly.

What's the best way to "debug" this or find out where the issue lies?

  • MacVim v7.3
  • OS X 10.6

Thanks!

UPDATE

I already have filetype plugin indent on and it's working for other packages (vim-ruby, vim-rails, etc.) that vundle is managing. Just not VimClojure.

Matthew Boston
  • 1,320
  • 10
  • 24
  • Which of the working plugins install a new suffix-filetype mapping? I'm still not convinced that the `filetype on` call happens in the correct order with the `Bundle` definition. (ie. after the `Bundle` call) – kotarak Oct 10 '11 at 15:22

5 Answers5

5

In order to enable loading filetype plugins you might need to add this in your .vimrc:

filetype plugin on

Tamas Kovacs
  • 1,495
  • 7
  • 9
  • I already have `filetype plugin indent on` and it's working for other packages that vundle is managing. Just not VimClojure. – Matthew Boston Oct 10 '11 at 10:53
  • But did you set `filetype plugin indent on` in your `.vimrc` or is it set by some script later on? If not set in your `.vimrc` then maybe it is set too late, try to put it in your .vimrc then. – Tamas Kovacs Oct 10 '11 at 11:14
  • I have an interesting way of separating my dotfiles files for `.vimrc`. You can take a look at them here: https://github.com/bostonaholic/vim-config. Basically, `.vimrc` calls `runtime! common_config/*.vim*` to load all vim files when vim is booted. In there, yes, I am calling `filetype plugin indent on`. – Matthew Boston Oct 10 '11 at 14:39
  • 1
    Are you sure your `common_config/*.vim*` files are sourced in the "right" order? I mean what if `plugin_config.vim` is sourced before `general_config.vim`? Then the `filetype plugin indent on` may come too late. I would give it a try and set `filetype plugin indent on` before anything else in `.vimrc`, just to make sure this isn't the problem. BTW, you can run vim in verbose mode to check the order of the scripts actually sourced. – Tamas Kovacs Oct 10 '11 at 16:28
  • Thanks, Tamas. That's what I'm looking at right now. I'll let you know my findings. – Matthew Boston Oct 10 '11 at 16:31
  • As I suspected it was that the fact that the `common_config/*.vim` files weren't being loaded in a predictable manner. So, if you check my github project, you'll see I've extracted them out and have been explicit in the order in which they run. Thanks for your help! – Matthew Boston Oct 10 '11 at 17:37
3

Make sure you're initializing Vundle and your bundles before the rest of your configuration in your vimrc. So, for example, you should have:

" =======================================================================
" Vundle setup and initialization. This needs to be done before any
" configuration so all plugins are loaded.

set nocompatible                    " required for Vundle
filetype off                        " required for Vundle, enabled later.

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'

" Powerline
Bundle 'Lokaltog/vim-powerline'
...

...where Powerline is just an example bundle. Then have the rest of your config...

" =======================================================================
" Actual vim configuration goes here.
" =======================================================================

syntax on                           "lots of syntax highlighting
set nocompatible                    "be iMproved
colorscheme mustang
filetype plugin indent on
...

Hope that helps...

Dan Pilone
  • 31
  • 2
0

I have the same problem on Ubuntu. It's caused by system-level vim settings.

You can what system-level vim settings are applied with :scriptnames. If you run redir @c | scriptnames | redir END | enew | put c inside of vim, you'll get a buffer containing all scripts sourced by vim. If you ignore all of your files (:g/\~/d), you can see all system-level scripts.

My problem was in the very first file: /usr/share/vim/vimrc

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
  syntax on
endif

Because syntax on appears before pathogen (my vim plugin manager) is setup, vim never looks in the bundle/vimclojure/ftdetect directory. I think vundle will have the same problem for you. (Try copying ftdetect/clojure.vim into ~/.vim/ftdetect/clojure.vim and see if you still have the problem.)

If you're having the same problem, you have three possible solutions:

  1. Comment out those lines and file a bug with whoever owns the offending file (Apple or MacVim). I'd guess that your files are in the MacVim bundle, since I don't remember MacVim doing system-level changes.
  2. Add filetype off before initializing vundle (you may need syntax off too). Pathogen uses pathogen#infect() to do this, maybe vundle has something similar. (Corresponding pathogen bug and fix.) Make sure you turn them back on after! (Also, make sure your vundle setup comes before anything else in your vimrc related to filetype/plugin/syntax.)
  3. Make symlinks from ftdetect files for all bundles into ~/.vim/ftdetect (and have doubled autocmds if the bug is ever fixed).
idbrii
  • 10,975
  • 5
  • 66
  • 107
0

Make sure your file extension is .clj, not .clojure nor .cloj

ryepes
  • 1
0

VimClojure installs a file ftdetect/clojure.vim. My suspicion is, that this is not picked up by Vim. Don't know vundle so I can't help with that. If vundle needs some initialisation in .vimrc, you should check that it happens before the filetype stuff.

kotarak
  • 17,099
  • 2
  • 49
  • 39