Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 57f1a0e

Browse files
committed
New user variables: syntastic_<filetype>_<checker>_sort.
1 parent 1327780 commit 57f1a0e

22 files changed

Lines changed: 117 additions & 77 deletions

File tree

doc/syntastic.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ CONTENTS *syntastic-contents*
3434
5.1.Choosing which checkers to use.........|syntastic-filetype-checkers|
3535
5.2.Choosing the executable................|syntastic-config-exec|
3636
5.3.Configuring specific checkers..........|syntastic-config-makeprg|
37+
5.4.Sorting errors.........................|syntastic-config-sort|
3738
6.Notes........................................|syntastic-notes|
3839
6.1.Handling of composite filetypes........|syntastic-composite|
3940
6.2.Editing files over network.............|syntastic-netrw|
@@ -208,7 +209,8 @@ disable generation of these labels by turning off '|syntastic_id_checkers|'.
208209
If |'syntastic_sort_aggregated_errors'| is set (which is the default), messages
209210
in the aggregated list are grouped by file, then sorted by line number, then
210211
type, then column number. Otherwise messages produced by the same checker are
211-
grouped together.
212+
grouped together, and sorting within each group is decided by the variables
213+
|'syntastic_<filetype>_<checker>_sort'|.
212214

213215
------------------------------------------------------------------------------
214216
2.6 Filtering errors *syntastic-filtering-errors*
@@ -688,6 +690,25 @@ Example: >
688690
<
689691
See |syntastic_quiet_messages| for the syntax.
690692

693+
------------------------------------------------------------------------------
694+
5.4 Sorting errors *syntastic-config-sort*
695+
696+
*'syntastic_<filetype>_<checker>_sort'*
697+
Syntastic may decide to group the errors produced by some checkers by file,
698+
then sort them by line number, then by type, then by column number. If you'd
699+
prefer to see the errors in the order in which they are output by the external
700+
checker you can set the variable |'g:syntastic_<filetype>_<checker>_sort'| to 0.
701+
702+
Alternatively, if syntastic doesn't reorder the errors produced by a checker
703+
but you'd like it to sort them, you can set the same variable to 1.
704+
705+
There is also a local version |'b:syntastic_<filetype>_<checker>_sort'| of
706+
this variable, that takes precedence over it in the buffers where it is
707+
defined.
708+
709+
For aggregated lists (see |syntastic-aggregating-errors|) these variables are
710+
ignored if |syntastic_sort_aggregated_errors| is set (which is the default).
711+
691712
==============================================================================
692713
6. Notes *syntastic-notes*
693714

plugin/syntastic.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ function! s:CacheErrors(checker_names) " {{{2
347347
call loclist.decorate(cname)
348348
endif
349349
call add(names, cname)
350-
if checker.getWantSort() && !sort_aggregated_errors
350+
if checker.wantSort() && !sort_aggregated_errors
351351
call loclist.sort()
352352
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_LOCLIST, 'sorted:', loclist)
353353
endif
@@ -509,6 +509,8 @@ function! SyntasticMake(options) " {{{2
509509
" E776: No location list
510510
" do nothing
511511
endtry
512+
else
513+
let errors = []
512514
endif
513515

514516
" restore options {{{3

plugin/syntastic/checker.vim

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ function! g:SyntasticChecker.New(args) " {{{2
1313
let newObj._filetype = a:args['filetype']
1414
let newObj._name = a:args['name']
1515
let newObj._exec = get(a:args, 'exec', newObj._name)
16-
let newObj._sort = 0
1716

1817
if has_key(a:args, 'redirect')
1918
let [filetype, name] = split(a:args['redirect'], '/')
2019
let prefix = 'SyntaxCheckers_' . filetype . '_' . name . '_'
20+
21+
if exists('g:syntastic_' . filetype . '_' . name . '_sort') && !exists('g:syntastic_' . newObj._filetype . '_' . newObj._name . '_sort')
22+
let g:syntastic_{newObj._filetype}_{newObj._name}_sort = g:syntastic_{filetype}_{name}_sort
23+
endif
2124
else
2225
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
2326
endif
@@ -74,14 +77,6 @@ function! g:SyntasticChecker.getLocList() " {{{2
7477
return g:SyntasticLoclist.New(self.getLocListRaw())
7578
endfunction " }}}2
7679

77-
function! g:SyntasticChecker.getWantSort() " {{{2
78-
return self._sort
79-
endfunction " }}}2
80-
81-
function! g:SyntasticChecker.setWantSort(val) " {{{2
82-
let self._sort = a:val
83-
endfunction " }}}2
84-
8580
function! g:SyntasticChecker.log(msg, ...) " {{{2
8681
let leader = self._filetype . '/' . self._name . ': '
8782
if a:0 > 0
@@ -111,6 +106,10 @@ function! g:SyntasticChecker.isAvailable() " {{{2
111106
return self._available
112107
endfunction " }}}2
113108

109+
function! g:SyntasticChecker.wantSort() " {{{2
110+
return syntastic#util#var(self._filetype . '_' . self._name . '_sort', 0)
111+
endfunction " }}}2
112+
114113
" }}}1
115114

116115
" Private methods {{{1

syntax_checkers/c/clang_check.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ if !exists('g:syntastic_clang_check_config_file')
1818
let g:syntastic_clang_check_config_file = '.syntastic_clang_check_config'
1919
endif
2020

21+
if !exists('g:syntastic_c_clang_check_sort')
22+
let g:syntastic_c_clang_check_sort = 1
23+
endif
24+
2125
let s:save_cpo = &cpo
2226
set cpo&vim
2327

