mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-22 17:05:42 +08:00
Add runner for c file
This commit is contained in:
parent
f4cbb7c00b
commit
24fce8f3d5
@ -52,5 +52,14 @@ function! SpaceVim#layers#lang#c#plugins() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#layers#lang#c#config() abort
|
function! SpaceVim#layers#lang#c#config() abort
|
||||||
|
call SpaceVim#plugins#runner#reg_runner('c', ['gcc -o #TEMP# %s', '#TEMP#'])
|
||||||
|
call SpaceVim#mapping#space#regesit_lang_mappings('c', funcref('s:language_specified_mappings'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:language_specified_mappings() abort
|
||||||
|
|
||||||
|
call SpaceVim#mapping#space#langSPC('nmap', ['l','r'],
|
||||||
|
\ 'call SpaceVim#plugins#runner#open()',
|
||||||
|
\ 'execute current file', 1)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
@ -28,8 +28,10 @@ function! s:open_win() abort
|
|||||||
wincmd p
|
wincmd p
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:target = ''
|
||||||
|
|
||||||
function! s:async_run(runner) abort
|
function! s:async_run(runner) abort
|
||||||
|
if type(a:runner) == type('')
|
||||||
let cmd = printf(a:runner, bufname('%'))
|
let cmd = printf(a:runner, bufname('%'))
|
||||||
let s:start_time = reltime()
|
let s:start_time = reltime()
|
||||||
let s:job_id = s:JOB.start(cmd,{
|
let s:job_id = s:JOB.start(cmd,{
|
||||||
@ -37,8 +39,27 @@ function! s:async_run(runner) abort
|
|||||||
\ 'on_stderr' : function('s:on_stderr'),
|
\ 'on_stderr' : function('s:on_stderr'),
|
||||||
\ 'on_exit' : function('s:on_exit'),
|
\ 'on_exit' : function('s:on_exit'),
|
||||||
\ })
|
\ })
|
||||||
|
elseif type(a:runner) == type([])
|
||||||
|
let s:target = tempname()
|
||||||
|
let compile_cmd = substitute(printf(a:runner[0], bufname('%')), '#TEMP#', s:target, 'g')
|
||||||
|
let s:start_time = reltime()
|
||||||
|
let s:job_id = s:JOB.start(compile_cmd,{
|
||||||
|
\ 'on_stdout' : function('s:on_stdout'),
|
||||||
|
\ 'on_stderr' : function('s:on_stderr'),
|
||||||
|
\ 'on_exit' : function('s:on_compile_exit'),
|
||||||
|
\ })
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:on_compile_exit(id, data, event) abort
|
||||||
|
if a:data == 0
|
||||||
|
let s:job_id = s:JOB.start(s:target,{
|
||||||
|
\ 'on_stdout' : function('s:on_stdout'),
|
||||||
|
\ 'on_stderr' : function('s:on_stderr'),
|
||||||
|
\ 'on_exit' : function('s:on_exit'),
|
||||||
|
\ })
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:update_statusline() abort
|
function! s:update_statusline() abort
|
||||||
redrawstatus!
|
redrawstatus!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user