Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enable syntax checks when loading a file (disabled by default)

  • Loading branch information...
commit 44913142a1182040678275ba8a9c9d26c54b8ccf 1 parent 4d99d5a
@tomtom authored
Showing with 37 additions and 14 deletions.
  1. +26 −8 autoload/checksyntax.vim
  2. +11 −6 plugin/checksyntax.vim
View
34 autoload/checksyntax.vim
@@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2010-01-03.
-" @Last Change: 2012-01-03.
-" @Revision: 308
+" @Last Change: 2012-02-10.
+" @Revision: 340
if !exists('g:checksyntax#failrx')
@@ -213,8 +213,9 @@ endif
if !exists('*CheckSyntaxFail')
" This function is called when a syntax error was found.
- function! CheckSyntaxFail(type, manually)
- call g:checksyntax#prototypes[a:type].Open()
+ function! CheckSyntaxFail(type, manually, bg)
+ " TLogVAR a:type, a:manually, a:bg
+ call g:checksyntax#prototypes[a:type].Open(a:bg)
endf
endif
@@ -225,8 +226,12 @@ function! g:checksyntax#prototypes.loc.Close() dict "{{{3
lclose
endf
-function! g:checksyntax#prototypes.loc.Open() dict "{{{3
+function! g:checksyntax#prototypes.loc.Open(bg) dict "{{{3
+ " TLogVAR a:bg
lopen
+ if a:bg
+ wincmd p
+ endif
endf
function! g:checksyntax#prototypes.loc.Make(args) dict "{{{3
@@ -246,8 +251,11 @@ function! g:checksyntax#prototypes.qfl.Close() dict "{{{3
cclose
endf
-function! g:checksyntax#prototypes.qfl.Open() dict "{{{3
+function! g:checksyntax#prototypes.qfl.Open(bg) dict "{{{3
copen
+ if a:bg
+ wincmd p
+ endif
endf
function! g:checksyntax#prototypes.qfl.Make(args) dict "{{{3
@@ -346,10 +354,12 @@ function! s:GetDef(ft) "{{{3
endf
-" :def: function! checksyntax#Check(manually, ?bang='', ?type=&ft)
+" :def: function! checksyntax#Check(manually, ?bang='', ?type=&ft, ?background=1)
function! checksyntax#Check(manually, ...)
let bang = a:0 >= 1 && a:1 != '' ? 1 : 0
let ft = a:0 >= 2 && a:2 != '' ? a:2 : &filetype
+ let bg = a:0 >= 3 && a:3 != '' ? a:3 : 0
+ " TLogVAR a:manually, bang, ft, bg
let def = a:manually ? {} : s:GetDef(ft .',auto')
if empty(def)
let def = s:GetDef(ft)
@@ -376,6 +386,11 @@ function! checksyntax#Check(manually, ...)
if !(a:manually || auto)
return
endif
+ if !exists('b:checksyntax_runs')
+ let b:checksyntax_runs = 1
+ else
+ let b:checksyntax_runs += 1
+ endif
" TLogVAR &makeprg, &l:makeprg, &g:makeprg, &errorformat
exec get(def, 'prepare', '')
if s:Make(def)
@@ -391,7 +406,10 @@ function! checksyntax#Check(manually, ...)
if len(list) == 0
call CheckSyntaxSucceed(type, a:manually)
else
- call CheckSyntaxFail(type, a:manually)
+ " TLogVAR type
+ " TLogVAR a:manually
+ " TLogVAR bg
+ call CheckSyntaxFail(type, a:manually, bg)
endif
endif
endf
View
17 plugin/checksyntax.vim
@@ -2,9 +2,9 @@
" @Author: Tom Link (micathom AT gmail com)
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 04-Mai-2005.
-" @Last Change: 2011-05-26.
+" @Last Change: 2012-02-10.
" GetLatestVimScripts: 1431 0 :AutoInstall: checksyntax.vim
-" @Revision: 396
+" @Revision: 407
if exists('g:loaded_checksyntax')
finish
@@ -12,19 +12,24 @@ endif
let g:loaded_checksyntax = 103
-" @TPluginInclude
if !exists('g:checksyntax_auto')
- " If non-null, enable automatic syntax checks after saving a file.
+ " If 1, enable automatic syntax checks after saving a file.
+ " If 2, enable automatic syntax checks when saving and loading a
+ " file.
let g:checksyntax_auto = 1
endif
-" @TPluginInclude
augroup CheckSyntax
autocmd!
- if g:checksyntax_auto
+ if g:checksyntax_auto >= 1
autocmd CheckSyntax BufWritePost * call checksyntax#Check(0)
endif
+ if g:checksyntax_auto >= 2
+ autocmd CheckSyntax BufEnter * if !exists('b:checksyntax_runs')
+ \ | call checksyntax#Check(0, 0, &ft, 1)
+ \ | endif
+ endif
augroup END
Please sign in to comment.
Something went wrong with that request. Please try again.