developer tip

VIM + Syntastic : 검사기를 비활성화하는 방법?

optionbox 2020. 7. 26. 12:54
반응형

VIM + Syntastic : 검사기를 비활성화하는 방법?


HTML 파일에 사용 가능한 Syntastic을 사용하고 있습니다. "validator w3"검사기가 활성화 된 매우 큰 파일이 있으므로 파일을 저장하는 동안 GVIM 또는 VIM이 매우 느려졌습니다 (: w).

현재 세션에 대해서만 일시적으로 syntastic을 토글 할 수 있습니까?


를 사용 :SyntasticToggleMode하면 Syntastic을 수동 모드로 전환 하여 자동 확인을 비활성화 할 수 있습니다. 그런 다음 :SyntasticCheck대신 실행하여 파일을 확인할 수 있습니다 .

자세한 내용은 :help syntastic-commands

또 다른 참고 사항 : Syntastic이 느린 경우 ale 을 대안으로 사용해보십시오 . Syntastic과 달리 비동기식으로 실행되므로 속도가 느리더라도 방해해서는 안됩니다.


기본적으로 Syntastic을 비활성화하고 내 .vimrc에서 다음을 사용하여 오류 검사를 활성화 / 비활성화합니다.

let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
nnoremap <C-w>E :SyntasticCheck<CR> :SyntasticToggleMode<CR>

오류 검사를 사용해야 할 때 간단히 ctrl-w E 를 누르십시오.


Jamie와 gospes 답변의 대안으로 다음과 같이 검사기 를 지정하여 검사기를 완전히 비활성화 할 수 있습니다 .

let g:syntastic_html_checkers=['']

또한가 syntastic_check_on_open1로 설정되어 있지 않은지 확인하십시오 . 위의 행을 상쇄합니다.

let g:syntastic_check_on_open = 0

Jamie Schembri 가 답변 한대로 전체 세션에 대해 Syntastic을 끌 수 있지만 "매우 큰 파일"에 문제가있는 경우 하나의 버퍼 만 비활성화 할 수 있습니다.

직장에서 작업하는 파일 중 일부는 PSR과 호환되지 않습니다. 대부분 잘 작동합니다. 문제 파일에 대해서만 Syntastic을 비활성화하는 기능을 찾고있었습니다. 주요 기고자가 제시 한 ' SyntasticDisableToggle '솔루션 의 간단한 형태가 저에게 효과적입니다.

"disable syntastic on a per buffer basis (some work files blow it up)
function! SyntasticDisableBuffer()
    let b:syntastic_skip_checks = 1
    SyntasticReset
    echo 'Syntastic disabled for this buffer'
endfunction

command! SyntasticDisableBuffer call SyntasticDisableBuffer()

이것은 다른 버퍼에 영향을 미치지 않기 때문에 내가 열어 놓은 다른 (부분적으로) 호환되는 파일 에이 멋진 플러그인을 계속 사용할 수 있습니다.


이것은 질문을 직접적으로 다루지는 않지만 현재 세션을 넘어서 도울 수 있습니다. 자주 편집해야하는 파일이 있지만 Syntastic을 항상 사용하지 않도록 설정하려는 경우 (예 : 수천 개의 오류가 발생하여이를 수정하지 않고 UI 속도 저하로 인한 결과) 블랙리스트에 올리면 매우 편리합니다.

이렇게하려면 syntastic_ignore_files옵션을 사용하십시오 . 도움말에 포함되어 있지만이 기능과 함께 정규 표현식을 사용하여 파일을 블랙리스트에 올릴 수 있습니다.

                                                    'syntastic_ignore_files'
Default: []
Use this option to specify files that syntastic should never check.  It's a
list of regular-expression patterns.  The full paths of files (see ::p) are
matched against these patterns, and the matches are case sensitive. Use \c
to specify case insensitive patterns.  Example:
    let g:syntastic_ignore_files = ['\m^/usr/include/', '\m\c\.h$']

다음 설정이 저에게 효과적이었습니다.

let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes':   [],'passive_filetypes': [] }
noremap <C-w>e :SyntasticCheck<CR>
noremap <C-w>f :SyntasticToggleMode<CR>

Ctrl-w + e shall enable checking
Ctrl-w + f shall disable checking 

To disable warnings use: 
let g:syntastic_quiet_messages={'level':'warnings'}

다른 사람들이 언급 한 것과 비슷하게, 여기에는 기본적으로 Syntastic을 끄는 vimrc 세그먼트가 있지만 현재 파일을 확인하기 위해 버튼 (여기서는 F10)을 매핑하고 확인을 끄려면 전환과 동일한 버튼을 사용합니다. 조금 느리지 만 작동합니다.

let g:syntastic_check_on_open = 0                                                                                 
let g:syntastic_check_on_wq = 0
let g:syntastic_mode_map = {'mode':'passive'}
nnoremap <F10> :SyntasticCheck<CR> :SyntasticToggleMode<CR> :w<CR>

파일 유형에 관계없이 단일 버퍼 검사를 해제하는 다른 옵션은을 사용하는 것 :let b:syntastic_mode="passive"입니다. 토글이 아니기 때문에 버퍼가 현재 수동 모드 인 경우에도 작동합니다.

모든 버퍼의 모든 파일 형식 검사를 일시적으로 해제하려면을 사용할 수 있습니다 :bufdo let b:syntastic_mode="passive". 모든 버퍼의 검사를 켜고 끄는 설정 매핑이 있습니다.

nnoremap <leader>sN :bufdo let b:syntastic_mode="passive"<cr>
nnoremap <leader>sY :bufdo unlet b:syntastic_mode<cr>

This is particularly helpful when doing :wqa with a lot of open buffers.


Thanks for Steven Lu, I can ignore the files of Ansible Roles, now.

" ignore files of Ansible Roles.
let g:syntastic_ignore_files = ['\m^roles/']

참고URL : https://stackoverflow.com/questions/20030603/vim-syntastic-how-to-disable-the-checker

반응형