Repository navigation
Expand file tree
/
Copy pathSingleCompile.vim
More file actions
148 lines (127 loc) · 5.23 KB
/
Copy pathSingleCompile.vim
File metadata and controls
148 lines (127 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
" Copyright (C) 2010-2014 Hong Xu
" This file is part of SingleCompile.
" SingleCompile is free software: you can redistribute it and/or modify
" it under the terms of the GNU General Public License as published by
" the Free Software Foundation, either version 3 of the License, or
" (at your option) any later version.
" SingleCompile is distributed in the hope that it will be useful,
" but WITHOUT ANY WARRANTY; without even the implied warranty of
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" GNU General Public License for more details.
" You should have received a copy of the GNU General Public License
" along with SingleCompile. If not, see <http://www.gnu.org/licenses/>.
" File: plugin/SingleCompile.vim
" GetLatestVimScripts: 3115 1 SingleCompile.zip
" version 2.12.0
" check doc/SingleCompile.txt for more version information
if v:version < 700
finish
endif
" check whether this script is already loaded
if exists("g:loaded_SingleCompile")
finish
endif
let g:loaded_SingleCompile = 1
let s:saved_cpo = &cpo
set cpo&vim
" commands {{{1
command -nargs=* SCCompile
\ if <q-args> == '' | call SingleCompile#Compile() |
\ else | call SingleCompile#Compile(<q-args>) | endif
command -nargs=* SCCompileRun
\ if <q-args> == '' | call SingleCompile#CompileRun() |
\ else | call SingleCompile#CompileRun(<q-args>) | endif
command -nargs=* SCCompileRunAsync
\ if <q-args> == '' | call SingleCompile#CompileRunAsync() |
\ else | call SingleCompile#CompileRunAsync(<q-args>) | endif
command -nargs=* SingleCompile
\ if <q-args> == '' | call SingleCompile#Compile() |
\ else | call SingleCompile#Compile(<q-args>) | endif
command -nargs=* SingleCompileRun
\ if <q-args> == '' | call SingleCompile#CompileRun() |
\ else | call SingleCompile#CompileRun(<q-args>) | endif
command -nargs=+ SCCompileAF
\ call SingleCompile#Compile('AdditionalFlags', <q-args>)
command -nargs=+ SCCompileRunAF
\ call SingleCompile#CompileRun('AdditionalFlags', <q-args>)
command -nargs=+ SCCompileRunAsyncAF
\ call SingleCompile#CompileRunAsync('AdditionalFlags', <q-args>)
command SCIsRunningAsync
\ if SingleCompileAsync#IsRunning() == 1 |
\ echo 'The background process is running.' |
\ else |
\ echo 'The background process is not running.' |
\ endif
command SCTerminateAsync
\ if SingleCompileAsync#Terminate() |
\ echohl ErrorMsg |
\ echo 'Failed to terminate the background process!' |
\ echohl None |
\ else |
\ echo 'Background process terminated.' |
\ endif
command SCChooseCompiler call SingleCompile#ChooseCompiler(&filetype)
command SCChooseInterpreter call SingleCompile#ChooseCompiler(&filetype)
command SCViewResult call SingleCompile#ViewResult(0)
command SCViewResultAsync call SingleCompile#ViewResult(1)
" menus {{{1
if !exists('g:SingleCompile_menumode')
let g:SingleCompile_menumode = 1
endif
if has('gui_running') && has('menu')
if g:SingleCompile_menumode == 1
let s:menu_root = 'Plugin.SingleCompile'
elseif g:SingleCompile_menumode == 2
let s:menu_root = 'SingleCompile'
endif
" if g:SingleCompile_menumode is not 1 or 2, then we don't need to create
" menu
if g:SingleCompile_menumode == 1 || g:SingleCompile_menumode == 2
for s:menu_textcmd in [
\ '&Compile<tab>:SCCompile '.
\ ':SCCompile<cr>',
\
\ 'Compile\ and\ &Run<tab>:SCCompileRun '.
\ ':SCCompileRun<cr>',
\
\ 'Compile\ and\ Run &Asynchronously'.
\ '<tab>:SCCompileRunAsync'.
\ ':SCCompileRunAsync<cr>',
\
\ 'C&hoose\ Compiler<tab>:SCChooseCompiler '.
\ ':SCChooseCompiler<cr>',
\
\ '&View\ Result<tab>:SCViewResult '.
\ ':SCViewResult<cr>',
\
\ 'V&iew\ Result\ of\ Asynchronous\ Running'.
\ '<tab>:SCViewResultAsync '.
\ ':SCViewResultAsync<cr>',
\
\ '&Terminate\ the\ Background\ Asynchronous\ Process'.
\ '<tab>:SCTerminateAsync '.
\ ':SCTerminateAsync<cr>'
\ ]
for s:menu_type in ['nnoremenu', 'inoremenu', 'vnoremenu']
exec s:menu_type.' '.s:menu_root.'.'.s:menu_textcmd
endfor
endfor
unlet! s:menu_root
unlet! s:menu_type
unlet! s:menu_textcmd
endif
endif
" }}}
" vim-addon-actions support (activate this addon after vim-addon-actions) {{{
" eg call scriptmanager#Activate(["vim-addon-actions","SingleCompile"])
if exists('g:vim_actions')
for cmd in ['SingleCompile','SingleCompileRun']
call actions#AddAction('run '.cmd,
\{'action': funcref#Function('return '.string([cmd]))})
endfor
endif
"}}}
let &cpo = s:saved_cpo
unlet! s:saved_cpo
" vim703: cc=78
" vim:fdm=marker et ts=4 tw=78 sw=4