使用非标准HTML标记的Vim和 Syntastic

问题描述 投票:1回答:2

我正在使用Vim和Ionic框架并面临一些麻烦。 Ionic具有自定义HTML标记和属性。我在Vim中使用的插件之一 - syntastic。因此,当我使用Ionic标签保存我的.html页面时,我收到有关这些标签的错误和警告。另外,Ionic有自定义选择器的组件,所以我有一些像<user-list></user-list>的标签。

有没有办法不沉默或忽略这些警告,但是使用Ionic HTML和自定义标签进行工作语法检查?我喜欢使用syntastic,它为我提供了有用的信息。

我找到了关于禁用Ionic的合成和/或沉默错误和警告的答案。这不是我想要的。我有什么选择吗?在这一刻,我想我不准备为Vim制作自己的插件,也许将来也是如此。

angular ionic-framework vim ionic3
2个回答
0
投票

首先尝试为typescript设置vim,看看syntastic是否仍然显示错误。使用https://github.com/leafgarland/typescript-vim语法和https://github.com/Quramy/tsuquyomi用于typescript服务器。这个article帮助了我。

另一种方法是通过合成来忽略离子标签。在my vimrc内:

" Set up the arrays to ignore for later
if !exists('g:syntastic_html_tidy_ignore_errors')
    let g:syntastic_html_tidy_ignore_errors = []
endif
" Ignore ionic tags in HTML syntax checking
" See http://stackoverflow.com/questions/30366621
" ignore errors about Ionic tags
let g:syntastic_html_tidy_ignore_errors += [
      \ "<ion-",
      \ "discarding unexpected </ion-",
      \ "plain text isn''t allowed in <head> elements"
]

1
投票

我的vimrc源代码插件特定的配置文件。我的syntastic配置文件有以下内容,它将上面的一些答案与其他一些技巧结合起来。

" Try to use HTML5 Tidy for better checking?
" installed it via homebrew, which puts it in this location
let g:syntastic_html_tidy_exec = '/usr/local/bin/tidy'
" which is better than the version which ships with mac, 
" /usr/bin/tidy/

" Ignore ionic tags in HTML syntax checking
" See http://stackoverflow.com/questions/30366621
" ignore errors about Ionic tags
let g:syntastic_html_tidy_ignore_errors += [
      \ "<ion-",
      \ "discarding unexpected </ion-"]
" It's probably better to add ion-pane and the like to g:syntastic_html_tidy_blocklevel_tags, and only ignore the errors about attributes. 

" Angular's attributes confuse HTML Tidy
let g:syntastic_html_tidy_ignore_errors += [
      \ " proprietary attribute \"ng-"]

" Angular UI-Router attributes confuse HTML Tidy
let g:syntastic_html_tidy_ignore_errors += [
      \ " proprietary attribute \"ui-sref"]

" Angular in particular often makes 'empty' blocks, so ignore
" this error. We might improve how we do this though.
" See also https://github.com/scrooloose/syntastic/wiki/HTML:---tidy
" specifically g:syntastic_html_tidy_empty_tags
let g:syntastic_html_tidy_ignore_errors += ["trimming empty "]

" Angular ignores
let g:syntastic_html_tidy_blocklevel_tags += [
      \ 'ng-include',
      \ 'ng-form'
      \ ]

" Angular UI-router ignores
let g:syntastic_html_tidy_ignore_errors += [
      \ " proprietary attribute \"ui-sref"]
© www.soinside.com 2019 - 2024. All rights reserved.