ZyX_I avatar ZyX_I committed b96d1ac

@%aurum/maputils: Added unite support
Ref #67

Comments (0)

Files changed (4)

autoload/aurum/maputils.vim

 execute frawor#Setup('0.0', {'@/resources': '0.0',
             \                       '@/os': '0.0',})
 let s:_messages={
-            \'plinst': 'If you install Command-T, Ctrlp, FuzzyFinder, ku '.
-            \          'or tlib you will be prompted with much less sucking '.
-            \          'interface',
+            \'plinst': 'If you install Command-T, Ctrlp, FuzzyFinder, unite, '.
+            \          'ku or tlib you will be prompted with '.
+            \          'much less sucking interface',
         \}
 let s:r={}
 "▶1 update
     endtry
 endfunction
 function s:F.listplugs.commandt.call(files, cbargs, pvargs)
-    let [b:aurum_callback_fun; b:aurum_addargs]=a:cbargs
+    let [b:aurum_cbfun; b:aurum_cbargs]=a:cbargs
     ruby $aurum_old_command_t = $command_t
     ruby $command_t = $aurum_command_t
     ruby $command_t.show_aurum_finder
 "▶2 ctrlp
 function s:CtrlpAccept(mode, str)
     let d={}
-    let d.cbfun=b:aurum_callback_fun
-    let addargs=b:aurum_addargs
+    let d.cbfun=b:aurum_cbfun
+    let cbargs=b:aurum_cbargs
     call ctrlp#exit()
-    return call(d.cbfun, [a:str]+addargs, {})
+    return call(d.cbfun, [a:str]+cbargs, {})
 endfunction
 let s:_functions+=['s:CtrlpAccept']
 let s:ctrlp_ext_var={
 function s:F.listplugs.ctrlp.call(files, cbargs, pvargs)
     let s:ctrlp_files=a:files
     call ctrlp#init(s:ctrlp_id)
-    let [b:aurum_callback_fun; b:aurum_addargs]=a:cbargs
+    let [b:aurum_cbfun; b:aurum_cbargs]=a:cbargs
 endfunction
 "▶2 fuf
 let s:F.listplugs.fuf={}
 "▶2 ku
 let s:F.listplugs.ku={}
 function s:KuOpen(candidate)
-    return call(b:aurum_callback_fun, [a:candidate.word]+b:aurum_addargs, {})
+    return call(b:aurum_cbfun, [a:candidate.word]+b:aurum_cbargs, {})
 endfunction
 let s:_functions+=['s:KuOpen']
 let s:ku_files=[]
     endtry
 endfunction
 function s:F.listplugs.ku.call(files, cbargs, pvargs)
-    let [b:aurum_callback_fun; b:aurum_addargs]=a:cbargs
+    let [b:aurum_cbfun; b:aurum_cbargs]=a:cbargs
     let s:ku_files=a:files
     call ku#start(['aurum'])
 endfunction
+"▶2 unite
+let s:F.listplugs.unite={}
+function s:F.listplugs.unite.init()
+    try
+        if !exists('*unite#start')
+            " XXX For some reason when doing “runtime autoload/unite.vim” vim 
+            "     sources this file for the second time when it finds “function! 
+            "     unite#version” statement. In this case s:save_cpo is unlet 
+            "     when second sourcing is finished and trying to use it when 
+            "     first sourcing is finished results in an error.
+            call unite#version()
+        endif
+        return exists('*unite#start')
+    catch
+        return 0
+    endtry
+endfunction
+function s:F.listplugs.unite.call(files, cbargs, pvargs)
+    call unite#start([['aurum', a:files, a:cbargs]])
+endfunction
 "▶1 promptuser
 function s:r.promptuser(files, cbargs, pvargs)
     if s:plug is 0

autoload/unite/kinds/aurum.vim

+"▶1 
+execute frawor#Setup('0.0', {})
+"▶1 s:kind
+function unite#kinds#aurum#define()
+    return s:kind
+endfunction
+let s:kind={
+            \          'name': 'aurum',
+            \'default_action': 'open',
+            \  'action_table': {'open': {'description': 'open file',
+            \                          'is_selectable': 1,}},
+            \       'parents': ['file'],
+        \}
+function s:kind.action_table.open.func(candidates)
+    if !empty(a:candidates)
+        let cbargs=a:candidates[0].action__cbargs
+        call call(cbargs[0], [a:candidates[0].word]+cbargs[1:], {})
+    endif
+endfunction
+"▶1
+call frawor#Lockvar(s:, 'kind')
+" vim: ft=vim ts=4 sts=4 et fmr=▶,▲

autoload/unite/sources/aurum.vim

+"▶1 
+execute frawor#Setup('0.0', {})
+"▶1 s:source
+function unite#sources#aurum#define()
+    return s:source
+endfunction
+let s:source={
+            \'name': 'aurum',
+            \'description': 'Changeset files',
+            \'hooks': {},
+        \}
+function s:source.hooks.on_init(args, context)
+    let a:context.source__files=a:args[0]
+    let a:context.source__cbargs=a:args[1]
+endfunction
+function s:source.gather_candidates(args, context)
+    return map(copy(a:context.source__files),
+                \'{"word": v:val, '.
+                \ '"abbr": v:val, '.
+                \ '"kind": "aurum", '.
+                \ '"action__cbargs": a:context.source__cbargs, '.
+                \'}')
+endfunction
+"▶1
+call frawor#Lockvar(s:, 'source')
+" vim: ft=vim ts=4 sts=4 et fmr=▶,▲
 - All buffers that define mappings also define Exit mapping (with default 
   LHS=X)
 - OpenAny/AnnotateAny mappings require one of Command-T, Ctrlp, FuzzyFinder, 
-  ku or tlib plugins installed. Otherwise they will show |inputlist()| that is 
-  unusable with large number of files.
+  unite, ku or tlib plugins installed. Otherwise they will show |inputlist()| 
+  that is unusable with large number of files.
   Note: currently if you install two or all of them the behavior is undefined 
         (depends on how keys “commandt”, “ctrlp” and “fuf” are arranged inside 
         a |Dictionary|).
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.