@@ -39,15 +43,11 @@ function! SyntaxCheckers_c_clang_check_GetLocList() dict
3943
\ '%-G%\m%\%%(LLVM ERROR:%\|No compilation database found%\)%\@!%.%#,' .
4044
\ '%E%m'
4145

42-
let loclist = SyntasticMake({
46+
return SyntasticMake({
4347
\ 'makeprg': makeprg,
4448
\ 'errorformat': errorformat,
4549
\ 'defaults': {'bufnr': bufnr('')},
4650
\ 'returns': [0, 1] })
47-
48-
call self.setWantSort(1)
49-
50-
return loclist
5151
endfunction
5252

5353
call g:SyntasticRegistry.CreateAndRegisterChecker({

syntax_checkers/c/clang_tidy.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ if !exists('g:syntastic_clang_tidy_config_file')
1818
let g:syntastic_clang_tidy_config_file = '.syntastic_clang_tidy_config'
1919
endif
2020

21+
if !exists('g:syntastic_c_clang_tidy_sort')
22+
let g:syntastic_c_clang_tidy_sort = 1
23+
endif
24+
2125
let s:save_cpo = &cpo
2226
set cpo&vim
2327

@@ -39,15 +43,11 @@ function! SyntaxCheckers_c_clang_tidy_GetLocList() dict
3943
\ '%-G%\m%\%%(LLVM ERROR:%\|No compilation database found%\)%\@!%.%#,' .
4044
\ '%E%m'
4145

42-
let loclist = SyntasticMake({
46+
return SyntasticMake({
4347
\ 'makeprg': makeprg,
4448
\ 'errorformat': errorformat,
4549
\ 'defaults': {'bufnr': bufnr('')},
4650
\ 'returns': [0, 1] })
47-
48-
call self.setWantSort(1)
49-
50-
return loclist
5151
endfunction
5252

5353
call g:SyntasticRegistry.CreateAndRegisterChecker({

syntax_checkers/c/oclint.vim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ if !exists('g:syntastic_oclint_config_file')
2525
let g:syntastic_oclint_config_file = '.syntastic_oclint_config'
2626
endif
2727

28+
if !exists('g:syntastic_c_oclint_sort')
29+
let g:syntastic_c_oclint_sort = 1
30+
endif
31+
2832
let s:save_cpo = &cpo
2933
set cpo&vim
3034

@@ -55,8 +59,6 @@ function! SyntaxCheckers_c_oclint_GetLocList() dict
5559
let e['text'] = substitute(e['text'], '\m\C P[1-3] ', ': ', '')
5660
endfor
5761

58-
call self.setWantSort(1)
59-
6062
return loclist
6163
endfunction
6264

syntax_checkers/css/prettycss.vim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ if exists("g:loaded_syntastic_css_prettycss_checker")
2020
endif
2121
let g:loaded_syntastic_css_prettycss_checker = 1
2222

23+
if !exists('g:syntastic_css_prettycss_sort')
24+
let g:syntastic_css_prettycss_sort = 1
25+
endif
26+
2327
let s:save_cpo = &cpo
2428
set cpo&vim
2529

@@ -49,8 +53,6 @@ function! SyntaxCheckers_css_prettycss_GetLocList() dict
4953
let e["text"] .= ')'
5054
endfor
5155

52-
call self.setWantSort(1)
53-
5456
return loclist
5557
endfunction
5658

syntax_checkers/haskell/scan.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ if exists('g:loaded_syntastic_haskell_scan_checker')
1515
endif
1616
let g:loaded_syntastic_haskell_scan_checker = 1
1717

18+
if !exists('g:syntastic_haskell_scan_sort')
19+
let g:syntastic_haskell_scan_sort = 1
20+
endif
21+
1822
let s:save_cpo = &cpo
1923
set cpo&vim
2024

@@ -23,14 +27,10 @@ function! SyntaxCheckers_haskell_scan_GetLocList() dict
2327

2428
let errorformat = '%f:%l:%v: %m'
2529

26-
let loclist = SyntasticMake({
30+
return SyntasticMake({
2731
\ 'makeprg': makeprg,
2832
\ 'errorformat': errorformat,
2933
\ 'subtype': 'Style' })
30-
31-
call self.setWantSort(1)
32-
33-
return loclist
3434
endfunction
3535

3636
call g:SyntasticRegistry.CreateAndRegisterChecker({

syntax_checkers/html/jshint.vim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ function! SyntaxCheckers_html_jshint_GetLocList() dict
3737

3838
let errorformat = '%A%f: line %l\, col %v\, %m \(%t%*\d\)'
3939

40-
call self.setWantSort(1)
41-
4240
return SyntasticMake({
4341
\ 'makeprg': makeprg,
4442
\ 'errorformat': errorformat,

syntax_checkers/javascript/eslint.vim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ if exists('g:loaded_syntastic_javascript_eslint_checker')
1414
endif
1515
let g:loaded_syntastic_javascript_eslint_checker = 1
1616

17+
if !exists('g:syntastic_javascript_eslint_sort')
18+
let g:syntastic_javascript_eslint_sort = 1
19+
endif
20+
1721
let s:save_cpo = &cpo
1822
set cpo&vim
1923

@@ -47,8 +51,6 @@ function! SyntaxCheckers_javascript_eslint_GetLocList() dict
4751
let e['col'] += 1
4852
endfor
4953

50-
call self.setWantSort(1)
51-
5254
return loclist
5355
endfunction
5456

0 commit comments

Comments
 (0)