summaryrefslogtreecommitdiffstats
path: root/tools/vim
diff options
context:
space:
mode:
authorscottmg@google.com <scottmg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-04 21:58:19 +0000
committerscottmg@google.com <scottmg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-04 21:58:19 +0000
commitfa444c2c575d016587c869672df9aee2696043cd (patch)
tree6ddf8477b843608d0d4405254e8451a3c4df57fe /tools/vim
parentf121003b1a1dc30ec9607fc8053e01f6fcbb2773 (diff)
downloadchromium_src-fa444c2c575d016587c869672df9aee2696043cd.zip
chromium_src-fa444c2c575d016587c869672df9aee2696043cd.tar.gz
chromium_src-fa444c2c575d016587c869672df9aee2696043cd.tar.bz2
improve tools/vim/ninja-build.vim for Windows
Get compile-file ninja build command to run properly, bind to Ctrl-F7 by default, and only do a redraw when not using gui (Windows spawns in a separate window so it's unnecessary flicker). R=thakis@chromium.org Review URL: https://chromiumcodereview.appspot.com/10382020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135452 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/vim')
-rw-r--r--tools/vim/ninja-build.vim15
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/vim/ninja-build.vim b/tools/vim/ninja-build.vim
index 21f2e33..7f60663 100644
--- a/tools/vim/ninja-build.vim
+++ b/tools/vim/ninja-build.vim
@@ -3,7 +3,7 @@
" found in the LICENSE file.
"
" Adds a "Compile this file" function, using ninja. On Mac, binds Cmd-k to
-" this command.
+" this command. On Windows, Ctrl-F7 (which is the same as the VS default).
"
" Requires that gyp has already generated build.ninja files, and that ninja is
" in your path (which it is automatically if depot_tools is in your path).
@@ -70,14 +70,20 @@ def compute_ninja_command(configuration=None):
def set_makepgr_to_single_file_ninja():
- vim.command('let &makeprg="%s"' % compute_ninja_command())
+ build_cmd = compute_ninja_command()
+ if sys.platform == 'win32':
+ # Escape \ for Vim, and ^ for both Vim and shell.
+ build_cmd = build_cmd.replace('\\', '\\\\').replace('^', '^^^^')
+ vim.command('let &makeprg=\'%s\'' % build_cmd)
endpython
fun! CrCompileFile()
let l:oldmakepgr = &makeprg
python set_makepgr_to_single_file_ninja()
silent make | cwindow
- redraw!
+ if !has('gui')
+ redraw!
+ endif
let &makeprg = l:oldmakepgr
endfun
@@ -86,5 +92,8 @@ command! CrCompileFile call CrCompileFile()
if has('mac')
map <D-k> :CrCompileFile<cr>
imap <D-k> <esc>:CrCompileFile<cr>
+elseif has('win32')
+ map <C-F7> :CrCompileFile<cr>
+ imap <C-F7> <esc>:CrCompileFile<cr>
endif
" TODO(linuxuser): Suggest a keyboard shortcut and send review to thakis@.