2

Currently, if I run :SyntasticCheck, :Errors displays errors for the current buffer only. What I want it to do is to check all Python (*.py) files in the current working directory, and so that all the locations are aggregated in a single LocationList.

I know this is possible because the Syntastic documentation implies it, e.g. there is a syntastic_ignore_files setting for ignoring patterns of filenames.


My failed attempt:

  1. Set let g:syntastic_aggregate_errors = 1
  2. Open all *.py files with :n *.py
  3. :bufdo SyntasticCheck
  4. It cycles through each buffer and runs the check. However, when this is finished :Errors shows errors only for the last buffer that was checked.
DBedrenko
  • 4,871
  • 4
  • 38
  • 73
  • Syntastic's ability for managing multiple code files in a single project is dependent on the language. I haven't seen any support for Python yet probably because Python is still in beta with an unsuccessful version 3 push. If you want, you can roll your own and provide tentative support (in ideal conditions) like support for C or Java. Load a packaged java project into vim and have syntastic check it, syntastic will magically know what to do, and examine the included files. Don't expect any silver bullets as like other IDE's: Visual Studio, Pycharm, IDLE or Netbeans. – Eric Leschinski May 22 '18 at 16:55
  • @EricLeschinski What is so difficult about applying `SyntasticCheck` on multiple files, one-by-one, then aggregating all the results in one LocationList in Vim? – DBedrenko May 23 '18 at 09:48

2 Answers2

2

Currently, if I run :SyntasticCheck, :Errors displays errors for the current buffer only. What I want it to do is to check all Python (*.py) files in the current working directory, and so that all the locations are aggregated in a single LocationList.

This is not possible, and there is currently no plan to implement it.

I know this is possible because the Syntastic documentation implies it, e.g. there is a syntastic_ignore_files setting for ignoring patterns of filenames.

Some checkers check include files and the like, and sometimes you may not care about errors there. Also, there are situations when you don't want to check certain files automatically (this is generally useful when you have active mode enabled).

let g:syntastic_aggregate_errors = 1

This aggregates errors when running different checkers against the same file. It doesn't aggregate errors when running the same checker against a set of files.

It cycles through each buffer and runs the check. However, when this is finished :Errors shows errors only for the last buffer that was checked.

Yes, :Errors shows the error window for the current buffer.

You might set g:syntastic_check_on_open and active mode and open the files in separate windows. That would run checks against all files, but the results would still be per file, not global. And window positions would be screwed up because of limitations in Vim's API. Basically, there is no way to do what you want if the checker you're running doesn't already check all files by itself.

lcd047
  • 5,731
  • 2
  • 28
  • 38
  • Thanks for the answer. It's too bad this isn't possible, because it's such a pain in the butt to periodically have to manually cycle through--and check--each file in my project. PS: I'll accept the answer in 24hrs if no better solution comes up. – DBedrenko Jan 21 '16 at 11:37
  • 2
    You could enable active mode and check files as you save them. Or write a script to run checks against all files outside Vim. Or just write tests... – lcd047 Jan 21 '16 at 12:24
  • If you lint as you develop and perform CI, I agree, cycling through errors across multiple files is not often necessary. However, if you're linting all files for the first time, or upgrading your linter with new rules to implement... the accumulated errors spread across files can be daunting. – Bluu Aug 23 '16 at 22:01
  • @Bluu Then write a script to run checks outside Vim, like I said. Make it output a list of files with problems, and edit them. Since you're a human, you'd still only be able to fix problems one file at a time. :) – lcd047 Aug 25 '16 at 06:10
  • Right, I've done that. I can get the exact list of files I need to edit into Vim buffers. But to jump to each error, I still need to do `:Bufdo SyntasticCheck`, `:Bufdo Errors`, and visit each buffer. Is there a better way? – Bluu Aug 25 '16 at 16:19
  • 1
    @Bluu Read the manual to find out how you can make use of `check_on_open` and active mode. Open first file, run the checkers, fix errors, close file. Open second file, run the checkers, fix errors, close file. Go on until you're done. Further attempts at automation won't buy you anything useful in this particular situation. – lcd047 Aug 26 '16 at 18:46
1

Vim supports errorfiles, so if your underlying checker can output a list of errors in the format expected by Vim, just run vim -q [errorfile] and the quickfix list will be populated with all the errors. You can cycle through the locations in the quickfix list (e.g. using :cn) and Vim will open the corresponding files for you as you go.

Nick Myatt
  • 11
  • 1