我正在使用Vim和Ionic框架并面临一些麻烦。 Ionic具有自定义HTML标记和属性。我在Vim中使用的插件之一 - syntastic。因此,当我使用Ionic标签保存我的.html页面时,我收到有关这些标签的错误和警告。另外,Ionic有自定义选择器的组件,所以我有一些标签,如<user-list></user-list>
。
有没有办法不沉默或忽略这些警告,但是使用Ionic HTML和自定义标签进行工作语法检查?我喜欢使用syntastic,它为我提供了有用的信息。
我找到了关于禁用Ionic和/或沉默错误和警告的合成的答案。这不是我想要的。我有什么选择吗?在这一刻,我想我不准备为Vim创建自己的插件,可能在将来。
答案 0 :(得分:1)
我的vimrc提供了插件特定的配置文件。我的合成配置文件包含以下内容,该文件将上面的一些答案与其他一些技巧结合在一起。
" 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"]
答案 1 :(得分: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"
]