From: R. Steve McKown Date: Sun, 17 Jan 2016 23:52:27 +0000 (-0700) Subject: Simplify unite integration X-Git-Url: https://oss.titaniummirror.com/gitweb?p=vim-mkbuild.git;a=commitdiff_plain;h=ab52ca0533919db331b92b9bee03520b06f5f83a Simplify unite integration Use a template found at https://github.com/Shougo/unite.vim/issues/695 to simplify the integration with unite. --- diff --git a/autoload/unite/kinds/mkbfiles.vim b/autoload/unite/kinds/mkbfiles.vim deleted file mode 100644 index e7c2b4c..0000000 --- a/autoload/unite/kinds/mkbfiles.vim +++ /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 diff --git a/autoload/unite/sources/mkbfiles.vim b/autoload/unite/sources/mkbfiles.vim index d69f8e3..1ff92b3 100644 --- a/autoload/unite/sources/mkbfiles.vim +++ b/autoload/unite/sources/mkbfiles.vim @@ -1,22 +1,25 @@ -" unite source: mkbuild filelist -" Version: 0.0.1 -" Author : R. Steve McKown -" 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()