From 3c07df5dfc49d5576577ff9ff5a0328bcc113b07 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Wed, 23 Apr 2014 14:45:21 +0300 Subject: [PATCH] Cleanup: lock some variables. --- autoload/syntastic/log.vim | 2 ++ autoload/syntastic/util.vim | 1 + plugin/syntastic.vim | 25 +++++++++++++++++++------ plugin/syntastic/highlighting.vim | 2 ++ plugin/syntastic/notifiers.vim | 1 + plugin/syntastic/registry.vim | 2 ++ plugin/syntastic/signs.vim | 3 ++- syntax_checkers/html/tidy.vim | 4 ++++ syntax_checkers/sass/sass.vim | 1 + 9 files changed, 34 insertions(+), 7 deletions(-) diff --git a/autoload/syntastic/log.vim b/autoload/syntastic/log.vim index 05a3d24e4..38aa28744 100644 --- a/autoload/syntastic/log.vim +++ b/autoload/syntastic/log.vim @@ -113,6 +113,7 @@ function! s:isDebugEnabled_dumb(level) " {{{2 endfunction " }}}2 let s:isDebugEnabled = function(exists('*and') ? 's:isDebugEnabled_smart' : 's:isDebugEnabled_dumb') +lockvar s:isDebugEnabled function! s:logRedirect(on) " {{{2 if exists("g:syntastic_debug_file") @@ -138,6 +139,7 @@ function! s:logTimestamp_dumb() " {{{2 endfunction " }}}2 let s:logTimestamp = function(has('reltime') ? 's:logTimestamp_smart' : 's:logTimestamp_dumb') +lockvar s:logTimestamp function! s:formatVariable(name) " {{{2 let vals = [] diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim index d4fa034b6..b4b900b1a 100644 --- a/autoload/syntastic/util.vim +++ b/autoload/syntastic/util.vim @@ -88,6 +88,7 @@ endfunction " }}}2 " strwidth() was added in Vim 7.3; if it doesn't exist, we use strlen() " and hope for the best :) let s:width = function(exists('*strwidth') ? 'strwidth' : 'strlen') +lockvar s:width "print as much of a:msg as possible without "Press Enter" prompt appearing function! syntastic#util#wideMsg(msg) " {{{2 diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index d18a8ff7a..c57fa686f 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -16,9 +16,11 @@ let g:loaded_syntastic_plugin = 1 if has('reltime') let g:syntastic_start = reltime() + lockvar! g:syntastic_start endif -let g:syntastic_version = '3.4.0-43' +let g:syntastic_version = '3.4.0-44' +lockvar g:syntastic_version " Sanity checks {{{1 @@ -30,6 +32,8 @@ for s:feature in ['autocmd', 'eval', 'modify_fname', 'quickfix', 'user_commands' endfor let s:running_windows = syntastic#util#isRunningWindows() +lockvar s:running_windows + if !s:running_windows && executable('uname') try let s:uname = system('uname') @@ -37,6 +41,7 @@ if !s:running_windows && executable('uname') call syntastic#log#error("your shell " . &shell . " doesn't use traditional UNIX syntax for redirections") finish endtry + lockvar s:uname endif " }}}1 @@ -70,6 +75,7 @@ let g:syntastic_defaults = { \ 'style_warning_symbol': 'S>', \ 'warning_symbol': '>>' \ } +lockvar! g:syntastic_defaults for s:key in keys(g:syntastic_defaults) if !exists('g:syntastic_' . s:key) @@ -106,13 +112,19 @@ let s:debug_dump_options = [ if v:version > 703 || (v:version == 703 && has('patch446')) call add(s:debug_dump_options, 'shellxescape') endif +lockvar! s:debug_dump_options " debug constants -let g:SyntasticDebugTrace = 1 -let g:SyntasticDebugLoclist = 2 -let g:SyntasticDebugNotifications = 4 -let g:SyntasticDebugAutocommands = 8 -let g:SyntasticDebugVariables = 16 +let g:SyntasticDebugTrace = 1 +lockvar g:SyntasticDebugTrace +let g:SyntasticDebugLoclist = 2 +lockvar g:SyntasticDebugLoclist +let g:SyntasticDebugNotifications = 4 +lockvar g:SyntasticDebugNotifications +let g:SyntasticDebugAutocommands = 8 +lockvar g:SyntasticDebugAutocommands +let g:SyntasticDebugVariables = 16 +lockvar g:SyntasticDebugVariables " }}}1 @@ -554,6 +566,7 @@ endfunction " }}}2 function! s:uname() " {{{2 if !exists('s:uname') let s:uname = system('uname') + lockvar s:uname endif return s:uname endfunction " }}}2 diff --git a/plugin/syntastic/highlighting.vim b/plugin/syntastic/highlighting.vim index 997b2e32d..85f3d2284 100644 --- a/plugin/syntastic/highlighting.vim +++ b/plugin/syntastic/highlighting.vim @@ -5,6 +5,7 @@ let g:loaded_syntastic_notifier_highlighting = 1 " Highlighting requires getmatches introduced in 7.1.040 let s:has_highlighting = v:version > 701 || (v:version == 701 && has('patch040')) +lockvar s:has_highlighting let g:SyntasticHighlightingNotifier = {} @@ -18,6 +19,7 @@ function! g:SyntasticHighlightingNotifier.New() " {{{2 if !s:setup_done call self._setup() let s:setup_done = 1 + lockvar s:setup_done endif return newObj diff --git a/plugin/syntastic/notifiers.vim b/plugin/syntastic/notifiers.vim index c268c19b5..62821cde0 100644 --- a/plugin/syntastic/notifiers.vim +++ b/plugin/syntastic/notifiers.vim @@ -6,6 +6,7 @@ let g:loaded_syntastic_notifiers = 1 let g:SyntasticNotifiers = {} let s:notifier_types = ['signs', 'balloons', 'highlighting', 'cursor', 'autoloclist'] +lockvar! s:notifier_types " Public methods {{{1 diff --git a/plugin/syntastic/registry.vim b/plugin/syntastic/registry.vim index 72ba93ad6..7d6274262 100644 --- a/plugin/syntastic/registry.vim +++ b/plugin/syntastic/registry.vim @@ -89,12 +89,14 @@ let s:defaultCheckers = { \ 'zpt': ['zptlint'], \ 'zsh': ['zsh', 'shellcheck'] \ } +lockvar! s:defaultCheckers let s:defaultFiletypeMap = { \ 'gentoo-metadata': 'xml', \ 'lhaskell': 'haskell', \ 'litcoffee': 'coffee' \ } +lockvar! s:defaultFiletypeMap let g:SyntasticRegistry = {} diff --git a/plugin/syntastic/signs.vim b/plugin/syntastic/signs.vim index 9c860da24..7acd78242 100644 --- a/plugin/syntastic/signs.vim +++ b/plugin/syntastic/signs.vim @@ -25,6 +25,7 @@ function! g:SyntasticSignsNotifier.New() " {{{2 if !s:setup_done call self._setup() let s:setup_done = 1 + lockvar s:setup_done endif return newObj @@ -41,7 +42,7 @@ function! g:SyntasticSignsNotifier.refresh(loclist) " {{{2 call self._signErrors(a:loclist) endif call self._removeSigns(old_signs) - let s:first_sign_id = s:next_sign_id + let s:first_sign_id = exists('s:next_sign_id') ? s:next_sign_id : 5000 endfunction " }}}2 " }}}1 diff --git a/syntax_checkers/html/tidy.vim b/syntax_checkers/html/tidy.vim index 67dab6051..c13451c3a 100644 --- a/syntax_checkers/html/tidy.vim +++ b/syntax_checkers/html/tidy.vim @@ -123,6 +123,7 @@ let s:ignore_errors = [ \ "proprietary attribute \"aria-valuenow\"", \ "proprietary attribute \"aria-valuetext\"" \ ] +lockvar! s:ignore_errors let s:blocklevel_tags = [ \ "main", @@ -135,6 +136,7 @@ let s:blocklevel_tags = [ \ "figure", \ "figcaption" \ ] +lockvar! s:blocklevel_tags let s:inline_tags = [ \ "video", @@ -153,11 +155,13 @@ let s:inline_tags = [ \ "details", \ "datalist" \ ] +lockvar! s:inline_tags let s:empty_tags = [ \ "wbr", \ "keygen" \ ] +lockvar! s:empty_tags function! s:IgnoreError(text) for i in s:ignore_errors + g:syntastic_html_tidy_ignore_errors diff --git a/syntax_checkers/sass/sass.vim b/syntax_checkers/sass/sass.vim index 353c1a93c..a515fe5f2 100644 --- a/syntax_checkers/sass/sass.vim +++ b/syntax_checkers/sass/sass.vim @@ -18,6 +18,7 @@ let g:loaded_syntastic_sass_sass_checker = 1 "sass caching for large files drastically speeds up the checking, but store it "in a temp location otherwise sass puts .sass_cache dirs in the users project let s:sass_cache_location = tempname() +lockvar s:sass_cache_location "By default do not check partials as unknown variables are a syntax error if !exists("g:syntastic_sass_check_partials")