1
0
Fork 0
mirror of synced 2024-11-18 23:05:34 -05:00
ultimate-vim/sources_non_forked/syntactic/plugin/syntastic/modemap.vim

80 lines
2.2 KiB
VimL
Raw Normal View History

2014-09-10 12:00:14 -04:00
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: