Skip to content

Commit b7b93c4

Browse files
committed
Make syntastic aware of <ng-form> directives used as custom element.
1 parent e5d3295 commit b7b93c4

3 files changed

Lines changed: 47 additions & 18 deletions

File tree

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Some niceties for using Vim with the AngularJS framework. See the [screencast][screencast].
66

77
The [canonical "what editor should I use for Angular?" post][editorchoice]
8-
pretty squarely lands on Webstorm/IntelliJ as the peoples' choice
8+
pretty squarely lands on Webstorm/IntelliJ as the peoples' choice
99
(12 people), but Vim is right there tied for second place along with
1010
NetBeans and Sublime (four people each as of April, 2014) in this
1111
super-scientific analysis. And don't make me quote [Tim Pope][tpope] on
@@ -35,9 +35,9 @@ So why was this plugin written at all? I'm glad you asked!
3535

3636
A, the "alternate" file, has been mapped to take you from your code to the
3737
corresponding test file, or from your test file to the corresponding
38-
implementation file. For example, if you're in app/js/rock-socks.js, and
38+
implementation file. For example, if you're in app/js/rock-socks.js, and
3939
you hammer :A, you will be taken to test/spec/rock-socks.js, if such a file
40-
exists. Some other common directory structure conventions in the angular
40+
exists. Some other common directory structure conventions in the angular
4141
community, such as app/src and test/unit, are also supported.
4242

4343
If the convention you use doesn't work out of the box, you can specify your
@@ -69,7 +69,7 @@ if (true) {
6969
file called awesome-service.js somewhere in a subdirectory of your path,
7070
you will be taken there. The default behavior of gf can also be quite
7171
useful in the context of an angular app, since file paths appear in views
72-
(with ng-include src="full/path.html) and directives (with templateUrl:
72+
(with ng-include src="full/path.html) and directives (with templateUrl:
7373
'src/myapp/modules/main/views//prompt-list.html', so an
7474
attempt has been made to allow this to work as well. If all that is missing
7575
from a template path is the "app" directory (which is a common value for
@@ -116,35 +116,46 @@ focus in on just one spec at a time (and one spec generally runs way fast).
116116
So, if you're anywhere inside a spec:
117117

118118
:AngularRunSpec
119-
119+
120120
or the "run spec" mapping:
121121

122122
<leader>rs
123-
123+
124124
will toggle the spec between "it" and "iit." This works especially well if
125125
you have a karma watch going, as shown in the [screencast][screencast].
126126

127127
You are able to do the same with a describe block using the run block command:
128-
128+
129129
:AngularRunSpecBlock
130130

131131
or the corresponding mapping:
132132

133133
<leader>rb
134134

135-
### Syntastic syntax checker ignores
135+
### Syntastic syntax checker customization
136136

137137
You know how you use syntastic to check your syntax as you edit, because
138138
it works for pretty much any language and is awesome? When you use angular
139139
directives (like ng-app, ng-repeat, and even library directives like
140-
ui-view), the html tidy check will complain. This is fixed out of the box,
141-
and you can use the same mechanism to make syntastic aware of your own
142-
directives by specifying exclusions in your .vimrc like this:
140+
ui-view), the html tidy check will complain. This is fixed out of the box.
141+
142+
Use the same mechanism to make syntastic aware of your own directives by
143+
specifying exclusions in your .vimrc like this:
143144

144145
```
145146
let g:syntastic_html_tidy_ignore_errors = ['proprietary attribute "myhotcompany-']
146147
```
147148

149+
Some angular directives can also be used as custom elements (i.e. ng-include,
150+
ng-form). These are added to the list of allowed tags by default. In order
151+
to make syntastic recognize your additional blocklevel tags define them in your
152+
.vimrc before the plugin is loaded:
153+
154+
```
155+
let g:syntastic_html_tidy_blocklevel_tags = ['myCustomTag']
156+
```
157+
158+
148159
## Installation
149160

150161
* Using [Pathogen][pathogen], run the following commands:

plugin/angular.vim

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,29 @@
77
"
88
" define your own proprietary attributes before this plugin loads, in your
99
" .vimrc, like so:
10-
" let g:syntastic_html_tidy_ignore_errors = [' proprietary attribute "myhotcompany-']
10+
" let g:syntastic_html_tidy_ignore_errors = [' proprietary attribute "myhotcompany-']
11+
" let g:syntastic_html_tidy_blocklevel_tags = ['myCustomTag']
1112
"
12-
" or copy the mechanism used here to ensure you get both your ignores and
13-
" the plugin's ignores.
13+
" or copy the mechanism used here to ensure you get both your settings and
14+
" the ones defined by the plugin.
1415
if !exists('g:syntastic_html_tidy_ignore_errors')
1516
let g:syntastic_html_tidy_ignore_errors = []
1617
endif
1718

1819
let g:syntastic_html_tidy_ignore_errors = g:syntastic_html_tidy_ignore_errors + [
1920
\ ' proprietary attribute "ng-',
2021
\ ' proprietary attribute "ui-',
21-
\ '<ng-include> is not recognized!',
22-
\ 'discarding unexpected <ng-include>',
23-
\ 'discarding unexpected </ng-include>',
2422
\ '<div> proprietary attribute "src'
2523
\ ]
2624

25+
if !exists('g:syntastic_html_tidy_blocklevel_tags')
26+
let g:syntastic_html_tidy_blocklevel_tags = []
27+
endif
28+
29+
let g:syntastic_html_tidy_blocklevel_tags = g:syntastic_html_tidy_blocklevel_tags + [
30+
\ 'ng-include',
31+
\ 'ng-form'
32+
\ ]
2733

2834
if !exists('g:angular_find_ignore')
2935
let g:angular_find_ignore = []

spec/runspec_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44

55
specify "html tidy syntastic ignores" do
66
value_of_variable = vim.echo('g:syntastic_html_tidy_ignore_errors')
7-
value_of_variable.should eq("[' proprietary attribute \"ng-', ' proprietary attribute \"ui-', '<ng-include> is not recognized!', 'discarding unexpected <ng-include>', 'discarding unexpected </ng-include>', '<div> proprietary attribute \"src']")
7+
value_of_variable.should include(
8+
' proprietary attribute "ng-',
9+
' proprietary attribute "ui-',
10+
'<div> proprietary attribute "src'
11+
)
12+
end
13+
14+
specify "html tidy syntastic tags" do
15+
value_of_variable = vim.echo('g:syntastic_html_tidy_blocklevel_tags')
16+
value_of_variable.should include(
17+
'ng-include',
18+
'ng-form'
19+
)
820
end
921

1022
specify "command with one spec" do

0 commit comments

Comments
 (0)