├── .gitignore ├── autoload └── unite │ └── sources │ ├── build.vim │ └── build │ └── builders │ ├── ant.vim │ ├── go.vim │ ├── make.vim │ ├── maven.vim │ ├── repoman.vim │ └── vint.vim └── doc └── unite-build.txt /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags 2 | -------------------------------------------------------------------------------- /autoload/unite/sources/build.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " FILE: build.vim 3 | " AUTHOR: Shougo Matsushita 4 | " License: MIT license {{{ 5 | " Permission is hereby granted, free of charge, to any person obtaining 6 | " a copy of this software and associated documentation files (the 7 | " "Software"), to deal in the Software without restriction, including 8 | " without limitation the rights to use, copy, modify, merge, publish, 9 | " distribute, sublicense, and/or sell copies of the Software, and to 10 | " permit persons to whom the Software is furnished to do so, subject to 11 | " the following conditions: 12 | " 13 | " The above copyright notice and this permission notice shall be included 14 | " in all copies or substantial portions of the Software. 15 | " 16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | " }}} 24 | "============================================================================= 25 | 26 | " Variables "{{{ 27 | call unite#util#set_default('g:unite_build_error_text', '!!') 28 | call unite#util#set_default('g:unite_build_warning_text', '??') 29 | call unite#util#set_default('g:unite_build_error_highlight', 'Error') 30 | call unite#util#set_default('g:unite_build_warning_highlight', 'Todo') 31 | call unite#util#set_default('g:unite_build_error_icon', '') 32 | call unite#util#set_default('g:unite_build_warning_icon', '') 33 | "}}} 34 | 35 | " Actions "{{{ 36 | " }}} 37 | 38 | function! unite#sources#build#define() "{{{ 39 | if has('signs') 40 | " Init signs. 41 | let error_icon = filereadable(expand(g:unite_build_error_icon)) ? 42 | \ ' icon=' . escape(expand(g:unite_build_error_icon), '| \') : '' 43 | let warning_icon = filereadable(expand(g:unite_build_warning_icon)) ? 44 | \ ' icon=' . escape(expand(g:unite_build_warning_icon), '| \') : '' 45 | execute 'sign define unite_build_error text=' . g:unite_build_error_text . 46 | \ ' linehl=' . g:unite_build_error_highlight . error_icon 47 | execute 'sign define unite_build_warning text=' . g:unite_build_warning_text . 48 | \ ' linehl=' . g:unite_build_warning_highlight . warning_icon 49 | 50 | command! UniteBuildClearHighlight call s:clear_highlight() 51 | endif 52 | 53 | if empty(s:builders) 54 | call s:init_builders() 55 | endif 56 | 57 | return s:source 58 | endfunction "}}} 59 | 60 | function! unite#sources#build#get_builders_name() "{{{ 61 | if empty(s:builders) 62 | call s:init_builders() 63 | endif 64 | 65 | return keys(s:builders) 66 | endfunction "}}} 67 | 68 | let s:init_id = 10000 69 | let s:sign_id_dict = {} 70 | 71 | let s:builders = {} 72 | let s:source = { 73 | \ 'name': 'build', 74 | \ 'hooks' : {}, 75 | \ 'syntax' : 'uniteSource__Build', 76 | \ } 77 | 78 | function! s:source.hooks.on_init(args, context) "{{{ 79 | let a:context.source__builder_is_bang = get(a:args, 0, '') == '!' 80 | let args = a:context.source__builder_is_bang ? 81 | \ a:args[1:] : a:args 82 | let a:context.source__builder_name = get(args, 0, '') 83 | let a:context.source__builder_args = args[1:] 84 | 85 | if a:context.source__builder_name == '' 86 | " Detect builder. 87 | for builder in values(s:builders) 88 | if has_key(builder, 'detect') && builder.detect(args, a:context) 89 | let a:context.source__builder_name = builder.name 90 | break 91 | endif 92 | endfor 93 | endif 94 | endfunction"}}} 95 | function! s:source.hooks.on_syntax(args, context) "{{{ 96 | syntax match uniteSource__Builder_Error 97 | \ /\s*\[Error\s*] : .*/ contained containedin=uniteSource__Build 98 | syntax match uniteSource__Builder_Warning 99 | \ /\s*\[Warning\s*] : .*/ contained containedin=uniteSource__Build 100 | syntax match uniteSource__Builder_Message 101 | \ /\s*\[Message\s*] : .*/ contained containedin=uniteSource__Build 102 | highlight default link uniteSource__Builder_Error Error 103 | highlight default link uniteSource__Builder_Warning WarningMsg 104 | highlight default link uniteSource__Builder_Message Comment 105 | endfunction"}}} 106 | function! s:source.hooks.on_close(args, context) "{{{ 107 | if has_key(a:context, 'source__proc') 108 | call a:context.source__proc.waitpid() 109 | endif 110 | endfunction "}}} 111 | 112 | function! s:source.complete(args, context, arglead, cmdline, cursorpos) "{{{ 113 | return filter(unite#sources#build#get_builders_name(), 114 | \ 'stridx(v:val, a:arglead) == 0') 115 | endfunction"}}} 116 | 117 | function! s:source.gather_candidates(args, context) "{{{ 118 | if empty(a:context.source__builder_name) 119 | let a:context.is_async = 0 120 | call unite#print_message('[build] empty builder.') 121 | return [] 122 | elseif !has_key(s:builders, a:context.source__builder_name) 123 | let a:context.is_async = 0 124 | call unite#print_message('[build] builder "' . 125 | \ a:context.source__builder_name . '" is not found.') 126 | return [] 127 | endif 128 | 129 | if !unite#util#has_vimproc() 130 | call unite#print_message('[build] no vimproc is detected.') 131 | return [] 132 | endif 133 | 134 | if has('signs') 135 | " Clear previous signs. 136 | call s:clear_highlight() 137 | 138 | let s:sign_id_dict[getcwd()] = { 139 | \ 'id' : (s:init_id + len(s:sign_id_dict)), 140 | \ 'len' : 0, 141 | \ } 142 | endif 143 | 144 | let a:context.source__builder = 145 | \ s:builders[a:context.source__builder_name] 146 | 147 | if a:context.is_redraw 148 | let a:context.is_async = 1 149 | endif 150 | 151 | let cmdline = a:context.source__builder.initialize( 152 | \ a:context.source__builder_args, a:context) 153 | call unite#print_message('[build] Command-line: ' . cmdline) 154 | 155 | " Set locale to English. 156 | let lang_save = $LANG 157 | let $LANG = 'C' 158 | let a:context.source__proc = vimproc#pgroup_open(cmdline, 0, 2) 159 | let $LANG = lang_save 160 | 161 | " Close handles. 162 | call a:context.source__proc.stdin.close() 163 | 164 | return [] 165 | endfunction "}}} 166 | 167 | function! s:source.async_gather_candidates(args, context) "{{{ 168 | let stdout = a:context.source__proc.stdout 169 | if stdout.eof 170 | " Disable async. 171 | call unite#print_message('[build] Completed.') 172 | 173 | let [cond, status] = a:context.source__proc.waitpid() 174 | if status 175 | call unite#print_message('[build] Build error occurred.') 176 | endif 177 | " Disable waitpid(). 178 | call remove(a:context, 'source__proc') 179 | 180 | let a:context.is_async = 0 181 | endif 182 | 183 | let candidates = [] 184 | for string in map(stdout.read_lines(-1, 300), 185 | \ "unite#util#iconv(v:val, 'char', &encoding)") 186 | let candidate = a:context.source__builder.parse(string, a:context) 187 | if !empty(candidate) 188 | call add(candidates, extend(candidate, 189 | \ s:default_candidate(), 'keep')) 190 | endif 191 | endfor 192 | 193 | if has('signs') 194 | " Set signs icon. 195 | let dict = s:sign_id_dict[getcwd()] 196 | for candidate in candidates 197 | if (candidate.type ==# 'warning' || candidate.type ==# 'error') 198 | \ && buflisted(candidate.filename) 199 | execute 'sign place' dict.id 'line='.candidate.line 200 | \ 'name=unite_build_'.candidate.type 'file='.candidate.filename 201 | let dict.len += 1 202 | endif 203 | endfor 204 | endif 205 | 206 | call map(candidates, 207 | \ "{ 208 | \ 'word': printf('[%-7s] : %s', 209 | \ substitute(v:val.type, '^.', '\\u\\0', ''), v:val.text), 210 | \ 'kind': (filereadable(v:val.filename) && 211 | \ !s:is_binary(v:val.filename)? 'jump_list' : 'common'), 212 | \ 'action__path' : v:val.filename, 213 | \ 'action__line' : v:val.line, 214 | \ 'action__col' : v:val.col, 215 | \ 'action__pattern' : 216 | \ unite#util#escape_pattern(v:val.pattern), 217 | \ 'action__directory' : 218 | \ unite#util#path2directory(v:val.filename), 219 | \ 'is_matched' : (v:val.type !=# 'message'), 220 | \ 'is_multiline' : 1, 221 | \ }") 222 | 223 | return candidates 224 | endfunction "}}} 225 | 226 | function! s:default_candidate() 227 | return { 228 | \ 'filename' : '', 229 | \ 'line' : 0, 230 | \ 'col' : 0, 231 | \ 'pattern' : '', 232 | \ } 233 | endfunction 234 | 235 | function! s:init_builders() 236 | for name in map(split(globpath(&runtimepath, 237 | \ 'autoload/unite/sources/build/builders/*.vim'), '\n'), 238 | \ 'fnamemodify(v:val, ":t:r")') 239 | let define = {'unite#sources#build#builders#' . name . '#define'}() 240 | for dict in (type(define) == type([]) ? define : [define]) 241 | if !empty(dict) && !has_key(s:builders, dict.name) 242 | let s:builders[dict.name] = dict 243 | endif 244 | endfor 245 | unlet define 246 | endfor 247 | endfunction 248 | 249 | function! s:clear_highlight() 250 | " Clear previous signs. 251 | if has_key(s:sign_id_dict, getcwd()) 252 | let dict = s:sign_id_dict[getcwd()] 253 | for cnt in range(1, dict.len) 254 | execute 'sign unplace' dict.id 255 | endfor 256 | 257 | call remove(s:sign_id_dict, getcwd()) 258 | endif 259 | endfunction 260 | 261 | function! s:is_binary(filename) 262 | return get(readfile(a:filename, 'b', 1), 0, '') =~ 263 | \'\%(^.ELF\|!\|^MZ\)\|[\x00-\x09\x10-\x1a\x1c-\x1f]\{5,}' 264 | endfunction 265 | 266 | " vim: foldmethod=marker 267 | -------------------------------------------------------------------------------- /autoload/unite/sources/build/builders/ant.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " FILE: ant.vim 3 | " AUTHOR: Shougo Matsushita 4 | " License: MIT license {{{ 5 | " Permission is hereby granted, free of charge, to any person obtaining 6 | " a copy of this software and associated documentation files (the 7 | " "Software"), to deal in the Software without restriction, including 8 | " without limitation the rights to use, copy, modify, merge, publish, 9 | " distribute, sublicense, and/or sell copies of the Software, and to 10 | " permit persons to whom the Software is furnished to do so, subject to 11 | " the following conditions: 12 | " 13 | " The above copyright notice and this permission notice shall be included 14 | " in all copies or substantial portions of the Software. 15 | " 16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | " }}} 24 | "============================================================================= 25 | 26 | " Variables "{{{ 27 | call unite#util#set_default('g:unite_builder_ant_command', 'ant') 28 | "}}} 29 | 30 | function! unite#sources#build#builders#ant#define() "{{{ 31 | return executable(unite#util#expand(g:unite_builder_ant_command)) ? 32 | \ s:builder : [] 33 | endfunction "}}} 34 | 35 | let s:builder = { 36 | \ 'name': 'ant', 37 | \ 'description': 'ant builder', 38 | \ } 39 | 40 | function! s:builder.detect(args, context) "{{{ 41 | return filereadable('build.xml') 42 | endfunction"}}} 43 | 44 | function! s:builder.initialize(args, context) "{{{ 45 | let a:context.builder__current_dir = 46 | \ unite#util#substitute_path_separator(getcwd()) 47 | return g:unite_builder_ant_command . ' ' . join(a:args) 48 | endfunction"}}} 49 | 50 | function! s:builder.parse(string, context) "{{{ 51 | if a:string =~ '^\s*$' 52 | " Skip. 53 | return {} 54 | elseif a:string =~ '\[.*\]\s\+\f\+:\d\+' 55 | " Error or warning. 56 | return s:analyze_error(matchstr(a:string, 57 | \ '\[.*\]\s\+\zs\f\+:\d\+.*'), a:context.builder__current_dir) 58 | endif 59 | 60 | return { 'type' : 'message', 'text' : a:string } 61 | endfunction "}}} 62 | 63 | function! s:analyze_error(string, current_dir) "{{{ 64 | let string = a:string 65 | 66 | let [word, list] = [string, split(string[2:], ':')] 67 | let candidate = {} 68 | 69 | if empty(list) 70 | " Message. 71 | return { 'type' : 'message', 'text' : string } 72 | endif 73 | 74 | if len(word) == 1 && unite#util#is_windows() 75 | let candidate.word = word . list[0] 76 | let list = list[1:] 77 | endif 78 | 79 | let filename = unite#util#substitute_path_separator(word[:1].list[0]) 80 | let candidate.filename = (filename !~ '^/\|\a\+:/') ? 81 | \ a:current_dir . '/' . filename : filename 82 | 83 | let list = list[1:] 84 | 85 | if !filereadable(filename) && '\<\f\+:' 86 | " Message. 87 | return { 'type' : 'message', 'text' : string } 88 | endif 89 | 90 | if len(list) > 0 && list[0] =~ '^\d\+$' 91 | let candidate.line = list[0] 92 | if len(list) > 1 && list[1] =~ '^\d\+$' 93 | let candidate.col = list[1] 94 | let list = list[1:] 95 | endif 96 | 97 | let list = list[1:] 98 | endif 99 | 100 | if len(list) > 1 && list[0] =~ '\s*\a\+' 101 | let candidate.type = tolower(matchstr(list[0], '\s*\zs\a\+')) 102 | if candidate.type != 'error' && candidate.type != 'warning' 103 | let candidate.type = 'message' 104 | endif 105 | let list = list[1:] 106 | else 107 | let candidate.type = 'message' 108 | endif 109 | 110 | let candidate.text = fnamemodify(filename, ':t') . ' : ' . join(list, ':') 111 | 112 | return candidate 113 | endfunction"}}} 114 | 115 | " vim: foldmethod=marker 116 | -------------------------------------------------------------------------------- /autoload/unite/sources/build/builders/go.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " FILE: go.vim 3 | " AUTHOR: Shougo Matsushita 4 | " License: MIT license {{{ 5 | " Permission is hereby granted, free of charge, to any person obtaining 6 | " a copy of this software and associated documentation files (the 7 | " "Software"), to deal in the Software without restriction, including 8 | " without limitation the rights to use, copy, modify, merge, publish, 9 | " distribute, sublicense, and/or sell copies of the Software, and to 10 | " permit persons to whom the Software is furnished to do so, subject to 11 | " the following conditions: 12 | " 13 | " The above copyright notice and this permission notice shall be included 14 | " in all copies or substantial portions of the Software. 15 | " 16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | " }}} 24 | "============================================================================= 25 | 26 | " Variables "{{{ 27 | call unite#util#set_default('g:unite_builder_go_command', 'go') 28 | "}}} 29 | 30 | function! unite#sources#build#builders#go#define() "{{{ 31 | return executable(unite#util#expand(g:unite_builder_go_command)) ? 32 | \ s:builder : [] 33 | endfunction "}}} 34 | 35 | let s:builder = { 36 | \ 'name': 'go', 37 | \ 'description': 'go builder', 38 | \ } 39 | 40 | function! s:builder.detect(args, context) "{{{ 41 | return $GOPATH != '' && stridx( 42 | \ unite#util#substitute_path_separator(getcwd()), 43 | \ split(unite#util#substitute_path_separator($GOPATH . '/src/'), 44 | \ unite#util#is_windows() ? ';' : ':')[0]) == 0 45 | endfunction"}}} 46 | 47 | function! s:builder.initialize(args, context) "{{{ 48 | return g:unite_builder_go_command 49 | \ . ' ' . (empty(a:args) ? 'build' : join(a:args)) 50 | endfunction"}}} 51 | 52 | function! s:builder.parse(string, context) "{{{ 53 | if a:string =~ ':' 54 | " Error. 55 | return s:analyze_error(a:string, 56 | \ unite#util#substitute_path_separator(getcwd())) 57 | endif 58 | 59 | return { 'type' : 'message', 'text' : a:string } 60 | endfunction "}}} 61 | 62 | function! s:analyze_error(string, current_dir) "{{{ 63 | let string = a:string 64 | 65 | let [word, list] = [string, split(string[2:], ':')] 66 | let candidate = {} 67 | 68 | if empty(list) 69 | " Message. 70 | return { 'type' : 'message', 'text' : string } 71 | endif 72 | 73 | if len(word) == 1 && unite#util#is_windows() 74 | let candidate.word = word . list[0] 75 | let list = list[1:] 76 | endif 77 | 78 | let filename = unite#util#substitute_path_separator(word[:1].list[0]) 79 | let candidate.filename = (filename !~ '^/\|\a\+:/') ? 80 | \ a:current_dir . '/' . filename : filename 81 | 82 | let list = list[1:] 83 | 84 | if !filereadable(filename) && '\<\f\+:' 85 | " Message. 86 | return { 'type' : 'message', 'text' : string } 87 | endif 88 | 89 | if len(list) > 0 && list[0] =~ '^\d\+$' 90 | let candidate.line = list[0] 91 | if len(list) > 1 && list[1] =~ '^\d\+$' 92 | let candidate.col = list[1] 93 | let list = list[1:] 94 | endif 95 | 96 | let list = list[1:] 97 | endif 98 | 99 | let candidate.type = 'error' 100 | let candidate.text = fnamemodify(filename, ':t') . ' : ' . join(list, ':') 101 | 102 | return candidate 103 | endfunction"}}} 104 | 105 | " vim: foldmethod=marker 106 | -------------------------------------------------------------------------------- /autoload/unite/sources/build/builders/make.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " FILE: make.vim 3 | " AUTHOR: Shougo Matsushita 4 | " License: MIT license {{{ 5 | " Permission is hereby granted, free of charge, to any person obtaining 6 | " a copy of this software and associated documentation files (the 7 | " "Software"), to deal in the Software without restriction, including 8 | " without limitation the rights to use, copy, modify, merge, publish, 9 | " distribute, sublicense, and/or sell copies of the Software, and to 10 | " permit persons to whom the Software is furnished to do so, subject to 11 | " the following conditions: 12 | " 13 | " The above copyright notice and this permission notice shall be included 14 | " in all copies or substantial portions of the Software. 15 | " 16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | " }}} 24 | "============================================================================= 25 | 26 | " Variables "{{{ 27 | call unite#util#set_default('g:unite_builder_make_command', 'make') 28 | "}}} 29 | 30 | function! unite#sources#build#builders#make#define() "{{{ 31 | return executable(unite#util#expand(g:unite_builder_make_command)) ? 32 | \ s:builder : [] 33 | endfunction "}}} 34 | 35 | let s:builder = { 36 | \ 'name': 'make', 37 | \ 'description': 'make builder', 38 | \ } 39 | 40 | function! s:builder.detect(args, context) "{{{ 41 | return filereadable('Makefile') || filereadable('makefile') 42 | endfunction"}}} 43 | 44 | function! s:builder.initialize(args, context) "{{{ 45 | let a:context.builder__dir_stack = [] 46 | let a:context.builder__current_dir = 47 | \ unite#util#substitute_path_separator(getcwd()) 48 | return g:unite_builder_make_command . ' ' . join(a:args) 49 | endfunction"}}} 50 | 51 | function! s:builder.parse(string, context) "{{{ 52 | if a:string =~ 53 | \'\<\f\+\%(\[\d\+\]\)\?\s*:\s*Entering\s\+directory\s\+`\f\+''' 54 | " Push current directory. 55 | call insert(a:context.builder__dir_stack, a:context.builder__current_dir) 56 | let a:context.builder__current_dir = 57 | \ unite#util#substitute_path_separator(matchstr(a:string, '`\zs\f\+\ze''')) 58 | return {} 59 | elseif a:string =~ '\= 0 92 | " Snip nested template. 93 | let string = s:snip_nest(string, '<', '>', 1) 94 | endif 95 | 96 | let [word, list] = [string, split(string[2:], ':')] 97 | let candidate = {} 98 | 99 | if empty(list) 100 | " Message. 101 | return { 'type' : 'message', 'text' : string } 102 | endif 103 | 104 | if len(word) == 1 && unite#util#is_windows() 105 | let candidate.word = word . list[0] 106 | let list = list[1:] 107 | endif 108 | 109 | let filename = unite#util#substitute_path_separator(word[:1].list[0]) 110 | let candidate.filename = (filename !~ '^/\|\a\+:/') ? 111 | \ a:current_dir . '/' . filename : filename 112 | 113 | let list = list[1:] 114 | 115 | if !filereadable(filename) 116 | " Message. 117 | return { 'type' : 'message', 'text' : string } 118 | endif 119 | 120 | if len(list) > 0 && list[0] =~ '^\d\+$' 121 | let candidate.line = list[0] 122 | if len(list) > 1 && list[1] =~ '^\d\+$' 123 | let candidate.col = list[1] 124 | let list = list[1:] 125 | endif 126 | 127 | let list = list[1:] 128 | endif 129 | 130 | if len(list) > 1 && list[0] =~ '\s*\a\+' 131 | let candidate.type = tolower(matchstr(list[0], '\s*\zs\a\+')) 132 | if candidate.type != 'error' && candidate.type != 'warning' 133 | let candidate.type = 'message' 134 | endif 135 | let list = list[1:] 136 | else 137 | let candidate.type = 'message' 138 | endif 139 | 140 | let candidate.text = fnamemodify(filename, ':t') . ' : ' . join(list, ':') 141 | 142 | return candidate 143 | endfunction"}}} 144 | 145 | " s:snip_nest('std::vector>', '<', '>', 1) 146 | " => "std::vector>" 147 | function! s:snip_nest(str, start, end, max) "{{{ 148 | let _ = '' 149 | let nest_level = 0 150 | for c in split(a:str, '\zs') 151 | if c ==# a:start 152 | let nest_level += 1 153 | let _ .= c 154 | elseif c ==# a:end 155 | let nest_level -= 1 156 | let _ .= c 157 | elseif nest_level <= a:max 158 | let _ .= c 159 | endif 160 | endfor 161 | 162 | return _ 163 | endfunction"}}} 164 | 165 | " vim: foldmethod=marker 166 | -------------------------------------------------------------------------------- /autoload/unite/sources/build/builders/maven.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " FILE: maven.vim 3 | " AUTHOR: Shougo Matsushita 4 | " License: MIT license {{{ 5 | " Permission is hereby grmavened, free of charge, to any person obtaining 6 | " a copy of this software and associated documentation files (the 7 | " "Software"), to deal in the Software without restriction, including 8 | " without limitation the rights to use, copy, modify, merge, publish, 9 | " distribute, sublicense, and/or sell copies of the Software, and to 10 | " permit persons to whom the Software is furnished to do so, subject to 11 | " the following conditions: 12 | " 13 | " The above copyright notice and this permission notice shall be included 14 | " in all copies or substmavenial portions of the Software. 15 | " 16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRmavenY OF ANY KIND, EXPRESS 17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRmavenIES OF 18 | " MERCHmavenABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | " }}} 24 | "============================================================================= 25 | 26 | " Variables "{{{ 27 | call unite#util#set_default('g:unite_builder_maven_command', 'mvn') 28 | "}}} 29 | 30 | function! unite#sources#build#builders#maven#define() "{{{ 31 | return executable(unite#util#expand(g:unite_builder_maven_command)) ? 32 | \ s:builder : [] 33 | endfunction "}}} 34 | 35 | let s:builder = { 36 | \ 'name': 'maven', 37 | \ 'description': 'maven builder', 38 | \ } 39 | 40 | function! s:builder.detect(args, context) "{{{ 41 | return filereadable('pom.xml') 42 | endfunction"}}} 43 | 44 | function! s:builder.initialize(args, context) "{{{ 45 | let a:context.builder__current_dir = 46 | \ unite#util#substitute_path_separator(getcwd()) 47 | return g:unite_builder_maven_command 48 | \ . ' ' . (empty(a:args) ? 'compile' : join(a:args)) 49 | endfunction"}}} 50 | 51 | function! s:builder.parse(string, context) "{{{ 52 | if a:string =~ '^\s*$' 53 | " Skip. 54 | return {} 55 | elseif a:string =~ '\[\u\+\]\s*$' 56 | " Skip. 57 | return {} 58 | elseif a:string =~ ' error: ' 59 | " Error or warning. 60 | return s:analyze_error(a:string, a:context.builder__current_dir) 61 | endif 62 | 63 | return { 'type' : 'message', 'text' : 64 | \ substitute(a:string, '^\[\u\+\]\s\+', '', '') } 65 | endfunction "}}} 66 | 67 | function! s:analyze_error(string, current_dir) "{{{ 68 | let matches = matchlist(a:string, 69 | \ '^\(\[\u\+\]\)\?\s\+\(\f\+\):\[\(\d\+\),\(\d\+\)\]\s\+\(.*\)$') 70 | let filename = unite#util#substitute_path_separator(matches[1]) 71 | if filename !~ '^/\|\a\+:/' 72 | let filename = a:current_dir . '/' . filename 73 | endif 74 | 75 | return { 'type' : (a:string =~# ' error: ' ? 'error' : 'warning'), 76 | \ 'filename' : filename, 'line' : matches[2], 'col' : matches[3], 77 | \ 'text' : fnamemodify(filename, ':t') . ' : ' . matches[4] } 78 | endfunction"}}} 79 | 80 | " vim: foldmethod=marker 81 | -------------------------------------------------------------------------------- /autoload/unite/sources/build/builders/repoman.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " FILE: repoman.vim 3 | " AUTHOR: Tatsuhiro Ujihisa 4 | " License: MIT license {{{ 5 | " Permission is hereby granted, free of charge, to any person obtaining 6 | " a copy of this software and associated documentation files (the 7 | " "Software"), to deal in the Software without restriction, including 8 | " without limitation the rights to use, copy, modify, merge, publish, 9 | " distribute, sublicense, and/or sell copies of the Software, and to 10 | " permit persons to whom the Software is furnished to do so, subject to 11 | " the following conditions: 12 | " 13 | " The above copyright notice and this permission notice shall be included 14 | " in all copies or substantial portions of the Software. 15 | " 16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | " }}} 24 | "============================================================================= 25 | 26 | " Variables "{{{ 27 | call unite#util#set_default('g:unite_builder_repoman_command', 'repoman') 28 | "}}} 29 | 30 | function! unite#sources#build#builders#repoman#define() "{{{ 31 | return executable(unite#util#expand(g:unite_builder_repoman_command)) ? 32 | \ s:builder : [] 33 | endfunction "}}} 34 | 35 | let s:builder = { 36 | \ 'name': 'repoman', 37 | \ 'description': 'repoman builder for ebuild files', 38 | \ } 39 | 40 | function! s:builder.detect(args, context) "{{{ 41 | return !empty(split(glob('*.ebuild'), "\n")) 42 | endfunction"}}} 43 | 44 | function! s:builder.initialize(args, context) "{{{ 45 | let a:context.__state = '' 46 | let arg = empty(a:args) ? 'manifest' : join(a:args) 47 | return g:unite_builder_repoman_command . ' ' . arg 48 | endfunction"}}} 49 | 50 | function! s:builder.parse(string, context) 51 | if empty(a:string) 52 | return {} 53 | endif 54 | if a:context.source__builder_args[0] ==# 'manifest' 55 | return s:_parse_manifest(a:string, a:context) 56 | elseif a:context.source__builder_args[0] ==# 'full' 57 | return s:_parse_full(a:string, a:context) 58 | else 59 | return {'type': 'message', 'text': printf('# %s', a:string)} 60 | endif 61 | endfunction 62 | 63 | function! s:_parse_manifest(string, context) 64 | let matches = matchlist(a:string, ">>> \\(\\w\\+\\) \\(.*\\)$") 65 | "echomsg string([a:context.__state, matches]) 66 | if len(matches) > 0 && matches[2] !=# '' 67 | let a:context.__state = matches[1] 68 | return {'type': 'message', 'text': printf('%s %s', matches[1], matches[2])} 69 | endif 70 | if a:context.__state ==# 'Downloading' 71 | if a:string =~ '^\s\+\|^Resolving\|^Connecting\|^HTTP request sent\|^==>\|^Location: ' 72 | return a:context.source__builder_is_bang ? 73 | \ {'type': 'message', 'text': printf(' %s', a:string)} : {} 74 | endif 75 | endif 76 | return {'type': 'message', 'text': printf(' %s', a:string)} 77 | endfunction 78 | 79 | function! s:_parse_full(string, context) 80 | if a:string == 'RepoMan scours the neighborhood...' 81 | return {} 82 | endif 83 | return {'type': 'message', 'text': printf('* %s', a:string)} 84 | endfunction 85 | 86 | " vim: foldmethod=marker 87 | -------------------------------------------------------------------------------- /autoload/unite/sources/build/builders/vint.vim: -------------------------------------------------------------------------------- 1 | "============================================================================= 2 | " FILE: vint.vim 3 | " AUTHOR: Shougo Matsushita 4 | " License: MIT license {{{ 5 | " Permission is hereby granted, free of charge, to any person obtaining 6 | " a copy of this software and associated documentation files (the 7 | " "Software"), to deal in the Software without restriction, including 8 | " without limitation the rights to use, copy, modify, merge, publish, 9 | " distribute, sublicense, and/or sell copies of the Software, and to 10 | " permit persons to whom the Software is furnished to do so, subject to 11 | " the following conditions: 12 | " 13 | " The above copyright notice and this permission notice shall be included 14 | " in all copies or substantial portions of the Software. 15 | " 16 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | " OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | " }}} 24 | "============================================================================= 25 | 26 | " Variables "{{{ 27 | call unite#util#set_default('g:unite_builder_vint_command', 'vint') 28 | "}}} 29 | 30 | function! unite#sources#build#builders#vint#define() "{{{ 31 | return executable(unite#util#expand(g:unite_builder_vint_command)) ? 32 | \ s:builder : [] 33 | endfunction "}}} 34 | 35 | let s:builder = { 36 | \ 'name': 'vint', 37 | \ 'description': 'vint builder', 38 | \ } 39 | 40 | function! s:builder.detect(args, context) "{{{ 41 | return glob('*.vim') != '' || glob('*/*.vim') != '' 42 | endfunction"}}} 43 | 44 | function! s:builder.initialize(args, context) "{{{ 45 | return printf('%s %s %s', 46 | \ g:unite_builder_vint_command, 47 | \ (empty(a:args) ? '' : join(a:args)), join(split(glob('*'), '\n'))) 48 | endfunction"}}} 49 | 50 | function! s:builder.parse(string, context) "{{{ 51 | if a:string =~ ':' 52 | " Error. 53 | return s:analyze_error(a:string, 54 | \ unite#util#substitute_path_separator(getcwd())) 55 | endif 56 | 57 | return { 'type' : 'message', 'text' : a:string } 58 | endfunction "}}} 59 | 60 | function! s:analyze_error(string, current_dir) "{{{ 61 | let string = a:string 62 | 63 | let [word, list] = [string, split(string[2:], ':')] 64 | let candidate = {} 65 | 66 | if empty(list) 67 | " Message. 68 | return { 'type' : 'message', 'text' : string } 69 | endif 70 | 71 | if len(word) == 1 && unite#util#is_windows() 72 | let candidate.word = word . list[0] 73 | let list = list[1:] 74 | endif 75 | 76 | let filename = unite#util#substitute_path_separator(word[:1].list[0]) 77 | let candidate.filename = (filename !~ '^/\|\a\+:/') ? 78 | \ a:current_dir . '/' . filename : filename 79 | 80 | let list = list[1:] 81 | 82 | if !filereadable(filename) && '\<\f\+:' 83 | " Message. 84 | return { 'type' : 'message', 'text' : string } 85 | endif 86 | 87 | if len(list) > 0 && list[0] =~ '^\d\+$' 88 | let candidate.line = list[0] 89 | if len(list) > 1 && list[1] =~ '^\d\+$' 90 | let candidate.col = list[1] 91 | let list = list[1:] 92 | endif 93 | 94 | let list = list[1:] 95 | endif 96 | 97 | let candidate.type = 'error' 98 | let candidate.text = fnamemodify(filename, ':t') . ' : ' . join(list, ':') 99 | 100 | return candidate 101 | endfunction"}}} 102 | 103 | " vim: foldmethod=marker 104 | -------------------------------------------------------------------------------- /doc/unite-build.txt: -------------------------------------------------------------------------------- 1 | *unite-build.txt* Build by unite interface 2 | 3 | Version: 0.1 4 | Author : Shougo 5 | License: MIT license {{{ 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | }}} 24 | 25 | CONTENTS *unite-build-contents* 26 | 27 | Usage |unite-build-usage| 28 | Install |unite-build-install| 29 | Interface |unite-build-interface| 30 | Commands |unite-build-commands| 31 | Variables |unite-build-variables| 32 | Sources variables |unite-build-builders-variables| 33 | Sources |unite-build-builders| 34 | Create source |unite-build-create-builder| 35 | Configuration Examples |unite-build-builder-examples| 36 | 37 | ============================================================================== 38 | USAGE *unite-build-usage* 39 | 40 | This source nominates builder output asynchronously. 41 | If arguments is not given, builder is detected. 42 | If argument 1 is "!", errors is not filtered. 43 | 44 | Source arguments: 45 | 1. builder name. 46 | 2-. builder arguments. 47 | 48 | Start unite build source. Builder is detected. 49 | > 50 | :Unite build 51 | :Unite build:make 52 | :Unite build:! 53 | < 54 | 55 | unite-builder description (Japanese) by rbtnn. 56 | http://qiita.com/items/270bcf94a8f588d3cd38 57 | 58 | 59 | ============================================================================== 60 | INSTALL *unite-build-install* 61 | 62 | Requirements: vimproc and unite.vim 63 | 64 | https://github.com/Shougo/vimproc 65 | https://github.com/Shougo/unite.vim 66 | 67 | ============================================================================== 68 | INTERFACE *unite-build-interface* 69 | 70 | ------------------------------------------------------------------------------ 71 | COMMANDS *unite-build-commands* 72 | 73 | :UniteBuildClearHighlight *:UniteBuildClearHighlight* 74 | Clear error highlight and signs in current directory. 75 | 76 | ------------------------------------------------------------------------------ 77 | VARIABLES *unite-build-variables* 78 | 79 | g:unite_build_error_text *g:unite_build_error_text* 80 | g:unite_build_warning_text *g:unite_build_warning_text* 81 | The occurred error or warning markup text(see |:sign-define| 82 | for details). 83 | Note: This option must be set before call unite.vim 84 | functions or unite.vim command. 85 | 86 | Default value is "!!" and "??". 87 | 88 | g:unite_build_error_highlight *g:unite_build_error_highlight* 89 | g:unite_build_warning_highlight *g:unite_build_warning_highlight* 90 | The error or warning highlight setting(see 91 | |:sign-define| for details). 92 | Note: This option must be set before call unite.vim 93 | functions or unite.vim command. 94 | 95 | Default value is "Error" and "Todo". 96 | 97 | g:unite_build_error_icon *g:unite_build_error_icon* 98 | g:unite_build_warning_icon *g:unite_build_warning_icon* 99 | The error or warning markup icon path(see |:sign-define| for 100 | details). This variable is enabled only in GUI Vim. 101 | If the icon is not found(or empty), text markers are displayed 102 | instead. 103 | Note: This option must be set before call unite.vim 104 | functions or unite.vim command. 105 | 106 | Default value is "". 107 | 108 | BUILDER VARIABLES *unite-build-builder-variables* 109 | 110 | g:unite_builder_make_command *g:unite_builder_make_command* 111 | |unite-build-builder-make| uses as the "make" command. 112 | 113 | Default is "make". 114 | 115 | g:unite_builder_repoman_command *g:unite_builder_repoman_command* 116 | |unite-build-builder-repoman| uses as the "repoman" command. 117 | 118 | Default is "repoman". 119 | 120 | g:unite_builder_ant_command *g:unite_builder_ant_command* 121 | |unite-build-builder-ant| uses as the "ant" command. 122 | 123 | Default is "ant". 124 | 125 | g:unite_builder_maven_command *g:unite_builder_maven_command* 126 | |unite-build-builder-maven| uses as the "maven" command. 127 | 128 | Default is "mvn". 129 | 130 | g:unite_builder_go_command *g:unite_builder_go_command* 131 | |unite-build-builder-go| uses as the "go" command. 132 | 133 | Default is "go". 134 | 135 | g:unite_builder_vint_command *g:unite_builder_vint_command* 136 | |unite-build-builder-vint| uses as the "vint" command. 137 | 138 | Default is "vint". 139 | 140 | ============================================================================== 141 | BUILDERS *unite-build-builders* 142 | 143 | *unite-build-builder-make* 144 | make This builder outputs "make" command output. 145 | It requires "Makefile" in current directory. 146 | 147 | Builder arguments: 148 | 1-. make arguments. 149 | 150 | *unite-build-builder-repoman* 151 | repoman This builder outputs "repoman manifest" command output. 152 | repoman is a tool for Gentoo Linux to manage ebuild files, the 153 | recipe files for its own package management system Portage. 154 | 155 | It requires at least one ebuild in current directory. 156 | 157 | *unite-build-builder-ant* 158 | ant This builder outputs "ant" command output. 159 | 160 | Builder arguments: 161 | 1-. ant arguments. 162 | 163 | 164 | *unite-build-builder-maven* 165 | maven This builder outputs "maven" command output. 166 | 167 | Builder arguments: 168 | 1-. ant arguments(default is "compile"). 169 | 170 | *unite-build-builder-go* 171 | go This builder outputs "go" command output. 172 | 173 | Builder arguments: 174 | 1-. arguments(default is "build"). 175 | 176 | 177 | 178 | *unite-build-builder-vint* 179 | vint This builder outputs "vint" command output. 180 | https://github.com/Kuniwak/vint 181 | 182 | Builder arguments: 183 | 1-. arguments. 184 | 185 | 186 | 187 | ============================================================================== 188 | CREATE BUILDER *unite-build-create-builder* 189 | 190 | Todo 191 | 192 | ------------------------------------------------------------------------------ 193 | BUILDER ATTRIBUTES *unite-build-builder-attributes* 194 | 195 | *unite-build-builder-attribute-name* 196 | name String (Required) 197 | Builder name. 198 | 199 | *unite-build-builder-attribute-description* 200 | description String (Optional) 201 | Builder description. 202 | 203 | *unite-build-builder-attribute-initialize* 204 | initialize Function (Required) 205 | Called when unite buffer is initialized. 206 | This function returns the build command (Ex: "make".) 207 | 208 | Function arguments: 209 | {args}, {context} 210 | 211 | *unite-build-builder-attribute-detect* 212 | detect Function (Optional) 213 | Called when unite-build doesn't receive a builder name. 214 | If you'd like to detect the build system, set this 215 | function to return 1. 216 | 217 | Function arguments: 218 | {args}, {context} 219 | 220 | *unite-build-builder-attribute-parse* 221 | parse Function (Required) 222 | Called when build process has an output. 223 | This function returns {candidate}. 224 | If the candidate is empty, unite-build ignores the 225 | candidate. Please refer to 226 | |unite-notation-{candidate}|. 227 | 228 | {candidate} *unite-build-notation-{candidate}* 229 | Candidate dictionary. It has information below. 230 | 231 | type (String) (Required) 232 | Candidate type. 233 | "error", "warning" or "message". 234 | 235 | text (String) (Required) 236 | Error message text. 237 | 238 | filename (String) (Optional) 239 | Error file name. 240 | 241 | line (Number) (Optional) 242 | Error line number. 243 | 244 | col (Number) (Optional) 245 | Error column number. 246 | 247 | pattern (String) (Optional) 248 | Error line pattern. 249 | 250 | ============================================================================== 251 | EXAMPLES *unite-build-examples* 252 | > 253 | 254 | < 255 | ============================================================================== 256 | vim:tw=78:ts=8:ft=help:norl:noet:fen: 257 | --------------------------------------------------------------------------------