Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
96 lines
2.9 KiB
VimL
96 lines
2.9 KiB
VimL
"=============================================================================
|
|
" FILE: grep_git.vim
|
|
" AUTHOR: Alisue <lambdalisue at hashnote.net>
|
|
" License: MIT license
|
|
"=============================================================================
|
|
|
|
function! unite#sources#grep_git#define() abort "{{{
|
|
return s:source
|
|
endfunction "}}}
|
|
|
|
function! unite#sources#grep_git#is_available() abort "{{{
|
|
if !executable('git')
|
|
return 0
|
|
endif
|
|
call unite#util#system('git rev-parse')
|
|
return (unite#util#get_last_status() == 0) ? 1 : 0
|
|
endfunction "}}}
|
|
function! unite#sources#grep_git#repository_root() abort "{{{
|
|
if !executable('git')
|
|
return ''
|
|
endif
|
|
let stdout = unite#util#system('git rev-parse --show-toplevel')
|
|
return (unite#util#get_last_status() == 0)
|
|
\ ? substitute(stdout, '\v\r?\n$', '', '')
|
|
\ : ''
|
|
endfunction "}}}
|
|
|
|
" Inherit from 'grep' source
|
|
let s:origin = unite#sources#grep#define()
|
|
let s:source = deepcopy(s:origin)
|
|
let s:source['name'] = 'grep/git'
|
|
let s:source['description'] = 'candidates from git grep'
|
|
|
|
function! s:source.gather_candidates(args, context) abort "{{{
|
|
"
|
|
" Note:
|
|
" Most of code in this function was copied from unite.vim
|
|
"
|
|
if !executable('git')
|
|
call unite#print_source_message(
|
|
\ 'command "git" is not executable.', s:source.name)
|
|
let a:context.is_async = 0
|
|
return []
|
|
elseif !unite#sources#grep_git#is_available()
|
|
call unite#print_source_message(
|
|
\ 'the current working directory is not in a git repository.', s:source.name)
|
|
let a:context.is_async = 0
|
|
return []
|
|
endif
|
|
|
|
if !unite#util#has_vimproc()
|
|
call unite#print_source_message(
|
|
\ 'vimproc plugin is not installed.', self.name)
|
|
let a:context.is_async = 0
|
|
return []
|
|
endif
|
|
|
|
if empty(a:context.source__targets)
|
|
\ || a:context.source__input == ''
|
|
call unite#print_source_message('Canceled.', s:source.name)
|
|
let a:context.is_async = 0
|
|
return []
|
|
endif
|
|
|
|
" replace ^/ into the repository root
|
|
let root = unite#sources#grep_git#repository_root()
|
|
call map(a:context.source__targets, 'substitute(v:val, "^/", root . "/", "")')
|
|
|
|
if a:context.is_redraw
|
|
let a:context.is_async = 1
|
|
endif
|
|
|
|
let cmdline = printf('git grep -n --no-color %s -- %s %s',
|
|
\ a:context.source__extra_opts,
|
|
\ string(a:context.source__input),
|
|
\ unite#helper#join_targets(a:context.source__targets),
|
|
\)
|
|
call unite#print_source_message('Command-line: ' . cmdline, s:source.name)
|
|
|
|
" Note:
|
|
" --no-color is specified thus $TERM='dumb' is not required (actually git
|
|
" will blame if the $TERM value is not properly configured thus it should
|
|
" not be 'dumb').
|
|
"
|
|
" Note:
|
|
" 'git grep' does not work properly with PTY
|
|
"
|
|
let a:context.source__proc = vimproc#plineopen3(
|
|
\ vimproc#util#iconv(cmdline, &encoding, 'char'), 0)
|
|
|
|
return self.async_gather_candidates(a:args, a:context)
|
|
endfunction "}}}
|
|
|
|
|
|
" vim: foldmethod=marker
|