tomtom / checksyntax_vim

Check a file's syntax when saving a file (php, ruby, tex ...) with vim
http://www.vim.org/scripts/script.php?script_id=1431
GNU General Public License v3.0
94 stars 9 forks source link

g:checksyntax#auto_mode only sets default 'auto' setting, but doesn't stop CheckSyntax from checking in all cases #12

Closed fidian closed 12 years ago

fidian commented 12 years ago

g:checksyntax#auto_mode really doesn't do what I'm expecting. The PHP syntax checker has its own 'auto' setting and I can't override that by changing g:checksyntax#auto_mode. Here's what I've added to my .vimrc:

" Turning off auto syntax checking
let g:checksyntax#auto_mode = 1
function ToggleSyntaxCheck()
    if g:checksyntax#auto_mode != 0
        let g:checksyntax#auto_mode = 0
        echo "Toggling auto syntax check: disabled"
    else
        let g:checksyntax#auto_mode = 1
        echo "Toggling auto syntax check: enabled"
    endif
endfunction
map <F5> :call ToggleSyntaxCheck()<CR>

When I work on files that don't have their own 'auto' setting, everything now works as expected, such as editing .js files and checking with jsl. However, when I work on PHP files, they are always syntax checked. The auto_mode variable looks like it would set a default "auto check" setting (like it would be for a prototype), but this still doesn't toggle whether or not CheckSyntax is supposed to run when I save. I could have g:checksyntax#enabled = 1 by default and modify checksyntax#Check to look for that variable. Is this the approach you'd suggest?