1
0
mirror of https://github.com/amix/vimrc synced 2025-07-10 03:25:00 +08:00

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.
This commit is contained in:
amix
2014-03-02 14:35:00 +00:00
parent 8c9210dca4
commit 0d8e7370bd
56 changed files with 1330 additions and 873 deletions

View File

@ -1,40 +1,38 @@
if exists("g:loaded_syntastic_notifier_autoloclist")
if exists("g:loaded_syntastic_notifier_autoloclist") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_notifier_autoloclist = 1
if !exists("g:syntastic_auto_loc_list")
let g:syntastic_auto_loc_list = 2
endif
let g:SyntasticAutoloclistNotifier = {}
" Public methods {{{1
"
function! g:SyntasticAutoloclistNotifier.New()
function! g:SyntasticAutoloclistNotifier.New() " {{{2
let newObj = copy(self)
return newObj
endfunction
endfunction " }}}2
function! g:SyntasticAutoloclistNotifier.refresh(loclist)
function! g:SyntasticAutoloclistNotifier.refresh(loclist) " {{{2
call syntastic#log#debug(g:SyntasticDebugNotifications, 'autoloclist: refresh')
call g:SyntasticAutoloclistNotifier.AutoToggle(a:loclist)
endfunction
endfunction " }}}2
function! g:SyntasticAutoloclistNotifier.AutoToggle(loclist)
function! g:SyntasticAutoloclistNotifier.AutoToggle(loclist) " {{{2
call syntastic#log#debug(g:SyntasticDebugNotifications, 'autoloclist: toggle')
if !a:loclist.isEmpty()
if g:syntastic_auto_loc_list == 1
if syntastic#util#var('auto_loc_list') == 1
call a:loclist.show()
endif
else
if g:syntastic_auto_loc_list > 0
if syntastic#util#var('auto_loc_list') > 0
"TODO: this will close the loc list window if one was opened by
"something other than syntastic
lclose
endif
endif
endfunction
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,12 +1,8 @@
if exists("g:loaded_syntastic_notifier_balloons")
if exists("g:loaded_syntastic_notifier_balloons") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_notifier_balloons = 1
if !exists("g:syntastic_enable_balloons")
let g:syntastic_enable_balloons = 1
endif
if !has('balloon_eval')
let g:syntastic_enable_balloons = 0
endif
@ -15,17 +11,17 @@ let g:SyntasticBalloonsNotifier = {}
" Public methods {{{1
function! g:SyntasticBalloonsNotifier.New()
function! g:SyntasticBalloonsNotifier.New() " {{{2
let newObj = copy(self)
return newObj
endfunction
endfunction " }}}2
function! g:SyntasticBalloonsNotifier.enabled()
function! g:SyntasticBalloonsNotifier.enabled() " {{{2
return has('balloon_eval') && syntastic#util#var('enable_balloons')
endfunction
endfunction " }}}2
" Update the error balloons
function! g:SyntasticBalloonsNotifier.refresh(loclist)
function! g:SyntasticBalloonsNotifier.refresh(loclist) " {{{2
let b:syntastic_balloons = {}
if self.enabled() && !a:loclist.isEmpty()
call syntastic#log#debug(g:SyntasticDebugNotifications, 'balloons: refresh')
@ -42,25 +38,29 @@ function! g:SyntasticBalloonsNotifier.refresh(loclist)
set beval bexpr=SyntasticBalloonsExprNotifier()
endif
endif
endfunction
endfunction " }}}2
" Reset the error balloons
" @vimlint(EVL103, 1, a:loclist)
function! g:SyntasticBalloonsNotifier.reset(loclist)
function! g:SyntasticBalloonsNotifier.reset(loclist) " {{{2
if has('balloon_eval')
call syntastic#log#debug(g:SyntasticDebugNotifications, 'balloons: reset')
set nobeval
endif
endfunction
endfunction " }}}2
" @vimlint(EVL103, 0, a:loclist)
" }}}1
" Private functions {{{1
function! SyntasticBalloonsExprNotifier()
function! SyntasticBalloonsExprNotifier() " {{{2
if !exists('b:syntastic_balloons')
return ''
endif
return get(b:syntastic_balloons, v:beval_lnum, '')
endfunction
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,4 +1,4 @@
if exists("g:loaded_syntastic_checker")
if exists("g:loaded_syntastic_checker") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_checker = 1
@ -7,7 +7,7 @@ let g:SyntasticChecker = {}
" Public methods {{{1
function! g:SyntasticChecker.New(args)
function! g:SyntasticChecker.New(args) " {{{2
let newObj = copy(self)
let newObj._filetype = a:args['filetype']
@ -34,29 +34,29 @@ function! g:SyntasticChecker.New(args)
endif
return newObj
endfunction
endfunction " }}}2
function! g:SyntasticChecker.getFiletype()
function! g:SyntasticChecker.getFiletype() " {{{2
return self._filetype
endfunction
endfunction " }}}2
function! g:SyntasticChecker.getName()
function! g:SyntasticChecker.getName() " {{{2
return self._name
endfunction
endfunction " }}}2
function! g:SyntasticChecker.getExec()
function! g:SyntasticChecker.getExec() " {{{2
if exists('g:syntastic_' . self._filetype . '_' . self._name . '_exec')
return expand(g:syntastic_{self._filetype}_{self._name}_exec)
endif
return self._exec
endfunction
endfunction " }}}2
function! g:SyntasticChecker.getExecEscaped()
function! g:SyntasticChecker.getExecEscaped() " {{{2
return syntastic#util#shescape(self.getExec())
endfunction
endfunction " }}}2
function! g:SyntasticChecker.getLocListRaw()
function! g:SyntasticChecker.getLocListRaw() " {{{2
let name = self._filetype . '/' . self._name
try
let list = self._locListFunc()
@ -69,13 +69,13 @@ function! g:SyntasticChecker.getLocListRaw()
call syntastic#log#debug(g:SyntasticDebugLoclist, name . ' raw:', list)
call self._quietMessages(list)
return list
endfunction
endfunction " }}}2
function! g:SyntasticChecker.getLocList()
function! g:SyntasticChecker.getLocList() " {{{2
return g:SyntasticLoclist.New(self.getLocListRaw())
endfunction
endfunction " }}}2
function! g:SyntasticChecker.makeprgBuild(opts)
function! g:SyntasticChecker.makeprgBuild(opts) " {{{2
let basename = self._filetype . '_' . self._name . '_'
let parts = []
@ -86,23 +86,42 @@ function! g:SyntasticChecker.makeprgBuild(opts)
call extend(parts, self._getOpt(a:opts, basename, 'tail', ''))
return join(parts)
endfunction
endfunction " }}}2
function! g:SyntasticChecker.isAvailable()
function! g:SyntasticChecker.isAvailable() " {{{2
return self._isAvailableFunc()
endfunction
endfunction " }}}2
" }}}1
" Private methods {{{1
function! g:SyntasticChecker._quietMessages(errors)
let filter = 'g:syntastic_' . self._filetype . '_' . self._name . '_quiet_messages'
if exists(filter) && type({filter}) == type({}) && !empty({filter})
call syntastic#util#dictFilter(a:errors, {filter})
call syntastic#log#debug(g:SyntasticDebugLoclist, 'filtered by ' . filter . ':', a:errors)
function! g:SyntasticChecker._quietMessages(errors) " {{{2
" wildcard quiet_messages
let quiet_filters = copy(syntastic#util#var('quiet_messages', {}))
if type(quiet_filters) != type({})
call syntastic#log#warn('ignoring invalid syntastic_quiet_messages')
unlet quiet_filters
let quiet_filters = {}
endif
endfunction
function! g:SyntasticChecker._populateHighlightRegexes(errors)
" per checker quiet_messages
let name = self._filetype . '_' . self._name
try
call extend( quiet_filters, copy(syntastic#util#var(name . '_quiet_messages', {})), 'force' )
catch /\m^Vim\%((\a\+)\)\=:E712/
call syntastic#log#warn('ignoring invalid syntastic_' . name . '_quiet_messages')
endtry
call syntastic#log#debug(g:SyntasticDebugLoclist, 'quiet_messages filter:', quiet_filters)
if !empty(quiet_filters)
call syntastic#util#dictFilter(a:errors, quiet_filters)
call syntastic#log#debug(g:SyntasticDebugLoclist, 'filtered by quiet_messages:', a:errors)
endif
endfunction " }}}2
function! g:SyntasticChecker._populateHighlightRegexes(errors) " {{{2
if has_key(self, '_highlightRegexFunc')
for e in a:errors
if e['valid']
@ -113,9 +132,9 @@ function! g:SyntasticChecker._populateHighlightRegexes(errors)
endif
endfor
endif
endfunction
endfunction " }}}2
function! g:SyntasticChecker._getOpt(opts, basename, name, default)
function! g:SyntasticChecker._getOpt(opts, basename, name, default) " {{{2
let user_val = syntastic#util#var(a:basename . a:name)
let ret = []
call extend( ret, self._shescape(get(a:opts, a:name . '_before', '')) )
@ -123,9 +142,9 @@ function! g:SyntasticChecker._getOpt(opts, basename, name, default)
call extend( ret, self._shescape(get(a:opts, a:name . '_after', '')) )
return ret
endfunction
endfunction " }}}2
function! g:SyntasticChecker._shescape(opt)
function! g:SyntasticChecker._shescape(opt) " {{{2
if type(a:opt) == type('') && a:opt != ''
return [a:opt]
elseif type(a:opt) == type([])
@ -133,12 +152,16 @@ function! g:SyntasticChecker._shescape(opt)
endif
return []
endfunction
endfunction " }}}2
" }}}1
" Non-method functions {{{1
function! SyntasticCheckerIsAvailableDefault() dict
function! SyntasticCheckerIsAvailableDefault() dict " {{{2
return executable(self.getExec())
endfunction
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,26 +1,22 @@
if exists("g:loaded_syntastic_notifier_cursor")
if exists("g:loaded_syntastic_notifier_cursor") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_notifier_cursor = 1
if !exists('g:syntastic_echo_current_error')
let g:syntastic_echo_current_error = 1
endif
let g:SyntasticCursorNotifier = {}
" Public methods {{{1
function! g:SyntasticCursorNotifier.New()
function! g:SyntasticCursorNotifier.New() " {{{2
let newObj = copy(self)
return newObj
endfunction
endfunction " }}}2
function! g:SyntasticCursorNotifier.enabled()
function! g:SyntasticCursorNotifier.enabled() " {{{2
return syntastic#util#var('echo_current_error')
endfunction
endfunction " }}}2
function! g:SyntasticCursorNotifier.refresh(loclist)
function! g:SyntasticCursorNotifier.refresh(loclist) " {{{2
if self.enabled() && !a:loclist.isEmpty()
call syntastic#log#debug(g:SyntasticDebugNotifications, 'cursor: refresh')
let b:syntastic_messages = copy(a:loclist.messages(bufnr('')))
@ -28,21 +24,23 @@ function! g:SyntasticCursorNotifier.refresh(loclist)
autocmd! syntastic CursorMoved
autocmd syntastic CursorMoved * call g:SyntasticRefreshCursor()
endif
endfunction
endfunction " }}}2
" @vimlint(EVL103, 1, a:loclist)
function! g:SyntasticCursorNotifier.reset(loclist)
function! g:SyntasticCursorNotifier.reset(loclist) " {{{2
call syntastic#log#debug(g:SyntasticDebugNotifications, 'cursor: reset')
autocmd! syntastic CursorMoved
unlet! b:syntastic_messages
let b:oldLine = -1
endfunction
endfunction " }}}2
" @vimlint(EVL103, 0, a:loclist)
" }}}1
" Private methods {{{1
" The following defensive nonsense is needed because of the nature of autocmd
function! g:SyntasticRefreshCursor()
function! g:SyntasticRefreshCursor() " {{{2
if !exists('b:syntastic_messages') || empty(b:syntastic_messages)
" file not checked
return
@ -62,6 +60,8 @@ function! g:SyntasticRefreshCursor()
else
echo
endif
endfunction
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,4 +1,4 @@
if exists("g:loaded_syntastic_notifier_highlighting")
if exists("g:loaded_syntastic_notifier_highlighting") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_notifier_highlighting = 1
@ -6,17 +6,13 @@ 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'))
if !exists("g:syntastic_enable_highlighting")
let g:syntastic_enable_highlighting = 1
endif
let g:SyntasticHighlightingNotifier = {}
let s:setup_done = 0
" Public methods {{{1
function! g:SyntasticHighlightingNotifier.New()
function! g:SyntasticHighlightingNotifier.New() " {{{2
let newObj = copy(self)
if !s:setup_done
@ -25,14 +21,14 @@ function! g:SyntasticHighlightingNotifier.New()
endif
return newObj
endfunction
endfunction " }}}2
function! g:SyntasticHighlightingNotifier.enabled()
function! g:SyntasticHighlightingNotifier.enabled() " {{{2
return s:has_highlighting && syntastic#util#var('enable_highlighting')
endfunction
endfunction " }}}2
" Sets error highlights in the cuirrent window
function! g:SyntasticHighlightingNotifier.refresh(loclist)
function! g:SyntasticHighlightingNotifier.refresh(loclist) " {{{2
if self.enabled()
call self.reset(a:loclist)
call syntastic#log#debug(g:SyntasticDebugNotifications, 'highlighting: refresh')
@ -59,11 +55,11 @@ function! g:SyntasticHighlightingNotifier.refresh(loclist)
endif
endfor
endif
endfunction
endfunction " }}}2
" Remove all error highlights from the window
" @vimlint(EVL103, 1, a:loclist)
function! g:SyntasticHighlightingNotifier.reset(loclist)
function! g:SyntasticHighlightingNotifier.reset(loclist) " {{{2
if s:has_highlighting
call syntastic#log#debug(g:SyntasticDebugNotifications, 'highlighting: reset')
for match in getmatches()
@ -72,13 +68,15 @@ function! g:SyntasticHighlightingNotifier.reset(loclist)
endif
endfor
endif
endfunction
endfunction " }}}2
" @vimlint(EVL103, 0, a:loclist)
" }}}1
" Private methods {{{1
" One time setup: define our own highlighting
function! g:SyntasticHighlightingNotifier._setup()
function! g:SyntasticHighlightingNotifier._setup() " {{{2
if s:has_highlighting
if !hlexists('SyntasticError')
highlight link SyntasticError SpellBad
@ -88,6 +86,8 @@ function! g:SyntasticHighlightingNotifier._setup()
highlight link SyntasticWarning SpellCap
endif
endif
endfunction
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,4 +1,4 @@
if exists("g:loaded_syntastic_loclist")
if exists("g:loaded_syntastic_loclist") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_loclist = 1
@ -7,7 +7,7 @@ let g:SyntasticLoclist = {}
" Public methods {{{1
function! g:SyntasticLoclist.New(rawLoclist)
function! g:SyntasticLoclist.New(rawLoclist) " {{{2
let newObj = copy(self)
let llist = filter(copy(a:rawLoclist), 'v:val["valid"] == 1')
@ -22,34 +22,34 @@ function! g:SyntasticLoclist.New(rawLoclist)
let newObj._name = ''
return newObj
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.current()
function! g:SyntasticLoclist.current() " {{{2
if !exists("b:syntastic_loclist")
let b:syntastic_loclist = g:SyntasticLoclist.New([])
endif
return b:syntastic_loclist
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.extend(other)
function! g:SyntasticLoclist.extend(other) " {{{2
let list = self.copyRaw()
call extend(list, a:other.copyRaw())
return g:SyntasticLoclist.New(list)
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.isEmpty()
function! g:SyntasticLoclist.isEmpty() " {{{2
return empty(self._rawLoclist)
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.copyRaw()
function! g:SyntasticLoclist.copyRaw() " {{{2
return copy(self._rawLoclist)
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.getRaw()
function! g:SyntasticLoclist.getRaw() " {{{2
return self._rawLoclist
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.getStatuslineFlag()
function! g:SyntasticLoclist.getStatuslineFlag() " {{{2
if !exists("self._stl_format")
let self._stl_format = ''
endif
@ -100,52 +100,48 @@ function! g:SyntasticLoclist.getStatuslineFlag()
endif
return self._stl_flag
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.getFirstIssue()
function! g:SyntasticLoclist.getFirstIssue() " {{{2
return get(self._rawLoclist, 0, {})
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.getName()
function! g:SyntasticLoclist.getName() " {{{2
return len(self._name)
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.setName(name)
function! g:SyntasticLoclist.setName(name) " {{{2
let self._name = a:name
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.decorate(name, filetype)
function! g:SyntasticLoclist.decorate(filetype, name) " {{{2
for e in self._rawLoclist
let e['text'] .= ' [' . a:filetype . '/' . a:name . ']'
endfor
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.quietMessages(filters)
call syntastic#util#dictFilter(self._rawLoclist, a:filters)
endfunction
function! g:SyntasticLoclist.errors()
function! g:SyntasticLoclist.errors() " {{{2
if !exists("self._cachedErrors")
let self._cachedErrors = self.filter({'type': "E"})
endif
return self._cachedErrors
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.warnings()
function! g:SyntasticLoclist.warnings() " {{{2
if !exists("self._cachedWarnings")
let self._cachedWarnings = self.filter({'type': "W"})
endif
return self._cachedWarnings
endfunction
endfunction " }}}2
" Legacy function. Syntastic no longer calls it, but we keep it
" around because other plugins (f.i. powerline) depend on it.
function! g:SyntasticLoclist.hasErrorsOrWarningsToDisplay()
function! g:SyntasticLoclist.hasErrorsOrWarningsToDisplay() " {{{2
return !self.isEmpty()
endfunction
endfunction " }}}2
" cache used by EchoCurrentError()
function! g:SyntasticLoclist.messages(buf)
function! g:SyntasticLoclist.messages(buf) " {{{2
if !exists("self._cachedMessages")
let self._cachedMessages = {}
let errors = self.errors() + self.warnings()
@ -165,7 +161,7 @@ function! g:SyntasticLoclist.messages(buf)
endif
return get(self._cachedMessages, a:buf, {})
endfunction
endfunction " }}}2
"Filter the list and return new native loclist
"e.g.
@ -174,14 +170,14 @@ endfunction
"would return all errors for buffer 10.
"
"Note that all comparisons are done with ==?
function! g:SyntasticLoclist.filter(filters)
function! g:SyntasticLoclist.filter(filters) " {{{2
let conditions = values(map(copy(a:filters), 's:translate(v:key, v:val)'))
let filter = len(conditions) == 1 ?
\ conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ')
return filter(copy(self._rawLoclist), filter)
endfunction
endfunction " }}}2
function! g:SyntasticLoclist.setloclist()
function! g:SyntasticLoclist.setloclist() " {{{2
if !exists('w:syntastic_loclist_set')
let w:syntastic_loclist_set = 0
endif
@ -189,16 +185,16 @@ function! g:SyntasticLoclist.setloclist()
call syntastic#log#debug(g:SyntasticDebugNotifications, 'loclist: setloclist ' . (replace ? '(replace)' : '(new)'))
call setloclist(0, self.getRaw(), replace ? 'r' : ' ')
let w:syntastic_loclist_set = 1
endfunction
endfunction " }}}2
"display the cached errors for this buf in the location list
function! g:SyntasticLoclist.show()
function! g:SyntasticLoclist.show() " {{{2
call syntastic#log#debug(g:SyntasticDebugNotifications, 'loclist: show')
call self.setloclist()
if !self.isEmpty()
let num = winnr()
execute "lopen " . g:syntastic_loc_list_height
execute "lopen " . syntastic#util#var('loc_list_height')
if num != winnr()
wincmd p
endif
@ -220,19 +216,25 @@ function! g:SyntasticLoclist.show()
endif
endfor
endif
endfunction
endfunction " }}}2
" }}}1
" Non-method functions {{{1
function! g:SyntasticLoclistHide()
function! g:SyntasticLoclistHide() " {{{2
call syntastic#log#debug(g:SyntasticDebugNotifications, 'loclist: hide')
silent! lclose
endfunction
endfunction " }}}2
" }}}1
" Private functions {{{1
function! s:translate(key, val)
function! s:translate(key, val) " {{{2
return 'get(v:val, ' . string(a:key) . ', "") ==? ' . string(a:val)
endfunction
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,4 +1,4 @@
if exists("g:loaded_syntastic_modemap")
if exists("g:loaded_syntastic_modemap") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_modemap = 1
@ -7,16 +7,16 @@ let g:SyntasticModeMap = {}
" Public methods {{{1
function! g:SyntasticModeMap.Instance()
function! g:SyntasticModeMap.Instance() " {{{2
if !exists('s:SyntasticModeMapInstance')
let s:SyntasticModeMapInstance = copy(self)
call s:SyntasticModeMapInstance.synch()
endif
return s:SyntasticModeMapInstance
endfunction
endfunction " }}}2
function! g:SyntasticModeMap.synch()
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', [])
@ -26,9 +26,9 @@ function! g:SyntasticModeMap.synch()
let self._activeFiletypes = []
let self._passiveFiletypes = []
endif
endfunction
endfunction " }}}2
function! g:SyntasticModeMap.allowsAutoChecking(filetype)
function! g:SyntasticModeMap.allowsAutoChecking(filetype) " {{{2
let fts = split(a:filetype, '\m\.')
if self.isPassive()
@ -36,13 +36,13 @@ function! g:SyntasticModeMap.allowsAutoChecking(filetype)
else
return self._noFiletypesArePassive(fts)
endif
endfunction
endfunction " }}}2
function! g:SyntasticModeMap.isPassive()
function! g:SyntasticModeMap.isPassive() " {{{2
return self._mode ==# 'passive'
endfunction
endfunction " }}}2
function! g:SyntasticModeMap.toggleMode()
function! g:SyntasticModeMap.toggleMode() " {{{2
call self.synch()
if self._mode ==# 'active'
@ -56,20 +56,24 @@ function! g:SyntasticModeMap.toggleMode()
let g:syntastic_mode_map = {}
endif
let g:syntastic_mode_map['mode'] = self._mode
endfunction
endfunction " }}}2
function! g:SyntasticModeMap.echoMode()
function! g:SyntasticModeMap.echoMode() " {{{2
echo "Syntastic: " . self._mode . " mode enabled"
endfunction
endfunction " }}}2
" }}}1
" Private methods {{{1
function! g:SyntasticModeMap._isOneFiletypeActive(filetypes)
function! g:SyntasticModeMap._isOneFiletypeActive(filetypes) " {{{2
return !empty(filter(copy(a:filetypes), 'index(self._activeFiletypes, v:val) != -1'))
endfunction
endfunction " }}}2
function! g:SyntasticModeMap._noFiletypesArePassive(filetypes)
function! g:SyntasticModeMap._noFiletypesArePassive(filetypes) " {{{2
return empty(filter(copy(a:filetypes), 'index(self._passiveFiletypes, v:val) != -1'))
endfunction
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,4 +1,4 @@
if exists("g:loaded_syntastic_notifiers")
if exists("g:loaded_syntastic_notifiers") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_notifiers = 1
@ -9,16 +9,16 @@ let s:notifier_types = ['signs', 'balloons', 'highlighting', 'cursor', 'autolocl
" Public methods {{{1
function! g:SyntasticNotifiers.Instance()
function! g:SyntasticNotifiers.Instance() " {{{2
if !exists('s:SyntasticNotifiersInstance')
let s:SyntasticNotifiersInstance = copy(self)
call s:SyntasticNotifiersInstance._initNotifiers()
endif
return s:SyntasticNotifiersInstance
endfunction
endfunction " }}}2
function! g:SyntasticNotifiers.refresh(loclist)
function! g:SyntasticNotifiers.refresh(loclist) " {{{2
call syntastic#log#debug(g:SyntasticDebugNotifications, 'notifiers: refresh')
for type in self._enabled_types
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
@ -26,9 +26,9 @@ function! g:SyntasticNotifiers.refresh(loclist)
call self._notifier[type].refresh(a:loclist)
endif
endfor
endfunction
endfunction " }}}2
function! g:SyntasticNotifiers.reset(loclist)
function! g:SyntasticNotifiers.reset(loclist) " {{{2
call syntastic#log#debug(g:SyntasticDebugNotifications, 'notifiers: reset')
for type in self._enabled_types
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
@ -40,11 +40,13 @@ function! g:SyntasticNotifiers.reset(loclist)
call self._notifier[type].reset(a:loclist)
endif
endfor
endfunction
endfunction " }}}2
" }}}1
" Private methods {{{1
function! g:SyntasticNotifiers._initNotifiers()
function! g:SyntasticNotifiers._initNotifiers() " {{{2
let self._notifier = {}
for type in s:notifier_types
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
@ -52,6 +54,8 @@ function! g:SyntasticNotifiers._initNotifiers()
endfor
let self._enabled_types = copy(s:notifier_types)
endfunction
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,8 +1,10 @@
if exists("g:loaded_syntastic_registry")
if exists("g:loaded_syntastic_registry") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_registry = 1
" Initialisation {{{1
let s:defaultCheckers = {
\ 'actionscript':['mxmlc'],
\ 'ada': ['gcc'],
@ -95,188 +97,167 @@ let s:defaultFiletypeMap = {
let g:SyntasticRegistry = {}
" }}}1
" Public methods {{{1
" TODO: Handling of filetype aliases: all public methods take aliases as
" parameters, all private methods take normalized filetypes. Public methods
" are thus supposed to normalize filetypes before calling private methods.
" Public methods {{{1
function! g:SyntasticRegistry.Instance()
function! g:SyntasticRegistry.Instance() " {{{2
if !exists('s:SyntasticRegistryInstance')
let s:SyntasticRegistryInstance = copy(self)
let s:SyntasticRegistryInstance._checkerRaw = {}
let s:SyntasticRegistryInstance._checkerMap = {}
let s:SyntasticRegistryInstance._cachedCheckersFor = {}
endif
return s:SyntasticRegistryInstance
endfunction
endfunction " }}}2
function! g:SyntasticRegistry.CreateAndRegisterChecker(args)
function! g:SyntasticRegistry.CreateAndRegisterChecker(args) " {{{2
let checker = g:SyntasticChecker.New(a:args)
let registry = g:SyntasticRegistry.Instance()
call registry._registerChecker(checker)
endfunction
endfunction " }}}2
function! g:SyntasticRegistry.checkable(ftalias)
return !empty(self.getActiveCheckers(a:ftalias))
endfunction
function! g:SyntasticRegistry.isCheckable(ftalias) " {{{2
let ft = s:normaliseFiletype(a:ftalias)
call self._loadCheckers(ft)
return !empty(self._checkerMap[ft])
endfunction " }}}2
function! g:SyntasticRegistry.getActiveCheckers(ftalias)
let filetype = s:SyntasticRegistryNormaliseFiletype(a:ftalias)
let checkers = self.availableCheckersFor(a:ftalias)
function! g:SyntasticRegistry.getCheckersMap(ftalias) " {{{2
let ft = s:normaliseFiletype(a:ftalias)
call self._loadCheckers(ft)
return self._checkerMap[ft]
endfunction " }}}2
if self._userHasFiletypeSettings(filetype)
return self._filterCheckersByUserSettings(checkers, filetype)
function! g:SyntasticRegistry.getCheckers(ftalias, list) " {{{2
let checkers_map = self.getCheckersMap(a:ftalias)
if empty(checkers_map)
return []
endif
if has_key(s:defaultCheckers, filetype)
return self._filterCheckersByDefaultSettings(checkers, filetype)
endif
let ft = s:normaliseFiletype(a:ftalias)
call self._checkDeprecation(ft)
return checkers[0:0]
endfunction
let ft_list =
\ !empty(a:list) ? a:list :
\ exists('b:syntastic_checkers') ? b:syntastic_checkers :
\ exists('g:syntastic_' . ft . '_checkers') ? g:syntastic_{ft}_checkers :
\ get(s:defaultCheckers, ft, [])
function! g:SyntasticRegistry.getCheckers(ftalias, list)
return self._filterCheckersByName(self.availableCheckersFor(a:ftalias), a:list)
endfunction
return !empty(ft_list) ?
\ self._filterCheckersByName(checkers_map, ft_list) : [checkers_map[keys(checkers_map)[0]]]
endfunction " }}}2
function! g:SyntasticRegistry.availableCheckersFor(ftalias)
if !has_key(self._cachedCheckersFor, a:ftalias)
let filetype = s:SyntasticRegistryNormaliseFiletype(a:ftalias)
let checkers = self._allCheckersFor(filetype)
let self._cachedCheckersFor[a:ftalias] = self._filterCheckersByAvailability(checkers)
endif
return self._cachedCheckersFor[a:ftalias]
endfunction
function! g:SyntasticRegistry.knownFiletypes()
function! g:SyntasticRegistry.getKnownFiletypes() " {{{2
let types = keys(s:defaultCheckers)
call extend(types, keys(s:defaultFiletypeMap))
if exists('g:syntastic_filetype_map')
call extend(types, keys(g:syntastic_filetype_map))
endif
if exists('g:syntastic_extra_filetypes') && type(g:syntastic_extra_filetypes) == type([])
call extend(types, g:syntastic_extra_filetypes)
endif
return syntastic#util#unique(types)
endfunction
function! g:SyntasticRegistry.echoInfoFor(ftalias_list)
return syntastic#util#unique(types)
endfunction " }}}2
function! g:SyntasticRegistry.echoInfoFor(ftalias_list) " {{{2
echomsg "Syntastic info for filetype: " . join(a:ftalias_list, '.')
let available = []
let active = []
for ftalias in a:ftalias_list
call extend(available, self.availableCheckersFor(ftalias))
call extend(active, self.getActiveCheckers(ftalias))
endfor
let ft_list = syntastic#util#unique(map( copy(a:ftalias_list), 's:normaliseFiletype(v:val)' ))
if len(ft_list) != 1
let available = []
let active = []
echomsg "Available checker(s): " . join(syntastic#util#unique(map(available, "v:val.getName()")))
echomsg "Currently enabled checker(s): " . join(syntastic#util#unique(map(active, "v:val.getName()")))
endfunction
for ft in ft_list
call extend(available, map( keys(self.getCheckersMap(ft)), 'ft . "/" . v:val' ))
call extend(active, map( self.getCheckers(ft, []), 'ft . "/" . v:val.getName()' ))
endfor
else
let ft = ft_list[0]
let available = keys(self.getCheckersMap(ft))
let active = map(self.getCheckers(ft, []), 'v:val.getName()')
endif
echomsg "Available checker(s): " . join(sort(available))
echomsg "Currently enabled checker(s): " . join(active)
endfunction " }}}2
" }}}1
" Private methods {{{1
function! g:SyntasticRegistry._registerChecker(checker) abort
function! g:SyntasticRegistry._registerChecker(checker) abort " {{{2
let ft = a:checker.getFiletype()
if !has_key(self._checkerMap, ft)
let self._checkerMap[ft] = []
if !has_key(self._checkerRaw, ft)
let self._checkerRaw[ft] = []
let self._checkerMap[ft] = {}
endif
call self._validateUniqueName(a:checker)
call add(self._checkerMap[ft], a:checker)
endfunction
let name = a:checker.getName()
call add(self._checkerRaw[ft], name)
function! g:SyntasticRegistry._allCheckersFor(filetype)
call self._loadCheckers(a:filetype)
if empty(self._checkerMap[a:filetype])
return []
if a:checker.isAvailable()
let self._checkerMap[ft][name] = a:checker
endif
endfunction " }}}2
return self._checkerMap[a:filetype]
endfunction
function! g:SyntasticRegistry._filterCheckersByName(checkers_map, list) " {{{2
return filter( map(copy(a:list), 'get(a:checkers_map, v:val, {})'), '!empty(v:val)' )
endfunction " }}}2
function! g:SyntasticRegistry._filterCheckersByDefaultSettings(checkers, filetype)
if has_key(s:defaultCheckers, a:filetype)
return self._filterCheckersByName(a:checkers, s:defaultCheckers[a:filetype])
endif
return a:checkers
endfunction
function! g:SyntasticRegistry._filterCheckersByUserSettings(checkers, filetype)
if exists("b:syntastic_checkers")
let whitelist = b:syntastic_checkers
else
let whitelist = g:syntastic_{a:filetype}_checkers
endif
return self._filterCheckersByName(a:checkers, whitelist)
endfunction
function! g:SyntasticRegistry._filterCheckersByName(checkers, list)
let checkers_by_name = {}
for c in a:checkers
let checkers_by_name[c.getName()] = c
endfor
let filtered = []
for name in a:list
if has_key(checkers_by_name, name)
call add(filtered, checkers_by_name[name])
endif
endfor
return filtered
endfunction
function! g:SyntasticRegistry._filterCheckersByAvailability(checkers)
return filter(copy(a:checkers), "v:val.isAvailable()")
endfunction
function! g:SyntasticRegistry._loadCheckers(filetype)
if self._haveLoadedCheckers(a:filetype)
function! g:SyntasticRegistry._loadCheckers(filetype) " {{{2
if has_key(self._checkerRaw, a:filetype)
return
endif
execute "runtime! syntax_checkers/" . a:filetype . "/*.vim"
if !has_key(self._checkerMap, a:filetype)
let self._checkerMap[a:filetype] = []
if !has_key(self._checkerRaw, a:filetype)
let self._checkerRaw[a:filetype] = []
let self._checkerMap[a:filetype] = {}
endif
endfunction
endfunction " }}}2
function! g:SyntasticRegistry._haveLoadedCheckers(filetype)
return has_key(self._checkerMap, a:filetype)
endfunction
function! g:SyntasticRegistry._validateUniqueName(checker) abort " {{{2
let ft = a:checker.getFiletype()
let name = a:checker.getName()
if index(self._checkerRaw[ft], name) > -1
throw 'Syntastic: Duplicate syntax checker name: ' . ft . '/' . name
endif
endfunction " }}}2
function! g:SyntasticRegistry._userHasFiletypeSettings(filetype)
if exists("g:syntastic_" . a:filetype . "_checker") && !exists("g:syntastic_" . a:filetype . "_checkers")
" Check for obsolete variable g:syntastic_<filetype>_checker
function! g:SyntasticRegistry._checkDeprecation(filetype) " {{{2
if exists('g:syntastic_' . a:filetype . '_checker') && !exists('g:syntastic_' . a:filetype . '_checkers')
let g:syntastic_{a:filetype}_checkers = [g:syntastic_{a:filetype}_checker]
call syntastic#log#deprecationWarn("variable g:syntastic_" . a:filetype . "_checker is deprecated")
call syntastic#log#deprecationWarn('variable g:syntastic_' . a:filetype . '_checker is deprecated')
endif
return exists("b:syntastic_checkers") || exists("g:syntastic_" . a:filetype . "_checkers")
endfunction
endfunction " }}}2
function! g:SyntasticRegistry._validateUniqueName(checker) abort
for checker in self._allCheckersFor(a:checker.getFiletype())
if checker.getName() ==# a:checker.getName()
throw "Syntastic: Duplicate syntax checker name for: " . a:checker.getName()
endif
endfor
endfunction
" }}}1
" Private functions {{{1
"resolve filetype aliases, and replace - with _ otherwise we cant name
"syntax checker functions legally for filetypes like "gentoo-metadata"
function! s:SyntasticRegistryNormaliseFiletype(ftalias)
function! s:normaliseFiletype(ftalias) " {{{2
let ft = get(s:defaultFiletypeMap, a:ftalias, a:ftalias)
let ft = get(g:syntastic_filetype_map, ft, ft)
let ft = substitute(ft, '\m-', '_', 'g')
return ft
endfunction
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,28 +1,9 @@
if exists("g:loaded_syntastic_notifier_signs")
if exists("g:loaded_syntastic_notifier_signs") || !exists("g:loaded_syntastic_plugin")
finish
endif
let g:loaded_syntastic_notifier_signs = 1
if !exists("g:syntastic_enable_signs")
let g:syntastic_enable_signs = 1
endif
if !exists("g:syntastic_error_symbol")
let g:syntastic_error_symbol = '>>'
endif
if !exists("g:syntastic_warning_symbol")
let g:syntastic_warning_symbol = '>>'
endif
if !exists("g:syntastic_style_error_symbol")
let g:syntastic_style_error_symbol = 'S>'
endif
if !exists("g:syntastic_style_warning_symbol")
let g:syntastic_style_warning_symbol = 'S>'
endif
" Initialisation {{{1
" start counting sign ids at 5000, start here to hopefully avoid conflicting
" with any other code that places signs (not sure if this precaution is
@ -34,9 +15,11 @@ let g:SyntasticSignsNotifier = {}
let s:setup_done = 0
" }}}1
" Public methods {{{1
function! g:SyntasticSignsNotifier.New()
function! g:SyntasticSignsNotifier.New() " {{{2
let newObj = copy(self)
if !s:setup_done
@ -45,13 +28,13 @@ function! g:SyntasticSignsNotifier.New()
endif
return newObj
endfunction
endfunction " }}}2
function! g:SyntasticSignsNotifier.enabled()
function! g:SyntasticSignsNotifier.enabled() " {{{2
return has('signs') && syntastic#util#var('enable_signs')
endfunction
endfunction " }}}2
function! g:SyntasticSignsNotifier.refresh(loclist)
function! g:SyntasticSignsNotifier.refresh(loclist) " {{{2
call syntastic#log#debug(g:SyntasticDebugNotifications, 'signs: refresh')
let old_signs = copy(self._bufSignIds())
if self.enabled()
@ -59,12 +42,14 @@ function! g:SyntasticSignsNotifier.refresh(loclist)
endif
call self._removeSigns(old_signs)
let s:first_sign_id = s:next_sign_id
endfunction
endfunction " }}}2
" }}}1
" Private methods {{{1
" One time setup: define our own sign types and highlighting
function! g:SyntasticSignsNotifier._setup()
function! g:SyntasticSignsNotifier._setup() " {{{2
if has('signs')
if !hlexists('SyntasticErrorSign')
highlight link SyntasticErrorSign error
@ -95,10 +80,10 @@ function! g:SyntasticSignsNotifier._setup()
exe 'sign define SyntasticStyleWarning text=' . g:syntastic_style_warning_symbol .
\ ' texthl=SyntasticStyleWarningSign linehl=SyntasticStyleWarningLine'
endif
endfunction
endfunction " }}}2
" Place signs by all syntax errors in the buffer
function! g:SyntasticSignsNotifier._signErrors(loclist)
function! g:SyntasticSignsNotifier._signErrors(loclist) " {{{2
let loclist = a:loclist
if !loclist.isEmpty()
@ -123,24 +108,26 @@ function! g:SyntasticSignsNotifier._signErrors(loclist)
endif
endfor
endif
endfunction
endfunction " }}}2
" Remove the signs with the given ids from this buffer
function! g:SyntasticSignsNotifier._removeSigns(ids)
function! g:SyntasticSignsNotifier._removeSigns(ids) " {{{2
if has('signs')
for i in a:ids
execute "sign unplace " . i
call remove(self._bufSignIds(), index(self._bufSignIds(), i))
endfor
endif
endfunction
endfunction " }}}2
" Get all the ids of the SyntaxError signs in the buffer
function! g:SyntasticSignsNotifier._bufSignIds()
function! g:SyntasticSignsNotifier._bufSignIds() " {{{2
if !exists("b:syntastic_sign_ids")
let b:syntastic_sign_ids = []
endif
return b:syntastic_sign_ids
endfunction
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker: