├── .gitignore ├── README.md ├── autoload ├── quickrun │ └── hook │ │ └── watchdogs_quickrun_running_checker.vim └── watchdogs.vim ├── bin └── vimparse.pl ├── doc └── watchdogs.jax └── plugin └── watchdogs.vim /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags-ja 2 | test/* 3 | test_watchdogs/* 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # watchdogs.vim 2 | 3 | Async syntax check plugin. 4 | 5 | 6 | ## Requirement 7 | 8 | * [vim-quickrun](https://github.com/thinca/vim-quickrun) 9 | * [vimproc](https://github.com/Shougo/vimproc) 10 | * [shabadou.vim](https://github.com/osyo-manga/shabadou.vim) 11 | 12 | * more 13 | * [vim-hier](https://github.com/jceb/vim-hier) 14 | * [quickfixstatus](https://github.com/dannyob/quickfixstatus) 15 | 16 | 17 | ## Supported 18 | * C 19 | * gcc 20 | * clang 21 | * C++ 22 | * g++ 23 | * g++03 24 | * clang++ 25 | * clang++03 26 | * clang-check 27 | * msvc 28 | * coffee 29 | * coffee 30 | * coffeelint 31 | * css 32 | * csslint 33 | * stylelint 34 | * D 35 | * dmd 36 | * go 37 | * gofmt 38 | * govet 39 | * golint 40 | * go vet 41 | * Haml 42 | * haml 43 | * haml-lint 44 | * Haskell 45 | * ghc-mod 46 | * hlint 47 | * hdevtools 48 | * Java 49 | * javac 50 | * JavaScript 51 | * jshint 52 | * eslint 53 | * JSON 54 | * jsonlint 55 | * Lua 56 | * luac 57 | * Nim 58 | * nim 59 | * Markdown 60 | * redpen 61 | * textlint 62 | * mdl 63 | * eslint-md 64 | * Perl 65 | * perl 66 | * vimparse.pl 67 | * PHP 68 | * php 69 | * phpcs 70 | * phpmd 71 | * Python 72 | * pyflakes 73 | * flake8 74 | * Ruby 75 | * ruby 76 | * rubocop 77 | * Rust 78 | * rustc 79 | * rustc_parse-only(use `$ rustc parse-only`) 80 | * sass 81 | * sass 82 | * Scala 83 | * scalac 84 | * scss 85 | * scss 86 | * scss-lint 87 | * stylelint 88 | * sh 89 | * sh 90 | * shellcheck 91 | * bashate 92 | * checkbashisms 93 | * TypeScript 94 | * tsc 95 | * tslint 96 | * Vim script 97 | * vint 98 | * vimlint 99 | * vimlint_by_dbakker 100 | * YAML 101 | * yaml-lint 102 | * zsh 103 | * zsh 104 | 105 | -------------------------------------------------------------------------------- /autoload/quickrun/hook/watchdogs_quickrun_running_checker.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | 3 | let s:save_cpo = &cpo 4 | set cpo&vim 5 | 6 | 7 | let s:hook = { 8 | \ "config" : { 9 | \ "enable" : 1 10 | \ }, 11 | \} 12 | 13 | function! s:hook.init(...) 14 | if self.config.enable 15 | let g:watchdogs_quickrun_running_check = 1 16 | endif 17 | endfunction 18 | 19 | function! s:hook.on_exit(...) 20 | let g:watchdogs_quickrun_running_check = 0 21 | endfunction 22 | 23 | 24 | function! quickrun#hook#watchdogs_quickrun_running_checker#new() 25 | return deepcopy(s:hook) 26 | endfunction 27 | 28 | let &cpo = s:save_cpo 29 | unlet s:save_cpo 30 | -------------------------------------------------------------------------------- /autoload/watchdogs.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpo 2 | set cpo&vim 3 | 4 | 5 | function! s:get_vimlint() 6 | return substitute(globpath(&rtp, "vimlint/vimlint.py"), '\\', '/', "g") 7 | endfunction 8 | 9 | 10 | 11 | function! s:executable_vimlint() 12 | return executable("python") && !empty(s:get_vimlint()) 13 | endfunction 14 | 15 | 16 | function! s:get_vimlint_syngan_plugin_dir() 17 | return substitute(fnamemodify(globpath(&rtp, "autoload/vimlint.vim"), ":h:h"), '\\', '/', "g") 18 | endfunction 19 | 20 | 21 | function! s:get_vimlparser_plugin_dir() 22 | return substitute(fnamemodify(globpath(&rtp, "autoload/vimlparser.vim"), ":h:h"), '\\', '/', "g") 23 | endfunction 24 | 25 | 26 | function! s:executable_vim_vimlint() 27 | return filereadable(globpath(&rtp, "autoload/vimlparser.vim")) && filereadable(globpath(&rtp, "autoload/vimlint.vim")) 28 | endfunction 29 | 30 | 31 | " let g:watchdogs#vimlint_config = get(g:, "watchdogs#vimlint_config", {}) 32 | let g:watchdogs#vimlint_empty_config = "{}" 33 | 34 | 35 | 36 | let g:watchdogs#default_config = { 37 | \ 38 | \ "watchdogs_checker/_" : { 39 | \ "runner" : "vimproc", 40 | \ "outputter" : "quickfix", 41 | \ "outputter/quickfix/open_cmd" : "cwindow", 42 | \ "hook/hier_update/enable_exit" : 1, 43 | \ "hook/quickfix_status_enable/enable_exit" : 1, 44 | \ "hook/shebang/enable" : 0, 45 | \ "hook/quickfix_replate_tempname_to_bufnr/enable_exit" : 1, 46 | \ "hook/quickfix_replate_tempname_to_bufnr/priority_exit" : -10, 47 | \ }, 48 | \ 49 | \ 50 | \ "c/watchdogs_checker" : { 51 | \ "type" 52 | \ : executable("gcc") ? "watchdogs_checker/gcc" 53 | \ : executable("clang") ? "watchdogs_checker/clang" 54 | \ : "" 55 | \ }, 56 | \ 57 | \ "watchdogs_checker/gcc" : { 58 | \ "command" : "gcc", 59 | \ "exec" : "%c %o -fsyntax-only %s:p ", 60 | \ }, 61 | \ 62 | \ "watchdogs_checker/clang" : { 63 | \ "command" : "clang", 64 | \ "exec" : "%c %o -fsyntax-only %s:p ", 65 | \ }, 66 | \ 67 | \ 68 | \ "cpp/watchdogs_checker" : { 69 | \ "type" 70 | \ : executable("clang-check") ? "watchdogs_checker/clang_check" 71 | \ : executable("g++") ? "watchdogs_checker/g++" 72 | \ : executable("clang++") ? "watchdogs_checker/clang++" 73 | \ : executable("cl") ? "watchdogs_checker/cl" 74 | \ : "", 75 | \ }, 76 | \ 77 | \ "watchdogs_checker/g++" : { 78 | \ "command" : "g++", 79 | \ "exec" : "%c -std=gnu++0x %o -fsyntax-only %s:p ", 80 | \ }, 81 | \ 82 | \ "watchdogs_checker/g++03" : { 83 | \ "command" : "g++", 84 | \ "exec" : "%c %o -fsyntax-only %s:p ", 85 | \ }, 86 | \ 87 | \ "watchdogs_checker/clang++" : { 88 | \ "command" : "clang++", 89 | \ "exec" : "%c -std=gnu++0x %o -fsyntax-only %s:p ", 90 | \ }, 91 | \ 92 | \ "watchdogs_checker/clang++03" : { 93 | \ "command" : "clang++", 94 | \ "exec" : "%c %o -fsyntax-only %s:p ", 95 | \ }, 96 | \ 97 | \ "watchdogs_checker/clang_check" : { 98 | \ "command" : "clang-check", 99 | \ "exec" : "%c %s:p -- %o", 100 | \ "cmdopt" : "--std=c++11", 101 | \ }, 102 | \ 103 | \ "watchdogs_checker/msvc" : { 104 | \ "command" : "cl", 105 | \ "exec" : "%c /Zs %o %s:p ", 106 | \ }, 107 | \ 108 | \ 109 | \ "typescript/watchdogs_checker" : { 110 | \ "type" 111 | \ : executable("tsc") ? "watchdogs_checker/tsc" 112 | \ : executable("tslint") ? "watchdogs_checker/tslint" 113 | \ : "" 114 | \ }, 115 | \ 116 | \ "watchdogs_checker/tsc" : { 117 | \ "command" : "tsc", 118 | \ "exec" : "%c --noEmit %o %s:p", 119 | \ "errorformat" : '%+A\ %#%f\ %#(%l\\,%c):\ %m,%C%m', 120 | \ }, 121 | \ 122 | \ "watchdogs_checker/tslint" : { 123 | \ "command" : "tslint", 124 | \ "exec" : "%c %s:p", 125 | \ "errorformat" : '%f[%l\\,\ %c]:\ %m', 126 | \ }, 127 | \ 128 | \ 129 | \ "coffee/watchdogs_checker" : { 130 | \ "type" 131 | \ : executable("coffeelint") ? "watchdogs_checker/coffeelint" 132 | \ : executable("coffee") ? "watchdogs_checker/coffee" 133 | \ : "" 134 | \ }, 135 | \ 136 | \ "watchdogs_checker/coffee" : { 137 | \ "command" : "coffee", 138 | \ "exec" : "%c -c -l -o /tmp %o %s:p", 139 | \ "errorformat" : 'Syntax%trror: In %f\, %m on line %l,%EError: In %f\, Parse error on line %l: %m,%EError: In %f\, %m on line %l,%W%f(%l): lint warning: %m,%-Z%p^,%W%f(%l): warning: %m,%-Z%p^,%E%f(%l): SyntaxError: %m,%-Z%p^,%-G%.%#', 140 | \ }, 141 | \ 142 | \ "watchdogs_checker/coffeelint" : { 143 | \ "command" : "coffeelint", 144 | \ "exec" : "%c --csv %o %s:p", 145 | \ "errorformat" : '%f\,%l\,%trror\,%m', 146 | \ }, 147 | \ 148 | \ "css/watchdogs_checker" : { 149 | \ "type" 150 | \ : executable("csslint") ? "watchdogs_checker/csslint" 151 | \ : executable("stylelint") ? "watchdogs_checker/stylelint" 152 | \ : "" 153 | \ }, 154 | \ 155 | \ "watchdogs_checker/csslint" : { 156 | \ "command" : "csslint", 157 | \ "exec" : "%c --format=compact %o %s:p", 158 | \ "errorformat" : '%f:\ line\ %l\\,\ col\ %c\\,\ %m', 159 | \ }, 160 | \ 161 | \ "watchdogs_checker/stylelint" : { 162 | \ "command" : "stylelint", 163 | \ "exec" : "%c %o %s:p", 164 | \ "errorformat" : '%+P%f,%*\s%l:%c%*\s%m,%-Q', 165 | \ }, 166 | \ 167 | \ "d/watchdogs_checker" : { 168 | \ "type" 169 | \ : executable("dmd") ? "watchdogs_checker/dmd" 170 | \ : "" 171 | \ }, 172 | \ 173 | \ "watchdogs_checker/dmd" : { 174 | \ "command" : "dmd", 175 | \ "exec" : "%c %o -c %s:p", 176 | \ }, 177 | \ 178 | \ 179 | \ "go/watchdogs_checker" : { 180 | \ "type" 181 | \ : executable("gofmt") ? "watchdogs_checker/gofmt" 182 | \ : executable("govet") ? "watchdogs_checker/govet" 183 | \ : executable("golint") ? "watchdogs_checker/golint" 184 | \ : executable("go") ? "watchdogs_checker/go_vet" 185 | \ : "" 186 | \ }, 187 | \ 188 | \ "watchdogs_checker/gofmt" : { 189 | \ "command" : "gofmt", 190 | \ "exec" : "%c -l %o %s:p", 191 | \ "errorformat" : '%f:%l:%c: %m,%-G%.%#', 192 | \ }, 193 | \ 194 | \ "watchdogs_checker/govet" : { 195 | \ "command" : "govet", 196 | \ "exec" : "%c %o %s:p", 197 | \ "errorformat" : 'govet: %.%\+: %f:%l:%c: %m,%W%f:%l: %m,%-G%.%#', 198 | \ }, 199 | \ 200 | \ "watchdogs_checker/golint" : { 201 | \ "command" : "golint", 202 | \ "exec" : "%c %o %s:p", 203 | \ "errorformat" : '%f:%l:%c: %m', 204 | \ }, 205 | \ 206 | \ "watchdogs_checker/go_vet" : { 207 | \ "command" : "go", 208 | \ "exec" : "%c vet %o %s:p", 209 | \ "errorformat" : 'vet: %.%\+: %f:%l:%c: %m,%W%f:%l: %m,%-G%.%#', 210 | \ }, 211 | \ 212 | \ 213 | \ "haml/watchdogs_checker" : { 214 | \ "type" 215 | \ : executable("haml") ? "watchdogs_checker/haml" 216 | \ : executable("haml-lint") ? "watchdogs_checker/haml-lint" 217 | \ : "" 218 | \ }, 219 | \ 220 | \ "watchdogs_checker/haml" : { 221 | \ "command" : "haml", 222 | \ "cmdopt" : "--check --trace", 223 | \ }, 224 | \ 225 | \ "watchdogs_checker/haml-lint" : { 226 | \ "command" : "haml-lint", 227 | \ "exec" : "%c --no-color %o %s:p", 228 | \ "errorformat" : '%f:%l \\[%t\\] %m', 229 | \ }, 230 | \ 231 | \ 232 | \ "haskell/watchdogs_checker" : { 233 | \ "type" 234 | \ : executable("ghc-mod") ? "watchdogs_checker/ghc-mod" 235 | \ : executable("hlint") ? "watchdogs_checker/hlint" 236 | \ : executable("hdevtools") ? "watchdogs_checker/hdevtools" 237 | \ : "" 238 | \ }, 239 | \ 240 | \ "watchdogs_checker/ghc-mod" : { 241 | \ "command" : "ghc-mod", 242 | \ "exec" : '%c %o check %s:p', 243 | \ "errorformat" : '%f:%l:%c:%trror: %m,%f:%l:%c:%tarning: %m,%f:%l:%c:parse %trror %m,%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: %m,%f:%l:%c:%m,%E%f:%l:%c:,%Z%m', 244 | \ "tempfile": 'TemporaryWatchDogSourceFile.hs' 245 | \ }, 246 | \ 247 | \ "watchdogs_checker/hlint" : { 248 | \ "command" : "hlint", 249 | \ "exec" : '%c %o %s:p', 250 | \ }, 251 | \ 252 | \ "watchdogs_checker/hdevtools" : { 253 | \ "command" : "hdevtools", 254 | \ "exec" : '%c check %o %s:p', 255 | \ }, 256 | \ 257 | \ 258 | \ "java/watchdogs_checker" : { 259 | \ "type" 260 | \ : executable("javac") ? "watchdogs_checker/javac" 261 | \ : "" 262 | \ }, 263 | \ 264 | \ "watchdogs_checker/javac" : { 265 | \ "command" : "javac", 266 | \ "exec" : "%c -d " . ( 267 | \ exists('$TEMP') ? $TEMP 268 | \ : exists('$TMP') ? $TMP 269 | \ : exists('$TMPDIR') ? $TMPDIR 270 | \ : "") . 271 | \ " %o %S:p", 272 | \ "errorformat" : '%tarning: %m,%-G%*\d error,%-G%*\d warnings,%f:%l: %trror: %m,%f:%l: %tarning: %m,%+G%.%#', 273 | \ }, 274 | \ 275 | \ 276 | \ "javascript/watchdogs_checker" : { 277 | \ "type" 278 | \ : executable("jshint") ? "watchdogs_checker/jshint" 279 | \ : executable("eslint") ? "watchdogs_checker/eslint" 280 | \ : "" 281 | \ }, 282 | \ 283 | \ "watchdogs_checker/jshint" : { 284 | \ "command" : "jshint", 285 | \ "exec" : "%c %o %s:p", 286 | \ "errorformat" : '%f: line %l\,\ col %c\, %m, %-G%.%#', 287 | \ }, 288 | \ 289 | \ "watchdogs_checker/eslint" : { 290 | \ "command" : "eslint", 291 | \ "exec" : "%c -f compact %o %s:p", 292 | \ "errorformat" : '%E%f: line %l\, col %c\, Error - %m,' . 293 | \ '%W%f: line %l\, col %c\, Warning - %m,' . 294 | \ '%-G%.%#', 295 | \ }, 296 | \ 297 | \ "json/watchdogs_checker" : { 298 | \ "type" 299 | \ : executable("jsonlint") ? "watchdogs_checker/jsonlint" 300 | \ : "" 301 | \ }, 302 | \ 303 | \ "watchdogs_checker/jsonlint" : { 304 | \ "command" : "jsonlint", 305 | \ "exec" : "%c %o -c %s:p", 306 | \ "errorformat" : '%f: line %l\\, col %c\\, %m', 307 | \ }, 308 | \ 309 | \ 310 | \ "lua/watchdogs_checker" : { 311 | \ "type" 312 | \ : executable("luac") ? "watchdogs_checker/luac" 313 | \ : "" 314 | \ }, 315 | \ 316 | \ "watchdogs_checker/luac" : { 317 | \ "command" : "luac", 318 | \ "exec" : "%c %o -p %s:p", 319 | \ "errorformat" : '%.%#: %#%f:%l: %m', 320 | \ }, 321 | \ 322 | \ 323 | \ "nim/watchdogs_checker" : { 324 | \ "type" : "watchdogs_checker/nim", 325 | \ }, 326 | \ 327 | \ "watchdogs_checker/nim" : { 328 | \ "command" : "nim", 329 | \ "cmdopt" : "check", 330 | \ "errorformat" : '%-GHint: %m,%E%f(%l\, %c) Error: %m,%W%f(%l\, %c) Hint: %m', 331 | \ }, 332 | \ 333 | \ 334 | \ "markdown/watchdogs_checker" : { 335 | \ "type" 336 | \ : executable("redpen") ? "watchdogs_checker/redpen" 337 | \ : executable("textlint") ? "watchdogs_checker/textlint" 338 | \ : executable("mdl") ? "watchdogs_checker/mdl" 339 | \ : executable("eslint-md") ? "watchdogs_checker/eslint-md" 340 | \ : "" 341 | \ }, 342 | \ 343 | \ "watchdogs_checker/textlint" : { 344 | \ "command" : "textlint", 345 | \ "exec" : "%c -f compact %o %s:p", 346 | \ "errorformat" : '%E%f: line %l\, col %c\, Error - %m,' . 347 | \ '%W%f: line %l\, col %c\, Warning - %m,' . 348 | \ '%-G%.%#' 349 | \ }, 350 | \ 351 | \ "watchdogs_checker/mdl" : { 352 | \ "command" : "mdl", 353 | \ "errorformat" : "%E%f:%l: %m," . 354 | \ "%W%f: Kramdown Warning: %m found on line %l" 355 | \ }, 356 | \ 357 | \ "watchdogs_checker/eslint-md" : { 358 | \ "command" : "eslint-md", 359 | \ "exec" : "%c -f compact %o %s:p", 360 | \ "errorformat" : '%E%f: line %l\, col %c\, Error - %m,' . 361 | \ '%W%f: line %l\, col %c\, Warning - %m,' . 362 | \ '%-G%.%#', 363 | \ }, 364 | \ 365 | \ 366 | \ "perl/watchdogs_checker" : { 367 | \ "type" 368 | \ : executable("perl") ? "watchdogs_checker/perl" 369 | \ : "" 370 | \ }, 371 | \ 372 | \ "watchdogs_checker/perl" : { 373 | \ "command" : "perl", 374 | \ "exec" : "%c %o -c %s:p", 375 | \ "errorformat" : '%m\ at\ %f\ line\ %l%.%#', 376 | \ }, 377 | \ 378 | \ "watchdogs_checker/vimparse.pl" : { 379 | \ "command" : "perl", 380 | \ "exec" : "%c " . substitute(expand(':p:h:h'), '\\', '\/', "g") . "/bin/vimparse.pl" . " -c %o %s:p", 381 | \ "errorformat" : '%f:%l:%m', 382 | \ }, 383 | \ 384 | \ 385 | \ "php/watchdogs_checker" : { 386 | \ "type" 387 | \ : executable("php") ? "watchdogs_checker/php" 388 | \ : executable("phpcs") ? "watchdogs_checker/phpcs" 389 | \ : executable("phpmd") ? "watchdogs_checker/phpmd" 390 | \ : "" 391 | \ }, 392 | \ 393 | \ "watchdogs_checker/php" : { 394 | \ "command" : "php", 395 | \ "exec" : "%c %o -l %s:p", 396 | \ "errorformat" : '%m\ in\ %f\ on\ line\ %l', 397 | \ }, 398 | \ 399 | \ "watchdogs_checker/phpcs" : { 400 | \ "command" : "phpcs", 401 | \ "exec" : "%c --report=emacs %o %s:p", 402 | \ "errorformat" : '%f:%l:%c:\ %m', 403 | \ }, 404 | \ 405 | \ "watchdogs_checker/phpmd" : { 406 | \ "command" : "phpmd", 407 | \ "exec" : "%c %s:p text %o", 408 | \ "cmdopt" : "cleancode,codesize,design,naming,unusedcode", 409 | \ "errorformat" : '%f:%l%\s%m,%-G%.%#', 410 | \ }, 411 | \ 412 | \ 413 | \ "python/watchdogs_checker" : { 414 | \ "type" 415 | \ : executable("flake8") ? "watchdogs_checker/flake8" 416 | \ : executable("pyflakes") ? "watchdogs_checker/pyflakes" 417 | \ : "" 418 | \ }, 419 | \ 420 | \ "watchdogs_checker/pyflakes" : { 421 | \ "command" : "pyflakes", 422 | \ "exec" : '%c %o %s:p', 423 | \ "errorformat" : '%f:%l:%m', 424 | \ }, 425 | \ 426 | \ "watchdogs_checker/flake8" : { 427 | \ "command" : "flake8", 428 | \ "exec" : '%c %o %s:p', 429 | \ "errorformat" : '%f:%l:%c: %m', 430 | \ }, 431 | \ 432 | \ "ruby/watchdogs_checker" : { 433 | \ "type" 434 | \ : executable("ruby") ? "watchdogs_checker/ruby" 435 | \ : "" 436 | \ }, 437 | \ 438 | \ "watchdogs_checker/ruby" : { 439 | \ "command" : "ruby", 440 | \ "exec" : "%c %o -c %s:p", 441 | \ }, 442 | \ 443 | \ "watchdogs_checker/rubocop" : { 444 | \ "command" : "rubocop", 445 | \ "exec" : "%c %o %s:p", 446 | \ "errorformat" : '%f:%l:%c:%m,%f:%l:%m,%-G%.%#', 447 | \ }, 448 | \ 449 | \ "rust/watchdogs_checker" : { 450 | \ "type" 451 | \ : executable("rustc") ? "watchdogs_checker/rustc" 452 | \ : "" 453 | \ }, 454 | \ 455 | \ "watchdogs_checker/rustc" : { 456 | \ "command" : "rustc", 457 | \ "exec" : '%c %o %s:p', 458 | \ "cmdopt" : "-Z no-trans", 459 | \ "errorformat" 460 | \ : '%-Gerror: aborting %.%#,' 461 | \ . '%-Gerror: Could not compile %.%#,' 462 | \ . '%Eerror: %m,' 463 | \ . '%Eerror[E%n]: %m,' 464 | \ . '%Wwarning: ,' 465 | \ . '%C %#--> %f:%l:%c' 466 | \ }, 467 | \ 468 | \ "watchdogs_checker/rustc_parse-only" : { 469 | \ "command" : "rustc", 470 | \ "exec" : '%c %o %s:p', 471 | \ "cmdopt" : "-Z parse-only", 472 | \ "errorformat" 473 | \ : '%E%f:%l:%c: %\d%#:%\d%# %.%\{-}error:%.%\{-} %m' 474 | \ . ',%W%f:%l:%c: %\d%#:%\d%# %.%\{-}warning:%.%\{-} %m' 475 | \ . ',%C%f:%l %m' 476 | \ . ',%-Z%.%#', 477 | \ }, 478 | \ 479 | \ 480 | \ "sass/watchdogs_checker" : { 481 | \ "type" 482 | \ : executable("sass") ? "watchdogs_checker/sass" 483 | \ : "" 484 | \ }, 485 | \ 486 | \ "watchdogs_checker/sass" : { 487 | \ "command" : "sass", 488 | \ "exec" : "%c %o --check ".(executable("compass") ? "--compass" : "")." %s:p", 489 | \ "errorformat" 490 | \ : '%ESyntax %trror:%m,%C on line %l of %f,%Z%.%#' 491 | \ . ',%Wwarning on line %l:,%Z%m,Syntax %trror on line %l: %m', 492 | \ }, 493 | \ 494 | \ 495 | \ "scss/watchdogs_checker" : { 496 | \ "type" 497 | \ : executable("sass") ? "watchdogs_checker/scss" 498 | \ : executable("scss-lint") ? "watchdogs_checker/scss-lint" 499 | \ : executable("stylelint") ? "watchdogs_checker/stylelint" 500 | \ : "", 501 | \ "cmdopt" 502 | \ : executable("sass") ? "" 503 | \ : executable("scss-lint") ? "" 504 | \ : executable("stylelint") ? "--syntax scss" 505 | \ : "" 506 | \ }, 507 | \ 508 | \ "watchdogs_checker/scss" : { 509 | \ "command" : "sass", 510 | \ "exec" : "%c %o --check ".(executable("compass") ? "--compass" : "")." %s:p", 511 | \ "errorformat" 512 | \ : '%ESyntax %trror:%m,%C on line %l of %f,%Z%.%#' 513 | \ .',%Wwarning on line %l:,%Z%m,Syntax %trror on line %l: %m', 514 | \ }, 515 | \ 516 | \ "watchdogs_checker/scss-lint" : { 517 | \ "command" : "scss-lint", 518 | \ "exec" : "%c %o %s:p", 519 | \ "errorformat" : '%f:%l\ %m, %-G%.%#', 520 | \ }, 521 | \ 522 | \ 523 | \ "scala/watchdogs_checker" : { 524 | \ "type" 525 | \ : executable("scalac") ? "watchdogs_checker/scalac" 526 | \ : "" 527 | \ }, 528 | \ 529 | \ "watchdogs_checker/scalac" : { 530 | \ "command" : "scalac", 531 | \ "exec" : "%c %o -Ystop-after:parser %s:p", 532 | \ "errorformat" : '%f:%l:\ error:\ %m,%-Z%p^,%-C%.%#,%-G%.%#', 533 | \ }, 534 | \ 535 | \ 536 | \ "sh/watchdogs_checker" : { 537 | \ "type" 538 | \ : executable("sh") ? "watchdogs_checker/sh" 539 | \ : executable("shellcheck") ? "watchdogs_checker/shellcheck" 540 | \ : executable("bashate") ? "watchdogs_checker/bashate" 541 | \ : executable("checkbashisms") ? "watchdogs_checker/checkbashisms" 542 | \ : "" 543 | \ }, 544 | \ 545 | \ "watchdogs_checker/sh" : { 546 | \ "command" : "sh", 547 | \ "exec" : "%c -n %o %s:p", 548 | \ "errorformat" : '%f:\ line\ %l:%m', 549 | \ }, 550 | \ 551 | \ "watchdogs_checker/shellcheck" : { 552 | \ "command" : "shellcheck", 553 | \ 'cmdopt' : '-f gcc', 554 | \ }, 555 | \ 556 | \ "watchdogs_checker/bashate" : { 557 | \ "command" : "bashate", 558 | \ "errorformat" : "%E[E] %m,%W[W] %m,%Z - %f : L%l,%-G%.%#", 559 | \ }, 560 | \ 561 | \ "watchdogs_checker/checkbashisms" : { 562 | \ "command" : "checkbashisms", 563 | \ "errorformat" : "%-Gscript %f is already a bash script; skipping," . 564 | \ "%Eerror: %f: %m\, opened in line %l," . 565 | \ "%Eerror: %f: %m," . 566 | \ "%Ecannot open script %f for reading: %m," . 567 | \ "%Wscript %f %m,%C%.# lines," . 568 | \ "%Wpossible bashism in %f line %l (%m):,%C%.%#,%Z.%#," . 569 | \ "%-G%.%#" 570 | \ }, 571 | \ 572 | \ 573 | \ "zsh/watchdogs_checker" : { 574 | \ "type" 575 | \ : executable("zsh") ? "watchdogs_checker/zsh" 576 | \ : "" 577 | \ }, 578 | \ 579 | \ "watchdogs_checker/zsh" : { 580 | \ "command" : "zsh", 581 | \ "exec" : "%c -n %o %s:p", 582 | \ "errorformat" : '%f:%l:%m', 583 | \ }, 584 | \ 585 | \ 586 | \ "vim/watchdogs_checker" : { 587 | \ "type" 588 | \ : executable("vint") ? "watchdogs_checker/vint" 589 | \ : s:executable_vim_vimlint() ? "watchdogs_checker/vimlint" 590 | \ : s:executable_vimlint() ? "watchdogs_checker/vimlint_by_dbakker" 591 | \ : "" 592 | \ }, 593 | \ 594 | \ "watchdogs_checker/vint" : { 595 | \ 'command': 'vint', 596 | \ "exec" : '%c %o %s', 597 | \ }, 598 | \ 599 | \ "watchdogs_checker/vimlint" : { 600 | \ 'command': 'vim', 601 | \ "exec" : '%C -X -N -u NONE -i NONE -V1 -e -s -c "set rtp+=' . s:get_vimlparser_plugin_dir() . ',' . s:get_vimlint_syngan_plugin_dir() . '" -c "call vimlint#vimlint(''%s'', %{ exists(''g:vimlint#config'') ? string(g:vimlint#config) : g:watchdogs#vimlint_empty_config })" -c "qall!"', 602 | \ 'errorformat': '%f:%l:%c:%trror: %m,%f:%l:%c:%tarning: %m,%f:%l:%c:%m', 603 | \ }, 604 | \ 605 | \ "watchdogs_checker/vimlint_by_dbakker" : { 606 | \ 'command': 'python', 607 | \ 'exec': '%C ' . s:get_vimlint() . ' %s', 608 | \ "runner" : "vimproc", 609 | \ 'errorformat': '%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: %m', 610 | \ }, 611 | \ 612 | \ 613 | \ "watchdogs_checker/redpen" : { 614 | \ "command" : "redpen", 615 | \ "exec" : "%c %o %s:p", 616 | \ }, 617 | \ 618 | \ 619 | \ "yaml/watchdogs_checker" : { 620 | \ "type" 621 | \ : executable("yaml-lint") ? "watchdogs_checker/yaml-lint" 622 | \ : "" 623 | \ }, 624 | \ 625 | \ "watchdogs_checker/yaml-lint" : { 626 | \ "command" : "yaml-lint", 627 | \ 'cmdopt' : '-q', 628 | \ "errorformat" : "%.%#(%f): %m at line %l column %c%.%#" 629 | \ }, 630 | \ 631 | \ 632 | \ "watchdogs_checker_dummy" : {} 633 | \} 634 | 635 | 636 | function! watchdogs#setup(config, ...) 637 | let flag = a:0 && a:1 ? "force" : "keep" 638 | let base = "watchdogs_checker/_" 639 | let a:config[base] = extend(get(a:config, base, {}), g:watchdogs#default_config[base], flag) 640 | " PP a:config[base] 641 | for [type, config] in items(g:watchdogs#default_config) 642 | if has_key(a:config, type) 643 | let a:config[type] = extend( 644 | \ a:config[type], 645 | \ g:watchdogs#default_config[type], 646 | \ flag 647 | \ ) 648 | else 649 | let a:config[type] = deepcopy(config) 650 | endif 651 | endfor 652 | 653 | for [type, config] in items(a:config) 654 | if type =~# '^watchdogs_checker/.\+$' 655 | let a:config[type] = extend( 656 | \ a:config[type], 657 | \ a:config[base], 658 | \ flag 659 | \ ) 660 | endif 661 | endfor 662 | 663 | return a:config 664 | endfunction 665 | 666 | 667 | let &cpo = s:save_cpo 668 | unlet s:save_cpo 669 | -------------------------------------------------------------------------------- /bin/vimparse.pl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osyo-manga/vim-watchdogs/8ee2af37095af08376ba2409da152c2a36a4ee90/bin/vimparse.pl -------------------------------------------------------------------------------- /doc/watchdogs.jax: -------------------------------------------------------------------------------- 1 | *watchdogs.txt* quickrun.vim を使用したシンタックスチェックを行うプラグインで 2 | す。 3 | 4 | 5 | ============================================================================== 6 | 目次 *watchdogs-contents* 7 | 8 | 概要 |watchdogs-introduction| 9 | 使い方 |watchdogs-usage| 10 | 対応しているシンタックスチェックツール |watchdogs-tools| 11 | コンフィグ |watchdogs-config| 12 | filetype ごとにツールを設定 |watchdogs-config-filetype| 13 | ツールの設定を追加 |watchdogs-config-tools| 14 | watchdogs_checker/* 全てに共通する設定を定義 |watchdogs-config-default| 15 | 自動シンタックスチェック |watchdogs-auto| 16 | ファイルの書き込み後 |watchdogs-auto-BufWritePost| 17 | 一定時間キー入力がなかった場合にチェックを行う |watchdogs-auto-CursorHold| 18 | インターフェース |watchdogs-interface| 19 | コマンド |watchdogs-commands| 20 | 関数 |watchdogs-functions| 21 | 設定 |watchdogs-setting| 22 | 変数 |watchdogs-variables| 23 | 設定例 |watchdogs-examples| 24 | C++ |watchdogs-examples-cpp| 25 | quickfix のエラーフォマットを指定する |watchdogs-examples-erroformat| 26 | command を変更する |watchdogs-examples-command| 27 | quickfix ウィンドウを自動的に閉じる |watchdogs-examples-close_quickfix| 28 | quickfix ウィンドウを開かせない |watchdogs-examples-unopen_quickfix| 29 | vimproc の更新間隔を短くする |watchdogs-examples-updatetime| 30 | 一部の filetype のみ無効にする |watchdogs-examples-disable| 31 | 新しいツールを定義する |watchdogs-examples-add_tool| 32 | filetype に対して指定したツールを設定する |watchdogs-examples-change_tool| 33 | 34 | 35 | ============================================================================== 36 | 概要 *watchdogs-introduction* 37 | 38 | *watchdogs.vim* は thinca 氏が作成された |quickrun| をバックエンドとしたシンタック 39 | スチェックを行うためのプラグインです。 40 | |quickrun| をバックエンドに使用することで、非同期でシンタックスチェックを行う 41 | ことができ、さらに幅広い拡張を行うこともできます。 42 | 本プラグインを使用するにあたって予め下記のプラグインを導入しておく必要があ 43 | ります。 44 | す。 45 | 46 | - vim-quickrun - github : https://github.com/thinca/vim-quickrun 47 | quickrun 48 | 49 | - vimproc - github : https://github.com/Shougo/vimproc 50 | quickrun で非同期を行うためのプラグイン 51 | 52 | - shabadou.vim - github : https://github.com/osyo-manga/shabadou.vim 53 | 汎用的な quickrun-hook をまとめたプラグイン 54 | 55 | 56 | 57 | また、下記のプラグインも導入しておくと利便性が上がります。 58 | 59 | - vim-hier - github : https://github.com/jceb/vim-hier 60 | quickfix の該当するコード箇所のハイライトを行う 61 | 本プラグインはデフォルトではハイライトの機能はないので、vim-hier などの外部 62 | プラグインを使用する必要があります 63 | 64 | - quickfixstatus - https://github.com/dannyob/quickfixstatus 65 | quickfix の該当箇所にカーソルを移動させるとエラー内容がコマンドウィンドウに 66 | 出力される 67 | 68 | 本プラグインは quickfix へと出力を行なっているので、上記のような quickfix を参 69 | 照するプラグインを使用することが出来ます。 70 | 71 | 72 | 各シンタックスチェックを行うための設定方法や拡張方法などは |g:quickrun_config| 73 | と同じなので予め |g:quickrun_config| を読んでおくとスムーズに設定を行うことが 74 | 出来ると思います。 75 | 76 | 77 | *watchdogs-synopsis* 78 | > 79 | " 現在の filetype に沿ったシンタックスチェックを行う 80 | " 出力は quickfix に行われる 81 | :WatchdogsRun 82 | < 83 | 84 | 85 | また、コマンドから呼び出す以外にもファイルの保存時や一定時間キー入力を行われな 86 | かった場合等に自動的でシンタックスチェックを行うこともできます。 87 | 88 | 89 | ============================================================================== 90 | 使い方 *watchdogs-usage* 91 | 92 | |:WatchdogsRun| コマンドで |g:quickrun_config| の設定を参照し、シンタックス 93 | チェックを行います。 94 | 95 | > 96 | " WatchdogsRun でシンタックスチェックを行います 97 | :WatchdogsRun 98 | 99 | " 使用するチェッカーを指定する 100 | WatchdogsRun watchdogs_checker/g++ 101 | 102 | " :QuickRun と同様の引数も渡すことが出来ます 103 | WatchdogsRun watchdogs_checker/g++ -cmdopt -Wall 104 | < 105 | 106 | 107 | また、下記の設定することで任意のタイミングに自動的にチェックを行うこと 108 | も出来ます。 109 | 110 | > 111 | " ファイルの書き込み後にシンタックスチェックを行う 112 | " 使用する場合は任意の filetype のキーで 1 を設定する 113 | let g:watchdogs_check_BufWritePost_enables = { 114 | \ "haskell" : 1 115 | \} 116 | < 117 | 118 | 119 | ============================================================================== 120 | 対応しているシンタックスチェックツール *watchdogs-tools* 121 | 122 | |watchdogs.vim| で既に定義されているシンタックスチェックの為のツールは次の通り 123 | です。 124 | 125 | 126 | - "g++" 127 | gcc の -fsyntax-only オプションで C++ のシンタックスチェックを行います。 128 | 129 | - "g++03" 130 | gcc の -fsyntax-only オプションで C++ のシンタックスチェックを行います。 131 | "g++" と違い -std=gnu++0x オプションはついていません。 132 | 133 | - "clang++" 134 | clang の -fsyntax-only オプションで C++ のシンタックスチェックを行います。 135 | 136 | - "clang++03" 137 | clang の -fsyntax-only オプションで C++ のシンタックスチェックを行います。 138 | "clang++" と違い -std=gnu++0x オプションはついていません。 139 | 140 | - "clang-check" 141 | clang の clang-check ツールを使用したシンタックスチェック 142 | 参照:http://clang.llvm.org/docs/ClangCheck.html 143 | 144 | - "msvc" 145 | cl.exe の /Zs オプションで C++ のシンタックスチェックを行います。 146 | 147 | - "ruby" 148 | ruby の -c オプションで Ruby のシンタックスチェックを行います。 149 | 150 | - "rubocop" 151 | rubocop を使用して Ruby のシンタックスチェックを行います。 152 | bbatsov/rubocop - https://github.com/bbatsov/rubocop 153 | 154 | - "javac" 155 | javac を使用した Java のシンタックスチェックを行います。 156 | classpathの設定は行っていませんので、必要に応じてcmdoptに追加してください。 157 | 158 | - "jshint" 159 | jshint を使用した JavaScript のシンタックスチェックを行います。 160 | 161 | - "eslint" 162 | eslint を使用した JavaScript のシンタックスチェックを行います。 163 | 164 | - "ghc-mod" 165 | ghc-mod を使用した Haskell のシンタックスチェックを行います。 166 | 167 | - "hlint" 168 | hlint を使用した Haskell のシンタックスチェックを行います。 169 | 170 | - "hdevtools" 171 | hdevtools を使用した Haskell のシンタックスチェックを行います。 172 | 173 | - "pyflakes" 174 | pyflakes を使用した Python のシンタックスチェックを行います。 175 | 176 | - "flake8" 177 | flake8 を使用した Python のシンタックスチェックを行います。 178 | 179 | - "perl" 180 | perl の -c オプションで perl のシンタックスチェックを行います。 181 | 182 | - "php" 183 | php の -l オプションで php のシンタックスチェックを行います。 184 | 185 | - "phpcs" 186 | PHP_CodeSniffer の --report=emacs オプションで php のシンタックスチェックを行います。 187 | squizlabs/PHP_CodeSniffer - https://github.com/squizlabs/PHP_CodeSniffer 188 | 189 | - "phpmd" 190 | PHP Mess Detector の cleancode,codesize,design,naming,unusedcode オプションで php のシンタックスチェックを行います。 191 | phpmd/phpmd - https://github.com/phpmd/phpmd 192 | 193 | - "luac" 194 | luac を使用した lua のシンタックスチェックを行います。 195 | 196 | - "dmd" 197 | dmd の -c オプションで D言語のシンタックスチェックを行います。 198 | 199 | - "gofmt" 200 | gofmt で GO言語のシンタックスチェックを行います。 201 | 202 | - "govet" 203 | govet で GO言語のシンタックスチェックを行います。 204 | 205 | - "golint" 206 | golint で GO言語のシンタックスチェックを行います。 207 | golang/lint - https://github.com/golang/lint 208 | 209 | - "go_vet" 210 | go の vet オプションで GO言語のシンタックスチェックを行います。 211 | 212 | - "gcc" 213 | gcc の -fsyntax-only オプションで C言語のシンタックスチェックを行います。 214 | 215 | - "clang" 216 | clang の -fsyntax-only オプションで C言語のシンタックスチェックを行います。 217 | 218 | - "vimparse.pl" 219 | vimparse.pl で perl のシンタックスチェックを行います。 220 | 221 | - "scalac" 222 | scalac で scala のシンタックスチェックを行います。 223 | 224 | - "sh" 225 | sh で sh のシンタックスチェックを行います。 226 | 227 | - "shellcheck" 228 | shellcheck で sh のシンタックスチェックを行います。 229 | koalaman/shellcheck - https://github.com/koalaman/shellcheck 230 | 231 | - "bashate" 232 | bashate で sh のシンタックスチェックを行います。 233 | openstack-dev/bashate - https://github.com/openstack-dev/bashate 234 | 235 | - "checkbashisms" 236 | checkbashisms で sh のシンタックスチェックを行います。 237 | devscripts/checkbashisms - http://debian.inode.at/debian/pool/main/d/devscripts/ 238 | 239 | - "zsh" 240 | zsh で zsh のシンタックスチェックを行います。 241 | 242 | - "sass" 243 | sass で --check オプションで sass のシンタックスチェックを行います。 244 | 245 | - "scss" 246 | scss で --check オプションで scss のシンタックスチェックを行います。 247 | 248 | - "scss-lint" 249 | scss-lint で scss のシンタックスチェックを行います。 250 | brigade/scss-lint - https://github.com/brigade/scss-lint 251 | 252 | - "stylelint" 253 | stylelint で css または scss のシンタックスチェックを行います。 254 | stylelint/stylelint - https://github.com/stylelint/stylelint 255 | 256 | - "tsc" 257 | tsc で typescript のシンタックスチェックを行います。 258 | 259 | - "tslint" 260 | tslint で typescript のシンタックスチェックを行います。 261 | palantir/tslint - https://github.com/palantir/tslint 262 | 263 | - "coffee" 264 | coffee の -c -l オプションで coffee のシンタックスチェックを行います。 265 | 266 | coffeelint で coffee のシンタックスチェックを行います。 267 | 268 | - "csslint" 269 | csslint で CSS のシンタックスチェックを行います。 270 | CSSLint/csslint - https://github.com/CSSLint/csslint 271 | 272 | - "vint" 273 | vint で Vim script のシンタックスチェックを行います。 274 | Kuniwak/vint - https://github.com/Kuniwak/vint 275 | 276 | - "vimlint" 277 | vim-vimlint で Vim script のシンタックスチェックを行います。 278 | syngan/vim-vimlint - https://github.com/syngan/vim-vimlint 279 | 280 | - "vimlint_by_dbakker" 281 | vim-lint で Vim script のシンタックスチェックを行います。 282 | dbakker/vim-lint - https://github.com/dbakker/vim-lint 283 | 284 | - "haml" 285 | haml の --check --trace オプションで haml のシンタックスチェックを 286 | 行います。 287 | 288 | - "haml-lint" 289 | haml-lint で haml のシンタックスチェックを行ないます。 290 | causes/haml-lint - https://github.com/causes/haml-lint 291 | 292 | - "jsonlint" 293 | jsonlint を使用した JSON のシンタックスチェックを行います。 294 | 295 | - "nim" 296 | nim を使用した nim のシンタックスチェックを行います。 297 | 298 | - "redpen" 299 | redpen を使用した自然言語で書かれた文書のチェックを行います。 300 | 301 | - "textlint" 302 | textlint を使用した自然言語で書かれた文書のチェックを行います。 303 | textlint/textlint - https://github.com/textlint/textlint 304 | 305 | - "mdl" 306 | mdl を使用した markdown のシンタックスチェックを行います。 307 | mivok/markdownlint - https://github.com/mivok/markdownlint 308 | 309 | - "eslint-md" 310 | eslint-md で markdown 内の JavaScript コードのシンタックスチェックを行います。 311 | wooorm/eslint-md - https://github.com/wooorm/eslint-md 312 | 313 | - "yaml-lint" 314 | yaml-lint で yaml のシンタックスチェックを行ないます。 315 | Pryz/yaml-lint - https://github.com/Pryz/yaml-lint 316 | 317 | - "rustc" 318 | rustc を使用した Rust のシンタックスチェックを行います。 319 | 320 | - "rustc_parse-only" 321 | rustc を使用した Rust のシンタックスチェックを行います。 322 | "rustc" との違いは `no-trans` オプションを使用します。 323 | 324 | 325 | 各ツールを使用する為に予め Vim から使えるようにしておく必要があります。 326 | 各ツールの細かい設定は autoload/watchdogs.vim に定義されている 327 | |g:watchdogs#default_config| を参照して下さい。 328 | 329 | 330 | また、各 filetype に対応しているデフォルトの設定は次の通りになります。 331 | 332 | - "cpp" 333 | デフォルト : "watchdogs_checker/g++" 334 | 335 | - "ruby" 336 | デフォルト : "watchdogs_checker/ruby" 337 | 338 | - "java" 339 | デフォルト : "watchdogs_checker/javac" 340 | 341 | - "javascript" 342 | デフォルト : "watchdogs_checker/jshint" 343 | 344 | - "haskell" 345 | デフォルト : "watchdogs_checker/ghc-mod" 346 | 347 | - "python" 348 | デフォルト : "watchdogs_checker/pyflakes" 349 | 350 | - "perl" 351 | デフォルト : "watchdogs_checker/perl" 352 | 353 | - "php" 354 | デフォルト : "watchdogs_checker/php" 355 | 356 | - "lua" 357 | デフォルト : "watchdogs_checker/luac" 358 | 359 | - "d" 360 | デフォルト : "watchdogs_checker/dmd" 361 | 362 | - "go" 363 | デフォルト : "watchdogs_checker/gofmt" 364 | 365 | - "c" 366 | デフォルト : "watchdogs_checker/c" 367 | 368 | - "scala" 369 | デフォルト : "watchdogs_checker/scalac" 370 | 371 | - "sh" 372 | デフォルト : "watchdogs_checker/sh" 373 | 374 | - "zsh" 375 | デフォルト : "watchdogs_checker/zsh" 376 | 377 | - "sass" 378 | デフォルト : "watchdogs_checker/sass" 379 | 380 | - "scss" 381 | デフォルト : "watchdogs_checker/scss" 382 | 383 | - "typescript" 384 | デフォルト : "watchdogs_checker/tsc" 385 | 386 | - "coffee" 387 | デフォルト : "watchdogs_checker/coffee" 388 | 389 | - "vim" 390 | デフォルト : "watchdogs_checker/vint" 391 | 392 | - "haml" 393 | デフォルト : "watchdogs_checker/haml" 394 | 395 | - "json" 396 | デフォルト : "watchdogs_checker/jsonlint" 397 | 398 | - "nim" 399 | デフォルト : "watchdogs_checker/nim" 400 | 401 | - "markdown" 402 | デフォルト : "watchdogs_checker/redpen" 403 | 404 | - "yaml" 405 | デフォルト : "watchdogs_checker/yaml-lint" 406 | 407 | - "rust" 408 | デフォルト : "watchdogs_checker/rustc" 409 | 410 | ============================================================================== 411 | コンフィグ *watchdogs-config* 412 | 413 | |watchdogs.vim| は |g:quickrun_config| に設定を記述する事によって、filetype ごと 414 | に使用するツールを設定したり、新しいツールの設定を追加することが出来ます。 415 | 416 | どの watchdogs_checker/* の設定を使用するかは次のような順で決定されます。 417 | 418 | 1.コマンドラインで指定された -type の値 419 | 2.|b:watchdogs_checker_type| 420 | 3.|g:quickrun_config| の &filetype/watchdogs_checker の type の値 421 | 422 | 423 | ------------------------------------------------------------------------------ 424 | filetype ごとにツールを設定 *watchdogs-config-filetype* 425 | 426 | 記述されているツールの設定を filetype ごとで使用する為には 427 | g:quickrun_config.{filetype}/watchdogs_checker.type に記述します。 428 | 429 | Example > 430 | " filetype=javascript で使用するツールを jshint にする 431 | let g:quickrun_config["javascript/watchdogs_checker"] = { 432 | \ "type" : "watchdogs_checker/jshint" 433 | \} 434 | 435 | " filetype=cpp で使用するツールを g++ にし、オプションも追加する 436 | let g:quickrun_config["cpp/watchdogs_checker"] = { 437 | \ "type" : "watchdogs_checker/g++", 438 | \ "cmdopt" : "-Wall", 439 | \} 440 | < 441 | 442 | 443 | また、b:watchdogs_checker_type に設定することで、それを使用する事も出来ます。 444 | 445 | Example > 446 | " そのバッファで使用される設定を記述 447 | let b:watchdogs_checker_type = "watchdogs_checker/clang" 448 | < 449 | 450 | b:watchdogs_checker_type は g:quickrun_config に書かれている設定より優先順位が 451 | 高いです。 452 | 453 | 454 | ------------------------------------------------------------------------------ 455 | ツールの設定を追加 *watchdogs-config-tools* 456 | 457 | g:quickrun_config.watchdogs_checker/{tool-name} に設定を記述します。 458 | 459 | Example > 460 | " jshint の設定を記述する 461 | " 指定するオプションなどは quickrun と同じ 462 | let g:quickrun_config["watchdogs_checker/jshint"] = { 463 | \ "command" : "jshint", 464 | \ "exec" : "%c %s:p", 465 | \ "quickfix/errorformat" : "%f: line %l\\,\ col %c\\, %m", 466 | \} 467 | < 468 | 469 | また、同名の config に設定を追加する事も出来ます。 470 | 471 | Example > 472 | " filetype=cpp で使用するツールを g++ にし、オプションも追加する 473 | let g:quickrun_config["cpp/watchdogs_checker"] = { 474 | \ "type" : "watchdogs_checker/cpp", 475 | \ "cmdopt" : "-Wall", 476 | \} 477 | < 478 | 479 | 480 | ------------------------------------------------------------------------------ 481 | watchdogs_checker/* 全てに共通する設定を定義 *watchdogs-config-default* 482 | 483 | |g:quickrun_config| の watchdogs_checker/_ に watchdogs_checker/* の全てに適用 484 | される設定を記述することができます。 485 | これは |watchdogs#setup()| 時にすべての watchdogs_checker/* に設定が追加され 486 | ます。 487 | すべての watchdogs_checker/* で共通の設定を行いたい場合はこれに設定を行ってく 488 | ださい。 489 | ここに記述された設定は各 watchdogs_checker/* よりも優先順位が低いです。 490 | 491 | > 492 | " :WatchdogsRun の出力先を buffer に指定する 493 | let g:quickrun_config["watchdogs_checker/_"] = { 494 | \ "outputter" : "buffer", 495 | \} 496 | 497 | " :WatchdogsRun -type watchdogs_checker/clang 498 | " の場合は quickfix へ出力する 499 | let g:quickrun_config["watchdogs_checker/clang"] = { 500 | \ "outputter" : "quickfix", 501 | \} 502 | < 503 | 504 | quickrun_config の詳細は |b:quickrun_config| を参照して下さい。 505 | 506 | 507 | ============================================================================== 508 | 自動シンタックスチェック *watchdogs-auto* 509 | 510 | 任意のタイミングで自動的にシンタックスチェックを行う為の設定です。 511 | また、この設定では |:QuickRun| が起動中にはシンタックスチェックは行われませ 512 | ん。 513 | 514 | 515 | ------------------------------------------------------------------------------ 516 | ファイルの書き込み後 *watchdogs-auto-BufWritePost* 517 | 518 | ファイルの書き込み後に自動的に |:WatchdogsRunSilent| を実行します。 519 | デフォルトでは無効になっているので使用するためには、 520 | |g:watchdogs_check_BufWritePost_enable| 521 | もしくは、 522 | |g:watchdogs_check_BufWritePost_enables| 523 | を設定して有効にする必要があります。 524 | 525 | 526 | Example > 527 | " 有効にする filetype を 1 に設定する 528 | " haskell と cpp のみを有効 529 | let g:watchdogs_check_BufWritePost_enables = { 530 | \ "cpp" : 1, 531 | \ "haskell" : 1 532 | \} 533 | 534 | " 全ての filetype を有効にする 535 | " 使用できない設定の場合、エラーが出る場合があるので注意 536 | let g:watchdogs_check_BufWritePost_enable = 1 537 | 538 | " 0 を設定することで一部の filetype のみ無効にする事ができる 539 | " これは g:watchdogs_check_BufWritePost_enable よりも優先順位が高い 540 | let g:watchdogs_check_BufWritePost_enables = { 541 | \ "javascript" : 0 542 | \} 543 | < 544 | 545 | 546 | ------------------------------------------------------------------------------ 547 | 一定時間キー入力がなかった場合にチェックを行う *watchdogs-auto-CursorHold* 548 | 549 | 一定時間キー入力が行われなかった場合に |:WatchdogsRunSilent| を実行します。 550 | 時間は |updatetime| に依存します。 551 | また、この設定ではファイル書き込み後に1度しか行われません。 552 | (ファイルに書き込んでいなければ、2回以上チェックが行われない。 553 | 554 | Example > 555 | " 有効にする filetype を 1 に設定する 556 | " haskell と cpp のみを有効 557 | let g:watchdogs_check_CursorHold_enables = { 558 | \ "cpp" : 1, 559 | \ "haskell" : 1 560 | \} 561 | 562 | " 全ての filetype を有効にする 563 | " 使用できない設定の場合、エラーが出る場合があるので注意 564 | let g:watchdogs_check_CursorHold_enable = 1 565 | 566 | " 0 を設定することで一部の filetype のみ無効にする事ができる 567 | " これは g:watchdogs_check_CursorHold_enable よりも優先順位が高い 568 | let g:watchdogs_check_CursorHold_enables = { 569 | \ "javascript" : 1 570 | \} 571 | < 572 | 573 | 574 | ============================================================================== 575 | インターフェース *watchdogs-interface* 576 | 577 | ------------------------------------------------------------------------------ 578 | コマンド *watchdogs-commands* 579 | 580 | :WatchdogsRun *:WatchdogsRun* 581 | 現在のバッファのシンタックスチェックを行います。 582 | 使用されるシンタックスチェックは |g:quickrun_config| を参照して決定さ 583 | れます。 584 | 585 | :WatchdogsRunSilent *:WatchdogsRunSilent* 586 | |:WatchdogsRun| とは違い、不正な設定だった場合にエラー出力が行われませ 587 | ん。 588 | 589 | :WatchdogsRunSweep *:WatchdogsRunSweep* 590 | |watchdogs.vim| を強制終了させます。 591 | 内部では |quickrun#sweep_sessions()| を呼び出しているだけなので詳しい 592 | 挙動に関してはそちらを参照して下さい。 593 | 594 | 595 | ------------------------------------------------------------------------------ 596 | 関数 *watchdogs-functions* 597 | 598 | watchdogs#setup({config}) *watchdogs#setup()* 599 | {config} に対して watchdogs.vim が定義している |g:quickrun_config| の 600 | 設定を追加します。 601 | この関数は |:WatchdogsRun| の初回起動時に呼び出され 602 | |g:quickrun_config| へと設定を追加します。 603 | |g:quickrun_config| の値を変更した場合、この関数を使用して設定を追加す 604 | る方がより安全です。 605 | 606 | Example: > 607 | " ユーザ側で g:quickrun_config を定義 608 | let g:quickrun_config = { 609 | ... 610 | \} 611 | 612 | " watchdogs.vim の設定を追加 613 | call watchdogs#setup(g:quickrun_config) 614 | < 615 | 616 | ============================================================================== 617 | 設定 *watchdogs-setting* 618 | 619 | ------------------------------------------------------------------------------ 620 | 変数 *watchdogs-variables* 621 | 622 | g:watchdogs_check_BufWritePost_enable *g:watchdogs_check_BufWritePost_enable* 623 | ファイル書き込み時の自動チェックの制御を行います。 624 | 詳しくは |watchdogs-auto-BufWritePost| を参照して下さい。 625 | > 626 | " Default 627 | let g:watchdogs_check_BufWritePost_enable = 0 628 | < 629 | 630 | g:watchdogs_check_BufWritePost_enables *g:watchdogs_check_BufWritePost_enables* 631 | ファイル書き込み時の自動チェックの制御を行います。 632 | 詳しくは |watchdogs-auto-BufWritePost| を参照して下さい。 633 | |g:watchdogs_check_BufWritePost_enable| とは違い、filetype ごとの設定を 634 | 行います。 635 | |g:watchdogs_check_BufWritePost_enable| よりも優先順位は高いです。 636 | > 637 | " Default 638 | let g:watchdogs_check_BufWritePost_enables = {} 639 | < 640 | 641 | g:watchdogs_check_CursorHold_enable *g:watchdogs_check_CursorHold_enable* 642 | 一定時間キー入力がなかった場合の自動チェックの制御を行います。 643 | 詳しくは |watchdogs-auto-CursorHold| を参照して下さい。 644 | > 645 | " Default 646 | let g:watchdogs_check_CursorHold_enable = 0 647 | < 648 | 649 | g:watchdogs_check_CursorHold_enables *g:watchdogs_check_CursorHold_enables* 650 | 一定時間キー入力がなかった場合の自動チェックの制御を行います。 651 | 詳しくは |watchdogs-auto-CursorHold| を参照して下さい。 652 | |g:watchdogs_check_CursorHold_enable| とは違い、filetype ごとの設定を 653 | 行います。 654 | |g:watchdogs_check_CursorHold_enable| よりも優先順位は高いです。 655 | > 656 | " Default 657 | let g:watchdogs_check_CursorHold_enables = {} 658 | < 659 | b:watchdogs_checker_type *b:watchdogs_checker_type* 660 | そのバッファで使用する設定名です。 661 | Example > 662 | " そのバッファで使用される設定を記述 663 | let b:watchdogs_checker_type = "watchdogs_checker/clang" 664 | << 665 | g:watchdogs_check_BufWritePost_enable_on_wq 666 | *g:watchdogs_check_BufWritePost_enable_on_wq* 667 | 0 が設定されている場合、|:wq| 時に |watchdogs-auto-BufWritePost| 668 | が実行されなくなります。 669 | Default: > 670 | let g:watchdogs_check_BufWritePost_enable_on_wq = 1 671 | < 672 | 673 | 674 | ============================================================================== 675 | 設定例 *watchdogs-examples* 676 | 677 | いくつかの g:quickrun_config の設定例です。 678 | ユーザ側で watchdogs.vim の拡張を行いたい場合に参考にして下さい。 679 | 680 | 681 | ------------------------------------------------------------------------------ 682 | C++ *watchdogs-examples-cpp* 683 | 684 | Example: > 685 | " gcc と clang にオプションを追加する 686 | let g:quickrun_config = { 687 | \ "watchdogs_checker/g++" : { 688 | \ "cmdopt" : "-Wall", 689 | \ }, 690 | \ 691 | \ "watchdogs_checker/clang++" : { 692 | \ "cmdopt" : "-Wall", 693 | \ }, 694 | \ 695 | \} 696 | 697 | " watchdogs.vim の設定を追加 698 | call watchdogs#setup(g:quickrun_config) 699 | < 700 | 701 | ------------------------------------------------------------------------------ 702 | quickfix のエラーフォマットを指定する *watchdogs-examples-erroformat* 703 | 任意の watchdogs_checker/* に quickfix/errorformat を設定します。 704 | 705 | Example: > 706 | " jshint のエラーフォマットを設定する 707 | let g:quickrun_config = { 708 | \ "watchdogs_checker/jshint" : { 709 | \ "quickfix/errorformat" : "%f: line %l\\,\ col %c\\, %m", 710 | \ }, 711 | \} 712 | 713 | " watchdogs.vim の設定を追加 714 | call watchdogs#setup(g:quickrun_config) 715 | < 716 | 717 | 718 | ------------------------------------------------------------------------------ 719 | command を変更する *watchdogs-examples-command* 720 | 721 | Example: > 722 | " pyflakes のパスを変更する 723 | let g:quickrun_config = { 724 | \ "watchdogs_checker/pyflakes" : { 725 | \ "command" : "C:/Python27/Scripts/pyflakes", 726 | \ }, 727 | \} 728 | 729 | " watchdogs.vim の設定を追加 730 | call watchdogs#setup(g:quickrun_config) 731 | < 732 | 733 | 734 | ------------------------------------------------------------------------------ 735 | quickfix ウィンドウを自動的に閉じる *watchdogs-examples-close_quickfix* 736 | |watchdogs-examples-unopen_quickfix| も一緒に参照してください。 737 | 738 | Example: > 739 | " hook-close_quickfix を有効にする 740 | " quickrun.vim の終了時に quickfix を閉じる 741 | let g:quickrun_config = { 742 | \ "watchdogs_checker/_" : { 743 | \ "hook/close_quickfix/enable_exit" : 1, 744 | \ }, 745 | \} 746 | 747 | " watchdogs.vim の設定を追加 748 | call watchdogs#setup(g:quickrun_config) 749 | < 750 | 751 | NOTE: この設定を使用した場合、ウィンドウ分割を利用していると意図しないウィン 752 | ドウへ移動する可能性があります。 753 | その場合は |watchdogs-examples-unopen_quickfix| を使用してください。 754 | 755 | 756 | ------------------------------------------------------------------------------ 757 | quickfix ウィンドウを開かせない *watchdogs-examples-unopen_quickfix* 758 | 759 | |quickfix| ウィンドウが開いてほしくない場合、 760 | |watchdogs-examples-close_quickfix| よりもこちらの設定の方が有効です。 761 | 762 | Example: > 763 | let g:quickrun_config = { 764 | \ "watchdogs_checker/_" : { 765 | \ 'outputter/quickfix/open_cmd' : '', 766 | \ }, 767 | \} 768 | 769 | " watchdogs.vim の設定を追加 770 | call watchdogs#setup(g:quickrun_config) 771 | < 772 | 773 | 774 | ------------------------------------------------------------------------------ 775 | vimproc の更新間隔を短くする *watchdogs-examples-updatetime* 776 | 777 | 'updatetime' の値が大きい場合、出力されるまでにタイムラグがある可能性がありま 778 | す。 779 | その場合は、vimproc/updatetime の値を小さくして、更新の間隔を短くする事で解決 780 | します。 781 | 782 | Example: > 783 | " runner/vimproc/updatetime に設定する 784 | let g:quickrun_config = { 785 | \ "watchdogs_checker/_" : { 786 | \ "runner/vimproc/updatetime" : 40, 787 | \ }, 788 | \} 789 | 790 | " watchdogs.vim の設定を追加 791 | call watchdogs#setup(g:quickrun_config) 792 | < 793 | 794 | 795 | ------------------------------------------------------------------------------ 796 | 一部の filetype のみ無効にする *watchdogs-examples-disable* 797 | 798 | |g:watchdogs_check_BufWritePost_enable| や 799 | |g:watchdogs_check_CursorHold_enable| などの一部の filetype のみ無効にします。 800 | 801 | 'updatetime' の値が大きい場合、出力されるまでにタイムラグがある可能性がありま 802 | す。 803 | その場合は、vimproc/updatetime の値を小さくして、更新の間隔を短くする事で解決 804 | します。 805 | 806 | Example: > 807 | " ファイル保存時のシンタックスチェックを有効にする 808 | let g:watchdogs_check_BufWritePost_enable = 1 809 | 810 | " haskell のみ無効にする 811 | let g:watchdogs_check_BufWritePost_enables = { 812 | \ "haskell" : 0 813 | \} 814 | < 815 | 816 | 817 | ------------------------------------------------------------------------------ 818 | 新しいツールを定義する *watchdogs-examples-add_tool* 819 | 820 | シンタックスチェックを行う設定を追加します。 821 | 使用できるようになるまで、2段階あり、 822 | まずは、watchdogs_checker/{tool-name} にツールの設定を記述し、その設定を使用する 823 | {filetype}/watchdogs_checker を設定します。 824 | 設定するオプションの細かい設定は |quickrun-options| を参照して下さい。 825 | 826 | 827 | Example: > 828 | let g:quickrun_config = {} 829 | 830 | " 新しいツールの設定を追加 831 | " g:quickrun_config.watchdogs_checker/{tool-name} に設定する 832 | " 833 | " command はツールのコマンド 834 | " exec の各オプションは 835 | " %c : command 836 | " %o : cmdopt 837 | " %s:p : ソースファイルの絶対パス 838 | " に展開される 839 | let g:quickrun_config["watchdogs_checker/g++"] = { 840 | \ "command" : "g++", 841 | \ "exec" : "%c %o -std=gnu++0x -fsyntax-only %s:p ", 842 | \} 843 | 844 | 845 | " 定義したツールを使用する filetype を指定する 846 | " {filetype}/watchdogs_checker を定義 847 | " type に定義した watchdogs_checker の名前を設定する 848 | " 固有のコマンドオプションを使用したいのであれば 849 | " cmdopt 850 | " に設定する 851 | let g:quickrun_config["cpp/watchdogs_checker"] = { 852 | \ "type" : "watchdogs_checker/g++", 853 | \ "cmdopt" : "-Wall", 854 | \} 855 | 856 | 857 | " watchdogs.vim の設定を追加 858 | call watchdogs#setup(g:quickrun_config) 859 | 860 | < 861 | ------------------------------------------------------------------------------ 862 | filetype に対して指定したツールを設定する *watchdogs-examples-change_tool* 863 | 864 | Example: > 865 | " C++ のシンタックスチェックを g++ にする 866 | " type に対して使用したい watchdogs_checker/{tool} を設定する 867 | let g:quickrun_config = { 868 | \ "cpp/watchdogs_checker" : { 869 | \ "type" : "watchdogs_checker/g++", 870 | \ }, 871 | \ 872 | \} 873 | 874 | " watchdogs.vim の設定を追加 875 | call watchdogs#setup(g:quickrun_config) 876 | < 877 | < 878 | ------------------------------------------------------------------------------ 879 | |:wq| 時に実行されないようにする *watchdogs-examples-no-run-wq* 880 | 881 | |g:watchdogs_check_BufWritePost_enable_on_wq| に 0 を設定します。 882 | 883 | Example: > 884 | let g:watchdogs_check_BufWritePost_enable_on_wq = 0 885 | < 886 | 887 | 888 | 889 | 890 | 891 | ============================================================================== 892 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 893 | -------------------------------------------------------------------------------- /plugin/watchdogs.vim: -------------------------------------------------------------------------------- 1 | if exists('g:loaded_watchdogs') 2 | finish 3 | endif 4 | let g:loaded_watchdogs = 1 5 | 6 | let s:save_cpo = &cpo 7 | set cpo&vim 8 | 9 | 10 | function! s:watchdogs_type(filetype) 11 | if empty(a:filetype) 12 | return "" 13 | endif 14 | return get(b:, "watchdogs_checker_type", a:filetype."/watchdogs_checker") 15 | endfunction 16 | 17 | 18 | function! s:is_empty_type(type) 19 | return a:type =~# '^.\+/watchdogs_checker$' 20 | \ && empty(get(get(g:quickrun_config, a:type, {}), "type", "")) 21 | endfunction 22 | 23 | 24 | function! s:setup_quickrun_config() 25 | if !exists("g:quickrun_config") 26 | let g:quickrun_config = {} 27 | endif 28 | if !has_key(g:quickrun_config, "watchdogs_checker_dummy") 29 | call watchdogs#setup(g:quickrun_config) 30 | endif 31 | endfunction 32 | 33 | 34 | function! s:run(args, deftype, ...) 35 | let is_output_msg = a:0 ? a:1 : 0 36 | call s:setup_quickrun_config() 37 | 38 | let config = quickrun#config(a:args) 39 | if !has_key(config, "type") 40 | let config.type = a:deftype 41 | endif 42 | 43 | if empty(config.type) 44 | \ || s:is_empty_type(get(config, "type", "")) 45 | if is_output_msg 46 | echoerr "==watchdogs error== Not support filetype " . config.type 47 | endif 48 | return 49 | endif 50 | 51 | call quickrun#run(config) 52 | endfunction 53 | 54 | 55 | command! -nargs=* -range=0 -complete=customlist,quickrun#complete 56 | \ WatchdogsRun call s:run(,s:watchdogs_type(&filetype), 1) 57 | 58 | command! -nargs=* -range=0 -complete=customlist,quickrun#complete 59 | \ WatchdogsRunSilent call s:run(,s:watchdogs_type(&filetype), 0) 60 | 61 | command! -nargs=0 62 | \ WatchdogsRunSweep call quickrun#sweep_sessions() 63 | 64 | 65 | let g:watchdogs_quickrun_running_check = 66 | \ get(g:, "watchdogs_quickrun_running_check", 0) 67 | 68 | 69 | let g:watchdogs_check_BufWritePost_enable = 70 | \ get(g:, "watchdogs_check_BufWritePost_enable", 0) 71 | 72 | let g:watchdogs_check_BufWritePost_enables = 73 | \ get(g:, "watchdogs_check_BufWritePost_enables", {}) 74 | 75 | let g:watchdogs_check_BufWritePost_enable_on_wq = 76 | \ get(g:, "watchdogs_check_BufWritePost_enable_on_wq", 1) 77 | 78 | 79 | let s:called_quit_pre = 0 80 | function! s:watchdogs_check_bufwrite(filetype) 81 | if !g:watchdogs_check_BufWritePost_enable_on_wq && s:called_quit_pre 82 | let s:called_quit_pre = 0 83 | return 84 | endif 85 | let s:called_quit_pre = 0 86 | if exists("*quickrun#is_running") 87 | if quickrun#is_running() 88 | return 89 | endif 90 | else 91 | if g:watchdogs_quickrun_running_check 92 | return 93 | endif 94 | endif 95 | if (g:watchdogs_check_BufWritePost_enable 96 | \ || get(g:watchdogs_check_BufWritePost_enables, a:filetype, 0)) 97 | \ && get(g:watchdogs_check_BufWritePost_enables, a:filetype, 1) 98 | WatchdogsRunSilent -hook/watchdogs_quickrun_running_checker/enable 0 99 | endif 100 | endfunction 101 | 102 | 103 | let g:watchdogs_check_CursorHold_enable = 104 | \ get(g:, "watchdogs_check_CursorHold_enable", 0) 105 | 106 | let g:watchdogs_check_CursorHold_enables = 107 | \ get(g:, "watchdogs_check_CursorHold_enables", {}) 108 | 109 | 110 | function! s:watchdogs_check_cursorhold(filetype) 111 | if exists("*quickrun#is_running") 112 | if quickrun#is_running() 113 | return 114 | endif 115 | else 116 | if g:watchdogs_quickrun_running_check 117 | return 118 | endif 119 | endif 120 | if get(b:, "watchdogs_checked_cursorhold", 0) 121 | return 122 | endif 123 | 124 | if (g:watchdogs_check_CursorHold_enable 125 | \ || get(g:watchdogs_check_CursorHold_enables, a:filetype, 0)) 126 | \ && get(g:watchdogs_check_CursorHold_enables, a:filetype, 1) 127 | let b:watchdogs_checked_cursorhold=1 128 | WatchdogsRunSilent -hook/watchdogs_quickrun_running_checker/enable 0 129 | endif 130 | endfunction 131 | 132 | 133 | augroup watchdogs-plugin 134 | autocmd! 135 | autocmd QuitPre * let s:called_quit_pre = 1 136 | autocmd CursorMoved * let s:called_quit_pre = 0 137 | autocmd BufWritePost * call watchdogs_check_bufwrite(&filetype) 138 | 139 | autocmd BufWritePost * let b:watchdogs_checked_cursorhold = 0 140 | autocmd TextChanged * let b:watchdogs_checked_cursorhold = 0 141 | autocmd TextChangedI * let b:watchdogs_checked_cursorhold = 0 142 | autocmd CursorHold * call watchdogs_check_cursorhold(&filetype) 143 | augroup END 144 | 145 | 146 | 147 | let &cpo = s:save_cpo 148 | unlet s:save_cpo 149 | --------------------------------------------------------------------------------