Chatsiri Rattana | c4b848b | 2012-10-13 16:09:44 +0700 | [diff] [blame] | 1 | *SingleCompile.txt* |
| 2 | |
| 3 | File: SingleCompile.txt |
| 4 | Version: 2.10.6 |
| 5 | Original Author and Current Maintainer: Hong Xu <dev@hong.me> |
| 6 | Last Change: 15 May 2012 |
| 7 | Homepage: http://www.vim.org/scripts/script.php?script_id=3115 |
| 8 | GitHub repo: https://github.com/xuhdev/SingleCompile |
| 9 | Description: Make it more convenient to compile or run a single source file. |
| 10 | License: |
| 11 | Copyright (C) 2010-2012 Hong Xu |
| 12 | |
| 13 | This file is part of SingleCompile. |
| 14 | |
| 15 | SingleCompile is free software: you can redistribute it and/or modify |
| 16 | it under the terms of the GNU General Public License as published by |
| 17 | the Free Software Foundation, either version 3 of the License, or |
| 18 | (at your option) any later version. |
| 19 | |
| 20 | SingleCompile is distributed in the hope that it will be useful, |
| 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | GNU General Public License for more details. |
| 24 | |
| 25 | You should have received a copy of the GNU General Public License |
| 26 | along with SingleCompile. If not, see <http://www.gnu.org/licenses/>. |
| 27 | |
| 28 | CONTENTS~ |
| 29 | *SingleCompile-contents* |
| 30 | ---------------------------------------------------------------------------- |
| 31 | 1. Overview |SingleCompile-overview| |
| 32 | 2. Installation |SingleCompile-installation| |
| 33 | 3. Commands |SingleCompile-commands| |
| 34 | 4. Settings |SingleCompile-settings| |
| 35 | 5. Key-mappings |SingleCompile-key-mapping| |
| 36 | 6. Compiler template |SingleCompile-compiler-template| |
| 37 | 7. Supporting plugins |SingleCompile-supporting-plugins| |
| 38 | 8. Advanced |SingleCompile-advanced| |
| 39 | 9. Credits |SingleCompile-credits| |
| 40 | 10. Todo |SingleCompile-todo| |
| 41 | |
| 42 | |
| 43 | OVERVIEW~ |
| 44 | *SingleCompile-overview* |
| 45 | ---------------------------------------------------------------------------- |
| 46 | This plugin is aimed at making it more convenient to compile or run a single |
| 47 | source file without leaving vim. |
| 48 | |
| 49 | A short introduction is available here: |
| 50 | http://hong-xu.github.com/blog/2012/03/07/use-singlecompile-to-compile-and-run-a-single-source-file-easily-in-vim/ |
| 51 | |
| 52 | Consider this situation: you have just written a small c source file for a |
| 53 | small test, but you have to write a Makefile to compile it or exit vim to |
| 54 | compile it or compile it using "!gcc" without quickfix feature because vim's |
| 55 | make command only use the "make" command? This plugin will help you out. |
| 56 | |
| 57 | Add these key-mappings to your vimrc: |
| 58 | > |
| 59 | nmap <F9> :SCCompile<cr> |
| 60 | nmap <F10> :SCCompileRun<cr> |
| 61 | < |
| 62 | Note that the two lines here should not have any trailing space. If your file |
| 63 | type is supported, then press F9 to compile your source file, and press F10 to |
| 64 | compile and run your source file. If there is a compilation error, and the |
| 65 | |quickfix| feature is enabled, then you could use |:cope| command to see the |
| 66 | error list. You may also use ":SCChooseCompiler" command to choose a compiler |
| 67 | if you have more than one kind of compiler available on you system. |
| 68 | ":SCViewResult" will show you the last run result. |
| 69 | |
| 70 | |
| 71 | Features: |
| 72 | 1. Compile or run the source file quickly using |quickfix| feature and |
| 73 | |compiler| feature of vim; |
| 74 | 2. Compilers and interpreters auto detecting; |
| 75 | 3. Fast switch between several installed compilers or interpreters; |
| 76 | 4. Multi-language support; |
| 77 | 5. Custom your own compiler/interpreter template; |
| 78 | 6. View the result of last run command at any time(requires "tee" command); |
| 79 | 7. Run the compiled program asynchronously and view the result at any time |
| 80 | (see |:SCCompileRunAsync|). |
| 81 | |
| 82 | |
| 83 | Here is a list of built-in supported compilers or interpreter(For some |
| 84 | compilers/interpreters, you need to set the environment varibles correctly to |
| 85 | make them available for SingleCompile): |
| 86 | |
| 87 | Ada: |
| 88 | gnat (GNAT) |
| 89 | |
| 90 | bash: |
| 91 | bash (Bourne-Again Shell) |
| 92 | |
| 93 | C: |
| 94 | bcc (Borland C++ Builder), Windows only |
| 95 | cc (UNIX C Compiler), UNIX only |
| 96 | ch (SoftIntegration Ch) |
| 97 | clang (the Clang C and Objective-C compiler) |
| 98 | gcc (GNU C Compiler) |
| 99 | icc (Intel C++ Compiler) |
| 100 | lcc (Little C Compiler) |
| 101 | msvc (Microsoft Visual C++ (In PATH)), Windows only |
| 102 | msvc80 (Microsoft Visual C++ 2005), Windows only |
| 103 | msvc90 (Microsoft Visual C++ 2008), Windows only |
| 104 | msvc100 (Microsoft Visual C++ 2010), Windows only |
| 105 | open-watcom (Open Watcom C/C++32 Compiler) |
| 106 | open64 (Open64 C Compiler), UNIX only |
| 107 | pcc (Portable C Compiler) |
| 108 | sol-studio (Sun C Compiler(Sun Solaris Studio)), UNIX only |
| 109 | tcc (Tiny C Compiler) |
| 110 | tcc-run (Tiny C Compiler with "-run" Flag) |
| 111 | |
| 112 | C++: |
| 113 | bcc (Borland C++ Builder), Windows Only |
| 114 | ch (SoftIntegration Ch) |
| 115 | clang (the Clang C and Objective-C compiler) |
| 116 | g++ (GNU C++ Compiler) |
| 117 | icc (Intel C++ Compiler) |
| 118 | msvc (Microsoft Visual C++ (In PATH)), Windows only |
| 119 | msvc80 (Microsoft Visual C++ 2005), Windows only |
| 120 | msvc90 (Microsoft Visual C++ 2008), Windows only |
| 121 | msvc100 (Microsoft Visual C++ 2010), Windows only |
| 122 | open-watcom (Open Watcom C/C++32 Compiler) |
| 123 | open64 (Open64 C++ Compiler), UNIX only |
| 124 | sol-studio (Sun C++ Compiler(Sun Solaris Studio)), UNIX only |
| 125 | |
| 126 | C#: |
| 127 | msvcs(Microsoft Visual C#), Windows Only |
| 128 | mono (Mono C# compiler) |
| 129 | |
| 130 | cmake: |
| 131 | cmake (cmake) |
| 132 | |
| 133 | csh: |
| 134 | csh (C Shell) |
| 135 | tcsh (TENEX C Shell) |
| 136 | |
| 137 | D: |
| 138 | dmd (DMD Compiler) |
| 139 | |
| 140 | dos batch: |
| 141 | dosbatch (DOS Batch) |
| 142 | |
| 143 | erlang: |
| 144 | escript (Erlang Scripting Support) |
| 145 | |
| 146 | Fortran: |
| 147 | ftn95 (Silverfrost FTN95), Windows only |
| 148 | g77 (GNU Fortran 77 Compiler) |
| 149 | g95 (G95) |
| 150 | gfortran (GNU Fortran Compiler) |
| 151 | ifort (Intel Fortran Compiler) |
| 152 | open-watcom (Open Watcom Fortran 77/32 Compiler) |
| 153 | open64-f90 (Open64 Fortran 90 Compiler), UNIX only |
| 154 | open64-f95 (Open64 Fortran 95 Compiler), UNIX only |
| 155 | sol-studio-f77 (Sun Fortran 77 Compiler(Sun Solaris Studio)), UNIX only |
| 156 | sol-studio-f90 (Sun Fortran 90 Compiler(Sun Solaris Studio)), UNIX only |
| 157 | sol-studio-f95 (Sun Fortran 95 Compiler(Sun Solaris Studio)), UNIX only |
| 158 | |
| 159 | Haskell: |
| 160 | ghc (Glasgow Haskell Compiler) |
| 161 | runhaskell (runhaskell) |
| 162 | |
| 163 | html: |
| 164 | arora (Arora) |
| 165 | chrome (Google Chrome) |
| 166 | epiphany (Epiphany) |
| 167 | firefox (Mozilla Firefox) |
| 168 | ie (Microsoft Internet Explorer) |
| 169 | konqueror (Konqueror) |
| 170 | opera (Opera) |
| 171 | |
| 172 | IDL(Interactive Data Language): |
| 173 | idl (ITT Visual Information Solutions Interactive Data Language) |
| 174 | gdl (GNU Data Language incremental compiler) |
| 175 | |
| 176 | Java: |
| 177 | gcj (GNU Java Compiler) |
| 178 | sunjdk (Sun Java Development Kit) |
| 179 | |
| 180 | JavaScript: |
| 181 | gjs (Javascript Bindings for GNOME) |
| 182 | js (SpiderMonkey, a JavaScript engine written in C) |
| 183 | node.js (node.js) |
| 184 | rhino (Rhino, a JavaScript engine written in Java) |
| 185 | |
| 186 | ksh: |
| 187 | ksh (Korn Shell) |
| 188 | |
| 189 | LaTeX: |
| 190 | latex (LaTeX) |
| 191 | pdflatex (pdfLaTeX) |
| 192 | |
| 193 | LISP: |
| 194 | clisp (GNU CLISP) |
| 195 | ecl (Embeddable Common-Lisp) |
| 196 | gcl (GNU Common Lisp) |
| 197 | |
| 198 | lua: |
| 199 | lua (Lua Interpreter) |
| 200 | |
| 201 | Makefile: |
| 202 | gmake (GNU Make) |
| 203 | nmake (Microsoft Program Maintenance Utility) |
| 204 | mingw32-make (MinGW32 Make) |
| 205 | |
| 206 | Markdown: |
| 207 | markdown (text-to-HTML conversion tool) |
| 208 | rdiscount (Discount Markdown Processor for Ruby) |
| 209 | |
| 210 | Object-C: |
| 211 | clang (the Clang C and Objective-C compiler) |
| 212 | gcc (GNU Object-C Compiler) |
| 213 | |
| 214 | Pascal: |
| 215 | fpc (Free Pascal Compiler) |
| 216 | gpc (GNU Pascal Compiler) |
| 217 | |
| 218 | perl: |
| 219 | perl (Perl Interpreter) |
| 220 | |
| 221 | PHP: |
| 222 | php (PHP Command Line Interface 'CLI') |
| 223 | |
| 224 | python: |
| 225 | ironpython (IronPython) |
| 226 | jython (Jython) |
| 227 | pypy (PyPy) |
| 228 | python (Python Interpreter) |
| 229 | python3 (Python 3 Interpreter) |
| 230 | |
| 231 | R: |
| 232 | R (R) |
| 233 | |
| 234 | reStructuredText: |
| 235 | rst2html (reST to HTML) |
| 236 | |
| 237 | ruby: |
| 238 | ruby (Ruby Interpreter) |
| 239 | |
| 240 | sh: |
| 241 | ash (Almquist Shell) |
| 242 | bash (Bourne-Again Shell) |
| 243 | dash (Debian Almquist Shell) |
| 244 | ksh (Korn Shell) |
| 245 | sh (Bourne Shell) |
| 246 | zsh (Z Shell) |
| 247 | |
| 248 | tcl: |
| 249 | tclsh (Simple shell containing Tcl interpreter) |
| 250 | |
| 251 | tcsh: |
| 252 | tcsh (TENEX C Shell) |
| 253 | |
| 254 | vb script: |
| 255 | vb (VB Script Interpreter) |
| 256 | |
| 257 | xhtml: |
| 258 | arora (Arora) |
| 259 | chrome (Google Chrome) |
| 260 | chromium (Chromium) |
| 261 | epiphany (Epiphany) |
| 262 | firefox (Mozilla Firefox) |
| 263 | ie (Microsoft Internet Explorer) |
| 264 | konqueror (Konqueror) |
| 265 | opera (Opera) |
| 266 | |
| 267 | zsh: |
| 268 | zsh (Z Shell) |
| 269 | |
| 270 | You can add your compiler or interpreter support if the compiler or |
| 271 | interpreter you want is not in the list. See details in the help file. |
| 272 | |
| 273 | There are some supporting code in this plugin for Marc Weber's |
| 274 | vim-addon-actions: |
| 275 | http://github.com/MarcWeber/vim-addon-actions |
| 276 | |
| 277 | If you find any bug, please report it to xuhdev@gmail.com or submit it on |
| 278 | the issue tracker: |
| 279 | https://bitbucket.org/xuhdev/singlecompile/issues |
| 280 | |
| 281 | If you've written some templates for some compilers or interpreters which are |
| 282 | not included as built-in template, and you think they are useful for other |
| 283 | people, you could send me an email to inform me, and I'll put them in the |
| 284 | built-in templates. |
| 285 | |
| 286 | |
| 287 | Git repository on github.com: https://github.com/xuhdev/SingleCompile |
| 288 | Mercurial repository on bitbucket.org: https://bitbucket.org/xuhdev/singlecompile |
| 289 | |
| 290 | Follow xuhdev on twitter if you are interested in my development: |
| 291 | http://twitter.com/xuhdev |
| 292 | |
| 293 | |
| 294 | INSTALLATION~ |
| 295 | *SingleCompile-installation* |
| 296 | ---------------------------------------------------------------------------- |
| 297 | Download the SingleCompile.zip file and extract it to your vim runtime |
| 298 | directory(~/.vim on linux and $VIM_INSTALLATION_FOLDER\vimfiles on windows), |
| 299 | you'd better then use ":helptags" command to generate the help tag(for example |
| 300 | use ":helptags ~/.vim/doc" on UNIX/Linux). |
| 301 | |
| 302 | |
| 303 | COMMANDS~ |
| 304 | *SingleCompile-commands* |
| 305 | ---------------------------------------------------------------------------- |
| 306 | |
| 307 | *:SCCompile* |
| 308 | Command: |
| 309 | :SCCompile |
| 310 | If you are editing a source file of a compiling language such as C, Java, this |
| 311 | command will compile the file which you are editing now. If you are editing a |
| 312 | source file of a interpreted language such as python language, this command |
| 313 | will run the file which you are editing. See |SingleCompile-compiler-template| |
| 314 | about the compilation command. |
| 315 | |
| 316 | You can add some arguments after the command. For example, you want to compile |
| 317 | your c source file with "-g -o %<" flag instead of the "-o %<" flag defined in |
| 318 | the language template(see |SingleCompile-compiler-template|) for just this |
| 319 | time, just use the following command: |
| 320 | > |
| 321 | :SCCompile -g -o %< |
| 322 | < |
| 323 | "%<" means the current file name without extension. |
| 324 | Also see |:SCCompileAF|. |
| 325 | |
| 326 | *:SingleCompile* |
| 327 | Command: |
| 328 | :SingleCompile |
| 329 | Same as |:SCCompile|, only for backward compatibility use. Not recommended to |
| 330 | use any more. |
| 331 | |
| 332 | *:SCCompileAF* |
| 333 | Command: |
| 334 | :SCCompileAF |
| 335 | This command is also used for compiling your source file, but it allows you to |
| 336 | append some additional compilation or interpretion flags other than the flags |
| 337 | already defined in the compiler and interpreter template. The "AF" is short |
| 338 | for "Addtional Flags". For example, GCC compiler for C has already been |
| 339 | defined some flags: "-o "%<"". But sometimes you also want to use "-O2" flag |
| 340 | to optimize your code, then you can use the following commands to compile your |
| 341 | file: |
| 342 | > |
| 343 | :SCCompileAF -O2 |
| 344 | < |
| 345 | :SCCompile can also be used with some arguments, but there are some |
| 346 | differences. :SCCompileAF use your arguments as "additional" compilation |
| 347 | flags, which means the flags defined in the original templates are also valid, |
| 348 | while :SCCompile use you arguments as compilation flags only, which means the |
| 349 | flags defined in the original templates are not used. For example, the |
| 350 | templates of GCC defined "flags" as '-o "%<"', "%<" stands for the output file |
| 351 | name. ":SCCompile -O2" will use "gcc -O2 some_file.c" to compile your source |
| 352 | file, while ":SCCompileAF -O2" will use "gcc -o some_file -O2 some_file.c" to |
| 353 | compile your source file. |
| 354 | |
| 355 | *:SCCompileRun* |
| 356 | Command: |
| 357 | :SCCompileRun |
| 358 | If you are editing a source file of a compiling language such as C, Java, this |
| 359 | command will compile the file which you are editing now and run the |
| 360 | executable; if you are editing a source file of a interpreted language such as |
| 361 | python, ruby, this command will run the source file you are editing. That |
| 362 | means, there is nothing different between |:SCCompile| and |:SCCompileRun| for an |
| 363 | interpreted language source file. |
| 364 | |
| 365 | You can also add some arguments after SCCompileRun command, the meaning of |
| 366 | arguments is the same as SingleCompile command above. Here is an example: |
| 367 | > |
| 368 | :SCCompileRun -g -o %< |
| 369 | < |
| 370 | |
| 371 | When the program you've just compiled (or the script you've just written) |
| 372 | runs, vim will hang up to wait for the program to terminate. If you do not |
| 373 | want vim to hang up when running the program, use |:SCCompileRunAsync| |
| 374 | instead. See |:SCCompileRunAsync| for further information. |
| 375 | |
| 376 | *:SingleCompileRun* |
| 377 | Command: |
| 378 | :SingleCompileRun |
| 379 | Same as |:SCCompileRun|, only for backward compatibility use. Not recommended |
| 380 | to use any more. |
| 381 | |
| 382 | *:SCCompileRunAF* |
| 383 | Command: |
| 384 | :SCCompileRunAF |
| 385 | Same as |:SCCompileAF|, but also run the binary file after compilation. For |
| 386 | example, the following command is going to compile your source file with an |
| 387 | additional "-O2" flag and run the output binary file: |
| 388 | > |
| 389 | :SCCompileRunAF -O2 |
| 390 | < |
| 391 | |
| 392 | *:SCCompileRunAsync* |
| 393 | Command: |
| 394 | :SCCompileRunAsync |
| 395 | Same as |:SCCompileRun|, but compile the source and run asynchronously. That |
| 396 | is to say, after the program starts to run, you are still able to edit the |
| 397 | source file, because vim does not hang up waiting for the program to |
| 398 | terminate. The result of the run could be viewed by |:SCViewResultAsync| |
| 399 | command. This command might not be available on your vim, see |
| 400 | |SingleCompile-asyncrunmode| for more information. This command is useful when |
| 401 | the program takes a long time to run or you are developing a GUI program. Also |
| 402 | see |:SCViewResultAsync|, |:SCTerminateAsync| and |:SCIsRunningAsync|. |
| 403 | |
| 404 | *:SCCompileRunAsyncAF* |
| 405 | Command: |
| 406 | :SCCompileRunAsyncAF |
| 407 | Same as |:SCCompileRunAF|, but compile the source and run asynchronously. The |
| 408 | result of the run could be viewed by |:SCViewResultAsync| command. This |
| 409 | command is disabled by default, to enable it, see |
| 410 | |SingleCompile-asyncrunmode|. Also see |:SCCompileRunAsync|. |
| 411 | |
| 412 | *:SCChooseCompiler* |
| 413 | Command: |
| 414 | :SCChooseCompiler |
| 415 | Choose a compiler to use. This command will display a list of compilers for |
| 416 | you to choose one. If you want to set a default compiler in your vimrc, please |
| 417 | use the function SingleCompile#ChooseCompiler. See |
| 418 | |SingleCompile-use-built-in-template|. |
| 419 | |
| 420 | *:SCChooseInterpreter* |
| 421 | Command: |
| 422 | :SCChooseInterpreter |
| 423 | Same as |:SCChooseCompiler|. |
| 424 | |
| 425 | *:SCIsRunningAsync* |
| 426 | Command: |
| 427 | :SCIsRunningAsync |
| 428 | Check whether the asynchronously run process is still running. Also see |
| 429 | |:SCCompileRunAsync|. |
| 430 | |
| 431 | *:SCTerminateAsync* |
| 432 | Command: |
| 433 | :SCTerminateAsync |
| 434 | Terminate the process which is running asynchronously if exists. Also see |
| 435 | |:SCCompileRunAsync|. |
| 436 | |
| 437 | *:SCViewResult* |
| 438 | Command: |
| 439 | :SCViewResult |
| 440 | View the result of the last run command. Only valid when "tee" command is |
| 441 | available. "tee" is usually available on a UNIX system. If you are under |
| 442 | Windows, install cygwin or visit the following link to download a "tee" |
| 443 | command for Windows: |
| 444 | http://gnuwin32.sourceforge.net/packages/coreutils.htm |
| 445 | |
| 446 | *:SCViewResultAsync* |
| 447 | Command: |
| 448 | :SCViewResultAsync |
| 449 | Same as |:SCViewResult|, but the result displayed is the result of the process |
| 450 | run by |:SCCompileRunAsync| or |:SCCompileRunAsyncAF|. |
| 451 | |
| 452 | |
| 453 | SETTINGS~ |
| 454 | *SingleCompile-settings* |
| 455 | ---------------------------------------------------------------------------- |
| 456 | |
| 457 | *SingleCompile-alwayscompile* |
| 458 | If g:SingleCompile_alwayscompile is set to 0, when using |:SCCompileRun| |
| 459 | command, SingleCompile may run the output of the compilation directly if the |
| 460 | modification time of the source file is earlier than the output file. If you |
| 461 | want to enable this feature, add the following line to your vimrc: |
| 462 | > |
| 463 | let g:SingleCompile_alwayscompile = 0 |
| 464 | < |
| 465 | The default value of g:SingleCompile_alwayscompile is 1. |
| 466 | |
| 467 | *SingleCompile-asyncrunmode* |
| 468 | This option specifies the asynchronous mode for |:SCCompileRunAsync| and |
| 469 | |:SCCompileRunAsyncAF|. The default value is "auto", which means SingleCompile |
| 470 | will automatically detect whether you are able to enable async run mode and |
| 471 | select one mode for you. Use the following line, replace modename with the |
| 472 | mode you want to change mode: |
| 473 | > |
| 474 | let g:SingleCompile_asyncrunmode = 'modename' |
| 475 | < |
| 476 | |
| 477 | Here is a list of available mode: |
| 478 | |
| 479 | auto This is the default value. SingleCompile automatically selects one |
| 480 | mode for you. |
| 481 | > |
| 482 | let g:SingleCompile_asyncrunmode = 'auto' |
| 483 | < |
| 484 | |
| 485 | none Disable asynchronous mode, which means |:SCCompileRunAsync| and |
| 486 | |:SCCompileRunAsyncAF| and related commands are disabled. |
| 487 | > |
| 488 | let g:SingleCompile_asyncrunmode = 'none' |
| 489 | < |
| 490 | |
| 491 | python Use python interface when running asynchronously. Required vim |
| 492 | compiled with python interface 2.6+. See |+python|. |
| 493 | > |
| 494 | let g:SingleCompile_asyncrunmode = 'python' |
| 495 | < |
| 496 | |
| 497 | |
| 498 | *SingleCompile-autowrite* |
| 499 | If you don't want to save your file automatically when you use "SingleCompile" |
| 500 | command or "SingleCompileRun" command, add the following line to your vimrc: |
| 501 | > |
| 502 | let g:SingleCompile_autowrite = 0 |
| 503 | < |
| 504 | NOTE: If you let g:SingleCompile_usequickfix=1, this option will take no |
| 505 | effect, the running result will depend on the vim's option 'autowrite'. See |
| 506 | 'autowrite' for more information. |
| 507 | |
| 508 | *SingleCompile-menumode* |
| 509 | If you don't want the menus of SingleCompile to show, copy the following line |
| 510 | to your vimrc: |
| 511 | > |
| 512 | let g:SingleCompile_menumode = 0 |
| 513 | < |
| 514 | If you want the menus of SingleCompile to show as a sub menu of Plugin, copy |
| 515 | the following line to your vimrc: |
| 516 | > |
| 517 | let g:SingleCompile_menumode = 1 |
| 518 | < |
| 519 | If you want the menus of SingleCompile to show in the menu bar, copy the |
| 520 | following line to your vimrc: |
| 521 | > |
| 522 | let g:SingleCompile_menumode = 2 |
| 523 | < |
| 524 | The default value is 1. |
| 525 | |
| 526 | *SingleCompile-resultheight* |
| 527 | g:SingleCompile_resultheight is the height of the result displaying window |
| 528 | triggered by |:SCViewResult| command. To set the value, add the following line |
| 529 | to your vimrc file: |
| 530 | > |
| 531 | let g:SingleCompile_resultheight = a_number |
| 532 | < |
| 533 | Replace a_number to any number you want, such as "10", "4". The default value |
| 534 | of g:SingleCompile_resultheight is 5. |
| 535 | |
| 536 | *SingleCompile-showquickfixiferror* |
| 537 | If |quickfix| is enabled and used, and you want the quickfix window to show |
| 538 | automatically if there is a compilation error, then add the following line to |
| 539 | your vimrc file: |
| 540 | > |
| 541 | let g:SingleCompile_showquickfixiferror = 1 |
| 542 | < |
| 543 | The default value of g:SingleCompile_showquickfixiferror is 0. Note that this |
| 544 | option will be ignored if you are using interpreting languages on Windows, |
| 545 | such as python, ruby. |
| 546 | |
| 547 | *SingleCompile-showresultafterrun* |
| 548 | If "tee" command is available on your system, copy the following line to your |
| 549 | vimrc file will make vim show the result of the run automatically after you |
| 550 | run the program: |
| 551 | > |
| 552 | let g:SingleCompile_showresultafterrun = 1 |
| 553 | < |
| 554 | This option is only valid for synchronous run. That is to say, asynchronous |
| 555 | run is not affected by this option. The default value of |
| 556 | g:SingleCompile_showresultafterrun is 0. Also see |:SCViewResult|. |
| 557 | |
| 558 | *SingleCompile-usedialog* |
| 559 | If you want SingleCompile to show message in a dialog, add the |
| 560 | following line to your vimrc: |
| 561 | > |
| 562 | let g:SingleCompile_usedialog = 1 |
| 563 | < |
| 564 | This setting will take no effect if your vim is not compiled with |
| 565 | '+dialog_con' and '+dialog_gui'. |
| 566 | |
| 567 | *SingleCompile-usequickfix* |
| 568 | If you don't want SingleCompile to use quickfix feature, add the following |
| 569 | line to your vimrc: |
| 570 | > |
| 571 | let g:SingleCompile_usequickfix = 0 |
| 572 | < |
| 573 | |
| 574 | |
| 575 | KEY-MAPPING~ |
| 576 | *SingleCompile-key-mapping* |
| 577 | ---------------------------------------------------------------------------- |
| 578 | I recommend you to copy the following two lines about key mapping to your |
| 579 | vimrc: |
| 580 | > |
| 581 | nmap <F9> :SingleCompile<cr> |
| 582 | nmap <F10> :SingleCompileRun<cr> |
| 583 | < |
| 584 | Then you can press F9 to compile, and F10 to compile and run. |
| 585 | |
| 586 | |
| 587 | COMPILER-TEMPLATE~ |
| 588 | *SingleCompile-compiler-template* |
| 589 | ---------------------------------------------------------------------------- |
| 590 | *SingleCompile-use-built-in-template* |
| 591 | *SingleCompile#ChooseCompiler* |
| 592 | To use a built-in compiler, add the following line to your vimrc file: |
| 593 | > |
| 594 | call SingleCompile#ChooseCompiler('filetype', 'compiler') |
| 595 | < |
| 596 | "filetype" is the type of file which your compiler is for, such as "c", |
| 597 | "python", and "compiler" is the short name of the compiler. "filetype" is a |
| 598 | terminology of vim. See |filetype| if you don't know what is "filetype". For |
| 599 | example: |
| 600 | > |
| 601 | call SingleCompile#ChooseCompiler('c', 'icc') |
| 602 | call SingleCompile#ChooseCompiler('fortran', 'gfortran') |
| 603 | < |
| 604 | This will choose icc (short for Intel C++ Compiler) as your current C compiler |
| 605 | and choose gfortran (GNU Fortran Compiler) as your current Fortran compiler. |
| 606 | For the list of built-in supported compilers, see |
| 607 | |SingleCompile-built-in-compilers|. |
| 608 | |
| 609 | If you don't choose a compiler by yourself, SingleCompile will automatically |
| 610 | choose one for you according to the compiler's priority value (See |
| 611 | |SingleCompile-priority|). |
| 612 | |
| 613 | You can also extend the compiler template if the compiler you want is not in |
| 614 | the built-in supporting list. SingleCompile#ChooseCompiler could also be used |
| 615 | to choose a user defined compiler. Check |SingleCompile-add-your-compiler| for |
| 616 | more information. |
| 617 | |
| 618 | *SingleCompile-add-your-compiler* |
| 619 | *SingleCompile#SetCompilerTemplate* |
| 620 | To add a new compiler support by yourself, there are two ways: |
| 621 | 1. (Recommended) Add the following lines to your vimrc file: |
| 622 | > |
| 623 | call SingleCompile#SetCompilerTemplate('filetype', 'compiler', 'compiler_name', 'command', 'flag', 'run_command') |
| 624 | call SingleCompile#SetOutfile('filetype', 'compiler', 'out_file') |
| 625 | call SingleCompile#ChooseCompiler('filetype', 'compiler') |
| 626 | < |
| 627 | Now Let's see the first line. "filetype" is the source file type, such as "c", |
| 628 | "cpp", "python", etc. It is a terminology of vim. See |filetype| if you don't |
| 629 | know what is "filetype". For compiling languages such as C, Java, Fortran, |
| 630 | "compiler" is the short name for the compiler, such as "gcc", "icc"; "command" |
| 631 | is the command of compiling, such as "gcc", "g++"; "flag" is the flags of |
| 632 | compiling, such as "-O2"; "run_command" is the command of running, such as |
| 633 | "./a.out". For interpreted languages such as Python, Ruby, "command" is the |
| 634 | command of interpreting, such as "python"; "flag" is the flags of |
| 635 | interpreting; and "run_command" MUST be set to be empty. |
| 636 | |
| 637 | For the second line, "filetype" and "compiler" has the same meanings with the |
| 638 | first line. "out_file" is the output file of the compilation, such as |
| 639 | "./a.out", "./a.exe", etc. This line could be omitted if you don't want |
| 640 | SingleCompile to check whether compilation is needed. See |
| 641 | |SingleCompile-alwayscompile| for more information. |
| 642 | |
| 643 | The first two lines are to set the template of your compiler, while the third |
| 644 | line is to tell SingleCompile to use your compiler. If the second line is |
| 645 | omitted, SingleCompile will detect the compilers available on your system |
| 646 | automatically, and use the first detected one. |
| 647 | |
| 648 | Here are some examples modified from built-in compiler templates: |
| 649 | > |
| 650 | " set the most common used run command |
| 651 | if has('win32') || has('win64') || has('os2') |
| 652 | let l:common_run_command = '$(FILE_TITLE)$' |
| 653 | let l:common_out_file = '$(FILE_TITLE)$.exe' |
| 654 | else |
| 655 | let l:common_run_command = './$(FILE_TITLE)$' |
| 656 | let l:common_out_file = '$(FILE_TITLE)$' |
| 657 | endif |
| 658 | |
| 659 | " c |
| 660 | call SingleCompile#SetCompilerTemplate('c', 'gcc', 'GNU C Compiler', |
| 661 | \'gcc', '-o $(FILE_TITLE)$', l:common_run_command) |
| 662 | call SingleCompile#SetOutfile('c', 'gcc', l:common_out_file) |
| 663 | call SingleCompile#SetCompilerTemplate('c', 'icc', |
| 664 | \'Intel C++ Compiler', 'icc', '-o $(FILE_TITLE)$', |
| 665 | \l:common_run_command) |
| 666 | call SingleCompile#SetOutfile('c', 'icc', l:common_out_file) |
| 667 | |
| 668 | call SingleCompile#ChooseCompiler('c', 'gcc') |
| 669 | |
| 670 | " fortran |
| 671 | call SingleCompile#SetCompilerTemplate('fortran', 'g77', |
| 672 | \'GNU Fortran 77 Compiler', 'g77', '-o $(FILE_TITLE)$', |
| 673 | \l:common_run_command) |
| 674 | call SingleCompile#SetOutfile('fortran', 'g77', l:common_out_file) |
| 675 | call SingleCompile#SetCompilerTemplate('fortran', 'ifort', |
| 676 | \'Intel Fortran Compiler', 'ifort', '-o $(FILE_TITLE)$', |
| 677 | \l:common_run_command) |
| 678 | call SingleCompile#SetOutfile('fortran', 'ifort', l:common_out_file) |
| 679 | |
| 680 | call SingleCompile#ChooseCompiler('fortran', 'g77') |
| 681 | |
| 682 | " python |
| 683 | call SingleCompile#SetCompilerTemplate('python', 'python', 'CPython', |
| 684 | \'python', '', '') |
| 685 | call SingleCompile#SetCompilerTemplate('python', 'jython', 'Jython', |
| 686 | \'jython', '', '') |
| 687 | |
| 688 | call SingleCompile#ChooseCompiler('python', 'jython') |
| 689 | < |
| 690 | |
| 691 | 2. (Deprecated, only kept for backward compatibility use) |
| 692 | If you use this method to add a language template, many features of |
| 693 | SingleCompile will be unavailable. For example, ":SCChooseCompiler" command |
| 694 | will not be available. So I don't recommend you to use this method, and this |
| 695 | method is kept ONLY for backward compatibility. |
| 696 | |
| 697 | Add the following lines to your vimrc file: |
| 698 | > |
| 699 | call SingleCompile#SetTemplate('filetype', 'command', 'stringA') |
| 700 | call SingleCompile#SetTemplate('filetype', 'flags', 'stringB') |
| 701 | call SingleCompile#SetTemplate('filetype', 'run', 'stringC') |
| 702 | < |
| 703 | For compiling languages such as C, Java, stringA is the command of compiling, |
| 704 | stringB is the flags of compiling, stringC is the command of running; For |
| 705 | interpreted languages such as Python, Ruby, stringA is the command of |
| 706 | interpreting, stringB is the flags of interpreting, stringC MUST be set to |
| 707 | be empty. |
| 708 | |
| 709 | Here are some examples: |
| 710 | > |
| 711 | " java |
| 712 | call SingleCompile#SetTemplate('java', 'command', 'javac') |
| 713 | call SingleCompile#SetTemplate('java', 'flags', '') |
| 714 | call SingleCompile#SetTemplate('java', 'run', 'java %<') |
| 715 | |
| 716 | " python |
| 717 | call SingleCompile#SetTemplate('python', 'command', 'python') |
| 718 | call SingleCompile#SetTemplate('python', 'flags', '') |
| 719 | call SingleCompile#SetTemplate('python', 'run', '') |
| 720 | |
| 721 | " latex |
| 722 | call SingleCompile#SetTemplate('tex', 'command', 'latex') |
| 723 | call SingleCompile#SetTemplate('tex', 'flags', '') |
| 724 | if has('unix') |
| 725 | call SingleCompile#SetTemplate('tex', 'run', 'xdvi %<.dvi') |
| 726 | elseif has('win32') |
| 727 | call SingleCompile#SetTemplate('tex', 'run', 'dviout %<.dvi') |
| 728 | endif |
| 729 | < |
| 730 | You can also use this method to modify the templates of a built-in supported |
| 731 | language. For example, you can change 'dviout' to 'yap' in the example above |
| 732 | to modify the built-in latex language template. |
| 733 | |
| 734 | Advanced: If you don't want to override the template if there is an existing |
| 735 | one, but use the new template if there is no corresponding template existing, |
| 736 | for example, you want to set the "command" of java language to javac if no |
| 737 | command is set for java, but do nothing if the command of java is not set, use |
| 738 | the following: |
| 739 | > |
| 740 | call SingleCompile#SetTemplate('java', 'command', 'javac', 1) |
| 741 | < |
| 742 | In this way, if the command of java is already set, this sentence will do |
| 743 | nothing. On the contrary, if the command of java is not set, it will set the |
| 744 | compilation command of java to "javac". |
| 745 | |
| 746 | *SingleCompile-built-in-compiler* |
| 747 | The following compilers have built-in support in this plugin (For some |
| 748 | compilers/interpreters, you need to set the environment varibles correctly to |
| 749 | make them available for SingleCompile): |
| 750 | |
| 751 | Ada: |
| 752 | gnat (GNAT) |
| 753 | |
| 754 | bash: |
| 755 | bash (Bourne-Again Shell) |
| 756 | |
| 757 | C: |
| 758 | bcc (Borland C++ Builder), Windows only |
| 759 | cc (UNIX C Compiler), UNIX only |
| 760 | ch (SoftIntegration Ch) |
| 761 | clang (the Clang C and Objective-C compiler) |
| 762 | gcc (GNU C Compiler) |
| 763 | icc (Intel C++ Compiler) |
| 764 | lcc (Little C Compiler) |
| 765 | msvc (Microsoft Visual C++ (In PATH)), Windows only |
| 766 | msvc80 (Microsoft Visual C++ 2005), Windows only |
| 767 | msvc90 (Microsoft Visual C++ 2008), Windows only |
| 768 | msvc100 (Microsoft Visual C++ 2010), Windows only |
| 769 | open-watcom (Open Watcom C/C++32 Compiler) |
| 770 | open64 (Open64 C Compiler), UNIX only |
| 771 | pcc (Portable C Compiler) |
| 772 | sol-studio (Sun C Compiler(Sun Solaris Studio)), UNIX only |
| 773 | tcc (Tiny C Compiler) |
| 774 | tcc-run (Tiny C Compiler with "-run" Flag) |
| 775 | |
| 776 | C++: |
| 777 | bcc (Borland C++ Builder), Windows Only |
| 778 | ch (SoftIntegration Ch) |
| 779 | clang (the Clang C and Objective-C compiler) |
| 780 | g++ (GNU C++ Compiler) |
| 781 | icc (Intel C++ Compiler) |
| 782 | msvc (Microsoft Visual C++ (In PATH)), Windows only |
| 783 | msvc80 (Microsoft Visual C++ 2005), Windows only |
| 784 | msvc90 (Microsoft Visual C++ 2008), Windows only |
| 785 | msvc100 (Microsoft Visual C++ 2010), Windows only |
| 786 | open-watcom (Open Watcom C/C++32 Compiler) |
| 787 | open64 (Open64 C++ Compiler), UNIX only |
| 788 | sol-studio (Sun C++ Compiler(Sun Solaris Studio)), UNIX only |
| 789 | |
| 790 | C#: |
| 791 | msvcs(Microsoft Visual C#), Windows Only |
| 792 | mono (Mono C# compiler) |
| 793 | |
| 794 | cmake: |
| 795 | cmake (cmake) |
| 796 | |
| 797 | csh: |
| 798 | csh (C Shell) |
| 799 | tcsh (TENEX C Shell) |
| 800 | |
| 801 | D: |
| 802 | dmd (DMD Compiler) |
| 803 | |
| 804 | dos batch: |
| 805 | dosbatch (DOS Batch) |
| 806 | |
| 807 | erlang: |
| 808 | escript (Erlang Scripting Support) |
| 809 | |
| 810 | Fortran: |
| 811 | ftn95 (Silverfrost FTN95), Windows only |
| 812 | g77 (GNU Fortran 77 Compiler) |
| 813 | g95 (G95) |
| 814 | gfortran (GNU Fortran Compiler) |
| 815 | ifort (Intel Fortran Compiler) |
| 816 | open-watcom (Open Watcom Fortran 77/32 Compiler) |
| 817 | open64-f90 (Open64 Fortran 90 Compiler), UNIX only |
| 818 | open64-f95 (Open64 Fortran 95 Compiler), UNIX only |
| 819 | sol-studio-f77 (Sun Fortran 77 Compiler(Sun Solaris Studio)), UNIX only |
| 820 | sol-studio-f90 (Sun Fortran 90 Compiler(Sun Solaris Studio)), UNIX only |
| 821 | sol-studio-f95 (Sun Fortran 95 Compiler(Sun Solaris Studio)), UNIX only |
| 822 | |
| 823 | Haskell: |
| 824 | ghc (Glasgow Haskell Compiler) |
| 825 | runhaskell (runhaskell) |
| 826 | |
| 827 | html: |
| 828 | arora (Arora) |
| 829 | chrome (Google Chrome) |
| 830 | chromium (Chromium) |
| 831 | epiphany (Epiphany) |
| 832 | firefox (Mozilla Firefox) |
| 833 | ie (Microsoft Internet Explorer) |
| 834 | konqueror (Konqueror) |
| 835 | opera (Opera) |
| 836 | |
| 837 | IDL(Interactive Data Language): |
| 838 | idl (ITT Visual Information Solutions Interactive Data Language) |
| 839 | gdl (GNU Data Language incremental compiler) |
| 840 | |
| 841 | Java: |
| 842 | gcj (GNU Java Compiler) |
| 843 | sunjdk (Sun Java Development Kit) |
| 844 | |
| 845 | JavaScript: |
| 846 | gjs (Javascript Bindings for GNOME) |
| 847 | js (SpiderMonkey, a JavaScript engine written in C) |
| 848 | node.js (node.js) |
| 849 | rhino (Rhino, a JavaScript engine written in Java) |
| 850 | |
| 851 | ksh: |
| 852 | ksh (Korn Shell) |
| 853 | |
| 854 | LaTeX: |
| 855 | latex (LaTeX) |
| 856 | pdflatex (pdfLaTeX) |
| 857 | |
| 858 | LISP: |
| 859 | clisp (GNU CLISP) |
| 860 | ecl (Embeddable Common-Lisp) |
| 861 | gcl (GNU Common Lisp) |
| 862 | |
| 863 | lua: |
| 864 | lua (Lua Interpreter) |
| 865 | |
| 866 | Makefile: |
| 867 | gmake (GNU Make) |
| 868 | nmake (Microsoft Program Maintenance Utility) |
| 869 | mingw32-make (MinGW32 Make) |
| 870 | |
| 871 | Markdown: |
| 872 | markdown (text-to-HTML conversion tool) |
| 873 | rdiscount (Discount Markdown Processor for Ruby) |
| 874 | |
| 875 | Object-C: |
| 876 | clang (the Clang C and Objective-C compiler) |
| 877 | gcc (GNU Object-C Compiler) |
| 878 | |
| 879 | Pascal: |
| 880 | fpc (Free Pascal Compiler) |
| 881 | gpc (GNU Pascal Compiler) |
| 882 | |
| 883 | perl: |
| 884 | perl (Perl Interpreter) |
| 885 | |
| 886 | PHP: |
| 887 | php (PHP Command Line Interface 'CLI') |
| 888 | |
| 889 | python: |
| 890 | ironpython (IronPython) |
| 891 | jython (Jython) |
| 892 | pypy (PyPy) |
| 893 | python (Python Interpreter) |
| 894 | python3 (Python 3 Interpreter) |
| 895 | |
| 896 | R: |
| 897 | R (R) |
| 898 | |
| 899 | ruby: |
| 900 | ruby (Ruby Interpreter) |
| 901 | |
| 902 | sh: |
| 903 | ash (Almquist Shell) |
| 904 | bash (Bourne-Again Shell) |
| 905 | dash (Debian Almquist Shell) |
| 906 | ksh (Korn Shell) |
| 907 | sh (Bourne Shell) |
| 908 | zsh (Z Shell) |
| 909 | |
| 910 | tcl: |
| 911 | tclsh (Simple shell containing Tcl interpreter) |
| 912 | |
| 913 | tcsh: |
| 914 | tcsh (TENEX C Shell) |
| 915 | |
| 916 | vb script: |
| 917 | vb (VB Script Interpreter) |
| 918 | |
| 919 | xhtml: |
| 920 | arora (Arora) |
| 921 | chrome (Google Chrome) |
| 922 | epiphany (Epiphany) |
| 923 | firefox (Mozilla Firefox) |
| 924 | ie (Microsoft Internet Explorer) |
| 925 | konqueror (Konqueror) |
| 926 | opera (Opera) |
| 927 | |
| 928 | zsh: |
| 929 | zsh (Z Shell) |
| 930 | |
| 931 | |
| 932 | See |SingleCompile-add-your-compiler| to add your compiler support. |
| 933 | |
| 934 | |
| 935 | SUPPORTINGS~ |
| 936 | *SingleCompile-supporting-plugins* |
| 937 | ---------------------------------------------------------------------------- |
| 938 | There are some supporting code in this plugin for Marc Weber's |
| 939 | vim-addon-actions: |
| 940 | http://github.com/MarcWeber/vim-addon-actions |
| 941 | |
| 942 | |
| 943 | ADVANCED~ |
| 944 | *SingleCompile-advanced* |
| 945 | ---------------------------------------------------------------------------- |
| 946 | This chapter is for advanced users. |
| 947 | |
| 948 | *SingleCompile-custom-compiler-detecting* |
| 949 | SingleCompile allows you to custom compiler detecting function by yourself. |
| 950 | |
| 951 | In |SingleCompile-compiler-template|, the following function is introduced: |
| 952 | > |
| 953 | call SingleCompile#SetCompilerTemplate('filetype', 'compiler', |
| 954 | \'compiler_name', 'command', 'flag', 'run_command') |
| 955 | < |
| 956 | |
| 957 | However, in fact, the function SingleCompile#SetCompilerTemplate could have a |
| 958 | seventh parameter. The seventh parameter is a |Funcref| which references to a |
| 959 | compiler detecting function. The compiler detecting function will be called in |
| 960 | the function SingleCompile#SetCompilerTemplate. The compiler detecting |
| 961 | function must accept one parameter, which would be passed in the "command" |
| 962 | parameter in SingleCompile#SetCompilerTemplate, and return a detected compiler |
| 963 | command if detected, which will be used as the compiling command by |
| 964 | SingleCompile, or returns 0 if the compiler is not detected. Thus, it is more |
| 965 | powerful to detect some compilers. If the seventh parameter is omitted, the |
| 966 | function will use a built-in default compiler detecting function instead. The |
| 967 | default function would check whether the "command" is in PATH, ~/bin, |
| 968 | /usr/local/bin, /usr/bin, /bin on UNIX and whether it is in PATH on other |
| 969 | OSes, and returns the full path of the command if it is not in PATH. If the |
| 970 | command is not detected, the default function would return 0. |
| 971 | |
| 972 | Here is a short example excerpted from built-in template(OpenWatcom detecting |
| 973 | function): |
| 974 | > |
| 975 | function! s:DetectWatcom(compiling_command) |
| 976 | let l:watcom_command = |
| 977 | \SingleCompile#DetectCompilerGenerally(a:compiling_command) |
| 978 | if l:watcom_command != 0 |
| 979 | return l:watcom_command |
| 980 | endif |
| 981 | |
| 982 | if $WATCOM != '' |
| 983 | return $WATCOM.'\binnt\'.a:compiling_command |
| 984 | endif |
| 985 | endfunction |
| 986 | < |
| 987 | SingleCompile#DetectCompilerGenerally is the default compiler detecting |
| 988 | function introduced in the above paragraph. This function first uses a general |
| 989 | way to detect the compiler. If the general way can not detect it, it check the |
| 990 | environment varible "$WATCOM" to get the compiler's installation directory and |
| 991 | get the full path of the compiling program. |
| 992 | |
| 993 | *SingleCompile-predo-postdo* |
| 994 | *SingleCompile-predo* |
| 995 | *SingleCompile-postdo* |
| 996 | *SingleCompile#SetPredo* |
| 997 | *SingleCompile#SetPostdo* |
| 998 | "Predo" and "Postdo" features allow you to initialize the compiler before |
| 999 | compiling and clean up after compiling in you own way. |
| 1000 | |
| 1001 | "Predo" feature allows you to define a function, which would be called before |
| 1002 | compiling by SingleCompile, all by yourself. In the same way, "Postdo" feature |
| 1003 | allows you to define a function called by SingleCompile after compiling. Your |
| 1004 | "Predo" or "Postdo" function should accept one parameter, which would be |
| 1005 | passed in a dictionary containing compiling information, and return a new |
| 1006 | compiling information modified in the function by you. SingleCompile will use |
| 1007 | the new compiling information in its following work. The dictionary passed in |
| 1008 | is like this: > |
| 1009 | {"command": "the-compiling-command", "args": "the-compiling-argument"} |
| 1010 | > |
| 1011 | Then modify the dictionary to meet your need and return the modified |
| 1012 | dictionary. If you don't want to modify the dictionary, please return the |
| 1013 | parameter passed in directly. |
| 1014 | |
| 1015 | The two functions below provide a way to set the "Predo" and "Postdo" |
| 1016 | functions: |
| 1017 | > |
| 1018 | call SingleCompile#SetPredo('filetype', 'compiler', |
| 1019 | \function('your_predo_function')) |
| 1020 | call SingleCompile#SetPostdo('filetype', 'compiler', |
| 1021 | \function('your_postdo_function')) |
| 1022 | < |
| 1023 | |
| 1024 | Example: OpenWatcom's "Predo" and "Postdo" functions: |
| 1025 | > |
| 1026 | " pre-do |
| 1027 | function! s:PredoWatcom(compiling_info) |
| 1028 | let s:old_path = $PATH |
| 1029 | let $PATH = $WATCOM.s:GetPathSeperator().'binnt'.s:GetEnvSeperator(). |
| 1030 | \$WATCOM.s:GetPathSeperator().'binw'.s:GetEnvSeperator(). |
| 1031 | \$PATH |
| 1032 | return a:compiling_info |
| 1033 | endfunction |
| 1034 | |
| 1035 | " post-do |
| 1036 | function! s:PostdoWatcom(compiling_info) " watcom pre-do {{{2 |
| 1037 | let $PATH = s:old_path |
| 1038 | return a:compiling_info |
| 1039 | endfunction |
| 1040 | |
| 1041 | call SingleCompile#SetPredo('c', 'open-watcom', function('s:PredoWatcom')) |
| 1042 | call SingleCompile#SetPostdo('c', 'open-watcom', function('s:PostdoWatcom')) |
| 1043 | < |
| 1044 | As you see, the OpenWatcom "Predo" function first saves the current PATH |
| 1045 | environment varible, then modifies $PATH to meet the OpenWatcom compiler needs. |
| 1046 | It returns the original compiling info because it does not need to modify it. |
| 1047 | The OpenWatcom "Postdo" function restores the original $PATH. After defining |
| 1048 | the two functions, the example calls "SetPredo" and "SetPostdo" function to |
| 1049 | set the functions as the "Predo" function and "Postdo" function for |
| 1050 | corresponding language and compiler. |
| 1051 | |
| 1052 | |
| 1053 | To make it less confusing, I better explain the calling order here. The |
| 1054 | calling order is: first the compiler detecting function, then "Predo" |
| 1055 | function, then compile, and the last is the "Postdo" function. |
| 1056 | |
| 1057 | *SingleCompile-vim-compiler* |
| 1058 | *SingleCompile#SetVimCompiler* |
| 1059 | SingleCompile can work with the compiler feature of vim(see |:compiler|). To |
| 1060 | set the compiler file in the compiler direcotry for a compiler, use |
| 1061 | SingleCompile#SetVimCompiler function. For example, for g77, the GNU Fortran |
| 1062 | 77 compiler, use the following line to set the compiler file for g77: |
| 1063 | > |
| 1064 | call SingleCompile#SetVimCompiler('fortran', 'g77', 'fortran_g77') |
| 1065 | < |
| 1066 | (This line is excerpted from the built-in templates.) |
| 1067 | |
| 1068 | Then if we are using g77 as our compiler, SingleCompile will first execute |
| 1069 | ":compiler fortran_g77" before compiling the source file. This will give us |
| 1070 | the advantage that vim's quickfix will recognize the messages output by g77 |
| 1071 | and help us locate these errors quickly. |
| 1072 | |
| 1073 | *SingleCompile-priority* |
| 1074 | *SingleCompile#SetPriority* |
| 1075 | Since version 2.9, every compiler template could be assigned a priority value. |
| 1076 | This value determines which compiler to use when seversal compilers has been |
| 1077 | detected. Use the following line to set a compiler's priority: |
| 1078 | > |
| 1079 | call SingleCompile#SetPriority('language_name', 'compiler_name', priority) |
| 1080 | < |
| 1081 | The parameter "priority" is an integer. The less the parameter "priority" is, |
| 1082 | the higher priority the compiler has. For example, the following two lines set |
| 1083 | two Fortran compilers' priorities (The two lines are excerpted from the |
| 1084 | built-in template): |
| 1085 | > |
| 1086 | call SingleCompile#SetPriority('fortran', 'gfortran', 70) |
| 1087 | call SingleCompile#SetPriority('fortran', 'ifort', 80) |
| 1088 | < |
| 1089 | After executing the two lines above, if ifort (which is Intel Fortran |
| 1090 | Compiler) and gfortran (GNU fortran compiler) are both detected by |
| 1091 | SingleCompile, and the user does not call |SingleCompile#ChooseCompiler| to |
| 1092 | choose a compiler explicitly, SingleCompile will choose gfortran as the |
| 1093 | current compiler. |
| 1094 | |
| 1095 | CREDITS~ |
| 1096 | *SingleCompile-credits* |
| 1097 | ---------------------------------------------------------------------------- |
| 1098 | Marc Weber Integrated SingleCompile with vim-addon-actions, and some other |
| 1099 | improvements |
| 1100 | Darek Fixed a directory switching bug |
| 1101 | sky hi Provided DMD compiler for D language built-in template |
| 1102 | Zhou Yichao Made several improvements and fixed several bugs. |
| 1103 | |
| 1104 | |
| 1105 | TODO~ |
| 1106 | *SingleCompile-todo* |
| 1107 | ---------------------------------------------------------------------------- |
| 1108 | Add asynchronous compilation support. |
| 1109 | |
| 1110 | Add matlab built-in template. |
| 1111 | |
| 1112 | If "tee" is used when we are executing ":make" command, currently we can't get |
| 1113 | the exit code of the compiler. We need to fix this. |
| 1114 | |
| 1115 | When running compiled program, if "tee" is used for redirecting, things |
| 1116 | written to stdout are not printed as if what happens when stdout is a tty. |
| 1117 | This need to be fixed. |
| 1118 | |
| 1119 | Make it possible to store compiler template in config files, such as ini |
| 1120 | files. |
| 1121 | |
| 1122 | Reduce startup time and shrink memory use. |
| 1123 | |
| 1124 | vim:ts=4:ft=help:tw=78:et |