Skip to content
Simon Ye edited this page May 21, 2015 · 16 revisions

Customization

~/.vimrc.before

This file is sourced before any other file or plugin. Janus core is loaded before this script, so you get access to all the functions defined in janus.vim.

This is perfect for setting things like the mapleader. Because any mappings using the <leader> keywords that is parsed before changing the mapleader, the mapleader won't have any effect on them.

~/.vimrc.after

~/.vimrc.after is loaded after Janus but before other plugins are loaded. This allows you to override anything set by Janus or any plugin.

This is useful for re-mapping some of the bindings to your liking, setting the colorscheme, changing the encoding or the expandtab, etc.

Adding a new plugin, color-scheme, ...

Create a ~/.janus directory for your custom additions. These will be loaded before any other group, except of course the core group. This will ensure that your version of any already-installed plugins will be loaded instead.

To add customizations or add more Vim plugins, create a ~/.janus directory and add your plugins there, either with a git clone or by adding submodules to your own git repository there. This directory is treated like a normal pathogen directory. An example of adding a plugin:

$ cd ~/.janus
$ git clone https://github.com/vim-scripts/Rename2.git rename2

Or, if you have a git repository in ~/.janus, you can use a submodule:

$ cd ~/.janus
$ git submodule add https://github.com/vim-scripts/Rename2.git rename2

Note: Plugins must be added within a containing directory as would be done by the git commands above, and not the bare my_plugin.vim file (as would be done in with Vim in ~/.vim/plugin/). Ex. ~/.janus/vim-gnupg/plugin/gnupg.vim, not ~/.janus/gnupg.vim.

Keeping the ~/.janus folder separate from the janus checkout in .vim lets you manage this folder of your own customizations separately, making it easier to duplicate your setup on multiple machines.

To override a color theme bundled with janus or plugin that cannot be loaded twice, you can place your plugin in ~/.janus.before. For example:

$ cd ~/.janus.before
$ git clone https://github.com/jnurmine/Zenburn.git

Even if not every vim-script hosted on vim.org has a git repository (by the author or a mirror), you can easily cro a git repository for it using Vim-scripts Github mirror.

The list of color schemes can be found in the color directory.

Disabling a plugin

Janus makes it easy to disable any included plugin, color-scheme, lang etc. Disabling a plug-in is done only within your ~/.vimrc.before file using the janus#disable_plugin() method. This does not work in ~/.gvimrc.before. This methods takes two arguments: the plugin name and optionally the reason for disabling the plugin. If reason is given, all bindings that Janus binds to the plugin will still be bind but the action will just be an echo that the plugin is disabled. For example:

Janus adds the binding <C-t> or <D-t> on MacVim to open the Command-t plugin which requires Vim built with ruby support. If your Vim is not built with ruby support, your Vim will not throw errors about it because Janus will disable the plugin automatically. However, if you try <C-t> or <D-t> (you might expect that nothing happens but..) the following message appears in the command-line area:

The plugin command-t is disabled for the following reason: Vim is compiled without ruby support.

Here's the signature of the janus#disable_plugin function. You might notice in the source code that it supports specifying the group as well, but since this feature is not working yet, please ignore it.

" Disable a plugin
"
" @param [String] The plugin name
" @param [String] The reason why it is disabled
" @return [Bool]
function! janus#disable_plugin(...)
endfunction

Disabling a plugin in ~/.vimrc.before example:

" Disable command-t because I don't like it, but keep the bindings to remind me
call janus#disable_plugin('command-t', "I don't like it")

" Disable Hammer because it doesn't work and remove the bindings
call janus#disable_plugin('hammer')

Customizing Snippets

The snippets that come with Janus are very extensive, but part of the allure of vim is being able to customize your setup. Adding snippets to Janus is really simple.

If you haven't already setup a ~/.janus directory, go ahead and do so.

mkdir ~/.janus

snipMate will hunt for a snippets directory in the sub directories of ~/.janus (but not at the root level). So, make a directory

mkdir -p ~/.janus/mysnippets/snippets # mysnippets can be whatever you like

Then place a blank _.snippets file in that directory to signal that it's a directory with snippets in it:

touch ~/.janus/mysnippets/snippets/_.snippets

You can now create snippets in your new snippets directory (~/.janus/mysnippets/snippets) following the regular snipMate help file instructions.

Creating Snippets That Already Exist In Janus

You'll likely run into creating a snippet that already exists in Janus's core snippets. If this happens, Vim will simply prompt you and ask which snippet you want to use.

If you run into this often, you may find it annoying and prefer to exclude all of Janus' snippets. This is easily done by using the disable plugin function in your ~/.vimrc.before file:

call janus#disable_plugin('vim-snippets') 

Of course, you could continue even further by following the steps above and create another custom snippets directory, but instead clone the honza repo in it and manually edit those snippets. It's Vim...it's up to you!