Last active
August 8, 2020 07:15
-
-
Save mhinz/1d62b803d328f83551e15c97a4b57868 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" | |
" usage: :Vimgrep /foo/ ** | |
" | |
function! s:exit_handler(id) dict abort | |
execute 'cfile' self.tempfile | |
copen | |
endfunction | |
function! s:vimgrep(args) abort | |
let tempfile = tempname() | |
let commands = [ 'noautocmd vimgrep '. a:args ] | |
let commands += [ 'let matches = map(getqflist(), "printf(\"%s:%d:%d:%s\", bufname(v:val.bufnr), v:val.lnum, v:val.col, v:val.text)")' ] | |
let commands += [ 'call writefile(matches, "'. tempfile .'")' ] | |
let commands += [ 'quitall!' ] | |
let cmd = join(map(commands, '"+".shellescape(v:val)')) | |
if has('nvim') | |
call jobstart('nvim '. cmd, { | |
\ 'on_exit': function('s:exit_handler'), | |
\ 'tempfile': tempfile, | |
\ }) | |
else | |
echomsg 'job_start() implementation missing' | |
endif | |
endfunction | |
command! -nargs=* -bang Vimgrep call s:vimgrep('<args>') |
Using nvim -u NONE
would mean that your magic
, smartcase
, ignorecase
, gdefault
, and other text matching settings would be ignored.
However, you may want to add a dummy file argument so if vim startup plugins (like vim-startify) check for args() that they find something and don't activate.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about using
nvim -u NONE
.