Skip to content

Instantly share code, notes, and snippets.

@bounceme
Last active October 4, 2016 04:59
Show Gist options
  • Save bounceme/a2cb5c341af1b33c48689f64c678235f to your computer and use it in GitHub Desktop.
Save bounceme/a2cb5c341af1b33c48689f64c678235f to your computer and use it in GitHub Desktop.
on-the-fly ide
augroup async
au!
augroup END
function! MYIDE()
au! async
if !empty(neomake#GetJobs()) || &buftype ==? 'nofile'
return
endif
if filereadable('s:neomaketemp')
call delete(s:neomaketemp)
endif
let s:neomaketemp = fnamemodify(fnamemodify(tempname(),':h'),':p') . 'neomaketemp.' . expand('%:e')
silent! call writefile(getline(1, '$'), s:neomaketemp)
let maker = deepcopy(neomake#GetMaker(neomake#makers#ft#{&ft}#EnabledMakers()[0],&ft),1)
let maker['append_file'] = 0
if !exists('maker["args"]')
let maker['args'] = []
endif
let maker['args'] += [s:neomaketemp]
let maker['mapexpr'] = 'substitute(v:val, escape('''.s:neomaketemp.''',".\\"), expand("%"), "")'
let keyName = maker['name']
if exists('g:neomake_'.&ft.'_' . keyName . '_maker')
let last = g:neomake_{&ft}_{keyName}_maker
endif
let g:neomake_{&ft}_{keyName}_maker = maker
exe ':Neomake ' . keyName
if exists('last')
let g:neomake_{&ft}_{keyName}_maker = last
else
unlet g:neomake_{&ft}_{keyName}_maker
endif
endfunction
au bufreadpost * Neomake
au User NeomakeFinished au! async textchanged * call MYIDE()
au quitpre * if filereadable('s:neomaketemp') | call delete(s:neomaketemp) | endif
@bounceme
Copy link
Author

bounceme commented Oct 1, 2016

found out how to use escape()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment