1
0
Fork 0
mirror of synced 2024-06-15 13:31:10 -04:00
ultimate-vim/sources_non_forked/syntastic/plugin/syntastic/modemap.vim
amix 0d8e7370bd Added vim-commentary and updarted the plugins.
commentary:
Comment stuff out.  Use `gcc` to comment out a line (takes a count),
`gc` to comment out the target of a motion (for example, `gcap` to
comment out a paragraph), and `gc` in visual mode to comment out the
selection.  That's it.
2014-03-02 14:35:00 +00:00

80 lines
2.2 KiB
VimL

if exists("g:loaded_syntastic_modemap") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_modemap = 1
let g:SyntasticModeMap = {}
" Public methods {{{1
function! g:SyntasticModeMap.Instance() " {{{2
if !exists('s:SyntasticModeMapInstance')
let s:SyntasticModeMapInstance = copy(self)
call s:SyntasticModeMapInstance.synch()
endif
return s:SyntasticModeMapInstance
endfunction " }}}2
function! g:SyntasticModeMap.synch() " {{{2
if exists('g:syntastic_mode_map')
let self._mode = get(g:syntastic_mode_map, 'mode', 'active')
let self._activeFiletypes = get(g:syntastic_mode_map, 'active_filetypes', [])
let self._passiveFiletypes = get(g:syntastic_mode_map, 'passive_filetypes', [])
else
let self._mode = 'active'
let self._activeFiletypes = []
let self._passiveFiletypes = []
endif
endfunction " }}}2
function! g:SyntasticModeMap.allowsAutoChecking(filetype) " {{{2
let fts = split(a:filetype, '\m\.')
if self.isPassive()
return self._isOneFiletypeActive(fts)
else
return self._noFiletypesArePassive(fts)
endif
endfunction " }}}2
function! g:SyntasticModeMap.isPassive() " {{{2
return self._mode ==# 'passive'
endfunction " }}}2
function! g:SyntasticModeMap.toggleMode() " {{{2
call self.synch()
if self._mode ==# 'active'
let self._mode = 'passive'
else
let self._mode = 'active'
endif
"XXX Changing a global variable. Tsk, tsk...
if !exists('g:syntastic_mode_map')
let g:syntastic_mode_map = {}
endif
let g:syntastic_mode_map['mode'] = self._mode
endfunction " }}}2
function! g:SyntasticModeMap.echoMode() " {{{2
echo "Syntastic: " . self._mode . " mode enabled"
endfunction " }}}2
" }}}1
" Private methods {{{1
function! g:SyntasticModeMap._isOneFiletypeActive(filetypes) " {{{2
return !empty(filter(copy(a:filetypes), 'index(self._activeFiletypes, v:val) != -1'))
endfunction " }}}2
function! g:SyntasticModeMap._noFiletypesArePassive(filetypes) " {{{2
return empty(filter(copy(a:filetypes), 'index(self._passiveFiletypes, v:val) != -1'))
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker: