Unite.vim
変数
g:unite_source_alias_aliases
sourceを定義する
autoload/unite/sourcesに以下の関数を定義したスクリプトファイルを配置し、
unite#sources#<source name>#defineという名前の関数を定義する。
この関数からSourceを返却する。
source
以下の属性を持つ
name (必須)
Sourceの名前。この属性に指定した名前を使って候補の一覧を表示できる。(:Unite {name})
gather_candidates(args, context) (必須)
candidateの一覧を返却する。
argsには、:Uniteコマンドを実行する際に渡したパラメータがリストとして渡される。
action_table
以下のいずれかを設定する。
action table
キーにkindの名前、値にaction tableを設定した辞書
hooks.on_pre_init(args, context)
sourceの初期化前に呼ばれる。
a:context.sourceを変更することで、動的にsourceを初期化できる。
candidate
word (必須)
uniteバッファに表示される名前。
action table
キーにアクション名、値に以下の属性を持つ辞書を設定する。
func (必須)
アクションの実行時に呼び出される関数。
引数としてcandidateを受け取る。
もしis_selectableに1が設定されている場合は、candidateの代わりに、candidateのリストを受け取る。
description
アクションの説明
is_quit
1が設定された場合、アクションの実行前にuniteバッファを閉じる。(デフォルトは1)
is_invalidate_cache
1が指定された場合、アクションの実行時にsourceのキャッシュを無効にする。(デフォルトは0)
tips
特定のソースを無効化する
g:unite_ignore_source_filesに無効化したいsourceのファイル名を指定する。
code:vim
let g:unite_ignore_source_files = [
\ 'function.vim',
\ 'command.vim',
\ 'process.vim',
\ 'window.vim',
\ 'vimgrep.vim',
\ 'script.vim',
\ 'launcher.vim'
\ ]
grep sourceのコマンドとしてagを設定する
code:vim
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts = '-i --vimgrep --hidden'
let g:unite_source_grep_recursive_opt = ''
動的にsourceを追加する
:call unite#define_source(source)