mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 23:00:04 +08:00
Add runner for c file
This commit is contained in:
parent
f4cbb7c00b
commit
24fce8f3d5
@ -41,16 +41,25 @@
|
||||
|
||||
|
||||
function! SpaceVim#layers#lang#c#plugins() abort
|
||||
let plugins = []
|
||||
if has('nvim')
|
||||
call add(plugins, ['tweekmonster/deoplete-clang2'])
|
||||
else
|
||||
call add(plugins, ['Rip-Rip/clang_complete'])
|
||||
endif
|
||||
call add(plugins, ['lyuts/vim-rtags', { 'if' : has('python3')}])
|
||||
return plugins
|
||||
let plugins = []
|
||||
if has('nvim')
|
||||
call add(plugins, ['tweekmonster/deoplete-clang2'])
|
||||
else
|
||||
call add(plugins, ['Rip-Rip/clang_complete'])
|
||||
endif
|
||||
call add(plugins, ['lyuts/vim-rtags', { 'if' : has('python3')}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
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
|
||||
|
||||
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,17 +28,38 @@ function! s:open_win() abort
|
||||
wincmd p
|
||||
endfunction
|
||||
|
||||
let s:target = ''
|
||||
|
||||
function! s:async_run(runner) abort
|
||||
let cmd = printf(a:runner, bufname('%'))
|
||||
let s:start_time = reltime()
|
||||
let s:job_id = s:JOB.start(cmd,{
|
||||
\ 'on_stdout' : function('s:on_stdout'),
|
||||
\ 'on_stderr' : function('s:on_stderr'),
|
||||
\ 'on_exit' : function('s:on_exit'),
|
||||
\ })
|
||||
if type(a:runner) == type('')
|
||||
let cmd = printf(a:runner, bufname('%'))
|
||||
let s:start_time = reltime()
|
||||
let s:job_id = s:JOB.start(cmd,{
|
||||
\ 'on_stdout' : function('s:on_stdout'),
|
||||
\ 'on_stderr' : function('s:on_stderr'),
|
||||
\ '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
|
||||
|
||||
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
|
||||
redrawstatus!
|
||||
|
Loading…
Reference in New Issue
Block a user