HanXu
HanXu

Reputation: 5597

How to load plugins in the new tab in mac vim?

I'm using macvim to code rails project.

I used some plugins, which is specific to rails(like vim-rails) and will be loaded only in a rails' app folder.

After I entered a rails's folder, I run mvim and everything goes fine.

However, when I use command + T to open a new tab. the function of those plugins disabled..seems they are not loaded..

How to load them when I open a new tab?

Upvotes: 3

Views: 237

Answers (2)

ZyX
ZyX

Reputation: 53664

If these plugins use the similar code to that one fugitive does, then putting something like

augroup LaunchFugitiveForAllBuffers
    autocmd!
    autocmd BufNew :doautocmd fugitive BufRead .
augroup END

(replace fugitive with actual event group name [1]). You can find this name by either grepping plugin files for BufRead (note: case does not really matter) or walking through the output of au BufRead like I did (there should not be many items). Note that things may be more complicated: for example your plugins attach to Filetype event and changing the above to doautocmd fugitive Filetype ruby may not help. Also note that you can purge out word fugitive at all leaving just a space, but it is potentially destructive operation and can be used only for testing (potentially very destructive in case of Filetype event and some others).

[1] Note: event group, not plugin name. These groups are likely to have the name that is a derivative of plugin name, but they are not forced to be equal to it.

Update: It seems that you need railsPluginDetect group for Tim Pope’s rails plugin. I do not have any rails project so I can’t say this for sure, but autocommand looks very similar to fugitive one. It is better though that you go to plugin bug tracker and add a request there (do not forget to search for an existing one).

Upvotes: 2

romainl
romainl

Reputation: 196809

Additional informations may be needed but I think that's because the new tab creates an empty virtual buffer.

Because your RoR-related plugins only work in a Rails folder and you are not in a Rails folder -- you are probably in ~, check :pwd to know what the working directory is -- those plugins don't work.

Upvotes: 0

Related Questions