Re: Files in ftdetect dirs are not searched
On 31/12/08 07:48, Matt Wozniski wrote: On Tue, Dec 30, 2008 at 1:14 PM, Daniel Schierbeck wrote: I have added several directories to my runtimepath, each corresponding to a git repository. For example, I have a directory ~/Projects/vim- rack that contains ftdetect/rack.vim and syntax/rack.vim. I'm able to manually :set filetype=rack (i.e. the syntax/rack.vim file is picked up), but the ftdetect file does not work. It works fine if I create a symlink at ~/.vim/ftdetect/rack.vim. It seems there's a bug in the way ftdetect files are sourced. This feeling is amplified by the fact that I can insert syntax errors into ~/Projects/vim-rack/ftdetect/rack.vim without Vim complaining on startup. I hope there's a simple workaround. Sorry I couldn't come up with the solution earlier on IRC, but after some sleep, I think I see what's going wrong here. 10 to 1 says you're using a 'nix distro that installs a default system-wide vimrc, and that system-wide vimrc does 'filetype on', meaning that $VIMRUNTIME/filetype.vim gets loaded before your ~/.vimrc ever adds your runtimepaths onto the default runtimepath, and only the ftdetect directories in the default runtimepath are used. I'm not really sure what to do about that, though. You could remove the system-wide vimrc entirely, and move anything done in it to your ~/.vimrc after your change to runtimepath... but this seems ugly as it affects other users. You could alias vim=vim --cmd 'set rtp^=yourdir' in your shell rc, but that also seems horrifically ugly. You could redo the runtime! ftdetect/*.vim, but that would make any autocmds from *other* directories in the runtimepath be re-added... I think the nicest thing to do would be to save the existing value of the 'runtimepath' option, overwrite it with *just* the directories you want added, do the runtime! ftdetect/*.vim, reset 'runtimepath' back to its old value, and then add the new paths to that option in the right spots... but that seems like a whole lot of work for this. Anyone see any better solutions? It's a shame there are no autocmds for an option being set... ~Matt You could use :filetype off :filetype on after changing your 'runtimepath', which would first unset the filetype-detection autocommands, and then re-source filetype.vim to set them again with the new 'runtimepath' (invoking your ftdetect/*.vim scripts). See :help :filetype-overview. Or if the reason is that you change 'runtimepath' after invoking :filetype plugin indent on or after sourcing vimrc_example.vim, do it before. The location of a possible system-wide vimrc is shown near the middle of the output of the :version command. If you compile your own Vim with the vim-default settings, it will look for a system vimrc at /usr/local/share/vim/vimrc, which is almost certainly different of the location (typically /etc/vimrc) used by a Vim version distributed together with a Linux distro. See my compiling HowTo for Unix/Linux at http://users.skynet.be/antoine.mechelynck/vim/compunix.htm Best regards, Tony. -- If A equals success, then the formula is A = X + Y + Z. X is work. Y is play. Z is keep your mouth shut. -- Albert Einstein --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Files in ftdetect dirs are not searched
On Wed, Dec 31, 2008 at 8:11 AM, Tony Mechelynck wrote: On 31/12/08 07:48, Matt Wozniski wrote: On Tue, Dec 30, 2008 at 1:14 PM, Daniel Schierbeck wrote: I hope there's a simple workaround. Sorry I couldn't come up with the solution earlier on IRC, but after some sleep, I think I see what's going wrong here. 10 to 1 says you're using a 'nix distro that installs a default system-wide vimrc, and that system-wide vimrc does 'filetype on', meaning that $VIMRUNTIME/filetype.vim gets loaded before your ~/.vimrc ever adds your runtimepaths onto the default runtimepath, and only the ftdetect directories in the default runtimepath are used. I'm not really sure what to do about that, though... You could use :filetype off :filetype on after changing your 'runtimepath', which would first unset the filetype-detection autocommands, and then re-source filetype.vim to set them again with the new 'runtimepath' (invoking your ftdetect/*.vim scripts). Yes, then that seems like the best solution. I hadn't thought that :filetype off | filetype on would reload filetype.vim, but now that I think about it it makes sense. So, that's the solution, then. ~Matt --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Files in ftdetect dirs are not searched
I have added several directories to my runtimepath, each corresponding to a git repository. For example, I have a directory ~/Projects/vim- rack that contains ftdetect/rack.vim and syntax/rack.vim. I'm able to manually :set filetype=rack (i.e. the syntax/rack.vim file is picked up), but the ftdetect file does not work. It works fine if I create a symlink at ~/.vim/ftdetect/rack.vim. It seems there's a bug in the way ftdetect files are sourced. This feeling is amplified by the fact that I can insert syntax errors into ~/Projects/vim-rack/ftdetect/rack.vim without Vim complaining on startup. I hope there's a simple workaround. Cheers, Daniel Schierbeck --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Files in ftdetect dirs are not searched
On 30/12/08 19:14, Daniel Schierbeck wrote: I have added several directories to my runtimepath, each corresponding to a git repository. For example, I have a directory ~/Projects/vim- rack that contains ftdetect/rack.vim and syntax/rack.vim. I'm able to manually :set filetype=rack (i.e. the syntax/rack.vim file is picked up), but the ftdetect file does not work. It works fine if I create a symlink at ~/.vim/ftdetect/rack.vim. It seems there's a bug in the way ftdetect files are sourced. This feeling is amplified by the fact that I can insert syntax errors into ~/Projects/vim-rack/ftdetect/rack.vim without Vim complaining on startup. I hope there's a simple workaround. Cheers, Daniel Schierbeck $VIMRUNTIME/filetype.vim (current version, 2008 Dec 08) includes the following at lines 2419-2421: Use the plugin-filetype checks last, they may overrule any of the previously detected filetypes. runtime! ftdetect/*.vim With an exclamation mark after :runtime, it will source every *.vim file in the ftdetect/ subdirectory of every directory in 'runtimepath'. This is done after normal filetype detection. So: 1) Is ~/Projects/vim-rack (without an ending slash) in your 'runtimepath' option? (Not its ftdetect subdirectory.) 2) If standard filetype detection finds a different default filetype, you set it using :setlocal filetype=rack, not :setfiletype rack, don't you? Best regards, Tony. -- How doth the little crocodile Improve his shining tail, And pour the waters of the Nile On every golden scale! How cheerfully he seems to grin, How neatly spreads his claws, And welcomes little fishes in, With gently smiling jaws! -- Lewis Carrol, Alice in Wonderland --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Files in ftdetect dirs are not searched
On Tue, Dec 30, 2008 at 1:14 PM, Daniel Schierbeck wrote: I have added several directories to my runtimepath, each corresponding to a git repository. For example, I have a directory ~/Projects/vim- rack that contains ftdetect/rack.vim and syntax/rack.vim. I'm able to manually :set filetype=rack (i.e. the syntax/rack.vim file is picked up), but the ftdetect file does not work. It works fine if I create a symlink at ~/.vim/ftdetect/rack.vim. It seems there's a bug in the way ftdetect files are sourced. This feeling is amplified by the fact that I can insert syntax errors into ~/Projects/vim-rack/ftdetect/rack.vim without Vim complaining on startup. I hope there's a simple workaround. Sorry I couldn't come up with the solution earlier on IRC, but after some sleep, I think I see what's going wrong here. 10 to 1 says you're using a 'nix distro that installs a default system-wide vimrc, and that system-wide vimrc does 'filetype on', meaning that $VIMRUNTIME/filetype.vim gets loaded before your ~/.vimrc ever adds your runtimepaths onto the default runtimepath, and only the ftdetect directories in the default runtimepath are used. I'm not really sure what to do about that, though. You could remove the system-wide vimrc entirely, and move anything done in it to your ~/.vimrc after your change to runtimepath... but this seems ugly as it affects other users. You could alias vim=vim --cmd 'set rtp^=yourdir' in your shell rc, but that also seems horrifically ugly. You could redo the runtime! ftdetect/*.vim, but that would make any autocmds from *other* directories in the runtimepath be re-added... I think the nicest thing to do would be to save the existing value of the 'runtimepath' option, overwrite it with *just* the directories you want added, do the runtime! ftdetect/*.vim, reset 'runtimepath' back to its old value, and then add the new paths to that option in the right spots... but that seems like a whole lot of work for this. Anyone see any better solutions? It's a shame there are no autocmds for an option being set... ~Matt --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---