]> oss.titaniummirror.com Git - vim-mkbuild.git/commitdiff
Simplify unite integration
authorR. Steve McKown <rsmckown@gmail.com>
Sun, 17 Jan 2016 23:52:27 +0000 (16:52 -0700)
committerR. Steve McKown <rsmckown@gmail.com>
Sun, 17 Jan 2016 23:56:50 +0000 (16:56 -0700)
Use a template found at https://github.com/Shougo/unite.vim/issues/695
to simplify the integration with unite.

autoload/unite/kinds/mkbfiles.vim [deleted file]
autoload/unite/sources/mkbfiles.vim

diff --git a/autoload/unite/kinds/mkbfiles.vim b/autoload/unite/kinds/mkbfiles.vim
deleted file mode 100644 (file)
index e7c2b4c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-let s:kind = {
-  \ 'name': 'mkbfiles',
-  \ 'default_action': 'execute',
-  \ 'action_table': {},
-  \ 'parents': [],
-  \ 'description': 'files used in mkbuild project'
-  \ }
-
-let s:kind.action_table.execute = { 'is_selectable': 1 }
-
-function! s:kind.action_table.execute.func(candidates)
-  if len(a:candidates) == 1
-    execute "e" a:candidates[0].word
-  endif
-endfunction
-
-function! unite#kinds#mkbfiles#define()
-  return s:kind
-endfunction
index d69f8e3aebf994578c7263b7d5dea175512c9969..1ff92b3e36f9603973c7a1f1e16cb9856706f3c0 100644 (file)
@@ -1,22 +1,25 @@
-" unite source: mkbuild filelist
-" Version: 0.0.1
-" Author : R. Steve McKown <rsmckown@gmail.com>
-" License: MIT License
+" unite source: file selection for projects using mkbuild
 
 let s:save_cpo = &cpo
 set cpo&vim
 
-let s:source = { 'name': 'mkbfiles' }
+let s:source = {
+  \ 'name': 'mkbfiles',
+  \ 'description': 'select files in an mkbuild based project',
+  \ 'action_table': {
+  \   'open' : { 'is_selectable': 1 },
+  \ },
+  \ 'default_action': 'open'
+  \ }
 
-function! s:source.gather_candidates(args, context)
-  let sourcecmd = 'find . -type f'
-  let filelist = split(mkbuild#filelist(), '\n')
+function! s:source.action_table.open.func(candidates)
+  for c in a:candidates
+    execute "e" c.word
+  endfor
+endfunction
 
-  return map(filelist, '{
-  \   "word": v:val,
-  \   "source": "mkbfiles",
-  \   "kind": "mkbfiles",
-  \ }')
+function! s:source.gather_candidates(args, context)
+  return map(split(mkbuild#filelist(), '\n'), '{ "word": v:val }')
 endfunction
 
 function! unite#sources#mkbfiles#define()