Fix indentation for script tags and refactor

Fixes the indentation for script tags. The javascript indentation
interpreted the `<script>` tag as a comparison operator.
This commit is contained in:
Adriaan Zonnenberg
2017-03-26 13:36:09 +02:00
parent 239401d54d
commit d4793f5963
2 changed files with 112 additions and 22 deletions

View File

@@ -8,7 +8,7 @@ Given vue (An unindented html template):
</div>
</template>
Do:
Do (Indent the whole buffer):
gg=G
Expect (The html template got indented):
@@ -18,6 +18,28 @@ Expect (The html template got indented):
</div>
</template>
Given vue (Template tag inside a template):
<template>
<div>
<template v-if="loading">
Loading...
</template>
</div>
</template>
Do (Indent the whole buffer):
gg=G
Expect (It didn't get unindented):
<template>
<div>
<template v-if="loading">
Loading...
</template>
</div>
</template>
#
# JavaScript
#
@@ -35,8 +57,7 @@ Given vue (An unindented JavaScript region):
Do (Indent the whole buffer):
gg=G
Expect vue (TODO):
* TODO: fix the indent script to exclude the surrounding html tag
Expect vue (The JavaScript region got indented):
<script>
export default {
methods: {
@@ -57,7 +78,7 @@ Given vue (An unindented css region):
}
</style>
Do:
Do (Indent the whole buffer):
gg=G
Expect vue (The css region got indented):
@@ -66,3 +87,49 @@ Expect vue (The css region got indented):
background: tomato;
}
</style>
#
# Pug
#
Given vue (Empty Pug region):
<template lang="pug">
</template>
Do (Insert list items):
o
ul\<CR>
li Item A\<CR>
li Item B
Expect:
<template lang="pug">
ul
li Item A
li Item B
</template>
#
# Stylus
#
Given vue (Empty Stylus region):
<style lang="stylus">
</style>
Do (Insert some styles):
o
body\<CR>
font-size: 14px\<CR>
\<CR>\<C-d>
h1\<CR>
font-size: 30px\<CR>
display: block
Expect:
<style lang="stylus">
body
font-size: 14px
h1
font-size: 30px
display: block
</style>