mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-06 18:54:27 +08:00
Compare commits
542 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fb2f63799 | ||
|
|
def5d57a1a | ||
|
|
f4c999bdf2 | ||
|
|
f960b9bd59 | ||
|
|
1b7e460de0 | ||
|
|
f0df5fa676 | ||
|
|
baf5546734 | ||
|
|
58e24035cc | ||
|
|
4ea41b2cba | ||
|
|
f2a80ddfa2 | ||
|
|
413fb145fe | ||
|
|
8b079dcf6e | ||
|
|
46e60676f2 | ||
|
|
1f5daf6810 | ||
|
|
15216aa849 | ||
|
|
209220ee02 | ||
|
|
fc547c48a8 | ||
|
|
60930a968d | ||
|
|
8255d7d0b9 | ||
|
|
9c526a43d6 | ||
|
|
a46a282c5e | ||
|
|
f8e6431776 | ||
|
|
1533dd03a1 | ||
|
|
dc6cb4fd07 | ||
|
|
76285f8ec4 | ||
|
|
e4d9455d5a | ||
|
|
c7643e5b61 | ||
|
|
e9033d0d88 | ||
|
|
5f559fae12 | ||
|
|
10b3746ecb | ||
|
|
61deeebdc9 | ||
|
|
37203af2b3 | ||
|
|
461700696e | ||
|
|
ef1d557b59 | ||
|
|
15ef997d4d | ||
|
|
f4afd031a3 | ||
|
|
5a7c7930c6 | ||
|
|
3f53d7b637 | ||
|
|
9f854c868e | ||
|
|
6ee9d6d417 | ||
|
|
685359e892 | ||
|
|
b9f1ae467b | ||
|
|
32dd6d3064 | ||
|
|
50b44d90c9 | ||
|
|
7b08b89d7d | ||
|
|
d02023cd7a | ||
|
|
6039842751 | ||
|
|
dad174f359 | ||
|
|
47c28892d9 | ||
|
|
192d22fe69 | ||
|
|
24fbb0aef7 | ||
|
|
0414b53a23 | ||
|
|
369a5420f0 | ||
|
|
456d094ef3 | ||
|
|
633320d968 | ||
|
|
5531b23f20 | ||
|
|
b7cc3a743f | ||
|
|
758421535f | ||
|
|
6a6dc6e093 | ||
|
|
97b0b6c643 | ||
|
|
f8fc806a61 | ||
|
|
ae7d31f290 | ||
|
|
d698f16587 | ||
|
|
19f2821b7b | ||
|
|
922784dad6 | ||
|
|
eb8a4782ba | ||
|
|
b79f9128d3 | ||
|
|
5d6870c0af | ||
|
|
5fc2cc0fae | ||
|
|
d99b422a39 | ||
|
|
3720be60fb | ||
|
|
313e241932 | ||
|
|
19e3240bf3 | ||
|
|
e6fb10d22a | ||
|
|
d2a7edf1ad | ||
|
|
37ac8c3421 | ||
|
|
7492853a59 | ||
|
|
88ecfac350 | ||
|
|
7a4bf3463e | ||
|
|
a33b7273a1 | ||
|
|
64656d8d4b | ||
|
|
0e20db0cb7 | ||
|
|
581ba25bf8 | ||
|
|
9cce773acb | ||
|
|
ca2b158737 | ||
|
|
03c2309f44 | ||
|
|
3dcdbff913 | ||
|
|
7843f18e40 | ||
|
|
63c98d801b | ||
|
|
645258ddd4 | ||
|
|
2ac3648bc8 | ||
|
|
3fb134b503 | ||
|
|
dcf8f6efd8 | ||
|
|
e7dd13a750 | ||
|
|
f5b185e3a2 | ||
|
|
acc5ac7a9b | ||
|
|
fb31b5dbb6 | ||
|
|
1ba2eb67fb | ||
|
|
a0aa79d660 | ||
|
|
40c89e5415 | ||
|
|
c0728a8dac | ||
|
|
06b4cda774 | ||
|
|
5cb3b51e47 | ||
|
|
927f72b49d | ||
|
|
18c0cf55f4 | ||
|
|
350f0ba10b | ||
|
|
2a8918a775 | ||
|
|
abdd9e440d | ||
|
|
e8c905853b | ||
|
|
8e06fbd056 | ||
|
|
2364a97f1c | ||
|
|
1be61f24ba | ||
|
|
ac8767eb15 | ||
|
|
5405e9dbf0 | ||
|
|
c7923d1ec4 | ||
|
|
5181a02a09 | ||
|
|
1c6b56f0e0 | ||
|
|
2196a056b4 | ||
|
|
a06966cfb2 | ||
|
|
fd4a3f6089 | ||
|
|
f1fba43944 | ||
|
|
609c66f043 | ||
|
|
bcadf12a03 | ||
|
|
d653ee7df0 | ||
|
|
ed79a9264d | ||
|
|
71c68c2d6c | ||
|
|
4b4e68ae1d | ||
|
|
abc97ac757 | ||
|
|
9c6d783636 | ||
|
|
230f41e55b | ||
|
|
94261d6515 | ||
|
|
aa801bc9b7 | ||
|
|
3af413c9a3 | ||
|
|
2247b1f457 | ||
|
|
6c38fe86c1 | ||
|
|
956f1b0b43 | ||
|
|
4efb1c333e | ||
|
|
d6e093d441 | ||
|
|
5442207ccb | ||
|
|
f0a0948d2d | ||
|
|
e5d28f004c | ||
|
|
20dd275531 | ||
|
|
5db2c29f14 | ||
|
|
5b217264dd | ||
|
|
1a9c1493ab | ||
|
|
44906fb16e | ||
|
|
4eca5f5693 | ||
|
|
dfff6672c6 | ||
|
|
64544b778d | ||
|
|
ebcf6d2205 | ||
|
|
d7b70c656a | ||
|
|
f12fa6e493 | ||
|
|
b8bb1e51b8 | ||
|
|
30d58ee417 | ||
|
|
b56be291c4 | ||
|
|
d228a90eb1 | ||
|
|
1fe780000b | ||
|
|
28ff569be3 | ||
|
|
f4b097af50 | ||
|
|
92710ebcd2 | ||
|
|
4805d355c1 | ||
|
|
3654efd3d1 | ||
|
|
3cace3fa08 | ||
|
|
26899b9981 | ||
|
|
c03599748f | ||
|
|
52f3af7ca8 | ||
|
|
6e93371365 | ||
|
|
7e1aa89fa4 | ||
|
|
bcab81cc24 | ||
|
|
02f5a2ec81 | ||
|
|
f8bf9dbf69 | ||
|
|
7735a778c8 | ||
|
|
6a6698a179 | ||
|
|
6f4869796c | ||
|
|
31d903d390 | ||
|
|
e42c07978e | ||
|
|
e2be3aa391 | ||
|
|
05bfff176b | ||
|
|
8239822548 | ||
|
|
1a0c1288e1 | ||
|
|
b4b21450f2 | ||
|
|
0b4310353a | ||
|
|
d550205295 | ||
|
|
1e9df4f015 | ||
|
|
0ccaa29dbd | ||
|
|
41f005e740 | ||
|
|
4feadc4062 | ||
|
|
dee767c998 | ||
|
|
699689c985 | ||
|
|
1ac0fb7011 | ||
|
|
cbe10f91b4 | ||
|
|
c790128137 | ||
|
|
997314f226 | ||
|
|
6f676c4a38 | ||
|
|
8b8aefd64c | ||
|
|
ea47fca11e | ||
|
|
e24ea1734e | ||
|
|
fb3cac36bb | ||
|
|
451367a2ce | ||
|
|
f752a4250c | ||
|
|
1672e5664c | ||
|
|
5819343b88 | ||
|
|
913dfe686d | ||
|
|
603d6e4fcd | ||
|
|
136b87a330 | ||
|
|
5eb1061a3d | ||
|
|
4110fb0f7b | ||
|
|
1691ccc7e8 | ||
|
|
0bd0a38a29 | ||
|
|
13b842d9c4 | ||
|
|
fceb37243a | ||
|
|
abdf10e91c | ||
|
|
333fede99b | ||
|
|
037c7e5720 | ||
|
|
5041c20aae | ||
|
|
77747c762a | ||
|
|
4933347202 | ||
|
|
1c240c6d6d | ||
|
|
2c429485ec | ||
|
|
7a9412d3da | ||
|
|
6e1175326e | ||
|
|
8a8f46bc17 | ||
|
|
6d572e21e4 | ||
|
|
cee9e9d6c8 | ||
|
|
0617f58dd6 | ||
|
|
57a5263d1d | ||
|
|
e82844db78 | ||
|
|
5dda53c1ec | ||
|
|
e2c2f48716 | ||
|
|
f36d6f4025 | ||
|
|
a210cc0c5e | ||
|
|
7e3af15e4e | ||
|
|
c523cfd5e2 | ||
|
|
8289c323e0 | ||
|
|
30f8568935 | ||
|
|
cda7349b65 | ||
|
|
610c2ea673 | ||
|
|
87e50225c1 | ||
|
|
1c46c5fb77 | ||
|
|
03bb2b26fe | ||
|
|
af10f14ae5 | ||
|
|
1ddd5f2270 | ||
|
|
25d321c66f | ||
|
|
fd0c0db219 | ||
|
|
ab5d0f026c | ||
|
|
b5a94de150 | ||
|
|
971a13ca98 | ||
|
|
3d6862d5d1 | ||
|
|
c24f2dcfcb | ||
|
|
a7e876d5b5 | ||
|
|
c6e11d22dc | ||
|
|
862abb3895 | ||
|
|
e1f2f00a5c | ||
|
|
d4647629b2 | ||
|
|
8b9bcac7a0 | ||
|
|
a9b29f786e | ||
|
|
fcf44c5f6d | ||
|
|
4cc293d464 | ||
|
|
7be2d5b977 | ||
|
|
26954b92cd | ||
|
|
47b54c2e5e | ||
|
|
edf74342b5 | ||
|
|
cd09765a83 | ||
|
|
5bfcf0abfd | ||
|
|
1c1c511896 | ||
|
|
0e08b66e6c | ||
|
|
62b3accc20 | ||
|
|
9ac3339942 | ||
|
|
2a8f0e094d | ||
|
|
2b4eea8775 | ||
|
|
76499f48b8 | ||
|
|
0d63cc76aa | ||
|
|
8b703a0a00 | ||
|
|
4b17969f5a | ||
|
|
3e668b3523 | ||
|
|
485abffe6c | ||
|
|
4d78123db9 | ||
|
|
920904c53b | ||
|
|
a3418eb419 | ||
|
|
070800e31d | ||
|
|
e9b90c7f90 | ||
|
|
def1f1aead | ||
|
|
55c704bc3a | ||
|
|
591bfc99dc | ||
|
|
d51cb7141f | ||
|
|
c0175decd3 | ||
|
|
bd5f03bb24 | ||
|
|
105bea22b8 | ||
|
|
f1a34ccaa3 | ||
|
|
39d8f88ccd | ||
|
|
bd6060ba91 | ||
|
|
a61cb0c138 | ||
|
|
92fa2e568f | ||
|
|
2b94508a46 | ||
|
|
dcf247fb5c | ||
|
|
3874d6210d | ||
|
|
23aea8c21a | ||
|
|
00536daaf6 | ||
|
|
0f45689b81 | ||
|
|
beeb159626 | ||
|
|
08eb534c42 | ||
|
|
437cd92004 | ||
|
|
761adcc4be | ||
|
|
ca6296fb7f | ||
|
|
96903b0913 | ||
|
|
949b8c26b7 | ||
|
|
320bb97cb4 | ||
|
|
23bb8c0175 | ||
|
|
39a5ba0eca | ||
|
|
ef3f51ba44 | ||
|
|
da9283aa5c | ||
|
|
7ac6a8acb8 | ||
|
|
ef27d24df0 | ||
|
|
c49d4567dc | ||
|
|
7711bf1f15 | ||
|
|
fe38681354 | ||
|
|
5d73777a65 | ||
|
|
3ccd466123 | ||
|
|
018a97523a | ||
|
|
b3c346c54d | ||
|
|
fbd353387b | ||
|
|
e185c13171 | ||
|
|
e18077e991 | ||
|
|
ff1aaf88a9 | ||
|
|
2b6f37f470 | ||
|
|
74055488de | ||
|
|
6adab8a234 | ||
|
|
19961fc270 | ||
|
|
ed36e194e5 | ||
|
|
5916ad27fa | ||
|
|
b00cf4d33f | ||
|
|
0511be8ac5 | ||
|
|
e8169335a5 | ||
|
|
6577e0e687 | ||
|
|
2f0bd7d02e | ||
|
|
56634e7f80 | ||
|
|
ef3b75e877 | ||
|
|
43e940a660 | ||
|
|
7005655302 | ||
|
|
d894c67aa9 | ||
|
|
7268e203b8 | ||
|
|
cd23a38f2b | ||
|
|
9480824c0f | ||
|
|
464291244a | ||
|
|
c087cff8ff | ||
|
|
6d2c6a1de4 | ||
|
|
fef441fa71 | ||
|
|
cd808a5fe5 | ||
|
|
9b80875e07 | ||
|
|
52545221f6 | ||
|
|
72610878e4 | ||
|
|
7f0521f094 | ||
|
|
fb11bd8b28 | ||
|
|
7aa1ff965a | ||
|
|
49cb1c2884 | ||
|
|
19395caea7 | ||
|
|
ba56b91719 | ||
|
|
dc8b589cd0 | ||
|
|
2f1e60f4fe | ||
|
|
381dd35018 | ||
|
|
d9481c235b | ||
|
|
6cd20746ad | ||
|
|
554e0c02f5 | ||
|
|
afb2086306 | ||
|
|
8989b0a49c | ||
|
|
ddbbe81d09 | ||
|
|
2e365c9573 | ||
|
|
576679e023 | ||
|
|
936d5c6c2f | ||
|
|
df3e61ba69 | ||
|
|
934feeb55f | ||
|
|
fee5b34b5f | ||
|
|
262777309f | ||
|
|
d2d6a9f385 | ||
|
|
8aeb24fa77 | ||
|
|
2ecc25f727 | ||
|
|
47f27f8c3d | ||
|
|
e990cebbae | ||
|
|
48373cbf0a | ||
|
|
d6ab310cc9 | ||
|
|
fb096ac4d4 | ||
|
|
8c1e42340d | ||
|
|
f3e6cc72a3 | ||
|
|
5a37a6ef26 | ||
|
|
59239b05bb | ||
|
|
135fb40b27 | ||
|
|
55eb236bd8 | ||
|
|
e058f514a5 | ||
|
|
55c0875505 | ||
|
|
d60db48777 | ||
|
|
b8569d50f4 | ||
|
|
b5ea573744 | ||
|
|
313a58d55c | ||
|
|
3c5eb601fb | ||
|
|
f82d715caa | ||
|
|
ac79b721c5 | ||
|
|
a765fe7b82 | ||
|
|
036b37fb64 | ||
|
|
c9b8c2edcb | ||
|
|
57de05e041 | ||
|
|
ea1b779868 | ||
|
|
ed7ab5fd49 | ||
|
|
c588b72fc1 | ||
|
|
c78a2ff435 | ||
|
|
6baf3c1210 | ||
|
|
c1691caa6a | ||
|
|
4c371b5fa6 | ||
|
|
32a1dac905 | ||
|
|
ef2cd77d40 | ||
|
|
0f2a0ed1e8 | ||
|
|
89dd2b7e71 | ||
|
|
6a06f58a5e | ||
|
|
445ca239ad | ||
|
|
bd4c1bfaef | ||
|
|
f8095a65dd | ||
|
|
9c17334509 | ||
|
|
9475526c1f | ||
|
|
5d90a2c83d | ||
|
|
a5313498d7 | ||
|
|
8f1775cf02 | ||
|
|
44af2e417d | ||
|
|
fcf0f567be | ||
|
|
ebba5bf1e2 | ||
|
|
e8e9877cfc | ||
|
|
9d7a3d4a44 | ||
|
|
13994cc066 | ||
|
|
afd55ad70c | ||
|
|
056b49c2bd | ||
|
|
f2fc51391c | ||
|
|
b2561af319 | ||
|
|
6016cf6bdd | ||
|
|
61360ddfdc | ||
|
|
4ab27087f9 | ||
|
|
6ad2017568 | ||
|
|
49d2c8280f | ||
|
|
58c9a51322 | ||
|
|
f7a8cce3d5 | ||
|
|
a726fe44c8 | ||
|
|
286869545f | ||
|
|
5dc6c1a001 | ||
|
|
57a2ca0e2f | ||
|
|
888fdb6699 | ||
|
|
9be8926559 | ||
|
|
8f088c9f73 | ||
|
|
c257e09d69 | ||
|
|
f18cb41f93 | ||
|
|
40c4b1e0b8 | ||
|
|
f1cbe2545f | ||
|
|
018cab0adc | ||
|
|
2a5684bac4 | ||
|
|
cb869edec4 | ||
|
|
222c509447 | ||
|
|
cca5dedd69 | ||
|
|
9791571ff4 | ||
|
|
b9bd4738dc | ||
|
|
6d924eb310 | ||
|
|
e1fecdc77b | ||
|
|
db7c3bebc8 | ||
|
|
7fb711c257 | ||
|
|
455f6f5760 | ||
|
|
fd7c37d618 | ||
|
|
43d5656dca | ||
|
|
5d54856b49 | ||
|
|
0b37e09e5e | ||
|
|
53e8b80dfd | ||
|
|
32bb75081c | ||
|
|
a98478d7dc | ||
|
|
e7460ef2ec | ||
|
|
daaa9450a6 | ||
|
|
4221cd94ed | ||
|
|
8cc33aedf4 | ||
|
|
32c9eaf0c6 | ||
|
|
917a9d4bb3 | ||
|
|
ae7d014738 | ||
|
|
6619d5078e | ||
|
|
8e515a11c2 | ||
|
|
30d304ff1f | ||
|
|
ca95069268 | ||
|
|
857ecdb813 | ||
|
|
aabea8343f | ||
|
|
64b64e6bf8 | ||
|
|
dd16ce3b0b | ||
|
|
1d6a0917dc | ||
|
|
6dfd49a31f | ||
|
|
f128d1013b | ||
|
|
3b8f3ac778 | ||
|
|
b162859ca8 | ||
|
|
62c6622153 | ||
|
|
4757aae967 | ||
|
|
6a68c46d88 | ||
|
|
8499af4c47 | ||
|
|
03c6771311 | ||
|
|
dad1eb19c3 | ||
|
|
9239eed295 | ||
|
|
6fd2031fa2 | ||
|
|
7c1f881014 | ||
|
|
fb7829ca4b | ||
|
|
bc262ed52b | ||
|
|
25aeb9d1c3 | ||
|
|
1f041e7dd3 | ||
|
|
6d07bd9752 | ||
|
|
857809e676 | ||
|
|
2aba8dde8b | ||
|
|
286788ae88 | ||
|
|
dc199ba273 | ||
|
|
f5bb76ba39 | ||
|
|
4825e6b6c9 | ||
|
|
f08061ec20 | ||
|
|
bc5903d69c | ||
|
|
f1daca4fa5 | ||
|
|
7f674cd356 | ||
|
|
f86c34fbe8 | ||
|
|
39a9986627 | ||
|
|
c0e0451489 | ||
|
|
77e2bd3c4e | ||
|
|
62f0a02346 | ||
|
|
f99392847f | ||
|
|
24eaace730 | ||
|
|
7aecdc809d | ||
|
|
594ca8e767 | ||
|
|
6a84397073 | ||
|
|
e5ff2df906 | ||
|
|
59c2fb6647 | ||
|
|
82c09728d7 | ||
|
|
0e4fe62138 | ||
|
|
73386514ea | ||
|
|
dc65299159 | ||
|
|
77c863af95 | ||
|
|
760d00cb89 | ||
|
|
c088101cb7 | ||
|
|
8c072f6a3b | ||
|
|
7aee52d710 | ||
|
|
8734406ab6 | ||
|
|
0d4bc41f03 | ||
|
|
8862640291 | ||
|
|
97b753223e | ||
|
|
2d3a46238b | ||
|
|
ab1be77b86 | ||
|
|
27350c3672 | ||
|
|
8c108ad27d | ||
|
|
f6c5a8c717 | ||
|
|
ac43ff8cd9 |
8
.github/FUNDING.yml
vendored
Normal file
8
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: mattn # Replace with a single Patreon username
|
||||
open_collective: mattn # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
custom: # Replace with a single custom sponsorship URL
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,4 +1,4 @@
|
||||
[submodule "docs"]
|
||||
path = docs
|
||||
url = git@github.com:mattn/zencoding-vim.git
|
||||
url = https://github.com/mattn/emmet-vim
|
||||
branch = gh-pages
|
||||
|
||||
11
.travis.yml
Normal file
11
.travis.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
language: generic
|
||||
sudo: false
|
||||
dist: xenial
|
||||
git:
|
||||
depth: 10
|
||||
|
||||
script:
|
||||
- uname -a
|
||||
- which -a vim
|
||||
- vim --cmd version --cmd quit
|
||||
- make test
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Yasuhiro Matsumoto
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
16
Makefile
16
Makefile
@@ -1,11 +1,15 @@
|
||||
all : zencoding-vim.zip
|
||||
all : emmet-vim.zip
|
||||
|
||||
remove-zip:
|
||||
-rm doc/tags
|
||||
-rm zencoding-vim.zip
|
||||
-rm emmet-vim.zip
|
||||
|
||||
zencoding-vim.zip: remove-zip
|
||||
zip -r zencoding-vim.zip autoload plugin doc
|
||||
emmet-vim.zip: remove-zip
|
||||
zip -r emmet-vim.zip autoload plugin doc
|
||||
|
||||
release: zencoding-vim.zip
|
||||
vimup update-script zencoding.vim
|
||||
release: emmet-vim.zip
|
||||
vimup update-script emmet.vim
|
||||
|
||||
test:
|
||||
@-rm -f test.log 2> /dev/null
|
||||
@vim -N -c "let &rtp .= ',' . getcwd()" -c "so unittest.vim" -c EmmetUnitTest! || cat test.log || exit 1
|
||||
|
||||
185
README.mkd
185
README.mkd
@@ -1,93 +1,200 @@
|
||||
# ZenCoding-vim
|
||||
# Emmet-vim
|
||||
|
||||
[zencoding-vim](http://mattn.github.com/zencoding-vim) is vim script support for expanding abbreviation like zen-coding(emmet).
|
||||
|
||||
[](https://travis-ci.org/mattn/emmet-vim)
|
||||
|
||||
[emmet-vim](https://mattn.github.io/emmet-vim/) is a vim plug-in
|
||||
which provides support for expanding abbreviations similar to
|
||||
[emmet](http://emmet.io/).
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
[Download zip file](http://www.vim.org/scripts/script.php?script_id=2981):
|
||||
|
||||
cd ~/.vim
|
||||
unzip zencoding-vim.zip
|
||||
```sh
|
||||
cd ~/.vim
|
||||
unzip emmet-vim.zip
|
||||
```
|
||||
|
||||
If you install pathogen.vim:
|
||||
To install using [pathogen.vim](https://github.com/tpope/vim-pathogen):
|
||||
|
||||
cd ~/.vim/bundle # or make directory
|
||||
unzip /path/to/zencoding-vim.zip
|
||||
```sh
|
||||
git clone https://github.com/mattn/emmet-vim.git ~/.vim/bundle/emmet-vim
|
||||
```
|
||||
|
||||
If you get source from repository:
|
||||
To install using [Vundle](https://github.com/gmarik/vundle):
|
||||
|
||||
cd ~/.vim/bundle # or make directory
|
||||
git clone http://github.com/mattn/zencoding-vim.git
|
||||
```vim
|
||||
" add this line to your .vimrc file
|
||||
Plugin 'mattn/emmet-vim'
|
||||
```
|
||||
|
||||
To install using [Vim-Plug](https://github.com/junegunn/vim-plug):
|
||||
|
||||
```vim
|
||||
" add this line to your .vimrc file
|
||||
Plug 'mattn/emmet-vim'
|
||||
```
|
||||
|
||||
To checkout the source from repository:
|
||||
|
||||
```sh
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/mattn/emmet-vim.git
|
||||
```
|
||||
|
||||
or:
|
||||
|
||||
git clone http://github.com/mattn/zencoding-vim.git
|
||||
cd zencoding-vim
|
||||
cp plugin/zencoding.vim ~/.vim/plugin/
|
||||
cp autoload/zencoding.vim ~/.vim/autoload/
|
||||
```sh
|
||||
git clone https://github.com/mattn/emmet-vim.git
|
||||
cd emmet-vim
|
||||
cp plugin/emmet.vim ~/.vim/plugin/
|
||||
cp autoload/emmet.vim ~/.vim/autoload/
|
||||
cp -a autoload/emmet ~/.vim/autoload/
|
||||
```
|
||||
|
||||
|
||||
## Quick Tutorial
|
||||
|
||||
Open or create New File:
|
||||
Open or create a New File:
|
||||
|
||||
vim index.html
|
||||
```sh
|
||||
vim index.html
|
||||
```
|
||||
|
||||
Type ("_" is the cursor position):
|
||||
Type ("\_" is the cursor position):
|
||||
|
||||
html:5_
|
||||
|
||||
Then type "<c-y>," (Ctrl + y + ','), you should see:
|
||||
Then type `<c-y>,` (<kbd>Ctrl</kbd><kbd>y</kbd><kbd>,</kbd>), and you should see:
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
```html
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
</head>
|
||||
<body>
|
||||
_
|
||||
</body>
|
||||
</html>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
[More Tutorials](https://raw.github.com/mattn/zencoding-vim/master/TUTORIAL)
|
||||
[More Tutorials](https://raw.githubusercontent.com/mattn/emmet-vim/master/TUTORIAL)
|
||||
|
||||
|
||||
## Enable in different mode
|
||||
|
||||
If you don't want to enable emmet in all modes,
|
||||
you can use set these options in `vimrc`:
|
||||
|
||||
```vim
|
||||
let g:user_emmet_mode='n' "only enable normal mode functions.
|
||||
let g:user_emmet_mode='inv' "enable all functions, which is equal to
|
||||
let g:user_emmet_mode='a' "enable all function in all mode.
|
||||
```
|
||||
|
||||
## Enable just for html/css
|
||||
|
||||
```vim
|
||||
let g:user_emmet_install_global = 0
|
||||
autocmd FileType html,css EmmetInstall
|
||||
```
|
||||
|
||||
## Redefine trigger key
|
||||
To remap the default `<C-Y>` leader:
|
||||
|
||||
```vim
|
||||
let g:user_emmet_leader_key='<C-Z>'
|
||||
```
|
||||
|
||||
Note that the trailing `,` still needs to be entered, so the new keymap would be `<C-Z>,`.
|
||||
|
||||
## Adding custom snippets
|
||||
If you have installed the [web-api](https://github.com/mattn/webapi-vim) for **emmet-vim** you can also add your own snippets using a custom **snippets.json** file.
|
||||
|
||||
Once you have installed the [web-api](https://github.com/mattn/webapi-vim) add this line to your **.vimrc**:
|
||||
```
|
||||
let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/.snippets_custom.json')), "\n"))
|
||||
```
|
||||
You can change the **path** to your **snippets_custom.json** according to your preferences.
|
||||
|
||||
[Here](http://docs.emmet.io/customization/snippets/) you can find instructions about creating your customized **snippets.json** file.
|
||||
|
||||
## Snippet to add meta tag for responsiveness
|
||||
Update this in your .vimrc file.
|
||||
|
||||
|
||||
let g:user_emmet_settings = {
|
||||
\ 'variables': {'lang': 'ja'},
|
||||
\ 'html': {
|
||||
\ 'default_attributes': {
|
||||
\ 'option': {'value': v:null},
|
||||
\ 'textarea': {'id': v:null, 'name': v:null, 'cols': 10, 'rows': 10},
|
||||
\ },
|
||||
\ 'snippets': {
|
||||
\ 'html:5': "<!DOCTYPE html>\n"
|
||||
\ ."<html lang=\"${lang}\">\n"
|
||||
\ ."<head>\n"
|
||||
\ ."\t<meta charset=\"${charset}\">\n"
|
||||
\ ."\t<title></title>\n"
|
||||
\ ."\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
|
||||
\ ."</head>\n"
|
||||
\ ."<body>\n\t${child}|\n</body>\n"
|
||||
\ ."</html>",
|
||||
\ },
|
||||
\ },
|
||||
\}
|
||||
|
||||
|
||||
## Project Authors
|
||||
|
||||
[Yasuhiro Matsumoto](http://mattn.kaoriya.net/)
|
||||
|
||||
## FAQ
|
||||
|
||||
* Pressing ctrl+y+, doesn't work
|
||||
|
||||
Probably you set `timeoutlen=0`. Most of Vim plugins which using key-mappings does not work with `timeoutlen=0`.
|
||||
|
||||
## Links
|
||||
|
||||
### Emmet official site:
|
||||
|
||||
* <http://emmet.io/>
|
||||
|
||||
### zen-coding official site:
|
||||
|
||||
> <http://code.google.com/p/zen-coding/>
|
||||
* <http://code.google.com/p/zen-coding/>
|
||||
|
||||
### zencoding.vim:
|
||||
### emmet.vim:
|
||||
|
||||
> <http://mattn.github.com/zencoding-vim>
|
||||
* <https://mattn.github.io/emmet-vim/>
|
||||
|
||||
### development repository:
|
||||
|
||||
> <https://github.com/mattn/zencoding-vim>
|
||||
* <https://github.com/mattn/emmet-vim>
|
||||
|
||||
### my blog posts about zencoding-vim:
|
||||
|
||||
> <http://mattn.kaoriya.net/software/vim/20100222103327.htm>
|
||||
* <http://mattn.kaoriya.net/software/vim/20100222103327.htm>
|
||||
|
||||
> <http://mattn.kaoriya.net/software/vim/20100306021632.htm>
|
||||
* <http://mattn.kaoriya.net/software/vim/20100306021632.htm>
|
||||
|
||||
### japanese blog posts about zencoding-vim:
|
||||
### Japanese blog posts about zencoding-vim:
|
||||
|
||||
> <http://d.hatena.ne.jp/idesaku/20100424/1272092255>
|
||||
* <http://d.hatena.ne.jp/idesaku/20100424/1272092255>
|
||||
|
||||
> <http://d.hatena.ne.jp/griefworker/20110118/vim_zen_coding>
|
||||
* <http://d.hatena.ne.jp/griefworker/20110118/vim_zen_coding>
|
||||
|
||||
> <http://d.hatena.ne.jp/sakurako_s/20110126/1295988873>
|
||||
* <http://d.hatena.ne.jp/sakurako_s/20110126/1295988873>
|
||||
|
||||
> <http://looxu.blogspot.jp/2010/02/zencodingvimhtml.html>
|
||||
* <http://looxu.blogspot.jp/2010/02/zencodingvimhtml.html>
|
||||
|
||||
### tutorial traslated in chinese:
|
||||
### A Chinese translation of the tutorial:
|
||||
|
||||
> <http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html>
|
||||
* <http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html>
|
||||
|
||||
|
||||
62
TUTORIAL
62
TUTORIAL
@@ -1,10 +1,10 @@
|
||||
Tutorial of zencoding.vim
|
||||
Tutorial for Emmet.vim
|
||||
|
||||
mattn <mattn.jp@gmail.com>
|
||||
|
||||
1. Expand Abbreviation
|
||||
1. Expand an Abbreviation
|
||||
|
||||
Type abbreviation as 'div>p#foo$*3>a' and type '<c-y>,'.
|
||||
Type the abbreviation as 'div>p#foo$*3>a' and type '<c-y>,'.
|
||||
---------------------
|
||||
<div>
|
||||
<p id="foo1">
|
||||
@@ -19,7 +19,7 @@ Tutorial of zencoding.vim
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
2. Wrap with Abbreviation
|
||||
2. Wrap with an Abbreviation
|
||||
|
||||
Write as below.
|
||||
---------------------
|
||||
@@ -27,8 +27,8 @@ Tutorial of zencoding.vim
|
||||
test2
|
||||
test3
|
||||
---------------------
|
||||
Then do visual select(line wize) and type '<c-y>,'.
|
||||
If you request 'Tag:', then type 'ul>li*'.
|
||||
Then do visual select(line wise) and type '<c-y>,'.
|
||||
Once you get to the 'Tag:' prompt, type 'ul>li*'.
|
||||
---------------------
|
||||
<ul>
|
||||
<li>test1</li>
|
||||
@@ -37,7 +37,7 @@ Tutorial of zencoding.vim
|
||||
</ul>
|
||||
---------------------
|
||||
|
||||
If you type tag as 'blockquote', then you'll see as following.
|
||||
If you type a tag, such as 'blockquote', then you'll see the following:
|
||||
---------------------
|
||||
<blockquote>
|
||||
test1
|
||||
@@ -46,25 +46,25 @@ Tutorial of zencoding.vim
|
||||
</blockquote>
|
||||
---------------------
|
||||
|
||||
3. Balance Tag Inward
|
||||
3. Balance a Tag Inward
|
||||
|
||||
type '<c-y>d' in insert mode.
|
||||
|
||||
4. Balance Tag Outward
|
||||
4. Balance a Tag Outward
|
||||
|
||||
type '<c-y>D' in insert mode.
|
||||
|
||||
5. Go to Next Edit Point
|
||||
5. Go to the Next Edit Point
|
||||
|
||||
type '<c-y>n' in insert mode.
|
||||
|
||||
6. Go to Previous Edit Point
|
||||
6. Go to the Previous Edit Point
|
||||
|
||||
type '<c-y>N' in insert mode.
|
||||
|
||||
7. Update <img> Size
|
||||
7. Update an <img>’s Size
|
||||
|
||||
Move cursor to img tag.
|
||||
Move cursor to the img tag.
|
||||
---------------------
|
||||
<img src="foo.png" />
|
||||
---------------------
|
||||
@@ -75,7 +75,7 @@ Tutorial of zencoding.vim
|
||||
|
||||
8. Merge Lines
|
||||
|
||||
select the lines included '<li>'
|
||||
select the lines, which include '<li>'
|
||||
---------------------
|
||||
<ul>
|
||||
<li class="list1"></li>
|
||||
@@ -83,14 +83,14 @@ Tutorial of zencoding.vim
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
---------------------
|
||||
and type '<c-y>m'
|
||||
and then type '<c-y>m'
|
||||
---------------------
|
||||
<ul>
|
||||
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
|
||||
</ul>
|
||||
---------------------
|
||||
|
||||
9. Remove Tag
|
||||
9. Remove a Tag
|
||||
|
||||
Move cursor in block
|
||||
---------------------
|
||||
@@ -112,7 +112,7 @@ Tutorial of zencoding.vim
|
||||
|
||||
10. Split/Join Tag
|
||||
|
||||
Move cursor in block
|
||||
Move the cursor inside block
|
||||
---------------------
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
@@ -123,7 +123,7 @@ Tutorial of zencoding.vim
|
||||
<div class="foo"/>
|
||||
---------------------
|
||||
|
||||
And type '<c-y>j' in there again.
|
||||
And then type '<c-y>j' in there again.
|
||||
---------------------
|
||||
<div class="foo">
|
||||
</div>
|
||||
@@ -131,7 +131,7 @@ Tutorial of zencoding.vim
|
||||
|
||||
11. Toggle Comment
|
||||
|
||||
Move cursor to block
|
||||
Move cursor inside the block
|
||||
---------------------
|
||||
<div>
|
||||
hello world
|
||||
@@ -150,7 +150,7 @@ Tutorial of zencoding.vim
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
12. Make anchor from URL
|
||||
12. Make an anchor from a URL
|
||||
|
||||
Move cursor to URL
|
||||
---------------------
|
||||
@@ -161,9 +161,9 @@ Tutorial of zencoding.vim
|
||||
<a href="http://www.google.com/">Google</a>
|
||||
---------------------
|
||||
|
||||
13. Make quoted text from URL
|
||||
13. Make some quoted text from a URL
|
||||
|
||||
Move cursor to URL
|
||||
Move cursor to the URL
|
||||
---------------------
|
||||
http://github.com/
|
||||
---------------------
|
||||
@@ -176,28 +176,28 @@ Tutorial of zencoding.vim
|
||||
</blockquote>
|
||||
---------------------
|
||||
|
||||
14. Installing zencoding.vim for language you using.
|
||||
14. Installing emmet.vim for the language you are using:
|
||||
|
||||
# cd ~/.vim
|
||||
# unzip zencoding-vim.zip
|
||||
# unzip emmet-vim.zip
|
||||
|
||||
or if you install pathogen.vim:
|
||||
Or if you are using pathogen.vim:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# unzip /path/to/zencoding-vim.zip
|
||||
# unzip /path/to/emmet-vim.zip
|
||||
|
||||
if you get sources from repository:
|
||||
Or if you get the sources from the repository:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# git clone http://github.com/mattn/zencoding-vim.git
|
||||
# git clone http://github.com/mattn/emmet-vim.git
|
||||
|
||||
15. Enable zencoding.vim for language you using.
|
||||
15. Enable emmet.vim for the language you using.
|
||||
|
||||
You can customize the behavior of language you using.
|
||||
You can customize the behavior of the languages you are using.
|
||||
|
||||
---------------------
|
||||
# cat >> ~/.vimrc
|
||||
let g:user_zen_settings = {
|
||||
let g:user_emmet_settings = {
|
||||
\ 'php' : {
|
||||
\ 'extends' : 'html',
|
||||
\ 'filters' : 'c',
|
||||
|
||||
247
TUTORIAL.mkd
Normal file
247
TUTORIAL.mkd
Normal file
@@ -0,0 +1,247 @@
|
||||
# Tutorial for Emmet.vim
|
||||
|
||||
mattn <mattn.jp@gmail.com>
|
||||
|
||||
|
||||
|
||||
## Expand an Abbreviation
|
||||
|
||||
Type the abbreviation as `div>p#foo$*3>a` and type `<c-y>,`
|
||||
|
||||
```html
|
||||
<div>
|
||||
<p id="foo1">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo2">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo3">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
</div>
|
||||
```
|
||||
|
||||
## Wrap with an Abbreviation
|
||||
|
||||
Write as below:
|
||||
|
||||
```html
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
```
|
||||
|
||||
Then do visual select(line wise) and type `<c-y>,`. Once you get to the 'Tag:' prompt, type `ul>li*`.
|
||||
|
||||
```html
|
||||
<ul>
|
||||
<li>test1</li>
|
||||
<li>test2</li>
|
||||
<li>test3</li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
If you type a tag, such as `blockquote`, then you'll see the following:
|
||||
|
||||
```html
|
||||
<blockquote>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
</blockquote>
|
||||
```
|
||||
|
||||
## Balance a Tag Inward
|
||||
|
||||
Just type `<c-y>d` in insert mode.
|
||||
|
||||
## Balance a Tag Outward
|
||||
|
||||
Just type `<c-y>D` in insert mode.
|
||||
|
||||
## Go to the Next Edit Point
|
||||
|
||||
Just type `<c-y>n` in insert mode.
|
||||
|
||||
## Go to the Previous Edit Point
|
||||
|
||||
Just type `<c-y>N` in insert mode.
|
||||
|
||||
## Update an <img>’s Size
|
||||
|
||||
Move cursor to the img tag.
|
||||
|
||||
```html
|
||||
<img src="foo.png" />
|
||||
```
|
||||
|
||||
Type `<c-y>i` on img tag
|
||||
|
||||
## Merge Lines
|
||||
|
||||
select the lines, which include `<li>`
|
||||
|
||||
```html
|
||||
<ul>
|
||||
<li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
and then type `<c-y>m`
|
||||
|
||||
```html
|
||||
<ul>
|
||||
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
## Remove the tag
|
||||
|
||||
Move cursor in block
|
||||
|
||||
```html
|
||||
<div class="foo">
|
||||
<a>cursor is here</a>
|
||||
</div>
|
||||
```
|
||||
|
||||
Type '<c-y>k' in insert mode.
|
||||
|
||||
```html
|
||||
<div class="foo">
|
||||
|
||||
</div>
|
||||
```
|
||||
|
||||
And type '<c-y>k' in there again.
|
||||
|
||||
```html
|
||||
|
||||
```
|
||||
|
||||
## Split/Join Tag
|
||||
|
||||
Move the cursor inside block
|
||||
|
||||
```html
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
</div>
|
||||
```
|
||||
|
||||
Type '<c-y>j' in insert mode.
|
||||
|
||||
```html
|
||||
<div class="foo"/>
|
||||
```
|
||||
|
||||
And then type '<c-y>j' in there again.
|
||||
|
||||
```html
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
</div>
|
||||
```
|
||||
|
||||
## Toggle Comment
|
||||
|
||||
Move cursor inside the block
|
||||
|
||||
```html
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
```
|
||||
|
||||
Type '<c-y>/' in insert mode.
|
||||
|
||||
```html
|
||||
<!-- <div>
|
||||
hello world
|
||||
</div> -->
|
||||
```
|
||||
|
||||
Type '<c-y>/' in there again.
|
||||
|
||||
```html
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
```
|
||||
|
||||
## Make an anchor from a URL
|
||||
|
||||
Move cursor to URL
|
||||
|
||||
```http
|
||||
http://www.google.com/
|
||||
```
|
||||
|
||||
Type '<c-y>a'
|
||||
|
||||
```html
|
||||
<a href="http://www.google.com/">Google</a>
|
||||
```
|
||||
|
||||
## Make some quoted text from a URL
|
||||
|
||||
Move cursor to the URL
|
||||
|
||||
```http
|
||||
http://github.com/
|
||||
```
|
||||
|
||||
Type '<c-y>A'
|
||||
|
||||
```html
|
||||
<blockquote class="quote">
|
||||
<a href="http://github.com/">Secure source code hosting and collaborative development - GitHub</a><br />
|
||||
<p>How does it work? Get up and running in seconds by forking a project, pushing an existing repository...</p>
|
||||
<cite>http://github.com/</cite>
|
||||
</blockquote>
|
||||
```
|
||||
|
||||
## Installing emmet.vim for the language you are using:
|
||||
|
||||
```sh
|
||||
cd ~/.vim
|
||||
unzip emmet-vim.zip
|
||||
```
|
||||
|
||||
Or if you are using pathogen.vim:
|
||||
|
||||
```shell
|
||||
cd ~/.vim/bundle # or make directory
|
||||
unzip /path/to/emmet-vim.zip
|
||||
```
|
||||
|
||||
Or if you get the sources from the repository:
|
||||
|
||||
```sh
|
||||
cd ~/.vim/bundle # or make directory
|
||||
git clone http://github.com/mattn/emmet-vim.git
|
||||
```
|
||||
|
||||
## Enable emmet.vim for the language you using.
|
||||
|
||||
You can customize the behavior of the languages you are using.
|
||||
|
||||
```sh
|
||||
cat >> ~/.vimrc
|
||||
let g:user_emmet_settings = {
|
||||
\ 'php' : {
|
||||
\ 'extends' : 'html',
|
||||
\ 'filters' : 'c',
|
||||
\ },
|
||||
\ 'xml' : {
|
||||
\ 'extends' : 'html',
|
||||
\ },
|
||||
\ 'haml' : {
|
||||
\ 'extends' : 'html',
|
||||
\ },
|
||||
\}
|
||||
```
|
||||
|
||||
2148
autoload/emmet.vim
Normal file
2148
autoload/emmet.vim
Normal file
File diff suppressed because it is too large
Load Diff
52
autoload/emmet/lang.vim
Normal file
52
autoload/emmet/lang.vim
Normal file
@@ -0,0 +1,52 @@
|
||||
let s:exists = {}
|
||||
function! emmet#lang#exists(type) abort
|
||||
if len(a:type) == 0
|
||||
return 0
|
||||
elseif has_key(s:exists, a:type)
|
||||
return s:exists[a:type]
|
||||
endif
|
||||
let s:exists[a:type] = len(globpath(&rtp, 'autoload/emmet/lang/'.a:type.'.vim')) > 0
|
||||
return s:exists[a:type]
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#type(type) abort
|
||||
let type = a:type
|
||||
let base = type
|
||||
let settings = emmet#getSettings()
|
||||
while base != ''
|
||||
for b in split(base, '\.')
|
||||
if emmet#lang#exists(b)
|
||||
return b
|
||||
endif
|
||||
if has_key(settings, b) && has_key(settings[b], 'extends')
|
||||
let base = settings[b].extends
|
||||
break
|
||||
else
|
||||
let base = ''
|
||||
endif
|
||||
endfor
|
||||
endwhile
|
||||
return 'html'
|
||||
endfunction
|
||||
|
||||
" get all extends for a type recursively
|
||||
function! emmet#lang#getExtends(type) abort
|
||||
let settings = emmet#getSettings()
|
||||
|
||||
if !has_key(settings[a:type], 'extends')
|
||||
return []
|
||||
endif
|
||||
|
||||
let extends = settings[a:type].extends
|
||||
if type(extends) ==# 1
|
||||
let tmp = split(extends, '\s*,\s*')
|
||||
unlet! extends
|
||||
let extends = tmp
|
||||
endif
|
||||
|
||||
for ext in extends
|
||||
let extends = extends + emmet#lang#getExtends(ext)
|
||||
endfor
|
||||
|
||||
return extends
|
||||
endfunction
|
||||
385
autoload/emmet/lang/css.vim
Normal file
385
autoload/emmet/lang/css.vim
Normal file
@@ -0,0 +1,385 @@
|
||||
function! emmet#lang#css#findTokens(str) abort
|
||||
let tmp = substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
|
||||
if tmp =~ '/' && tmp =~ '^[a-zA-Z0-9/_.]\+$'
|
||||
" maybe path or something
|
||||
return ''
|
||||
endif
|
||||
return substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#parseIntoTree(abbr, type) abort
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
let prefix = 0
|
||||
let value = ''
|
||||
|
||||
let indent = emmet#getIndentation(type)
|
||||
let aliases = emmet#getResource(type, 'aliases', {})
|
||||
let snippets = emmet#getResource(type, 'snippets', {})
|
||||
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
let root = emmet#newNode()
|
||||
|
||||
" emmet
|
||||
let tokens = split(abbr, '+\ze[^+)!]')
|
||||
let block = emmet#util#searchRegion('{', '}')
|
||||
if abbr !~# '^@' && emmet#getBaseType(type) ==# 'css' && type !=# 'sass' && type !=# 'styled' && block[0] ==# [0,0] && block[1] ==# [0,0]
|
||||
let current = emmet#newNode()
|
||||
let current.snippet = substitute(abbr, '\s\+$', '', '') . " {\n" . indent . "${cursor}\n}"
|
||||
let current.name = ''
|
||||
call add(root.child, deepcopy(current))
|
||||
else
|
||||
for n in range(len(tokens))
|
||||
let token = tokens[n]
|
||||
let prop = matchlist(token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+\%(p\|e\|em\|x\|vh\|vw\|re\|rem\|%\)\{0,}-\{0,1}\|-auto\)*\)$')
|
||||
if len(prop)
|
||||
let token = substitute(prop[1], '^(\(.*\))', '\1', '')
|
||||
if token =~# '^-'
|
||||
let prefix = 1
|
||||
let token = token[1:]
|
||||
endif
|
||||
let value = ''
|
||||
for vt in split(prop[2], '\a\+\zs')
|
||||
let ut = matchstr(vt, '[a-z]\+$')
|
||||
if ut == 'auto'
|
||||
let ut = ''
|
||||
endif
|
||||
for v in split(vt, '\d\zs-')
|
||||
if len(value) > 0
|
||||
let value .= ' '
|
||||
endif
|
||||
if v !~ '[a-z]\+$'
|
||||
let v .= ut
|
||||
endif
|
||||
if token =~# '^[z]'
|
||||
" TODO
|
||||
let value .= substitute(v, '[^0-9.]*$', '', '')
|
||||
elseif v =~# 'em$'
|
||||
let value .= v
|
||||
elseif v =~# 'ex$'
|
||||
let value .= v
|
||||
elseif v =~# 'vh$'
|
||||
let value .= v
|
||||
elseif v =~# 'vw$'
|
||||
let value .= v
|
||||
elseif v =~# 'rem$'
|
||||
let value .= v
|
||||
elseif v ==# 'auto'
|
||||
let value .= v
|
||||
elseif v =~# 'p$'
|
||||
let value .= substitute(v, 'p$', '%', '')
|
||||
elseif v =~# '%$'
|
||||
let value .= v
|
||||
elseif v =~# 'e$'
|
||||
let value .= substitute(v, 'e$', 'em', '')
|
||||
elseif v =~# 'x$'
|
||||
let value .= substitute(v, 'x$', 'ex', '')
|
||||
elseif v =~# 're$'
|
||||
let value .= substitute(v, 're$', 'rem', '')
|
||||
elseif v =~# '\.'
|
||||
let value .= v . 'em'
|
||||
elseif v ==# '0'
|
||||
let value .= '0'
|
||||
else
|
||||
let value .= v . 'px'
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
|
||||
let tag_name = token
|
||||
if tag_name =~# '.!$'
|
||||
let tag_name = tag_name[:-2]
|
||||
let important = 1
|
||||
else
|
||||
let important = 0
|
||||
endif
|
||||
" make default node
|
||||
let current = emmet#newNode()
|
||||
let current.important = important
|
||||
let current.name = tag_name
|
||||
|
||||
" aliases
|
||||
if has_key(aliases, tag_name)
|
||||
let current.name = aliases[tag_name]
|
||||
endif
|
||||
|
||||
" snippets
|
||||
if !empty(snippets)
|
||||
let snippet_name = tag_name
|
||||
if !has_key(snippets, snippet_name)
|
||||
let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-\)')
|
||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
||||
if len(vv) == 0
|
||||
let vv = filter(sort(keys(snippets)), 'substitute(v:val, ":", "", "g") == snippet_name')
|
||||
endif
|
||||
if len(vv) > 0
|
||||
let snippet_name = vv[0]
|
||||
else
|
||||
let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-*\)')
|
||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
||||
if len(vv) == 0
|
||||
let pat = '^' . join(split(tag_name, '\zs'), '[^:]\{-}')
|
||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
||||
if len(vv) == 0
|
||||
let pat = '^' . join(split(tag_name, '\zs'), '.\{-}')
|
||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
||||
endif
|
||||
endif
|
||||
let minl = -1
|
||||
for vk in vv
|
||||
let vvs = snippets[vk]
|
||||
if minl == -1 || len(vvs) < minl
|
||||
let snippet_name = vk
|
||||
let minl = len(vvs)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
if has_key(snippets, snippet_name)
|
||||
let snippet = snippets[snippet_name]
|
||||
if use_pipe_for_cursor
|
||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
||||
endif
|
||||
let lines = split(snippet, "\n")
|
||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
||||
let current.snippet = join(lines, "\n")
|
||||
let current.name = ''
|
||||
let current.snippet = substitute(current.snippet, ';', value . ';', '')
|
||||
if use_pipe_for_cursor && len(value) > 0
|
||||
let current.snippet = substitute(current.snippet, '\${cursor}', '', 'g')
|
||||
endif
|
||||
if n < len(tokens) - 1
|
||||
let current.snippet .= "\n"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let current.pos = 0
|
||||
let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$')
|
||||
if len(lg) == 0
|
||||
let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*)$')
|
||||
if len(lg)
|
||||
let [lg[1], lg[2], lg[3]] = ['linear', lg[1], lg[2]]
|
||||
endif
|
||||
endif
|
||||
if len(lg)
|
||||
let current.name = ''
|
||||
let current.snippet = printf("background-image:-webkit-gradient(%s, 0 0, 0 100%, from(%s), to(%s));\n", lg[1], lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image:-webkit-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image:-moz-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image:-o-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image:linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
elseif prefix
|
||||
let snippet = current.snippet
|
||||
let current.snippet = '-webkit-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-moz-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-o-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-ms-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = snippet
|
||||
call add(root.child, current)
|
||||
elseif token =~# '^c#\([0-9a-fA-F]\{3}\|[0-9a-fA-F]\{6}\)\(\.[0-9]\+\)\?'
|
||||
let cs = split(token, '\.')
|
||||
let current.name = ''
|
||||
let [r,g,b] = [0,0,0]
|
||||
if len(cs[0]) == 5
|
||||
let rgb = matchlist(cs[0], 'c#\(.\)\(.\)\(.\)')
|
||||
let r = eval('0x'.rgb[1].rgb[1])
|
||||
let g = eval('0x'.rgb[2].rgb[2])
|
||||
let b = eval('0x'.rgb[3].rgb[3])
|
||||
elseif len(cs[0]) == 8
|
||||
let rgb = matchlist(cs[0], 'c#\(..\)\(..\)\(..\)')
|
||||
let r = eval('0x'.rgb[1])
|
||||
let g = eval('0x'.rgb[2])
|
||||
let b = eval('0x'.rgb[3])
|
||||
endif
|
||||
if len(cs) == 1
|
||||
let current.snippet = printf('color:rgb(%d, %d, %d);', r, g, b)
|
||||
else
|
||||
let current.snippet = printf('color:rgb(%d, %d, %d, %s);', r, g, b, string(str2float('0.'.cs[1])))
|
||||
endif
|
||||
call add(root.child, current)
|
||||
elseif token =~# '^c#'
|
||||
let current.name = ''
|
||||
let current.snippet = 'color:\${cursor};'
|
||||
call add(root.child, current)
|
||||
else
|
||||
call add(root.child, current)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
return root
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let current = a:current
|
||||
let value = current.value[1:-2]
|
||||
let tmp = substitute(value, '\${cursor}', '', 'g')
|
||||
if tmp !~ '.*{[ \t\r\n]*}$'
|
||||
if emmet#useFilter(a:filters, 'fc')
|
||||
let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1: \2', 'g')
|
||||
else
|
||||
let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1:\2', 'g')
|
||||
endif
|
||||
if current.important
|
||||
let value = substitute(value, ';', ' !important;', '')
|
||||
endif
|
||||
endif
|
||||
return value
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#imageSize() abort
|
||||
let img_region = emmet#util#searchRegion('{', '}')
|
||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = emmet#util#getContent(img_region)
|
||||
let fn = matchstr(content, '\<url(\zs[^)]\+\ze)')
|
||||
let fn = substitute(fn, '[''" \t]', '', 'g')
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let indent = emmet#getIndentation('css')
|
||||
if content =~# '.*\<width\s*:[^;]*;.*'
|
||||
let content = substitute(content, '\<width\s*:[^;]*;', 'width: ' . width . 'px;', '')
|
||||
else
|
||||
let content = substitute(content, '}', indent . 'width: ' . width . "px;\n}", '')
|
||||
endif
|
||||
if content =~# '.*\<height\s*:[^;]*;.*'
|
||||
let content = substitute(content, '\<height\s*:[^;]*;', 'height: ' . height . 'px;', '')
|
||||
else
|
||||
let content = substitute(content, '}', indent . 'height: ' . height . "px;\n}", '')
|
||||
endif
|
||||
call emmet#util#setContent(img_region, content)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#imageEncode() abort
|
||||
let img_region = emmet#util#searchRegion('url(', ')')
|
||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = emmet#util#getContent(img_region)
|
||||
let fn = matchstr(content, '\<url(\zs[^)]\+\ze)')
|
||||
let fn = substitute(fn, '[''" \t]', '', 'g')
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
let encoded = emmet#util#imageEncodeDecode(fn, 0)
|
||||
call emmet#util#setContent(img_region, 'url(' . encoded . ')')
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#parseTag(tag) abort
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#toggleComment() abort
|
||||
let line = getline('.')
|
||||
let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
|
||||
if line =~# '{\s*$'
|
||||
let block = emmet#util#searchRegion('/\*', '\*/\zs')
|
||||
if emmet#util#regionIsValid(block)
|
||||
let content = emmet#util#getContent(block)
|
||||
let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '')
|
||||
call emmet#util#setContent(block, content)
|
||||
else
|
||||
let node = expand('<cword>')
|
||||
if len(node)
|
||||
exe "normal ciw\<c-r>='/* '.node.' */'\<cr>"
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if line =~# mx
|
||||
let space = substitute(matchstr(line, mx), mx, '\1', '')
|
||||
let line = substitute(matchstr(line, mx), mx, '\2', '')
|
||||
let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g')
|
||||
else
|
||||
let mx = '^\(\s*\)\(''[^'']*''\|[^'']*\|;\)\s*$'
|
||||
" TODO multi-property
|
||||
"let mx = '^\(\s*\)\(\%(''[^'']*''\|[^'';]\+\)*;\{0,1}\)'
|
||||
let line = substitute(line, mx, '\1/* \2 */', '')
|
||||
endif
|
||||
call setline('.', line)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#balanceTag(flag) range abort
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if !emmet#util#regionIsValid(block)
|
||||
if a:flag > 0
|
||||
let block = emmet#util#searchRegion('^', ';')
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if a:flag > 0
|
||||
let content = emmet#util#getContent(block)
|
||||
if content !~# '^{.*}$'
|
||||
let block = emmet#util#searchRegion('{', '}')
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let pos = searchpos('.*;', 'nW')
|
||||
if pos[0] != 0
|
||||
call setpos('.', [0, pos[0], pos[1], 0])
|
||||
let block = emmet#util#searchRegion('^', ';')
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe 'normal! gv'
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#css#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#moveNextPrev(flag) abort
|
||||
call search('""\|()\|\(:\s*\zs;\{1,0}$\)', a:flag ? 'Wbp' : 'Wp')
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#splitJoinTag() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#removeTag() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#mergeLines() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
241
autoload/emmet/lang/elm.vim
Normal file
241
autoload/emmet/lang/elm.vim
Normal file
@@ -0,0 +1,241 @@
|
||||
function! emmet#lang#elm#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#parseIntoTree(abbr, type) abort
|
||||
let tree = emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
if len(tree.child) < 2 | return tree | endif
|
||||
|
||||
" Add ',' nodes between root elements.
|
||||
let new_children = []
|
||||
for child in tree.child[0:-2]
|
||||
let comma = emmet#newNode()
|
||||
let comma.name = ','
|
||||
call add(new_children, child)
|
||||
call add(new_children, comma)
|
||||
endfor
|
||||
call add(new_children, tree.child[-1])
|
||||
let tree.child = new_children
|
||||
return tree
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#renderNode(node)
|
||||
let elm_nodes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'
|
||||
\, 'div', 'p', 'hr', 'pre', 'blockquote'
|
||||
\, 'span', 'a', 'code', 'em', 'strong', 'i', 'b', 'u', 'sub', 'sup', 'br'
|
||||
\, 'ol', 'ul', 'li', 'dl', 'dt', 'dd'
|
||||
\, 'img', 'iframe', 'canvas', 'math'
|
||||
\, 'form', 'input', 'textarea', 'button', 'select', 'option'
|
||||
\, 'section', 'nav', 'article', 'aside', 'header', 'footer', 'address', 'main_', 'body'
|
||||
\, 'figure', 'figcaption'
|
||||
\, 'table', 'caption', 'colgroup', 'col', 'tbody', 'thead', 'tfoot', 'tr', 'td', 'th'
|
||||
\, 'fieldset', 'legend', 'label', 'datalist', 'optgroup', 'keygen', 'output', 'progress', 'meter'
|
||||
\, 'audio', 'video', 'source', 'track'
|
||||
\, 'embed', 'object', 'param'
|
||||
\, 'ins', 'del'
|
||||
\, 'small', 'cite', 'dfn', 'abbr', 'time', 'var', 'samp', 'kbd', 's', 'q'
|
||||
\, 'mark', 'ruby', 'rt', 'rp', 'bdi', 'bdo', 'wbr'
|
||||
\, 'details', 'summary', 'menuitem', 'menu']
|
||||
|
||||
if index(elm_nodes, a:node) >= 0
|
||||
return a:node
|
||||
endif
|
||||
return 'node "' . a:node . '"'
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#renderParam(param)
|
||||
let elm_events = ["onClick", "onDoubleClick"
|
||||
\, "onMouseDown", "onMouseUp"
|
||||
\, "onMouseEnter", "onMouseLeave"
|
||||
\, "onMouseOver", "onMouseOut"
|
||||
\, "onInput", "onCheck", "onSubmit"
|
||||
\, "onBlur", "onFocus"
|
||||
\, "on", "onWithOptions", "Options", "defaultOptions"
|
||||
\, "targetValue", "targetChecked", "keyCode"]
|
||||
if index(elm_events, a:param) >= 0
|
||||
return a:param
|
||||
endif
|
||||
let elm_attributes = ["style", "map" , "class", "id", "title", "hidden"
|
||||
\, "type", "type_", "value", "defaultValue", "checked", "placeholder", "selected"
|
||||
\, "accept", "acceptCharset", "action", "autocomplete", "autofocus"
|
||||
\, "disabled", "enctype", "formaction", "list", "maxlength", "minlength", "method", "multiple"
|
||||
\, "name", "novalidate", "pattern", "readonly", "required", "size", "for", "form"
|
||||
\, "max", "min", "step"
|
||||
\, "cols", "rows", "wrap"
|
||||
\, "href", "target", "download", "downloadAs", "hreflang", "media", "ping", "rel"
|
||||
\, "ismap", "usemap", "shape", "coords"
|
||||
\, "src", "height", "width", "alt"
|
||||
\, "autoplay", "controls", "loop", "preload", "poster", "default", "kind", "srclang"
|
||||
\, "sandbox", "seamless", "srcdoc"
|
||||
\, "reversed", "start"
|
||||
\, "align", "colspan", "rowspan", "headers", "scope"
|
||||
\, "async", "charset", "content", "defer", "httpEquiv", "language", "scoped"
|
||||
\, "accesskey", "contenteditable", "contextmenu", "dir", "draggable", "dropzone"
|
||||
\, "itemprop", "lang", "spellcheck", "tabindex"
|
||||
\, "challenge", "keytype"
|
||||
\, "cite", "datetime", "pubdate", "manifest"]
|
||||
|
||||
if index(elm_attributes, a:param) >= 0
|
||||
if a:param == 'type'
|
||||
return 'type_'
|
||||
endif
|
||||
return a:param
|
||||
endif
|
||||
return 'attribute "' . a:param . '"'
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let str = ''
|
||||
|
||||
" comma between items with *, eg. li*3
|
||||
if itemno > 0
|
||||
let str = ", "
|
||||
endif
|
||||
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
endif
|
||||
|
||||
if len(current.name) > 0
|
||||
" inserted root comma nodes
|
||||
if current_name == ','
|
||||
return "\n, "
|
||||
endif
|
||||
let str .= emmet#lang#elm#renderNode(current_name)
|
||||
let tmp = ''
|
||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
|
||||
let attr = emmet#lang#elm#renderParam(attr)
|
||||
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
let tmp .= ', ' . attr . ' True'
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let valtmp = substitute(Val, '\${cursor}', '', '')
|
||||
if attr ==# 'id' && len(valtmp) > 0
|
||||
let tmp .=', id "' . Val . '"'
|
||||
elseif attr ==# 'class' && len(valtmp) > 0
|
||||
let tmp .= ', class "' . substitute(Val, '\.', ' ', 'g') . '"'
|
||||
else
|
||||
let tmp .= ', ' . attr . ' "' . Val . '"'
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if ! len(tmp)
|
||||
let str .= ' []'
|
||||
else
|
||||
let tmp = strpart(tmp, 2)
|
||||
let str .= ' [ ' . tmp . ' ]'
|
||||
endif
|
||||
|
||||
" No children quit early
|
||||
if len(current.child) == 0 && len(current.value) == 0
|
||||
"Place cursor in node with no value or children
|
||||
let str .= ' [${cursor}]'
|
||||
return str
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
|
||||
" Parent contex text
|
||||
if len(current.value) > 0
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
" let str = substitute(str, '\$#', text, 'g')
|
||||
let inner .= ', text "' . text . '"'
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
" Has children
|
||||
for child in current.child
|
||||
if len(child.name) == 0 && len(child.value) > 0
|
||||
" Text node
|
||||
let text = child.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let inner .= ', text "' . text . '"'
|
||||
else
|
||||
" Other nodes
|
||||
let inner .= ', ' . emmet#toString(child, type, inline, filters, 0, indent)
|
||||
endif
|
||||
endfor
|
||||
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let inner = strpart(inner, 2)
|
||||
|
||||
let inner = substitute(inner, ' ', '', 'g')
|
||||
|
||||
if ! len(inner)
|
||||
let str .= ' []'
|
||||
else
|
||||
let str .= ' [ ' . inner . ' ]'
|
||||
endif
|
||||
|
||||
else
|
||||
let str = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
|
||||
let str .= "\n"
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#parseTag(tag) abort
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#toggleComment() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#balanceTag(flag) range abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#elm#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#moveNextPrev(flag) abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#splitJoinTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#removeTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#mergeLines() abort
|
||||
endfunction
|
||||
@@ -1,24 +1,23 @@
|
||||
function! zencoding#lang#haml#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
function! emmet#lang#haml#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#parseIntoTree(abbr, type)
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
function! emmet#lang#haml#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
function! emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||
let str = ""
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let attribute_style = emmet#getResource('haml', 'attribute_style', 'hash')
|
||||
let str = ''
|
||||
|
||||
let comment_indent = ''
|
||||
let comment = ''
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
@@ -26,30 +25,54 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
|
||||
if len(current.name) > 0
|
||||
let str .= '%' . current_name
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ' :' . attr . ' => true'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= attr . '=true'
|
||||
end
|
||||
else
|
||||
if dollar_expr
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let valtmp = substitute(val, '\${cursor}', '', '')
|
||||
if attr == 'id' && len(valtmp) > 0
|
||||
let str .= '#' . val
|
||||
elseif attr == 'class' && len(valtmp) > 0
|
||||
let str .= '.' . substitute(val, ' ', '.', 'g')
|
||||
let valtmp = substitute(Val, '\${cursor}', '', '')
|
||||
if attr ==# 'id' && len(valtmp) > 0
|
||||
let str .= '#' . Val
|
||||
elseif attr ==# 'class' && len(valtmp) > 0
|
||||
let str .= '.' . substitute(Val, ' ', '.', 'g')
|
||||
else
|
||||
if len(tmp) > 0 | let tmp .= ',' | endif
|
||||
let val = substitute(val, '\${cursor}', '', '')
|
||||
let tmp .= ' :' . attr . ' => "' . val . '"'
|
||||
if len(tmp) > 0
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ','
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= ' '
|
||||
endif
|
||||
endif
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ' :' . attr . ' => "' . Val . '"'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= attr . '="' . Val . '"'
|
||||
end
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(tmp)
|
||||
if attribute_style ==# 'hash'
|
||||
let str .= '{' . tmp . ' }'
|
||||
elseif attribute_style ==# 'html'
|
||||
let str .= '(' . tmp . ')'
|
||||
end
|
||||
endif
|
||||
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0
|
||||
let str .= "/"
|
||||
let str .= '/'
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
@@ -59,13 +82,14 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
let str = substitute(str, '\$#', text, 'g')
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= " " . text
|
||||
let str .= ' ' . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . " |"
|
||||
let str .= "\n" . indent . line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) == 0
|
||||
@@ -80,18 +104,18 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= " " . text
|
||||
let str .= ' ' . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . " |"
|
||||
let str .= "\n" . indent . line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) > 0
|
||||
for child in current.child
|
||||
let inner .= zencoding#toString(child, type, inline, filters, itemno)
|
||||
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= "\n" . indent . inner
|
||||
endif
|
||||
else
|
||||
@@ -106,75 +130,78 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#imageSize()
|
||||
function! emmet#lang#haml#imageSize() abort
|
||||
let line = getline('.')
|
||||
let current = zencoding#lang#haml#parseTag(line)
|
||||
let current = emmet#lang#haml#parseTag(line)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~ '^\s*$'
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~ '^\(/\|http\)'
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let haml = zencoding#toString(current, 'haml', 1)
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", "", "g"))
|
||||
let current.attrs_order += ['width', 'height']
|
||||
let haml = emmet#toString(current, 'haml', 1)
|
||||
let haml = substitute(haml, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#encodeImage()
|
||||
function! emmet#lang#haml#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#parseTag(tag)
|
||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
|
||||
function! emmet#lang#haml#parseTag(tag) abort
|
||||
let current = emmet#newNode()
|
||||
let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', 'i')
|
||||
let attrs = substitute(match, mx, '\2', 'i')
|
||||
let current.name = substitute(match, mx, '\1', '')
|
||||
let attrs = substitute(match, mx, '\2', '')
|
||||
let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) == 0
|
||||
if len(match) ==# 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let current.attrs_order += [name]
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#toggleComment()
|
||||
function! emmet#lang#haml#toggleComment() abort
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~ '^\s*-#'
|
||||
if line =~# '^\s*-#'
|
||||
call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*'))
|
||||
elseif line =~ '^\s*%[a-z]'
|
||||
elseif line =~# '^\s*%[a-z]'
|
||||
call setline('.', space . '-# ' . line[len(space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#balanceTag(flag) range
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
function! emmet#lang#haml#balanceTag(flag) range abort
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
@@ -228,7 +255,11 @@ function! zencoding#lang#haml#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#moveNextPrev(flag)
|
||||
function! emmet#lang#haml#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#haml#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#moveNextPrev(flag) abort
|
||||
let pos = search('""', a:flag ? 'Wb' : 'W')
|
||||
if pos != 0
|
||||
silent! normal! l
|
||||
@@ -236,11 +267,11 @@ function! zencoding#lang#haml#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#splitJoinTag()
|
||||
function! emmet#lang#haml#splitJoinTag() abort
|
||||
let n = line('.')
|
||||
let sml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze%[a-z]'
|
||||
if getline(n) =~# '^\s*\ze%[a-z]'
|
||||
if len(matchstr(getline(n), '^\s*%[a-z]')) < sml
|
||||
break
|
||||
endif
|
||||
@@ -255,13 +286,13 @@ function! zencoding#lang#haml#splitJoinTag()
|
||||
if l <= ml
|
||||
break
|
||||
endif
|
||||
exe n "delete"
|
||||
exe n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)')
|
||||
let spaces = matchstr(getline(sn), '^\s*')
|
||||
let settings = zencoding#getSettings()
|
||||
let settings = emmet#getSettings()
|
||||
if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1
|
||||
call append(sn, spaces . ' ')
|
||||
call setpos('.', [0, sn+1, 1, 0])
|
||||
@@ -276,11 +307,11 @@ function! zencoding#lang#haml#splitJoinTag()
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#removeTag()
|
||||
function! emmet#lang#haml#removeTag() abort
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze[a-z]'
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
break
|
||||
endif
|
||||
@@ -296,8 +327,11 @@ function! zencoding#lang#haml#removeTag()
|
||||
let n += 1
|
||||
endwhile
|
||||
if sn == n
|
||||
exe "delete"
|
||||
exe 'delete'
|
||||
else
|
||||
exe sn "," (n-1) "delete"
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#mergeLines() abort
|
||||
endfunction
|
||||
1036
autoload/emmet/lang/html.vim
Normal file
1036
autoload/emmet/lang/html.vim
Normal file
File diff suppressed because it is too large
Load Diff
335
autoload/emmet/lang/jade.vim
Normal file
335
autoload/emmet/lang/jade.vim
Normal file
@@ -0,0 +1,335 @@
|
||||
function! emmet#lang#jade#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let attribute_style = emmet#getResource('jade', 'attribute_style', 'hash')
|
||||
let str = ''
|
||||
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
endif
|
||||
if len(current.name) > 0
|
||||
let str .= '' . current_name
|
||||
let tmp = ''
|
||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ' ' . attr . ' = true'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= attr . '=true'
|
||||
end
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let valtmp = substitute(Val, '\${cursor}', '', '')
|
||||
if attr ==# 'id' && len(valtmp) > 0
|
||||
let str .= '#' . Val
|
||||
elseif attr ==# 'class' && len(valtmp) > 0
|
||||
let str .= '.' . substitute(Val, ' ', '.', 'g')
|
||||
else
|
||||
if len(tmp) > 0
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ', '
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= ' '
|
||||
endif
|
||||
endif
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= '' . attr . '="' . Val . '"'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= attr . '="' . Val . '"'
|
||||
end
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(tmp)
|
||||
if attribute_style ==# 'hash'
|
||||
let str .= '(' . tmp . ')'
|
||||
elseif attribute_style ==# 'html'
|
||||
let str .= '(' . tmp . ')'
|
||||
end
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
if len(current.value) > 0
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
let str = substitute(str, '\$#', text, 'g')
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= ' ' . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) == 0
|
||||
let str .= '${cursor}'
|
||||
endif
|
||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
||||
let text = current.child[0].value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= ' ' . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) > 0
|
||||
for child in current.child
|
||||
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= "\n" . indent . inner
|
||||
endif
|
||||
else
|
||||
let str = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
let str .= "\n"
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#imageSize() abort
|
||||
let line = getline('.')
|
||||
let current = emmet#lang#jade#parseTag(line)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let current.attrs_order += ['width', 'height']
|
||||
let jade = emmet#toString(current, 'jade', 1)
|
||||
let jade = substitute(jade, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . jade, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#parseTag(tag) abort
|
||||
let current = emmet#newNode()
|
||||
let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', '')
|
||||
let attrs = substitute(match, mx, '\2', '')
|
||||
let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) ==# 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let current.attrs_order += [name]
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#toggleComment() abort
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~# '^\s*-#'
|
||||
call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*'))
|
||||
elseif line =~# '^\s*%[a-z]'
|
||||
call setline('.', space . '-# ' . line[len(space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#balanceTag(flag) range abort
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
|
||||
if l > 0 && l < ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l > ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#jade#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#moveNextPrev(flag) abort
|
||||
let pos = search('""', a:flag ? 'Wb' : 'W')
|
||||
if pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#splitJoinTag() abort
|
||||
let n = line('.')
|
||||
let sml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
while n > 0
|
||||
if getline(n) =~# '^\s*\ze%[a-z]'
|
||||
if len(matchstr(getline(n), '^\s*%[a-z]')) < sml
|
||||
break
|
||||
endif
|
||||
let line = getline(n)
|
||||
call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
|
||||
let sn = n
|
||||
let n += 1
|
||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if len(matchstr(getline(n), '^\s*')) > ml
|
||||
while n <= line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*'))
|
||||
if l <= ml
|
||||
break
|
||||
endif
|
||||
exe n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)')
|
||||
let spaces = matchstr(getline(sn), '^\s*')
|
||||
let settings = emmet#getSettings()
|
||||
if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1
|
||||
call append(sn, spaces . ' ')
|
||||
call setpos('.', [0, sn+1, 1, 0])
|
||||
else
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
startinsert!
|
||||
endif
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#removeTag() abort
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
let sn = n
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
if sn == n
|
||||
exe 'delete'
|
||||
else
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#mergeLines() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
51
autoload/emmet/lang/less.vim
Normal file
51
autoload/emmet/lang/less.vim
Normal file
@@ -0,0 +1,51 @@
|
||||
function! emmet#lang#less#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#scss#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
return emmet#lang#scss#toString(a:settings, a:current, a:type, a:inline, a:filters, a:itemno, a:indent)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#imageSize() abort
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#imageEncode() abort
|
||||
return emmet#lang#css#imageEncode()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#parseTag(tag) abort
|
||||
return emmet#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#toggleComment() abort
|
||||
call emmet#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#balanceTag(flag) range abort
|
||||
call emmet#lang#scss#balanceTag(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#less#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#moveNextPrev(flag) abort
|
||||
call emmet#lang#scss#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#splitJoinTag() abort
|
||||
call emmet#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#removeTag() abort
|
||||
call emmet#lang#css#removeTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#mergeLines() abort
|
||||
call emmet#lang#css#mergeLines()
|
||||
endfunction
|
||||
@@ -1,16 +1,12 @@
|
||||
function! zencoding#lang#sass#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
function! emmet#lang#sass#findTokens(str) abort
|
||||
return emmet#lang#css#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#parseIntoTree(abbr, type)
|
||||
if a:abbr =~ '>'
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
else
|
||||
return zencoding#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endif
|
||||
function! emmet#lang#sass#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
function! emmet#lang#sass#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
@@ -18,7 +14,7 @@ function! zencoding#lang#sass#toString(settings, current, type, inline, filters,
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let str = ""
|
||||
let str = ''
|
||||
|
||||
let current_name = current.name
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
@@ -27,13 +23,13 @@ function! zencoding#lang#sass#toString(settings, current, type, inline, filters,
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
while val =~# '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
if attr == 'id'
|
||||
if attr ==# 'id'
|
||||
let str .= '#' . val
|
||||
elseif attr == 'class'
|
||||
elseif attr ==# 'class'
|
||||
let str .= '.' . val
|
||||
else
|
||||
let tmp .= attr . ': ' . val
|
||||
@@ -50,43 +46,46 @@ function! zencoding#lang#sass#toString(settings, current, type, inline, filters,
|
||||
|
||||
let inner = ''
|
||||
for child in current.child
|
||||
let inner .= zencoding#toString(child, type, inline, filters, itemno)
|
||||
let tmp = emmet#toString(child, type, inline, filters, itemno, indent)
|
||||
let tmp = substitute(tmp, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let tmp = substitute(tmp, "\n" . escape(indent, '\') . '$', '${cursor}\n', 'g')
|
||||
let inner .= tmp
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . indent, 'g')
|
||||
let inner = substitute(inner, "\n" . indent . "$", "", 'g')
|
||||
if len(inner) > 0
|
||||
let str .= indent . inner
|
||||
endif
|
||||
else
|
||||
let text = zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let text = substitute(text, '\s*;$', '', '')
|
||||
let text = emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let text = substitute(text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g')
|
||||
return text
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#imageSize()
|
||||
function! emmet#lang#sass#imageSize() abort
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#encodeImage()
|
||||
function! emmet#lang#sass#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#parseTag(tag)
|
||||
function! emmet#lang#sass#parseTag(tag) abort
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#toggleComment()
|
||||
function! emmet#lang#sass#toggleComment() abort
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#balanceTag(flag) range
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
function! emmet#lang#sass#balanceTag(flag) range abort
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
@@ -140,7 +139,11 @@ function! zencoding#lang#sass#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#moveNextPrev(flag)
|
||||
function! emmet#lang#sass#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#sass#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#moveNextPrev(flag) abort
|
||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
@@ -150,8 +153,11 @@ function! zencoding#lang#sass#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#splitJoinTag()
|
||||
function! emmet#lang#sass#splitJoinTag() abort
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#removeTag()
|
||||
function! emmet#lang#sass#removeTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#mergeLines() abort
|
||||
endfunction
|
||||
129
autoload/emmet/lang/scss.vim
Normal file
129
autoload/emmet/lang/scss.vim
Normal file
@@ -0,0 +1,129 @@
|
||||
function! emmet#lang#scss#findTokens(str) abort
|
||||
return emmet#lang#css#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#parseIntoTree(abbr, type) abort
|
||||
if a:abbr =~# '>'
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
else
|
||||
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let str = ''
|
||||
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
if len(current.name) > 0
|
||||
let str .= current_name
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
while val =~# '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
if attr ==# 'id'
|
||||
let str .= '#' . val
|
||||
elseif attr ==# 'class'
|
||||
let str .= '.' . val
|
||||
else
|
||||
let tmp .= attr . ': ' . val . ';'
|
||||
endif
|
||||
endfor
|
||||
if len(tmp) > 0
|
||||
let str .= " {\n"
|
||||
for line in split(tmp, "\n")
|
||||
let str .= indent . line . "\n"
|
||||
endfor
|
||||
else
|
||||
let str .= " {\n"
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
for child in current.child
|
||||
let inner .= emmet#toString(child, type, inline, filters, itemno)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= indent . inner . "${cursor}\n}\n"
|
||||
else
|
||||
return emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#imageSize() abort
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#imageEncode() abort
|
||||
return emmet#lang#css#imageEncode()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#parseTag(tag) abort
|
||||
return emmet#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#toggleComment() abort
|
||||
call emmet#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#balanceTag(flag) range abort
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
call setpos('.', curpos)
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
if a:flag < 0
|
||||
let ret = searchpair('}', '', '.\zs{')
|
||||
else
|
||||
let ret = searchpair('{', '', '}', 'bW')
|
||||
endif
|
||||
if ret > 0
|
||||
let pos1 = emmet#util#getcurpos()[1:2]
|
||||
if a:flag < 0
|
||||
let pos2 = searchpairpos('{', '', '}')
|
||||
else
|
||||
let pos2 = searchpairpos('{', '', '}')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe 'normal! gv'
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#scss#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#moveNextPrev(flag) abort
|
||||
call emmet#lang#css#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#splitJoinTag() abort
|
||||
call emmet#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#removeTag() abort
|
||||
call emmet#lang#css#removeTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#mergeLines() abort
|
||||
call emmet#lang#css#mergeLines()
|
||||
endfunction
|
||||
@@ -1,39 +1,43 @@
|
||||
function! zencoding#lang#slim#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
function! emmet#lang#slim#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#parseIntoTree(abbr, type)
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
function! emmet#lang#slim#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let settings = a:settings
|
||||
function! emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||
let str = ""
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let str = ''
|
||||
|
||||
let comment_indent = ''
|
||||
let comment = ''
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
endif
|
||||
if len(current.name) > 0
|
||||
let str .= current_name
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
let str .= ' ' . attr . '=true'
|
||||
else
|
||||
if dollar_expr
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
endif
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
let str .= ' ' . attr . '="' . val . '"'
|
||||
let str .= ' ' . attr . '="' . Val . '"'
|
||||
endif
|
||||
endfor
|
||||
|
||||
let inner = ''
|
||||
@@ -44,9 +48,10 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
let str = substitute(str, '\$#', text, 'g')
|
||||
endif
|
||||
for line in split(text, "\n")
|
||||
let str .= indent . "| " . line . "\n"
|
||||
let str .= indent . '| ' . line . "\n"
|
||||
endfor
|
||||
elseif len(current.child) == 0
|
||||
let str .= '${cursor}'
|
||||
@@ -60,14 +65,14 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
for line in split(text, "\n")
|
||||
let str .= indent . "| " . line . "\n"
|
||||
let str .= indent . '| ' . line . "\n"
|
||||
endfor
|
||||
elseif len(current.child) > 0
|
||||
for child in current.child
|
||||
let inner .= zencoding#toString(child, type, inline, filters, itemno)
|
||||
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= "\n" . indent . inner
|
||||
endif
|
||||
else
|
||||
@@ -78,44 +83,46 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
if str !~ "\n$"
|
||||
if str !~# "\n$"
|
||||
let str .= "\n"
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#imageSize()
|
||||
function! emmet#lang#slim#imageSize() abort
|
||||
let line = getline('.')
|
||||
let current = zencoding#lang#slim#parseTag(line)
|
||||
let current = emmet#lang#slim#parseTag(line)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~ '^\s*$'
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~ '^\(/\|http\)'
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let slim = zencoding#toString(current, 'slim', 1)
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", "", "g"))
|
||||
let current.attrs_order += ['width', 'height']
|
||||
let slim = emmet#toString(current, 'slim', 1)
|
||||
let slim = substitute(slim, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#encodeImage()
|
||||
function! emmet#lang#slim#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#parseTag(tag)
|
||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
|
||||
function! emmet#lang#slim#parseTag(tag) abort
|
||||
let current = emmet#newNode()
|
||||
let mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', 'i')
|
||||
let attrs = substitute(match, mx, '\2', 'i')
|
||||
let current.name = substitute(match, mx, '\1', '')
|
||||
let attrs = substitute(match, mx, '\2', '')
|
||||
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
@@ -126,33 +133,34 @@ function! zencoding#lang#slim#parseTag(tag)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let current.attrs_order += [name]
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#toggleComment()
|
||||
function! emmet#lang#slim#toggleComment() abort
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~ '^\s*/'
|
||||
if line =~# '^\s*/'
|
||||
call setline('.', space . line[len(space)+1:])
|
||||
elseif line =~ '^\s*[a-z]'
|
||||
elseif line =~# '^\s*[a-z]'
|
||||
call setline('.', space . '/' . line[len(space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#balanceTag(flag) range
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
function! emmet#lang#slim#balanceTag(flag) range abort
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
@@ -206,7 +214,11 @@ function! zencoding#lang#slim#balanceTag(flag) range
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#moveNextPrev(flag)
|
||||
function! emmet#lang#slim#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#slim#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#moveNextPrev(flag) abort
|
||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
@@ -216,18 +228,18 @@ function! zencoding#lang#slim#moveNextPrev(flag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#splitJoinTag()
|
||||
function! emmet#lang#slim#splitJoinTag() abort
|
||||
let n = line('.')
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze[a-z]'
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let sn = n
|
||||
let n += 1
|
||||
if getline(n) =~ '^\s*|'
|
||||
if getline(n) =~# '^\s*|'
|
||||
while n <= line('$')
|
||||
if getline(n) !~ '^\s*|'
|
||||
if getline(n) !~# '^\s*|'
|
||||
break
|
||||
endif
|
||||
exe n "delete"
|
||||
exe n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
@@ -242,11 +254,11 @@ function! zencoding#lang#slim#splitJoinTag()
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#removeTag()
|
||||
function! emmet#lang#slim#removeTag() abort
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze[a-z]'
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let ml = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
break
|
||||
endif
|
||||
@@ -262,8 +274,11 @@ function! zencoding#lang#slim#removeTag()
|
||||
let n += 1
|
||||
endwhile
|
||||
if sn == n
|
||||
exe "delete"
|
||||
exe 'delete'
|
||||
else
|
||||
exe sn "," (n-1) "delete"
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#mergeLines() abort
|
||||
endfunction
|
||||
65
autoload/emmet/lorem/en.vim
Normal file
65
autoload/emmet/lorem/en.vim
Normal file
@@ -0,0 +1,65 @@
|
||||
function! emmet#lorem#en#expand(command) abort
|
||||
let wcount = matchstr(a:command, '\(\d*\)$')
|
||||
let wcount = wcount > 0 ? wcount : 30
|
||||
|
||||
let common = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit']
|
||||
let words = ['exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet',
|
||||
\ 'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi',
|
||||
\ 'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi',
|
||||
\ 'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos',
|
||||
\ 'facilis', 'neque', 'nihil', 'expedita', 'vitae', 'vero', 'ipsum',
|
||||
\ 'nisi', 'animi', 'cumque', 'pariatur', 'velit', 'modi', 'natus',
|
||||
\ 'iusto', 'eaque', 'sequi', 'illo', 'sed', 'ex', 'et', 'voluptatibus',
|
||||
\ 'tempora', 'veritatis', 'ratione', 'assumenda', 'incidunt', 'nostrum',
|
||||
\ 'placeat', 'aliquid', 'fuga', 'provident', 'praesentium', 'rem',
|
||||
\ 'necessitatibus', 'suscipit', 'adipisci', 'quidem', 'possimus',
|
||||
\ 'voluptas', 'debitis', 'sint', 'accusantium', 'unde', 'sapiente',
|
||||
\ 'voluptate', 'qui', 'aspernatur', 'laudantium', 'soluta', 'amet',
|
||||
\ 'quo', 'aliquam', 'saepe', 'culpa', 'libero', 'ipsa', 'dicta',
|
||||
\ 'reiciendis', 'nesciunt', 'doloribus', 'autem', 'impedit', 'minima',
|
||||
\ 'maiores', 'repudiandae', 'ipsam', 'obcaecati', 'ullam', 'enim',
|
||||
\ 'totam', 'delectus', 'ducimus', 'quis', 'voluptates', 'dolores',
|
||||
\ 'molestiae', 'harum', 'dolorem', 'quia', 'voluptatem', 'molestias',
|
||||
\ 'magni', 'distinctio', 'omnis', 'illum', 'dolorum', 'voluptatum', 'ea',
|
||||
\ 'quas', 'quam', 'corporis', 'quae', 'blanditiis', 'atque', 'deserunt',
|
||||
\ 'laboriosam', 'earum', 'consequuntur', 'hic', 'cupiditate',
|
||||
\ 'quibusdam', 'accusamus', 'ut', 'rerum', 'error', 'minus', 'eius',
|
||||
\ 'ab', 'ad', 'nemo', 'fugit', 'officia', 'at', 'in', 'id', 'quos',
|
||||
\ 'reprehenderit', 'numquam', 'iste', 'fugiat', 'sit', 'inventore',
|
||||
\ 'beatae', 'repellendus', 'magnam', 'recusandae', 'quod', 'explicabo',
|
||||
\ 'doloremque', 'aperiam', 'consequatur', 'asperiores', 'commodi',
|
||||
\ 'optio', 'dolor', 'labore', 'temporibus', 'repellat', 'veniam',
|
||||
\ 'architecto', 'est', 'esse', 'mollitia', 'nulla', 'a', 'similique',
|
||||
\ 'eos', 'alias', 'dolore', 'tenetur', 'deleniti', 'porro', 'facere',
|
||||
\ 'maxime', 'corrupti']
|
||||
let ret = []
|
||||
let sentence = 0
|
||||
for i in range(wcount)
|
||||
let arr = common
|
||||
if sentence > 0
|
||||
let arr += words
|
||||
endif
|
||||
let r = emmet#util#rand()
|
||||
let word = arr[r % len(arr)]
|
||||
if sentence == 0
|
||||
let word = substitute(word, '^.', '\U&', '')
|
||||
endif
|
||||
let sentence += 1
|
||||
call add(ret, word)
|
||||
if (sentence > 5 && emmet#util#rand() < 10000) || i == wcount - 1
|
||||
if i == wcount - 1
|
||||
let endc = '?!...'[emmet#util#rand() % 5]
|
||||
call add(ret, endc)
|
||||
else
|
||||
let endc = '?!,...'[emmet#util#rand() % 6]
|
||||
call add(ret, endc . ' ')
|
||||
endif
|
||||
if endc !=# ','
|
||||
let sentence = 0
|
||||
endif
|
||||
else
|
||||
call add(ret, ' ')
|
||||
endif
|
||||
endfor
|
||||
return join(ret, '')
|
||||
endfunction
|
||||
27
autoload/emmet/lorem/ja.vim
Normal file
27
autoload/emmet/lorem/ja.vim
Normal file
@@ -0,0 +1,27 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
function! emmet#lorem#ja#expand(command) abort
|
||||
let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '')
|
||||
let wcount = wcount > 0 ? wcount : 30
|
||||
|
||||
let url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html"
|
||||
let content = emmet#util#cache(url)
|
||||
if len(content) == 0
|
||||
let content = emmet#util#getContentFromURL(url)
|
||||
let content = matchstr(content, '<div[^>]*>\zs.\{-}</div>')
|
||||
let content = substitute(content, '[ \r]', '', 'g')
|
||||
let content = substitute(content, '<br[^>]*>', "\n", 'g')
|
||||
let content = substitute(content, '<[^>]\+>', '', 'g')
|
||||
let content = join(filter(split(content, "\n"), 'len(v:val)>0'), "\n")
|
||||
call emmet#util#cache(url, content)
|
||||
endif
|
||||
|
||||
let content = substitute(content, "、\n", "、", "g")
|
||||
let clines = split(content, '\n')
|
||||
let lines = filter(clines, 'len(substitute(v:val,".",".","g"))<=wcount')
|
||||
if len(lines) == 0
|
||||
let lines = clines
|
||||
endif
|
||||
let r = emmet#util#rand()
|
||||
return lines[r % len(lines)]
|
||||
endfunction
|
||||
412
autoload/emmet/util.vim
Normal file
412
autoload/emmet/util.vim
Normal file
@@ -0,0 +1,412 @@
|
||||
"==============================================================================
|
||||
" region utils
|
||||
"==============================================================================
|
||||
" deleteContent : delete content in region
|
||||
" if region make from between '<foo>' and '</foo>'
|
||||
" --------------------
|
||||
" begin:<foo>
|
||||
" </foo>:end
|
||||
" --------------------
|
||||
" this function make the content as following
|
||||
" --------------------
|
||||
" begin::end
|
||||
" --------------------
|
||||
function! emmet#util#deleteContent(region) abort
|
||||
let lines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe 'delete '.(a:region[1][0] - a:region[0][0])
|
||||
call setline(line('.'), lines[0][:a:region[0][1]-2] . lines[-1][a:region[1][1]])
|
||||
endfunction
|
||||
|
||||
" change_content : change content in region
|
||||
" if region make from between '<foo>' and '</foo>'
|
||||
" --------------------
|
||||
" begin:<foo>
|
||||
" </foo>:end
|
||||
" --------------------
|
||||
" and content is
|
||||
" --------------------
|
||||
" foo
|
||||
" bar
|
||||
" baz
|
||||
" --------------------
|
||||
" this function make the content as following
|
||||
" --------------------
|
||||
" begin:foo
|
||||
" bar
|
||||
" baz:end
|
||||
" --------------------
|
||||
function! emmet#util#setContent(region, content) abort
|
||||
let newlines = split(a:content, '\n', 1)
|
||||
let oldlines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe 'delete '.(a:region[1][0] - a:region[0][0])
|
||||
if len(newlines) == 0
|
||||
let tmp = ''
|
||||
if a:region[0][1] > 1
|
||||
let tmp = oldlines[0][:a:region[0][1]-2]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let tmp .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), tmp)
|
||||
elseif len(newlines) == 1
|
||||
if a:region[0][1] > 1
|
||||
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let newlines[0] .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), newlines[0])
|
||||
else
|
||||
if a:region[0][1] > 1
|
||||
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let newlines[-1] .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), newlines[0])
|
||||
call append(line('.'), newlines[1:])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" select_region : select region
|
||||
" this function make a selection of region
|
||||
function! emmet#util#selectRegion(region) abort
|
||||
call setpos('.', [0, a:region[1][0], a:region[1][1], 0])
|
||||
normal! v
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
endfunction
|
||||
|
||||
" point_in_region : check point is in the region
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#pointInRegion(point, region) abort
|
||||
if !emmet#util#regionIsValid(a:region) | return 0 | endif
|
||||
if a:region[0][0] > a:point[0] | return 0 | endif
|
||||
if a:region[1][0] < a:point[0] | return 0 | endif
|
||||
if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif
|
||||
if a:region[1][0] == a:point[0] && a:region[1][1] < a:point[1] | return 0 | endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" cursor_in_region : check cursor is in the region
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#cursorInRegion(region) abort
|
||||
if !emmet#util#regionIsValid(a:region) | return 0 | endif
|
||||
let cur = emmet#util#getcurpos()[1:2]
|
||||
return emmet#util#pointInRegion(cur, a:region)
|
||||
endfunction
|
||||
|
||||
" region_is_valid : check region is valid
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#regionIsValid(region) abort
|
||||
if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" search_region : make region from pattern which is composing start/end
|
||||
" this function return array of position
|
||||
function! emmet#util#searchRegion(start, end) abort
|
||||
let b = searchpairpos(a:start, '', a:end, 'bcnW')
|
||||
if b == [0, 0]
|
||||
return [searchpairpos(a:start, '', a:end, 'bnW'), searchpairpos(a:start, '\%#', a:end, 'nW')]
|
||||
else
|
||||
return [b, searchpairpos(a:start, '', a:end. '', 'nW')]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" get_content : get content in region
|
||||
" this function return string in region
|
||||
function! emmet#util#getContent(region) abort
|
||||
if !emmet#util#regionIsValid(a:region)
|
||||
return ''
|
||||
endif
|
||||
let lines = getline(a:region[0][0], a:region[1][0])
|
||||
if a:region[0][0] == a:region[1][0]
|
||||
let lines[0] = lines[0][a:region[0][1]-1:a:region[1][1]-1]
|
||||
else
|
||||
let lines[0] = lines[0][a:region[0][1]-1:]
|
||||
let lines[-1] = lines[-1][:a:region[1][1]-1]
|
||||
endif
|
||||
return join(lines, "\n")
|
||||
endfunction
|
||||
|
||||
" region_in_region : check region is in the region
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#regionInRegion(outer, inner) abort
|
||||
if !emmet#util#regionIsValid(a:inner) || !emmet#util#regionIsValid(a:outer)
|
||||
return 0
|
||||
endif
|
||||
return emmet#util#pointInRegion(a:inner[0], a:outer) && emmet#util#pointInRegion(a:inner[1], a:outer)
|
||||
endfunction
|
||||
|
||||
" get_visualblock : get region of visual block
|
||||
" this function return region of visual block
|
||||
function! emmet#util#getVisualBlock() abort
|
||||
return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
|
||||
endfunction
|
||||
|
||||
"==============================================================================
|
||||
" html utils
|
||||
"==============================================================================
|
||||
function! emmet#util#getContentFromURL(url) abort
|
||||
let res = system(printf('%s -i %s', g:emmet_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
|
||||
while res =~# '^HTTP/1.\d 3' || res =~# '^HTTP/1\.\d 200 Connection established' || res =~# '^HTTP/1\.\d 100 Continue'
|
||||
let pos = stridx(res, "\r\n\r\n")
|
||||
if pos != -1
|
||||
let res = strpart(res, pos+4)
|
||||
else
|
||||
let pos = stridx(res, "\n\n")
|
||||
let res = strpart(res, pos+2)
|
||||
endif
|
||||
endwhile
|
||||
let pos = stridx(res, "\r\n\r\n")
|
||||
if pos != -1
|
||||
let content = strpart(res, pos+4)
|
||||
else
|
||||
let pos = stridx(res, "\n\n")
|
||||
let content = strpart(res, pos+2)
|
||||
endif
|
||||
let header = res[:pos-1]
|
||||
let charset = matchstr(content, '<meta[^>]\+content=["''][^;"'']\+;\s*charset=\zs[^;"'']\+\ze["''][^>]*>')
|
||||
if len(charset) == 0
|
||||
let charset = matchstr(content, '<meta\s\+charset=["'']\?\zs[^"'']\+\ze["'']\?[^>]*>')
|
||||
endif
|
||||
if len(charset) == 0
|
||||
let charset = matchstr(header, '\nContent-Type:.* charset=[''"]\?\zs[^''";\n]\+\ze')
|
||||
endif
|
||||
if len(charset) == 0
|
||||
let s1 = len(split(content, '?'))
|
||||
let utf8 = iconv(content, 'utf-8', &encoding)
|
||||
let s2 = len(split(utf8, '?'))
|
||||
return (s2 == s1 || s2 >= s1 * 2) ? utf8 : content
|
||||
endif
|
||||
return iconv(content, charset, &encoding)
|
||||
endfunction
|
||||
|
||||
function! emmet#util#getTextFromHTML(buf) abort
|
||||
let threshold_len = 100
|
||||
let threshold_per = 0.1
|
||||
let buf = a:buf
|
||||
|
||||
let buf = strpart(buf, stridx(buf, '</head>'))
|
||||
let buf = substitute(buf, '<style[^>]*>.\{-}</style>', '', 'g')
|
||||
let buf = substitute(buf, '<script[^>]*>.\{-}</script>', '', 'g')
|
||||
let res = ''
|
||||
let max = 0
|
||||
let mx = '\(<td[^>]\{-}>\)\|\(<\/td>\)\|\(<div[^>]\{-}>\)\|\(<\/div>\)'
|
||||
let m = split(buf, mx)
|
||||
for str in m
|
||||
let c = split(str, '<[^>]*?>')
|
||||
let str = substitute(str, '<[^>]\{-}>', ' ', 'g')
|
||||
let str = substitute(str, '>', '>', 'g')
|
||||
let str = substitute(str, '<', '<', 'g')
|
||||
let str = substitute(str, '"', '"', 'g')
|
||||
let str = substitute(str, ''', '''', 'g')
|
||||
let str = substitute(str, ' ', ' ', 'g')
|
||||
let str = substitute(str, '¥', '\¥', 'g')
|
||||
let str = substitute(str, '&', '\&', 'g')
|
||||
let str = substitute(str, '^\s*\(.*\)\s*$', '\1', '')
|
||||
let str = substitute(str, '\s\+', ' ', 'g')
|
||||
let l = len(str)
|
||||
if l > threshold_len
|
||||
let per = (l+0.0) / len(c)
|
||||
if max < l && per > threshold_per
|
||||
let max = l
|
||||
let res = str
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let res = substitute(res, '^\s*\(.*\)\s*$', '\1', 'g')
|
||||
return res
|
||||
endfunction
|
||||
|
||||
function! emmet#util#getImageSize(fn) abort
|
||||
let fn = a:fn
|
||||
|
||||
if emmet#util#isImageMagickInstalled()
|
||||
return emmet#util#imageSizeWithImageMagick(fn)
|
||||
endif
|
||||
|
||||
if filereadable(fn)
|
||||
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
|
||||
else
|
||||
if fn !~# '^\w\+://'
|
||||
let path = fnamemodify(expand('%'), ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
let path = tolower(path)
|
||||
endif
|
||||
for k in keys(g:emmet_docroot)
|
||||
let root = fnamemodify(k, ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
let root = tolower(root)
|
||||
endif
|
||||
if stridx(path, root) == 0
|
||||
let v = g:emmet_docroot[k]
|
||||
let fn = (len(v) == 0 ? k : v) . fn
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
let hex = substitute(system(g:emmet_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g')
|
||||
endif
|
||||
|
||||
let [width, height] = [-1, -1]
|
||||
if hex =~# '^89504e470d0a1a0a'
|
||||
let width = eval('0x'.hex[32:39])
|
||||
let height = eval('0x'.hex[40:47])
|
||||
endif
|
||||
if hex =~# '^ffd8'
|
||||
let pos = 4
|
||||
while pos < len(hex)
|
||||
let bs = hex[pos+0:pos+3]
|
||||
let pos += 4
|
||||
if bs ==# 'ffc0' || bs ==# 'ffc2'
|
||||
let pos += 6
|
||||
let height = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
|
||||
let pos += 4
|
||||
let width = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
|
||||
break
|
||||
elseif bs =~# 'ffd[9a]'
|
||||
break
|
||||
elseif bs =~# 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)'
|
||||
let pos += (eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])) * 2
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
if hex =~# '^47494638'
|
||||
let width = eval('0x'.hex[14:15].hex[12:13])
|
||||
let height = eval('0x'.hex[18:19].hex[16:17])
|
||||
endif
|
||||
|
||||
return [width, height]
|
||||
endfunction
|
||||
|
||||
function! emmet#util#imageSizeWithImageMagick(fn) abort
|
||||
let img_info = system('identify -format "%wx%h" "'.a:fn.'"')
|
||||
let img_size = split(substitute(img_info, '\n', '', ''), 'x')
|
||||
if len(img_size) != 2
|
||||
return [-1, -1]
|
||||
endif
|
||||
return img_size
|
||||
endfunction
|
||||
|
||||
function! emmet#util#isImageMagickInstalled() abort
|
||||
if !get(g:, 'emmet_use_identify', 1)
|
||||
return 0
|
||||
endif
|
||||
return executable('identify')
|
||||
endfunction
|
||||
|
||||
function! s:b64encode(bytes, table, pad)
|
||||
let b64 = []
|
||||
for i in range(0, len(a:bytes) - 1, 3)
|
||||
let n = a:bytes[i] * 0x10000
|
||||
\ + get(a:bytes, i + 1, 0) * 0x100
|
||||
\ + get(a:bytes, i + 2, 0)
|
||||
call add(b64, a:table[n / 0x40000])
|
||||
call add(b64, a:table[n / 0x1000 % 0x40])
|
||||
call add(b64, a:table[n / 0x40 % 0x40])
|
||||
call add(b64, a:table[n % 0x40])
|
||||
endfor
|
||||
if len(a:bytes) % 3 == 2
|
||||
let b64[-1] = a:pad
|
||||
elseif len(a:bytes) % 3 == 1
|
||||
let b64[-1] = a:pad
|
||||
let b64[-2] = a:pad
|
||||
endif
|
||||
return b64
|
||||
endfunction
|
||||
|
||||
function! emmet#util#imageEncodeDecode(fn, flag) abort
|
||||
let fn = a:fn
|
||||
|
||||
if filereadable(fn)
|
||||
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
|
||||
else
|
||||
if fn !~# '^\w\+://'
|
||||
let path = fnamemodify(expand('%'), ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
let path = tolower(path)
|
||||
endif
|
||||
for k in keys(g:emmet_docroot)
|
||||
let root = fnamemodify(k, ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
let root = tolower(root)
|
||||
endif
|
||||
if stridx(path, root) == 0
|
||||
let v = g:emmet_docroot[k]
|
||||
let fn = (len(v) == 0 ? k : v) . fn
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
let hex = substitute(system(g:emmet_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g')
|
||||
endif
|
||||
|
||||
let bin = map(split(hex, '..\zs'), 'eval("0x" . v:val)')
|
||||
let table = split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', '\zs')
|
||||
let ret = 'data:image/'
|
||||
if hex =~# '^89504e470d0a1a0a'
|
||||
let ret .= 'png'
|
||||
elseif hex =~# '^ffd8'
|
||||
let ret .= 'jpeg'
|
||||
elseif hex =~# '^47494638'
|
||||
let ret .= 'gif'
|
||||
elseif hex =~# '^00000020667479706176696600000000'
|
||||
let ret .= 'avif'
|
||||
else
|
||||
let ret .= 'unknown'
|
||||
endif
|
||||
return ret . ';base64,' . join(s:b64encode(bin, table, '='), '')
|
||||
endfunction
|
||||
|
||||
function! emmet#util#unique(arr) abort
|
||||
let m = {}
|
||||
let r = []
|
||||
for i in a:arr
|
||||
if !has_key(m, i)
|
||||
let m[i] = 1
|
||||
call add(r, i)
|
||||
endif
|
||||
endfor
|
||||
return r
|
||||
endfunction
|
||||
|
||||
let s:seed = localtime()
|
||||
function! emmet#util#srand(seed) abort
|
||||
let s:seed = a:seed
|
||||
endfunction
|
||||
|
||||
function! emmet#util#rand() abort
|
||||
let s:seed = s:seed * 214013 + 2531011
|
||||
return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000
|
||||
endfunction
|
||||
|
||||
function! emmet#util#cache(name, ...) abort
|
||||
let content = get(a:000, 0, '')
|
||||
let dir = expand('~/.emmet/cache')
|
||||
if !isdirectory(dir)
|
||||
call mkdir(dir, 'p', 0700)
|
||||
endif
|
||||
let file = dir . '/' . substitute(a:name, '\W', '_', 'g')
|
||||
if len(content) == 0
|
||||
if !filereadable(file)
|
||||
return ''
|
||||
endif
|
||||
return join(readfile(file), "\n")
|
||||
endif
|
||||
call writefile(split(content, "\n"), file)
|
||||
endfunction
|
||||
|
||||
function! emmet#util#getcurpos() abort
|
||||
let pos = getpos('.')
|
||||
if mode(0) ==# 'i' && pos[2] > 0
|
||||
let pos[2] -=1
|
||||
endif
|
||||
return pos
|
||||
endfunction
|
||||
|
||||
function! emmet#util#closePopup() abort
|
||||
return pumvisible() ? "\<c-e>" : ''
|
||||
endfunction
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
let s:exists = {}
|
||||
function zencoding#lang#exists(type)
|
||||
if len(a:type) == 0
|
||||
return 0
|
||||
elseif has_key(s:exists, a:type)
|
||||
return s:exists[a:type]
|
||||
endif
|
||||
let s:exists[a:type] = len(globpath(&rtp, 'autoload/zencoding/lang/'.a:type.'.vim')) > 0
|
||||
return s:exists[a:type]
|
||||
endfunction
|
||||
|
||||
@@ -1,228 +0,0 @@
|
||||
function! zencoding#lang#css#findTokens(str)
|
||||
return substitute(a:str, '^.*[;{]\s*', '', '')
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#parseIntoTree(abbr, type)
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
let prefix = 0
|
||||
let value = ''
|
||||
|
||||
let settings = zencoding#getSettings()
|
||||
let indent = zencoding#getIndentation(type)
|
||||
|
||||
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
|
||||
|
||||
" emmet
|
||||
let tokens = split(abbr, '+\ze[^)!]')
|
||||
for n in range(len(tokens))
|
||||
let token = tokens[n]
|
||||
let prop = matchlist(token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+[pe]\{0,1}-\{0,1}\|-auto\)*\)$')
|
||||
if len(prop)
|
||||
let token = substitute(prop[1], '^(\(.*\))', '\1', '')
|
||||
if token =~ '^-'
|
||||
let prefix = 1
|
||||
let token = token[1:]
|
||||
endif
|
||||
let value = ''
|
||||
for v in split(prop[2], '\d\zs-')
|
||||
if len(value) > 0
|
||||
let value .= ' '
|
||||
endif
|
||||
if token =~ '^[z]'
|
||||
" TODO
|
||||
let value .= substitute(v, '[^0-9.]*$', '', '')
|
||||
elseif v =~ 'p$'
|
||||
let value .= substitute(v, 'p$', '%', '')
|
||||
elseif v =~ 'e$'
|
||||
let value .= substitute(v, 'e$', 'em', '')
|
||||
elseif v =~ '\.'
|
||||
let value .= v . 'em'
|
||||
elseif v == 'auto'
|
||||
let value .= v
|
||||
else
|
||||
let value .= v . 'px'
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
let tag_name = token
|
||||
if tag_name =~ '.!$'
|
||||
let tag_name = tag_name[:-2]
|
||||
let important = 1
|
||||
else
|
||||
let important = 0
|
||||
endif
|
||||
" make default node
|
||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': important }
|
||||
let current.name = tag_name
|
||||
|
||||
" aliases
|
||||
let aliases = zencoding#getResource(type, 'aliases', {})
|
||||
if has_key(aliases, tag_name)
|
||||
let current.name = aliases[tag_name]
|
||||
endif
|
||||
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
" snippets
|
||||
let snippets = zencoding#getResource(type, 'snippets', {})
|
||||
if !empty(snippets) && has_key(snippets, tag_name)
|
||||
let snippet = snippets[tag_name]
|
||||
if use_pipe_for_cursor
|
||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
||||
endif
|
||||
let lines = split(snippet, "\n")
|
||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
||||
let current.snippet = join(lines, "\n")
|
||||
let current.name = ''
|
||||
let current.snippet = substitute(current.snippet, ';', value . ';', '')
|
||||
if use_pipe_for_cursor && len(value) > 0 && stridx(value, '${cursor}') == -1
|
||||
let current.snippet = substitute(current.snippet, '${cursor}', '', 'g') . '${cursor}'
|
||||
endif
|
||||
if n < len(tokens) - 1
|
||||
let current.snippet .= "\n"
|
||||
endif
|
||||
endif
|
||||
|
||||
let current.pos = 0
|
||||
let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\w\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$')
|
||||
if len(lg)
|
||||
let current.name = ''
|
||||
let current.snippet = printf("background-image: -webkit-gradient(%s, 0 0, 0 100%, from(%s), to(%s));\n", lg[1], lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image: -webkit-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image: -moz-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image: -o-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image: linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
elseif prefix
|
||||
let snippet = current.snippet
|
||||
let current.snippet = '-webkit-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-moz-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = snippet
|
||||
call add(root.child, current)
|
||||
else
|
||||
call add(root.child, current)
|
||||
endif
|
||||
endfor
|
||||
return root
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let current = a:current
|
||||
let value = current.value[1:-2]
|
||||
if zencoding#useFilter(a:filters, 'fc')
|
||||
let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1: \2', 'g')
|
||||
else
|
||||
let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1:\2', 'g')
|
||||
endif
|
||||
if current.important
|
||||
let value = substitute(value, ';', ' !important;', '')
|
||||
endif
|
||||
return value
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#parseTag(tag)
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#toggleComment()
|
||||
let line = getline('.')
|
||||
let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
|
||||
if line =~ '{\s*$'
|
||||
let block = zencoding#util#searchRegion('/\*', '\*/\zs')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
let content = zencoding#util#getContent(block)
|
||||
let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '')
|
||||
call zencoding#util#setContent(block, content)
|
||||
else
|
||||
let node = expand('<cword>')
|
||||
if len(node)
|
||||
exe "normal ciw\<c-r>='/* '.node.' */'\<cr>"
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if line =~ mx
|
||||
let space = substitute(matchstr(line, mx), mx, '\1', '')
|
||||
let line = substitute(matchstr(line, mx), mx, '\2', '')
|
||||
let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g')
|
||||
else
|
||||
let mx = '^\(\s*\)\(.*\)\s*$'
|
||||
let line = substitute(line, mx, '\1/* \2 */', '')
|
||||
endif
|
||||
call setline('.', line)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#balanceTag(flag) range
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
if !zencoding#util#regionIsValid(block)
|
||||
if a:flag > 0
|
||||
let block = zencoding#util#searchRegion('^', ';')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if a:flag > 0
|
||||
let content = zencoding#util#getContent(block)
|
||||
if content !~ '^{.*}$'
|
||||
let block = zencoding#util#searchRegion('{', '}')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let pos = searchpos('.*;', 'nW')
|
||||
if pos[0] != 0
|
||||
call setpos('.', [0, pos[0], pos[1], 0])
|
||||
let block = zencoding#util#searchRegion('^', ';')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe "normal! gv"
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#moveNextPrev(flag)
|
||||
let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
else
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#splitJoinTag()
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#removeTag()
|
||||
" nothing to do
|
||||
endfunction
|
||||
@@ -1,673 +0,0 @@
|
||||
let s:mx = '\([+>]\|[<^]\+\)\{-}\s*'
|
||||
\ .'\((*\)\{-}\s*'
|
||||
\ .'\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|{\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}[ \t\r\n}]*\)'
|
||||
\ .'\('
|
||||
\ .'\%('
|
||||
\ .'\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)'
|
||||
\ .'\|\%(\[[^\]]\+\]\)'
|
||||
\ .'\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)'
|
||||
\ .'\)*'
|
||||
\ .'\)'
|
||||
\ .'\%(\({\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}\)\)\{0,1}'
|
||||
\ .'\%(\*\([0-9]\+\)\)\{0,1}'
|
||||
\ .'\(\%()\%(\*[0-9]\+\)\{0,1}\)*\)'
|
||||
|
||||
function! zencoding#lang#html#findTokens(str)
|
||||
let str = a:str
|
||||
let [pos, last_pos] = [0, 0]
|
||||
while 1
|
||||
let tag = matchstr(str, '<[a-zA-Z].\{-}>', pos)
|
||||
if len(tag) == 0
|
||||
break
|
||||
endif
|
||||
let pos = stridx(str, tag, pos) + len(tag)
|
||||
endwhile
|
||||
let last_pos = pos
|
||||
while len(str) > 0
|
||||
let token = matchstr(str, s:mx, pos)
|
||||
if token == ''
|
||||
break
|
||||
endif
|
||||
if token =~ '^\s'
|
||||
let token = matchstr(token, '^\s*\zs.*')
|
||||
let last_pos = stridx(str, token, pos)
|
||||
endif
|
||||
let pos = stridx(str, token, pos) + len(token)
|
||||
endwhile
|
||||
return a:str[last_pos :-1]
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#parseIntoTree(abbr, type)
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
|
||||
let settings = zencoding#getSettings()
|
||||
if !has_key(settings, type)
|
||||
let type = 'html'
|
||||
endif
|
||||
if len(type) == 0 | let type = 'html' | endif
|
||||
|
||||
let settings = zencoding#getSettings()
|
||||
let indent = zencoding#getIndentation(type)
|
||||
|
||||
" try 'foo' to (foo-x)
|
||||
let rabbr = zencoding#getExpandos(type, abbr)
|
||||
if rabbr == abbr
|
||||
" try 'foo+(' to (foo-x)
|
||||
let rabbr = substitute(abbr, '\%(+\|^\)\([a-zA-Z][a-zA-Z0-9+]\+\)+\([(){}>]\|$\)', '\="(".zencoding#getExpandos(type, submatch(1)).")".submatch(2)', 'i')
|
||||
endif
|
||||
let abbr = rabbr
|
||||
|
||||
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
|
||||
let parent = root
|
||||
let last = root
|
||||
let pos = []
|
||||
while len(abbr)
|
||||
" parse line
|
||||
let match = matchstr(abbr, s:mx)
|
||||
let str = substitute(match, s:mx, '\0', 'ig')
|
||||
let operator = substitute(match, s:mx, '\1', 'ig')
|
||||
let block_start = substitute(match, s:mx, '\2', 'ig')
|
||||
let tag_name = substitute(match, s:mx, '\3', 'ig')
|
||||
let attributes = substitute(match, s:mx, '\4', 'ig')
|
||||
let value = substitute(match, s:mx, '\5', 'ig')
|
||||
let multiplier = 0 + substitute(match, s:mx, '\6', 'ig')
|
||||
let block_end = substitute(match, s:mx, '\7', 'ig')
|
||||
let important = 0
|
||||
if len(str) == 0
|
||||
break
|
||||
endif
|
||||
if tag_name =~ '^#'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
if tag_name =~ '.!$'
|
||||
let tag_name = tag_name[:-2]
|
||||
let important = 1
|
||||
endif
|
||||
if tag_name =~ '^\.'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
if multiplier <= 0 | let multiplier = 1 | endif
|
||||
|
||||
" make default node
|
||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
|
||||
let current.name = tag_name
|
||||
|
||||
let current.important = important
|
||||
|
||||
" aliases
|
||||
let aliases = zencoding#getResource(type, 'aliases', {})
|
||||
if has_key(aliases, tag_name)
|
||||
let current.name = aliases[tag_name]
|
||||
endif
|
||||
|
||||
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
" snippets
|
||||
let snippets = zencoding#getResource(type, 'snippets', {})
|
||||
if !empty(snippets) && has_key(snippets, tag_name)
|
||||
let snippet = snippets[tag_name]
|
||||
if use_pipe_for_cursor
|
||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
||||
endif
|
||||
let lines = split(snippet, "\n")
|
||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
||||
let current.snippet = join(lines, "\n")
|
||||
let current.name = ''
|
||||
endif
|
||||
|
||||
" default_attributes
|
||||
let default_attributes = zencoding#getResource(type, 'default_attributes', {})
|
||||
if !empty(default_attributes)
|
||||
for pat in [current.name, tag_name]
|
||||
if has_key(default_attributes, pat)
|
||||
if type(default_attributes[pat]) == 4
|
||||
let a = default_attributes[pat]
|
||||
if use_pipe_for_cursor
|
||||
for k in keys(a)
|
||||
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
|
||||
endfor
|
||||
else
|
||||
for k in keys(a)
|
||||
let current.attr[k] = a[k]
|
||||
endfor
|
||||
endif
|
||||
else
|
||||
for a in default_attributes[pat]
|
||||
if use_pipe_for_cursor
|
||||
for k in keys(a)
|
||||
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
|
||||
endfor
|
||||
else
|
||||
for k in keys(a)
|
||||
let current.attr[k] = a[k]
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
if has_key(settings.html.default_attributes, current.name)
|
||||
let current.name = substitute(current.name, ':.*$', '', '')
|
||||
endif
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
" parse attributes
|
||||
if len(attributes)
|
||||
let attr = attributes
|
||||
while len(attr)
|
||||
let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)')
|
||||
if len(item) == 0
|
||||
break
|
||||
endif
|
||||
if item[0] == '#'
|
||||
let current.attr.id = item[1:]
|
||||
endif
|
||||
if item[0] == '.'
|
||||
let current.attr.class = substitute(item[1:], '\.', ' ', 'g')
|
||||
endif
|
||||
if item[0] == '['
|
||||
let atts = item[1:-2]
|
||||
while len(atts)
|
||||
let amat = matchstr(atts, '\(\w\+\%(="[^"]*"\|=''[^'']*''\|[^ ''"\]]*\)\{0,1}\)')
|
||||
if len(amat) == 0
|
||||
break
|
||||
endif
|
||||
let key = split(amat, '=')[0]
|
||||
let val = amat[len(key)+1:]
|
||||
if val =~ '^["'']'
|
||||
let val = val[1:-2]
|
||||
endif
|
||||
let current.attr[key] = val
|
||||
let atts = atts[stridx(atts, amat) + len(amat):]
|
||||
endwhile
|
||||
endif
|
||||
let attr = substitute(strpart(attr, len(item)), '^\s*', '', '')
|
||||
endwhile
|
||||
endif
|
||||
|
||||
" parse text
|
||||
if tag_name =~ '^{.*}$'
|
||||
let current.name = ''
|
||||
let current.value = tag_name
|
||||
else
|
||||
let current.value = value
|
||||
endif
|
||||
let current.multiplier = multiplier
|
||||
|
||||
" parse step inside/outside
|
||||
if !empty(last)
|
||||
if operator =~ '>'
|
||||
unlet! parent
|
||||
let parent = last
|
||||
let current.parent = last
|
||||
let current.pos = last.pos + 1
|
||||
else
|
||||
let current.parent = parent
|
||||
let current.pos = last.pos
|
||||
endif
|
||||
else
|
||||
let current.parent = parent
|
||||
let current.pos = 1
|
||||
endif
|
||||
if operator =~ '[<^]'
|
||||
for c in range(len(operator))
|
||||
let tmp = parent.parent
|
||||
if empty(tmp)
|
||||
break
|
||||
endif
|
||||
let parent = tmp
|
||||
let current.parent = tmp
|
||||
endfor
|
||||
endif
|
||||
|
||||
call add(parent.child, current)
|
||||
let last = current
|
||||
|
||||
" parse block
|
||||
if block_start =~ '('
|
||||
if operator =~ '>'
|
||||
let last.pos += 1
|
||||
endif
|
||||
for n in range(len(block_start))
|
||||
let pos += [last.pos]
|
||||
endfor
|
||||
endif
|
||||
if block_end =~ ')'
|
||||
for n in split(substitute(substitute(block_end, ' ', '', 'g'), ')', ',),', 'g'), ',')
|
||||
if n == ')'
|
||||
if len(pos) > 0 && last.pos >= pos[-1]
|
||||
for c in range(last.pos - pos[-1])
|
||||
let tmp = parent.parent
|
||||
if !has_key(tmp, 'parent')
|
||||
break
|
||||
endif
|
||||
let parent = tmp
|
||||
endfor
|
||||
if len(pos) > 0
|
||||
call remove(pos, -1)
|
||||
endif
|
||||
let last = parent
|
||||
let last.pos += 1
|
||||
endif
|
||||
elseif len(n)
|
||||
let cl = last.child
|
||||
let cls = []
|
||||
for c in range(n[1:])
|
||||
let cls += cl
|
||||
endfor
|
||||
let last.child = cls
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
let abbr = abbr[stridx(abbr, match) + len(match):]
|
||||
|
||||
if g:zencoding_debug > 1
|
||||
echomsg "str=".str
|
||||
echomsg "block_start=".block_start
|
||||
echomsg "tag_name=".tag_name
|
||||
echomsg "operator=".operator
|
||||
echomsg "attributes=".attributes
|
||||
echomsg "value=".value
|
||||
echomsg "multiplier=".multiplier
|
||||
echomsg "block_end=".block_end
|
||||
echomsg "abbr=".abbr
|
||||
echomsg "pos=".string(pos)
|
||||
echomsg "---"
|
||||
endif
|
||||
endwhile
|
||||
return root
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||
|
||||
if zencoding#useFilter(filters, 'haml')
|
||||
return zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
if zencoding#useFilter(filters, 'slim')
|
||||
return zencoding#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
|
||||
let comment = ''
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current_name, '\$$', itemno+1, '')
|
||||
endif
|
||||
|
||||
let str = ''
|
||||
if len(current_name) == 0
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
return text
|
||||
endif
|
||||
if len(current_name) > 0
|
||||
let str .= '<' . current_name
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
if dollar_expr
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let str .= ' ' . attr . '="' . val . '"'
|
||||
if zencoding#useFilter(filters, 'c')
|
||||
if attr == 'id' | let comment .= '#' . val | endif
|
||||
if attr == 'class' | let comment .= '.' . val | endif
|
||||
endif
|
||||
endfor
|
||||
if len(comment) > 0
|
||||
let str = "<!-- " . comment . " -->\n" . str
|
||||
endif
|
||||
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1
|
||||
let str .= settings.html.empty_element_suffix
|
||||
else
|
||||
let str .= ">"
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let str .= text
|
||||
let nc = len(current.child)
|
||||
let dr = 0
|
||||
if nc > 0
|
||||
for n in range(nc)
|
||||
let child = current.child[n]
|
||||
if child.multiplier > 1
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
elseif len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
||||
if nc > 1 || (len(child.name) > 0 && stridx(','.settings.html.inline_elements.',', ','.child.name.',') == -1)
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
elseif current.multiplier == 1 && nc == 1 && len(child.name) == 0
|
||||
echo current.multiplier
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
endif
|
||||
endif
|
||||
let inner = zencoding#toString(child, type, 0, filters, itemno)
|
||||
let inner = substitute(inner, "^\n", "", 'g')
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= inner
|
||||
endfor
|
||||
else
|
||||
let str .= '${cursor}'
|
||||
endif
|
||||
if dr
|
||||
let str .= "\n"
|
||||
endif
|
||||
let str .= "</" . current_name . ">"
|
||||
endif
|
||||
if len(comment) > 0
|
||||
let str .= "\n<!-- /" . comment . " -->"
|
||||
endif
|
||||
if len(current_name) > 0 && current.multiplier > 0 || stridx(','.settings.html.block_elements.',', ','.current_name.',') != -1
|
||||
let str .= "\n"
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#imageSize()
|
||||
let img_region = zencoding#util#searchRegion('<img\s', '>')
|
||||
if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = zencoding#util#getContent(img_region)
|
||||
if content !~ '^<img[^><]\+>$'
|
||||
return
|
||||
endif
|
||||
let current = zencoding#lang#html#parseTag(content)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~ '^\s*$'
|
||||
return
|
||||
elseif fn !~ '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let html = substitute(zencoding#toString(current, 'html', 1), '\n', '', '')
|
||||
call zencoding#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#encodeImage()
|
||||
let img_region = zencoding#util#searchRegion('<img\s', '>')
|
||||
if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = zencoding#util#getContent(img_region)
|
||||
if content !~ '^<img[^><]\+>$'
|
||||
return
|
||||
endif
|
||||
let current = zencoding#lang#html#parseTag(content)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn !~ '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let html = zencoding#toString(current, 'html', 1)
|
||||
call zencoding#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#parseTag(tag)
|
||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', 'i')
|
||||
let attrs = substitute(match, mx, '\2', 'i')
|
||||
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) == 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#toggleComment()
|
||||
let orgpos = getpos('.')
|
||||
let curpos = getpos('.')
|
||||
let mx = '<\%#[^>]*>'
|
||||
while 1
|
||||
let block = zencoding#util#searchRegion('<!--', '-->')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
let block[1][1] += 2
|
||||
let content = zencoding#util#getContent(block)
|
||||
let content = substitute(content, '^<!--\s\(.*\)\s-->$', '\1', '')
|
||||
call zencoding#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
let block = zencoding#util#searchRegion('<[^>]', '>')
|
||||
if !zencoding#util#regionIsValid(block)
|
||||
let pos1 = searchpos('<', 'bcW')
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
return
|
||||
endif
|
||||
let curpos = getpos('.')
|
||||
continue
|
||||
endif
|
||||
let pos1 = block[0]
|
||||
let pos2 = block[1]
|
||||
let content = zencoding#util#getContent(block)
|
||||
let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+')
|
||||
if tag_name[0] == '/'
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpairpos('<'. tag_name[1:] . '>', '', '</' . tag_name[1:] . '>', 'bnW')
|
||||
let pos1 = searchpos('>', 'cneW')
|
||||
let block = [pos2, pos1]
|
||||
elseif tag_name =~ '/$'
|
||||
if !zencoding#util#pointInRegion(orgpos[1:2], block)
|
||||
" it's broken tree
|
||||
call setpos('.', orgpos)
|
||||
let block = zencoding#util#searchRegion('>', '<')
|
||||
let content = '><!-- ' . zencoding#util#getContent(block)[1:-2] . ' --><'
|
||||
call zencoding#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
else
|
||||
call setpos('.', [0, pos2[0], pos2[1], 0])
|
||||
let pos2 = searchpairpos('<'. tag_name . '>', '', '</' . tag_name . '>', 'nW')
|
||||
call setpos('.', [0, pos2[0], pos2[1], 0])
|
||||
let pos2 = searchpos('>', 'cneW')
|
||||
let block = [pos1, pos2]
|
||||
endif
|
||||
if !zencoding#util#regionIsValid(block)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block)
|
||||
let content = '<!-- ' . zencoding#util#getContent(block) . ' -->'
|
||||
call zencoding#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#balanceTag(flag) range
|
||||
let vblock = zencoding#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
let settings = zencoding#getSettings()
|
||||
|
||||
if a:flag > 0
|
||||
while 1
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let pos1 = searchpos(mx, 'bW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
||||
let pos2 = searchpos('>', 'nW')
|
||||
else
|
||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '>\zs', 'nW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
break
|
||||
endif
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block) && zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
else
|
||||
while 1
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let pos1 = searchpos(mx, 'W')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
||||
let pos2 = searchpos('>', 'nW')
|
||||
else
|
||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '>\zs', 'nW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
break
|
||||
endif
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe "normal! gv"
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#moveNextPrev(flag)
|
||||
let pos = search('\%(</\w\+\)\@<!\zs><\/\|\(""\)\|^\(\s*\)$', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 3
|
||||
startinsert!
|
||||
elseif pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#splitJoinTag()
|
||||
let curpos = getpos('.')
|
||||
while 1
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let pos1 = searchpos(mx, 'bcnW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block)
|
||||
let content = content[:-3] . "></" . tag_name . '>'
|
||||
call zencoding#util#setContent(block, content)
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if tag_name[0] == '/'
|
||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
||||
else
|
||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
let content = zencoding#util#getContent(block)
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||
let content = matchstr(content, mx)[:-2] . '/>'
|
||||
call zencoding#util#setContent(block, content)
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#removeTag()
|
||||
let curpos = getpos('.')
|
||||
while 1
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let pos1 = searchpos(mx, 'bcnW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block)
|
||||
call zencoding#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if tag_name[0] == '/'
|
||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
||||
else
|
||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
let content = zencoding#util#getContent(block)
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||
call zencoding#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
@@ -1,122 +0,0 @@
|
||||
function! zencoding#lang#scss#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#parseIntoTree(abbr, type)
|
||||
if a:abbr =~ '>'
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
else
|
||||
return zencoding#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let str = ""
|
||||
|
||||
let current_name = current.name
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
if len(current.name) > 0
|
||||
let str .= current_name
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
if attr == 'id'
|
||||
let str .= '#' . val
|
||||
elseif attr == 'class'
|
||||
let str .= '.' . val
|
||||
else
|
||||
let tmp .= attr . ': ' . val . ';'
|
||||
endif
|
||||
endfor
|
||||
if len(tmp) > 0
|
||||
let str .= " {\n"
|
||||
for line in split(tmp, "\n")
|
||||
let str .= indent . line . "\n"
|
||||
endfor
|
||||
else
|
||||
let str .= " {\n"
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
for child in current.child
|
||||
let inner .= zencoding#toString(child, type, inline, filters, itemno)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
|
||||
let str .= indent . inner . "\n}\n"
|
||||
else
|
||||
return zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#imageSize()
|
||||
call zencoding#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#encodeImage()
|
||||
return zencoding#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#parseTag(tag)
|
||||
return zencoding#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#toggleComment()
|
||||
call zencoding#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#balanceTag(flag) range
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
call setpos('.', curpos)
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
if a:flag < 0
|
||||
let ret = searchpair('}', '', '.\zs{')
|
||||
else
|
||||
let ret = searchpair('{', '', '}', 'bW')
|
||||
endif
|
||||
if ret > 0
|
||||
let pos1 = getpos('.')[1:2]
|
||||
if a:flag < 0
|
||||
let pos2 = searchpairpos('{', '', '}')
|
||||
else
|
||||
let pos2 = searchpairpos('{', '', '}')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe "normal! gv"
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#moveNextPrev(flag)
|
||||
call zencoding#lang#css#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#splitJoinTag()
|
||||
call zencoding#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#removeTag()
|
||||
call zencoding#lang#ss#removeTag()
|
||||
endfunction
|
||||
@@ -1,230 +0,0 @@
|
||||
"==============================================================================
|
||||
" region utils
|
||||
"==============================================================================
|
||||
" deleteContent : delete content in region
|
||||
" if region make from between '<foo>' and '</foo>'
|
||||
" --------------------
|
||||
" begin:<foo>
|
||||
" </foo>:end
|
||||
" --------------------
|
||||
" this function make the content as following
|
||||
" --------------------
|
||||
" begin::end
|
||||
" --------------------
|
||||
function! zencoding#util#deleteContent(region)
|
||||
let lines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe "delete ".(a:region[1][0] - a:region[0][0])
|
||||
call setline(line('.'), lines[0][:a:region[0][1]-2] . lines[-1][a:region[1][1]])
|
||||
endfunction
|
||||
|
||||
" change_content : change content in region
|
||||
" if region make from between '<foo>' and '</foo>'
|
||||
" --------------------
|
||||
" begin:<foo>
|
||||
" </foo>:end
|
||||
" --------------------
|
||||
" and content is
|
||||
" --------------------
|
||||
" foo
|
||||
" bar
|
||||
" baz
|
||||
" --------------------
|
||||
" this function make the content as following
|
||||
" --------------------
|
||||
" begin:foo
|
||||
" bar
|
||||
" baz:end
|
||||
" --------------------
|
||||
function! zencoding#util#setContent(region, content)
|
||||
let newlines = split(a:content, '\n', 1)
|
||||
let oldlines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe "delete ".(a:region[1][0] - a:region[0][0])
|
||||
if len(newlines) == 0
|
||||
let tmp = ''
|
||||
if a:region[0][1] > 1
|
||||
let tmp = oldlines[0][:a:region[0][1]-2]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let tmp .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), tmp)
|
||||
elseif len(newlines) == 1
|
||||
if a:region[0][1] > 1
|
||||
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let newlines[0] .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), newlines[0])
|
||||
else
|
||||
if a:region[0][1] > 1
|
||||
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let newlines[-1] .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), newlines[0])
|
||||
call append(line('.'), newlines[1:])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" select_region : select region
|
||||
" this function make a selection of region
|
||||
function! zencoding#util#selectRegion(region)
|
||||
call setpos('.', [0, a:region[1][0], a:region[1][1], 0])
|
||||
normal! v
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
endfunction
|
||||
|
||||
" point_in_region : check point is in the region
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#pointInRegion(point, region)
|
||||
if !zencoding#util#regionIsValid(a:region) | return 0 | endif
|
||||
if a:region[0][0] > a:point[0] | return 0 | endif
|
||||
if a:region[1][0] < a:point[0] | return 0 | endif
|
||||
if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif
|
||||
if a:region[1][0] == a:point[0] && a:region[1][1] < a:point[1] | return 0 | endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" cursor_in_region : check cursor is in the region
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#cursorInRegion(region)
|
||||
if !zencoding#util#regionIsValid(a:region) | return 0 | endif
|
||||
let cur = getpos('.')[1:2]
|
||||
return zencoding#util#pointInRegion(cur, a:region)
|
||||
endfunction
|
||||
|
||||
" region_is_valid : check region is valid
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#regionIsValid(region)
|
||||
if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" search_region : make region from pattern which is composing start/end
|
||||
" this function return array of position
|
||||
function! zencoding#util#searchRegion(start, end)
|
||||
return [searchpairpos(a:start, '', a:end, 'bcnW'), searchpairpos(a:start, '\%#', a:end, 'nW')]
|
||||
endfunction
|
||||
|
||||
" get_content : get content in region
|
||||
" this function return string in region
|
||||
function! zencoding#util#getContent(region)
|
||||
if !zencoding#util#regionIsValid(a:region)
|
||||
return ''
|
||||
endif
|
||||
let lines = getline(a:region[0][0], a:region[1][0])
|
||||
if a:region[0][0] == a:region[1][0]
|
||||
let lines[0] = lines[0][a:region[0][1]-1:a:region[1][1]-1]
|
||||
else
|
||||
let lines[0] = lines[0][a:region[0][1]-1:]
|
||||
let lines[-1] = lines[-1][:a:region[1][1]-1]
|
||||
endif
|
||||
return join(lines, "\n")
|
||||
endfunction
|
||||
|
||||
" region_in_region : check region is in the region
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#regionInRegion(outer, inner)
|
||||
if !zencoding#util#regionIsValid(a:inner) || !zencoding#util#regionIsValid(a:outer)
|
||||
return 0
|
||||
endif
|
||||
return zencoding#util#pointInRegion(a:inner[0], a:outer) && zencoding#util#pointInRegion(a:inner[1], a:outer)
|
||||
endfunction
|
||||
|
||||
" get_visualblock : get region of visual block
|
||||
" this function return region of visual block
|
||||
function! zencoding#util#getVisualBlock()
|
||||
return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
|
||||
endfunction
|
||||
|
||||
"==============================================================================
|
||||
" html utils
|
||||
"==============================================================================
|
||||
function! zencoding#util#getContentFromURL(url)
|
||||
let res = system(printf("%s %s", g:zencoding_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
|
||||
let s1 = len(split(res, '?'))
|
||||
let utf8 = iconv(res, 'utf-8', &encoding)
|
||||
let s2 = len(split(utf8, '?'))
|
||||
return s2 > s1 * 2 ? utf8 : res
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#getTextFromHTML(buf)
|
||||
let threshold_len = 100
|
||||
let threshold_per = 0.1
|
||||
let buf = a:buf
|
||||
|
||||
let buf = strpart(buf, stridx(buf, '</head>'))
|
||||
let buf = substitute(buf, '<style[^>]*>.\{-}</style>', '', 'g')
|
||||
let buf = substitute(buf, '<script[^>]*>.\{-}</script>', '', 'g')
|
||||
let res = ''
|
||||
let max = 0
|
||||
let mx = '\(<td[^>]\{-}>\)\|\(<\/td>\)\|\(<div[^>]\{-}>\)\|\(<\/div>\)'
|
||||
let m = split(buf, mx)
|
||||
for str in m
|
||||
let c = split(str, '<[^>]*?>')
|
||||
let str = substitute(str, '<[^>]\{-}>', ' ', 'g')
|
||||
let str = substitute(str, '>', '>', 'g')
|
||||
let str = substitute(str, '<', '<', 'g')
|
||||
let str = substitute(str, '"', '"', 'g')
|
||||
let str = substitute(str, ''', "'", 'g')
|
||||
let str = substitute(str, ' ', ' ', 'g')
|
||||
let str = substitute(str, '¥', '\¥', 'g')
|
||||
let str = substitute(str, '&', '\&', 'g')
|
||||
let str = substitute(str, '^\s*\(.*\)\s*$', '\1', '')
|
||||
let str = substitute(str, '\s\+', ' ', 'g')
|
||||
let l = len(str)
|
||||
if l > threshold_len
|
||||
let per = (l+0.0) / len(c)
|
||||
if max < l && per > threshold_per
|
||||
let max = l
|
||||
let res = str
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let res = substitute(res, '^\s*\(.*\)\s*$', '\1', 'g')
|
||||
return res
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#getImageSize(fn)
|
||||
let fn = a:fn
|
||||
if filereadable(fn)
|
||||
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
|
||||
else
|
||||
let hex = substitute(system(g:zencoding_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g')
|
||||
endif
|
||||
|
||||
let [width, height] = [-1, -1]
|
||||
if hex =~ '^89504e470d0a1a0a'
|
||||
let width = eval('0x'.hex[32:39])
|
||||
let height = eval('0x'.hex[40:47])
|
||||
endif
|
||||
if hex =~ '^ffd8'
|
||||
let pos = 4
|
||||
while pos < len(hex)
|
||||
let bs = hex[pos+0:pos+3]
|
||||
let pos += 4
|
||||
if bs == 'ffc0' || bs == 'ffc2'
|
||||
let pos += 6
|
||||
let height = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
|
||||
let pos += 4
|
||||
let width = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
|
||||
break
|
||||
elseif bs =~ 'ffd[9a]'
|
||||
break
|
||||
elseif bs =~ 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)'
|
||||
let pos += (eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])) * 2
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
if hex =~ '^47494638'
|
||||
let width = eval('0x'.hex[14:15].hex[12:13])
|
||||
let height = eval('0x'.hex[18:19].hex[16:17])
|
||||
endif
|
||||
|
||||
return [width, height]
|
||||
endfunction
|
||||
|
||||
1771
doc/emmet.txt
Normal file
1771
doc/emmet.txt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
doc/screenshot.gif
Normal file
BIN
doc/screenshot.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -1,429 +0,0 @@
|
||||
*zencoding.txt* ZenCoding for Vim
|
||||
|
||||
-------------------------------------------------------
|
||||
ZenCoding: vim plugins for HTML and CSS hi-speed coding
|
||||
-------------------------------------------------------
|
||||
|
||||
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
WebSite: http://mattn.kaoriya.net/
|
||||
Repository: http://github.com/mattn/zencoding-vim
|
||||
Site: http://mattn.github.com/zencoding-vim
|
||||
License: BSD style license
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *zencoding-contents*
|
||||
|
||||
Introduction |zencoding-introduction|
|
||||
Install |zencoding-install|
|
||||
Tutorial |zencoding-tutorial|
|
||||
1. Expand Abbreviation |zencoding-expandabbr|
|
||||
2. Wrap with Abbreviation |zencoding-wrap-wtih-abbreviation|
|
||||
3. Balance Tag Inward |zencoding-balance-tag-inward|
|
||||
4. Balance Tag Outward |zencoding-balance-tag-outward|
|
||||
5. Go to Next Edit Point |zencoding-goto-next-point| |<C-Y>n|
|
||||
6. Go to Previous Edit Point |zencoding-goto-previous-point|
|
||||
7. Update <img> Size |zencoding-update-image-size|
|
||||
8. Merge Lines |zencoding-merge-lines|
|
||||
9. Remove Tag |zencoding-remove-tag|
|
||||
10. Split/Join Tag |zencoding-split-join-tag|
|
||||
11. Toggle Comment |zencoding-toggle-comment|
|
||||
12. Make anchor from URL |zencoding-make-anchor-url|
|
||||
13. Make quoted text from URL |zencoding-quoted-text-url|
|
||||
14. Code Pretty |zencoding-code-pretty|
|
||||
Customize |zencoding-customize|
|
||||
1. Key Mappings |zencoding-customize-keymappings|
|
||||
2. Indent Size |zencoding-indent-size|
|
||||
3. Define Tag's Behavior |zencoding-define-tags-behavior|
|
||||
4. Complete Tag |zencoding-complete-tag|
|
||||
Links |zencoding-links|
|
||||
ToDo |zencoding-todo|
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *zencoding-introduction* *zencoding*
|
||||
|
||||
|ZenCoding| is an editor plugin for high-speed HTML, XML, XSL (or any other
|
||||
structured code format) coding and editing. The core of this plugin is a
|
||||
powerful abbreviation engine which allows you to expand expressions?similar to
|
||||
CSS selectors?into HTML code:
|
||||
>
|
||||
div#page>div.logo+ul#navigation>li*5>a
|
||||
<
|
||||
...can be expanded into:
|
||||
>
|
||||
<div id="page">
|
||||
<div class="logo"></div>
|
||||
<ul id="navigation">
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<
|
||||
Read more about current Zen Coding syntax
|
||||
http://code.google.com/p/zen-coding/wiki/ZenHTMLSelectorsEn
|
||||
|
||||
Abbreviation engine has a modular structure which allows you to expand
|
||||
abbreviations into different languages. Zen Coding currently supports CSS,
|
||||
HTML, XML/XSL and HAML, Slim languages via filters.
|
||||
|
||||
==============================================================================
|
||||
INSTALL *zencoding-install*
|
||||
|
||||
Install the distributed files into Vim runtime directory which is usually
|
||||
~/.vim/, or $HOME/vimfiles on Windows.
|
||||
|
||||
If you install pathogen that provided from Tim Pope, you should extract the
|
||||
file into 'bundle' directory.
|
||||
|
||||
==============================================================================
|
||||
TUTORIAL *zencoding-tutorial*
|
||||
|
||||
If you are seeing this file as :help, then you can't edit this file.
|
||||
You should copy this section and create new buffer, paste and write as
|
||||
'zencoding-tutor.txt'. Formally, open the file to start tutorial.
|
||||
|
||||
1. Expand Abbreviation *zencoding-expandabbr* *<C-Y>,*
|
||||
|
||||
Type abbreviation as 'div>p#foo$*3>a' and type |<C-Y>,|.
|
||||
>
|
||||
<div>
|
||||
<p id="foo1">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo2">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo3">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
</div>
|
||||
<
|
||||
2. Wrap with Abbreviation *zencoding-wrap-wtih-abbreviation* *v_<C-Y>,*
|
||||
|
||||
Write as below.
|
||||
>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
<
|
||||
Then do visual select(line wize) and type |<C-Y>,|.
|
||||
If you request 'Tag:', then type 'ul>li*'.
|
||||
>
|
||||
<ul>
|
||||
<li>test1</li>
|
||||
<li>test2</li>
|
||||
<li>test3</li>
|
||||
</ul>
|
||||
<
|
||||
If you type tag as 'blockquote', then you'll see as following.
|
||||
>
|
||||
<blockquote>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
</blockquote>
|
||||
<
|
||||
3. Balance Tag Inward *zencoding-balance-tag-inward* *<C-Y>d*
|
||||
|
||||
To select inward of ul tag, type |<C-Y>d| in insert mode.
|
||||
>
|
||||
<ul>
|
||||
* <li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
If cursor is at '*', |<C-Y>d| select from begin of <ul> to end of </ul>.
|
||||
If cursor is at first of <li>, it select <li class="list1"></li>.
|
||||
|
||||
4. Balance Tag Outward *zencoding-balance-tag-outward* *<C-Y>D*
|
||||
|
||||
To select outward of ul tag, insert mode, type <C-Y>D in insert mode.
|
||||
>
|
||||
<ul>
|
||||
* <li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
If cursor is at '*', |<C-Y>D| select from next letter of <ul> to previous
|
||||
letter of </ul>.
|
||||
If cursor is at first of <li>, it select <li class="list1"></li>.
|
||||
|
||||
5. Go to Next Edit Point *zencoding-goto-next-point* *<C-Y>n*
|
||||
|
||||
To jump next point that need to edit, type |<C-Y>n| in insert mode.
|
||||
>
|
||||
* <div id="foo" class="">foo</div>
|
||||
<div id="bar" class="bar"></li>
|
||||
<
|
||||
If cursor is at '*', |<C-Y>n| move a cursor into attribute value of div
|
||||
specified id as 'foo'. And type again |<C-Y>n| move a cursor into inner of
|
||||
div specified id as 'bar'.
|
||||
|
||||
6. Go to Previous Edit Point *zencoding-goto-previous-point* *<C-Y>N*
|
||||
|
||||
To jump previous point that need to edit, type |<C-Y>N| in insert mode.
|
||||
>
|
||||
<div id="foo" class="">foo</div>
|
||||
<div id="bar" class="bar"></li> *
|
||||
<
|
||||
If cursor is at '*', |<C-Y>N| move a cursor into div specified id as 'bar'.
|
||||
And type again |<C-Y>N| move a cursor into attribute value of 'foo'.
|
||||
|
||||
7. Update <img> Size *zencoding-update-image-size* *<C-Y>i*
|
||||
|
||||
To expand or update size of image, type |<C-Y>i| on img tag
|
||||
>
|
||||
<img src="foo.png" />
|
||||
<
|
||||
Type '<c-y>i' on img tag
|
||||
>
|
||||
<img src="foo.png" width="32" height="32" />
|
||||
<
|
||||
If you change image, then type it again. it will be following.
|
||||
>
|
||||
<img src="foo-48.png" width="32" height="48" />
|
||||
<
|
||||
8. Merge Lines *zencoding-merge-lines*
|
||||
|
||||
To join multi line text like following, type |J|.
|
||||
>
|
||||
<ul>
|
||||
<li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
If you select part of line include <li> and type |<C-Y>m|, it will be
|
||||
following.
|
||||
>
|
||||
<ul>
|
||||
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
9. Remove Tag *zencoding-remove-tag* *<C-Y>k*
|
||||
|
||||
To remove tag in the block, type |<C-Y>k|.
|
||||
>
|
||||
<div class="foo">
|
||||
<a>cursor is here</a>
|
||||
</div>
|
||||
<
|
||||
Type |<C-Y>k| in insert mode, then
|
||||
>
|
||||
<div class="foo">
|
||||
|
||||
</div>
|
||||
<
|
||||
And type |<C-Y>k| in there again, then div will be removed.
|
||||
|
||||
10. Split/Join Tag *zencoding-split-join-tag* *<C-Y>j*
|
||||
|
||||
To join block, type |<C-Y>j|.
|
||||
>
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
</div>
|
||||
<
|
||||
Type |<C-Y>j| in insert mode. then,
|
||||
>
|
||||
<div class="foo"/>
|
||||
<
|
||||
And type |<C-Y>j| in there again.
|
||||
>
|
||||
<div class="foo">
|
||||
</div>
|
||||
<
|
||||
11. Toggle Comment *zencoding-toggle-comment* *<C-Y>/*
|
||||
|
||||
Move cursor to block
|
||||
>
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
<
|
||||
Type '<c-y>/' in insert mode.
|
||||
>
|
||||
<!-- <div>
|
||||
hello world
|
||||
</div> -->
|
||||
<
|
||||
Type '<c-y>/' in there again.
|
||||
>
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
<
|
||||
12. Make anchor from URL *zencoding-make-anchor-url* *<C-Y>a*
|
||||
|
||||
Move cursor to URL
|
||||
>
|
||||
http://www.google.com/
|
||||
<
|
||||
Type |<C-Y>a|
|
||||
>
|
||||
<a href="http://www.google.com/">Google</a>
|
||||
<
|
||||
13. Make quoted text from URL *zencoding-quoted-text-url* *<C-Y>A*
|
||||
|
||||
Move cursor to URL
|
||||
>
|
||||
http://github.com/
|
||||
<
|
||||
Type |<C-Y>A|
|
||||
>
|
||||
<blockquote class="quote">
|
||||
<a href="http://github.com/">Secure source code hosting and collaborative development - GitHub</a><br />
|
||||
<p>How does it work? Get up and running in seconds by forking a project, pushing an existing repository...</p>
|
||||
<cite>http://github.com/</cite>
|
||||
</blockquote>
|
||||
<
|
||||
14. Code Pretty *zencoding-code-pretty* *<C-Y>c*
|
||||
|
||||
Select code block, for example select following code from "int main()".
|
||||
>
|
||||
<p>Writing in C language</p>
|
||||
|
||||
int main() {
|
||||
puts("hello world");
|
||||
}
|
||||
<
|
||||
Type |<C-Y>c|
|
||||
>
|
||||
<p>Writing in C language</p>
|
||||
|
||||
<span class="Type">int</span> main() {<br />
|
||||
puts(<span class="Constant">"hello world"</span>);<br />
|
||||
}<br />
|
||||
<
|
||||
==============================================================================
|
||||
CUSTOMIZE *zencoding-customize*
|
||||
|
||||
1. Key Mapping *zencoding-customize-keymappings*
|
||||
|
||||
To specify leading key for expanding or balance tag, or for all,
|
||||
Add this line in your vimrc: >
|
||||
>
|
||||
let g:user_zen_leader_key = '<c-y>'
|
||||
<
|
||||
Or if you prefer to map for each actions, then you set each variables.
|
||||
|
||||
'user_zen_expandabbr_key'
|
||||
'user_zen_expandword_key'
|
||||
'user_zen_balancetaginward_key'
|
||||
'user_zen_balancetagoutward_key'
|
||||
'user_zen_next_key'
|
||||
'user_zen_prev_key'
|
||||
'user_zen_imagesize_key'
|
||||
'user_zen_togglecomment_key'
|
||||
'user_zen_splitjointag_key'
|
||||
'user_zen_removetag_key'
|
||||
'user_zen_anchorizeurl_key'
|
||||
'user_zen_anchorizesummary_key'
|
||||
|
||||
2. Indent Size *zencoding-indent-size*
|
||||
|
||||
To change indent size of html, add this code in your vimrc.
|
||||
>
|
||||
let g:user_zen_settings = {
|
||||
\ 'html' : {
|
||||
\ 'indentation' : ' '
|
||||
\ },
|
||||
\}
|
||||
<
|
||||
If you prefer to change global indent size then add this.
|
||||
>
|
||||
let g:user_zen_settings = {
|
||||
\ 'indentation' : ' '
|
||||
\}
|
||||
<
|
||||
3. Define Tag's Behavior *zencoding-define-tags-behavior*
|
||||
|
||||
zencoding.vim can change behavior of expanding abbreviation for each
|
||||
filetypes as |Dictionary|. for details, see official site of zencoding.
|
||||
for example, vimmer can add following.
|
||||
>
|
||||
let g:user_zen_settings = {
|
||||
\ 'lang' : 'ja',
|
||||
\ 'html' : {
|
||||
\ 'filters' : 'html',
|
||||
\ 'indentation' : ' '
|
||||
\ },
|
||||
\ 'perl' : {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'aliases' : {
|
||||
\ 'req' : "require '|'"
|
||||
\ },
|
||||
\ 'snippets' : {
|
||||
\ 'use' : "use strict\nuse warnings\n\n",
|
||||
\ 'w' : "warn \"${cursor}\";",
|
||||
\ },
|
||||
\ },
|
||||
\ 'php' : {
|
||||
\ 'extends' : 'html',
|
||||
\ 'filters' : 'html,c',
|
||||
\ },
|
||||
\ 'css' : {
|
||||
\ 'filters' : 'fc',
|
||||
\ },
|
||||
\ 'javascript' : {
|
||||
\ 'snippets' : {
|
||||
\ 'jq' : "$(function() {\n\t${cursor}${child}\n});",
|
||||
\ 'jq:each' : "$.each(arr, function(index, item)\n\t${child}\n});",
|
||||
\ 'fn' : "(function() {\n\t${cursor}\n})();",
|
||||
\ 'tm' : "setTimeout(function() {\n\t${cursor}\n}, 100);",
|
||||
\ },
|
||||
\ },
|
||||
\ 'java' : {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'snippets' : {
|
||||
\ 'main': "public static void main(String[] args) {\n\t|\n}",
|
||||
\ 'println': "System.out.println(\"|\");",
|
||||
\ 'class': "public class | {\n}\n",
|
||||
\ },
|
||||
\ },
|
||||
\}
|
||||
<
|
||||
4. Complete Tag *zencoding-complete-tag*
|
||||
|
||||
If you want to complete tags using |omnifunc| then add this.
|
||||
>
|
||||
let g:use_zen_complete_tag = 1
|
||||
<
|
||||
==============================================================================
|
||||
LINKS *zencoding-links*
|
||||
|
||||
zen-coding official site:
|
||||
http://code.google.com/p/zen-coding/
|
||||
|
||||
zencoding.vim:
|
||||
http://mattn.github.com/zencoding-vim
|
||||
|
||||
development repository:
|
||||
https://github.com/mattn/zencoding-vim
|
||||
|
||||
my blog posts about zencoding-vim:
|
||||
http://mattn.kaoriya.net/software/vim/20100222103327.htm
|
||||
http://mattn.kaoriya.net/software/vim/20100306021632.htm
|
||||
|
||||
japanese blog posts about zencoding-vim:
|
||||
http://d.hatena.ne.jp/idesaku/20100424/1272092255
|
||||
http://d.hatena.ne.jp/griefworker/20110118/vim_zen_coding
|
||||
http://d.hatena.ne.jp/sakurako_s/20110126/1295988873
|
||||
http://looxu.blogspot.jp/2010/02/zencodingvimhtml.html
|
||||
|
||||
tutorial traslated in chinese:
|
||||
http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html
|
||||
|
||||
==============================================================================
|
||||
TODO *zencoding-todo*
|
||||
* wrapping inline selected.
|
||||
* more documents.
|
||||
* more contributor.
|
||||
* more time to improve zencodig.vim.
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0:
|
||||
1
docs
Submodule
1
docs
Submodule
Submodule docs added at ff5a094cc8
@@ -1,21 +1,21 @@
|
||||
script_name: ZenCoding.vim
|
||||
script_name: Emmet.vim
|
||||
script_id: '2981'
|
||||
script_type: utility
|
||||
script_package: zencoding-vim.zip
|
||||
script_version: '0.80'
|
||||
script_package: emmet-vim.zip
|
||||
script_version: '0.86'
|
||||
required_vim_version: '7.0'
|
||||
summary: vim plugins for HTML and CSS hi-speed coding.
|
||||
|
||||
detailed_description: |
|
||||
|
||||
This is vim script support expanding abbreviation like zen-coding.
|
||||
ref: http://code.google.com/p/zen-coding/
|
||||
This is vim script support expanding abbreviation like emmet.
|
||||
ref: http://emmet.io/
|
||||
|
||||
There is a movie using zencoding.vim
|
||||
ref: http://mattn.github.com/zencoding-vim
|
||||
There is a movie using emmet.vim
|
||||
ref: http://mattn.github.com/emmet-vim
|
||||
|
||||
Source Repository.
|
||||
ref: http://github.com/mattn/zencoding-vim
|
||||
ref: http://github.com/mattn/emmet-vim
|
||||
|
||||
Type abbreviation
|
||||
+-------------------------------------
|
||||
@@ -52,18 +52,18 @@ detailed_description: |
|
||||
|
||||
Tutorial:
|
||||
|
||||
http://github.com/mattn/zencoding-vim/raw/master/TUTORIAL
|
||||
http://github.com/mattn/emmet-vim/raw/master/TUTORIAL
|
||||
|
||||
How work this:
|
||||
|
||||
http://mattn.github.com/zencoding-vim
|
||||
http://mattn.github.com/emmet-vim
|
||||
|
||||
Tips:
|
||||
|
||||
You can customize behavior of expanding with overriding config.
|
||||
This configuration will be marged at loading plugin.
|
||||
This configuration will be merged at loading plugin.
|
||||
|
||||
let g:user_zen_settings = {
|
||||
let g:user_emmet_settings = {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'perl' : {
|
||||
\ 'aliases' : {
|
||||
@@ -76,28 +76,40 @@ detailed_description: |
|
||||
\ }
|
||||
\}
|
||||
|
||||
let g:user_zen_expandabbr_key = '<c-e>'
|
||||
let g:user_emmet_expandabbr_key = '<c-e>'
|
||||
|
||||
let g:use_zen_complete_tag = 1
|
||||
let g:use_emmet_complete_tag = 1
|
||||
|
||||
You can set language attribute in html using zen_settings['lang'].
|
||||
You can set language attribute in html using emmet_settings['lang'].
|
||||
|
||||
install_details: |
|
||||
|
||||
# cd ~/.vim
|
||||
# unzip zencoding-vim.zip
|
||||
# unzip emmet-vim.zip
|
||||
|
||||
or if you install pathogen.vim:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# unzip /path/to/zencoding-vim.zip
|
||||
# unzip /path/to/emmet-vim.zip
|
||||
|
||||
if you get sources from repository:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# git clone http://github.com/mattn/zencoding-vim.git
|
||||
# git clone http://github.com/mattn/emmet-vim.git
|
||||
|
||||
versions:
|
||||
- '0.86': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes.
|
||||
- '0.85': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes.
|
||||
- '0.84': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes. fix bug that interpose insert completion plugins.
|
||||
- '0.83': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes.
|
||||
- '0.82': |
|
||||
This is an upgrade for Emmet.vim: many bug fixes.
|
||||
- '0.81': |
|
||||
Release of Emmet.vim: renamed from ZenCoding.vim.
|
||||
- '0.80': |
|
||||
This is an upgrade for ZenCoding.vim: add emmet features.
|
||||
- '0.74': |
|
||||
192
plugin/emmet.vim
Normal file
192
plugin/emmet.vim
Normal file
@@ -0,0 +1,192 @@
|
||||
"=============================================================================
|
||||
" File: emmet.vim
|
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
" Last Change: 26-Jul-2015.
|
||||
" Version: 0.86
|
||||
" WebPage: http://github.com/mattn/emmet-vim
|
||||
" Description: vim plugins for HTML and CSS hi-speed coding.
|
||||
" SeeAlso: http://emmet.io/
|
||||
" Usage:
|
||||
"
|
||||
" This is vim script support expanding abbreviation like emmet.
|
||||
" ref: http://emmet.io/
|
||||
"
|
||||
" Type abbreviation
|
||||
" +-------------------------------------
|
||||
" | html:5_
|
||||
" +-------------------------------------
|
||||
" "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma)
|
||||
" NOTE: Don't worry about key map. you can change it easily.
|
||||
" +-------------------------------------
|
||||
" | <!DOCTYPE HTML>
|
||||
" | <html lang="en">
|
||||
" | <head>
|
||||
" | <title></title>
|
||||
" | <meta charset="UTF-8">
|
||||
" | <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
" | </head>
|
||||
" | <body>
|
||||
" | _
|
||||
" | </body>
|
||||
" | </html>
|
||||
" +-------------------------------------
|
||||
" Type following
|
||||
" +-------------------------------------
|
||||
" | div#foo$*2>div.bar
|
||||
" +-------------------------------------
|
||||
" And type "<c-y>,"
|
||||
" +-------------------------------------
|
||||
" |<div id="foo1">
|
||||
" | <div class="bar">_</div>
|
||||
" |</div>
|
||||
" |<div id="foo2">
|
||||
" | <div class="bar"></div>
|
||||
" |</div>
|
||||
" +-------------------------------------
|
||||
"
|
||||
" Tips:
|
||||
"
|
||||
" You can customize behavior of expanding with overriding config.
|
||||
" This configuration will be merged at loading plugin.
|
||||
"
|
||||
" let g:user_emmet_settings = {
|
||||
" \ 'indentation' : ' ',
|
||||
" \ 'perl' : {
|
||||
" \ 'aliases' : {
|
||||
" \ 'req' : 'require '
|
||||
" \ },
|
||||
" \ 'snippets' : {
|
||||
" \ 'use' : "use strict\nuse warnings\n\n",
|
||||
" \ 'warn' : "warn \"|\";",
|
||||
" \ }
|
||||
" \ }
|
||||
" \}
|
||||
"
|
||||
" You can set language attribute in html using 'emmet_settings.lang'.
|
||||
"
|
||||
" GetLatestVimScripts: 2981 1 :AutoInstall: emmet.vim
|
||||
" script type: plugin
|
||||
|
||||
if &compatible || v:version < 702 || (exists('g:loaded_emmet_vim') && g:loaded_emmet_vim)
|
||||
finish
|
||||
endif
|
||||
let g:loaded_emmet_vim = 1
|
||||
|
||||
let s:save_cpo = &cpoptions
|
||||
set cpoptions&vim
|
||||
|
||||
if !exists('g:emmet_html5')
|
||||
let g:emmet_html5 = 1
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_docroot')
|
||||
let g:emmet_docroot = {}
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_debug')
|
||||
let g:emmet_debug = 0
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_curl_command')
|
||||
let g:emmet_curl_command = 'curl -s -L -A Mozilla/5.0'
|
||||
endif
|
||||
|
||||
if !exists('g:user_emmet_leader_key')
|
||||
let g:user_emmet_leader_key = '<c-y>'
|
||||
endif
|
||||
|
||||
function! s:install_plugin(mode, buffer)
|
||||
let buffer = a:buffer ? '<buffer>' : ''
|
||||
let items = [
|
||||
\ {'mode': 'i', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(0,"")<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(3,"")<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(2,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(1,"")<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': ':call emmet#expandAbbr(1,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#updateTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': ':call emmet#updateTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': '<esc>:call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': ':call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': '<esc>:call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': ':call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': ':call emmet#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': ':call emmet#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': '<esc>:call emmet#moveNextPrevItem(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': ':call emmet#moveNextPrevItem(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': '<esc>:call emmet#moveNextPrevItem(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': ':call emmet#moveNextPrevItem(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#imageSize()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': ':call emmet#imageSize()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_imageencode_key', 'key': 'I', 'plug': 'emmet-image-encode', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#imageEncode()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_imageencode_key', 'key': 'I', 'plug': 'emmet-image-encode', 'func': ':call emmet#imageEncode()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#toggleComment()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': ':call emmet#toggleComment()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': '<esc>:call emmet#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': ':call emmet#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#removeTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': ':call emmet#removeTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': ':call emmet#anchorizeURL(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': ':call emmet#anchorizeURL(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#mergeLines()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': ':call emmet#mergeLines()<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_codepretty_key', 'key': 'c', 'plug': 'emmet-code-pretty', 'func': ':call emmet#codePretty()<cr>'},
|
||||
\]
|
||||
|
||||
let only_plug = get(g:, 'emmet_install_only_plug', 0)
|
||||
for item in items
|
||||
if a:mode !=# 'a' && stridx(a:mode, item.mode) == -1
|
||||
continue
|
||||
endif
|
||||
exe item.mode . 'noremap '. buffer .' <plug>(' . item.plug . ') ' . item.func
|
||||
if item.var != '' && !only_plug
|
||||
if exists('g:' . item.var)
|
||||
let key = eval('g:' . item.var)
|
||||
else
|
||||
let key = g:user_emmet_leader_key . item.key
|
||||
endif
|
||||
if !hasmapto('<plug>(' . item.plug . ')', item.mode) && !len(maparg(key, item.mode))
|
||||
exe item.mode . 'map ' . buffer . ' <unique> <silent>' . key . ' <plug>(' . item.plug . ')'
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if exists('g:user_emmet_complete_tag') && g:user_emmet_complete_tag
|
||||
if get(g:, 'user_emmet_install_global', 1)
|
||||
set omnifunc=emmet#completeTag
|
||||
else
|
||||
setlocal omnifunc=emmet#completeTag
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
command! -nargs=0 -bar EmmetInstall call <SID>install_plugin(get(g:, 'user_emmet_mode', 'a'), 1)
|
||||
|
||||
if get(g:, 'user_emmet_install_global', 1)
|
||||
call s:install_plugin(get(g:, 'user_emmet_mode', 'a'), 0)
|
||||
endif
|
||||
|
||||
if get(g:, 'user_emmet_install_command', 1)
|
||||
command! -nargs=1 Emmet call emmet#expandAbbr(4, <q-args>)
|
||||
endif
|
||||
|
||||
function! s:setup_styledEmmetAbbreviation() abort
|
||||
if index(['javascript', 'javascriptreact', 'typescript', 'typescriptreact'], &filetype) != -1
|
||||
syntax match styledEmmetAbbreviation "[a-z0-9#+!%]\+" containedin=styledDefinition contained
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup ___emmet_setup___
|
||||
au!
|
||||
autocmd Syntax * call s:setup_styledEmmetAbbreviation()
|
||||
augroup END
|
||||
|
||||
let &cpoptions = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:set et:
|
||||
@@ -1,149 +0,0 @@
|
||||
"=============================================================================
|
||||
" File: zencoding.vim
|
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
" Last Change: 02-Nov-2012.
|
||||
" Version: 0.80
|
||||
" WebPage: http://github.com/mattn/zencoding-vim
|
||||
" Description: vim plugins for HTML and CSS hi-speed coding.
|
||||
" SeeAlso: http://code.google.com/p/zen-coding/
|
||||
" Usage:
|
||||
"
|
||||
" This is vim script support expanding abbreviation like zen-coding.
|
||||
" ref: http://code.google.com/p/zen-coding/
|
||||
"
|
||||
" Type abbreviation
|
||||
" +-------------------------------------
|
||||
" | html:5_
|
||||
" +-------------------------------------
|
||||
" "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma)
|
||||
" NOTE: Don't worry about key map. you can change it easily.
|
||||
" +-------------------------------------
|
||||
" | <!DOCTYPE HTML>
|
||||
" | <html lang="en">
|
||||
" | <head>
|
||||
" | <title></title>
|
||||
" | <meta charset="UTF-8">
|
||||
" | </head>
|
||||
" | <body>
|
||||
" | _
|
||||
" | </body>
|
||||
" | </html>
|
||||
" +-------------------------------------
|
||||
" Type following
|
||||
" +-------------------------------------
|
||||
" | div#foo$*2>div.bar
|
||||
" +-------------------------------------
|
||||
" And type "<c-y>,"
|
||||
" +-------------------------------------
|
||||
" |<div id="foo1">
|
||||
" | <div class="bar">_</div>
|
||||
" |</div>
|
||||
" |<div id="foo2">
|
||||
" | <div class="bar"></div>
|
||||
" |</div>
|
||||
" +-------------------------------------
|
||||
"
|
||||
" Tips:
|
||||
"
|
||||
" You can customize behavior of expanding with overriding config.
|
||||
" This configuration will be marged at loading plugin.
|
||||
"
|
||||
" let g:user_zen_settings = {
|
||||
" \ 'indentation' : ' ',
|
||||
" \ 'perl' : {
|
||||
" \ 'aliases' : {
|
||||
" \ 'req' : 'require '
|
||||
" \ },
|
||||
" \ 'snippets' : {
|
||||
" \ 'use' : "use strict\nuse warnings\n\n",
|
||||
" \ 'warn' : "warn \"|\";",
|
||||
" \ }
|
||||
" \ }
|
||||
" \}
|
||||
"
|
||||
" You can set language attribute in html using 'zen_settings.lang'.
|
||||
"
|
||||
" GetLatestVimScripts: 2981 1 :AutoInstall: zencoding.vim
|
||||
" script type: plugin
|
||||
|
||||
if &cp || (exists('g:loaded_zencoding_vim') && g:loaded_zencoding_vim)
|
||||
finish
|
||||
endif
|
||||
let g:loaded_zencoding_vim = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:zencoding_debug')
|
||||
let g:zencoding_debug = 0
|
||||
endif
|
||||
|
||||
if !exists('g:zencoding_curl_command')
|
||||
let g:zencoding_curl_command = 'curl -s -L -A Mozilla/5.0'
|
||||
endif
|
||||
|
||||
if exists('g:use_zen_complete_tag') && g:use_zen_complete_tag
|
||||
setlocal omnifunc=zencoding#CompleteTag
|
||||
endif
|
||||
|
||||
if !exists('g:user_zen_leader_key')
|
||||
let g:user_zen_leader_key = '<c-y>'
|
||||
endif
|
||||
|
||||
function! s:install_plugin()
|
||||
for item in [
|
||||
\ {'mode': 'i', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandAbbr', 'func': '<c-g>u<esc>:call zencoding#expandAbbr(0,"")<cr>a'},
|
||||
\ {'mode': 'v', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandVisual', 'func': ':call zencoding#expandAbbr(2,"")<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandNormal', 'func': ':call zencoding#expandAbbr(3,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_expandword_key', 'key': ';', 'plug': 'ZenCodingExpandWord', 'func': '<c-g>u<esc>:call zencoding#expandAbbr(1,"")<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_expandword_key', 'key': ',', 'plug': 'ZenCodingExpandWord', 'func': ':call zencoding#expandAbbr(1,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardInsert', 'func': '<esc>:call zencoding#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardNormal', 'func': ':call zencoding#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardVisual', 'func': ':call zencoding#balanceTag(2)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardInsert', 'func': '<esc>:call zencoding#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardNormal', 'func': ':call zencoding#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardVisual', 'func': ':call zencoding#balanceTag(-2)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': '<esc>:call zencoding#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': ':call zencoding#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': '<esc>:call zencoding#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': ':call zencoding#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': '<esc>:call zencoding#imageSize()<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': ':call zencoding#imageSize()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': '<esc>:call zencoding#toggleComment()<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': ':call zencoding#toggleComment()<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_zen_mergelines_key', 'key': 'm', 'plug': 'ZenCodingMergeLines', 'func': ':call zencoding#mergeLines()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagInsert', 'func': '<esc>:call zencoding#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagNormal', 'func': ':call zencoding#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': '<esc>:call zencoding#removeTag()<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zencoding#removeTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': '<esc>:call zencoding#anchorizeURL(0)<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': ':call zencoding#anchorizeURL(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': '<esc>:call zencoding#anchorizeURL(1)<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call zencoding#anchorizeURL(1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_zen_codepretty_key', 'key': 'c', 'plug': 'ZenCodingCodePretty', 'func': ':call zencoding#codePretty()<cr>'},
|
||||
\]
|
||||
|
||||
if !hasmapto('<plug>'.item.plug, item.mode)
|
||||
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
|
||||
endif
|
||||
if !exists('g:' . item.var)
|
||||
endif
|
||||
if exists('g:' . item.var)
|
||||
let key = eval('g:' . item.var)
|
||||
else
|
||||
let key = g:user_zen_leader_key . item.key
|
||||
endif
|
||||
if len(maparg(key, item.mode)) == 0
|
||||
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
call s:install_plugin()
|
||||
delfunction s:install_plugin
|
||||
|
||||
command! -nargs=1 Zen call zencoding#expandAbbr(4, <q-args>)
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:set et:
|
||||
566
unittest.vim
566
unittest.vim
@@ -1,28 +1,40 @@
|
||||
" {{{
|
||||
let s:sfile = expand('<sfile>')
|
||||
let s:logging = 0
|
||||
|
||||
function! s:reload(d)
|
||||
exe "so" a:d."/plugin/zencoding.vim"
|
||||
exe 'so' a:d.'/plugin/emmet.vim'
|
||||
for f in split(globpath(a:d, 'autoload/**/*.vim'), "\n")
|
||||
silent! exe "so" f
|
||||
silent! exe 'so' f
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:logn(msg)
|
||||
echon a:msg
|
||||
call writefile([a:msg, ''], "test.log", "ab")
|
||||
endfunction
|
||||
|
||||
function! s:log(msg)
|
||||
echo a:msg
|
||||
call writefile(split(a:msg, "\n"), "test.log", "ab")
|
||||
endfunction
|
||||
|
||||
function! s:show_type(type)
|
||||
echohl Search | echon "[" a:type "]\n" | echohl None
|
||||
echohl Search | call s:log('['.a:type.']') | echohl None
|
||||
echo "\r"
|
||||
endfunction
|
||||
|
||||
function! s:show_category(category)
|
||||
echohl MatchParen | echon "[" a:category "]\n" | echohl None
|
||||
echohl MatchParen | call s:log('['.a:category.']') | echohl None
|
||||
echo "\r"
|
||||
endfunction
|
||||
|
||||
function! s:show_pass(pass)
|
||||
echohl Title | echo "pass".a:pass."\n" | echohl None
|
||||
echohl Title | call s:log('pass '.substitute(a:pass, '\s', '', 'g')) | echohl None
|
||||
endfunction
|
||||
|
||||
function! s:show_done()
|
||||
echohl IncSearch | echo "done" | echohl None
|
||||
echohl IncSearch | call s:log('done') | echohl None
|
||||
endfunction
|
||||
|
||||
function! s:escape(str)
|
||||
@@ -35,43 +47,45 @@ endfunction
|
||||
function! s:show_title(no, title)
|
||||
let title = s:escape(a:title)
|
||||
let width = &columns - 23
|
||||
echohl MoreMsg | echon "\rtesting #".printf("%03d", a:no)
|
||||
echohl None | echon ": " . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
|
||||
echon "\r"
|
||||
echohl MoreMsg | call s:logn('testing #'.printf('%03d', a:no))
|
||||
echohl None | call s:logn(': '.(len(title) < width ? (title.' '.repeat('.', width-len(title)+1)) : strpart(title, 0, width+2)).'... ')
|
||||
endfunction
|
||||
|
||||
function! s:show_skip(no, title)
|
||||
let title = s:escape(a:title)
|
||||
let width = &columns - 23
|
||||
echohl WarningMsg | echon "\rskipped #".printf("%03d", a:no)
|
||||
echohl None | echon ": " . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
|
||||
echo ""
|
||||
echon "\r"
|
||||
echohl WarningMsg | call s:logn('skipped #'.printf('%03d', a:no))
|
||||
echohl None | call s:logn(': '.(len(title) < width ? (title.' '.repeat('.', width-len(title)+1)) : strpart(title, 0, width+2)).'... ')
|
||||
echo ''
|
||||
endfunction
|
||||
|
||||
function! s:show_ok()
|
||||
echohl Title | echon "ok\n" | echohl None
|
||||
echo ""
|
||||
echohl Title | call s:logn('ok') | echohl None
|
||||
echo ''
|
||||
endfunction
|
||||
|
||||
function! s:show_ng(no, expect, got)
|
||||
echohl WarningMsg | echon "ng\n" | echohl None
|
||||
echohl ErrorMsg | echo "failed test #".a:no | echohl None
|
||||
echohl WarningMsg | call s:logn('ng') | echohl None
|
||||
echohl ErrorMsg | call s:log('failed test #'.a:no) | echohl None
|
||||
set more
|
||||
echohl WarningMsg | echo printf("expect(%d):", len(a:expect)) | echohl None
|
||||
echohl WarningMsg | call s:log(printf('expect(%d):', len(a:expect))) | echohl None
|
||||
echo join(split(a:expect, "\n", 1), "|\n")
|
||||
echohl WarningMsg | echo printf("got(%d):", len(a:got)) | echohl None
|
||||
echo join(split(a:got, "\n", 1), "|\n")
|
||||
echohl WarningMsg | call s:log(printf('got(%d):', len(a:got))) | echohl None
|
||||
call s:log(join(split(a:got, "\n", 1), "|\n"))
|
||||
let cs = split(a:expect, '\zs')
|
||||
for c in range(len(cs))
|
||||
if c < len(a:got)
|
||||
if a:expect[c] != a:got[c]
|
||||
echohl WarningMsg | echo "differ at:" | echohl None
|
||||
echo a:expect[c :-1]
|
||||
echohl WarningMsg | call s:log('differ at:') | echohl None
|
||||
call s:log(a:expect[c :-1])
|
||||
break
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
echo ""
|
||||
throw "stop"
|
||||
echo ''
|
||||
throw 'stop'
|
||||
endfunction
|
||||
|
||||
function! s:test(...)
|
||||
@@ -90,15 +104,25 @@ function! s:test(...)
|
||||
let start = reltime()
|
||||
for n in range(len(tests))
|
||||
if len(index) > 0 && n != index | continue | endif
|
||||
if has_key(tests[n], 'ignore') && tests[n].ignore | continue | endif
|
||||
let query = tests[n].query
|
||||
let options = has_key(tests[n], 'options') ? tests[n].options : {}
|
||||
let result = tests[n].result
|
||||
if has_key(tests[n], 'skip') && tests[n].skip != 0
|
||||
call s:show_skip(n+1, query)
|
||||
continue
|
||||
endif
|
||||
let oldoptions = {}
|
||||
for opt in keys(options)
|
||||
if has_key(g:, opt)
|
||||
let oldoptions[opt] = get(g:, opt)
|
||||
endif
|
||||
let g:[opt] = options[opt]
|
||||
endfor
|
||||
if stridx(query, '$$$$') != -1
|
||||
silent! 1new
|
||||
silent! exe "setlocal ft=".testgroup.type
|
||||
silent! exe 'setlocal ft='.testgroup.type
|
||||
EmmetInstall
|
||||
silent! let key = matchstr(query, '.*\$\$\$\$\zs.*\ze\$\$\$\$')
|
||||
if len(key) > 0
|
||||
exe printf('let key = "%s"', key)
|
||||
@@ -117,8 +141,15 @@ function! s:test(...)
|
||||
call s:show_title(n+1, query)
|
||||
else
|
||||
call s:show_title(n+1, query)
|
||||
unlet! res | let res = zencoding#ExpandWord(query, testgroup.type, 0)
|
||||
unlet! res | let res = emmet#expandWord(query, testgroup.type, 0)
|
||||
endif
|
||||
for opt in keys(options)
|
||||
if has_key(oldoptions, opt)
|
||||
let g:[opt] = oldoptions[opt]
|
||||
else
|
||||
call remove(g:, opt)
|
||||
endif
|
||||
endfor
|
||||
if stridx(result, '$$$$') != -1
|
||||
if res ==# result
|
||||
call s:show_ok()
|
||||
@@ -138,28 +169,38 @@ function! s:test(...)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:do_tests(...)
|
||||
function! s:do_tests(bang, ...)
|
||||
try
|
||||
if exists('g:user_zen_settings')
|
||||
let s:old_user_zen_settings = g:user_zen_settings
|
||||
let g:user_zen_settings = { 'indentation': "\t" }
|
||||
let s:logging = a:bang
|
||||
if exists('g:user_emmet_settings')
|
||||
let s:old_user_emmet_settings = g:user_emmet_settings
|
||||
endif
|
||||
let g:user_emmet_settings = {'variables': {'indentation': "\t", 'use_selection': 1}}
|
||||
let oldmore = &more
|
||||
call s:reload(fnamemodify(s:sfile, ':h'))
|
||||
let &more = 0
|
||||
call call('s:test', a:000)
|
||||
call s:show_done()
|
||||
if a:bang == '!'
|
||||
qall!
|
||||
endif
|
||||
catch
|
||||
echohl ErrorMsg | echomsg v:exception | echohl None
|
||||
if a:bang == '!'
|
||||
cquit!
|
||||
endif
|
||||
finally
|
||||
let &more=oldmore
|
||||
if exists('g:user_zen_settings')
|
||||
let g:user_zen_settings = s:old_user_zen_settings
|
||||
if exists('s:old_user_emmet_settings')
|
||||
let g:user_emmet_settings = s:old_user_emmet_settings
|
||||
endif
|
||||
if exists('s:old_user_emmet_install_global')
|
||||
let g:user_emmet_install_global = s:old_user_emmet_install_global
|
||||
endif
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! g:zencoding_unittest_complete(arglead, cmdline, cmdpos)
|
||||
function! s:emmet_unittest_complete(arglead, cmdline, cmdpos)
|
||||
let args = split(a:cmdline, '\s\+', 1)
|
||||
let testgroups = eval(join(filter(split(substitute(join(readfile(s:sfile), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
|
||||
try
|
||||
@@ -173,14 +214,15 @@ function! g:zencoding_unittest_complete(arglead, cmdline, cmdpos)
|
||||
return []
|
||||
endfunction
|
||||
|
||||
command! -nargs=* -complete=customlist,g:zencoding_unittest_complete ZenCodingUnitTest call s:do_tests(<f-args>)
|
||||
command! -bang -nargs=* -complete=customlist,<SID>emmet_unittest_complete EmmetUnitTest call s:do_tests("<bang>", <f-args>)
|
||||
if s:sfile == expand('%:p')
|
||||
ZenCodingUnitTest
|
||||
EmmetUnitTest
|
||||
endif
|
||||
" }}}
|
||||
|
||||
finish
|
||||
[
|
||||
{
|
||||
{ 'test-html': "{{{",
|
||||
'type': "html",
|
||||
'categories': [
|
||||
{
|
||||
@@ -212,7 +254,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "div#wrapper.box.current[title=TITLE rel]",
|
||||
'result': "<div id=\"wrapper\" rel=\"\" class=\"box current\" title=\"TITLE\"></div>\n",
|
||||
'result': "<div id=\"wrapper\" class=\"box current\" title=\"TITLE\" rel=\"\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#main+div#sub",
|
||||
@@ -248,15 +290,15 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "a[href=http://www.google.com/].foo#hoge",
|
||||
'result': "<a id=\"hoge\" href=\"http://www.google.com/\" class=\"foo\"></a>\n",
|
||||
'result': "<a id=\"hoge\" class=\"foo\" href=\"http://www.google.com/\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[href=http://www.google.com/]{Google}",
|
||||
'result': "<a href=\"http://www.google.com/\">Google</a>\n",
|
||||
},
|
||||
{
|
||||
'query': "{ZenCoding}",
|
||||
'result': "ZenCoding",
|
||||
'query': "{Emmet}",
|
||||
'result': "Emmet",
|
||||
},
|
||||
{
|
||||
'query': "a+b",
|
||||
@@ -280,23 +322,23 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "blockquote>b>i<<b",
|
||||
'result': "<blockquote><b><i></i></b></blockquote>\n<b></b>\n",
|
||||
'result': "<blockquote>\n\t<b><i></i></b>\n</blockquote>\n<b></b>\n",
|
||||
},
|
||||
{
|
||||
'query': "blockquote>b>i^^b",
|
||||
'result': "<blockquote><b><i></i></b></blockquote>\n<b></b>\n",
|
||||
'result': "<blockquote>\n\t<b><i></i></b>\n</blockquote>\n<b></b>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[href=foo][class=bar]",
|
||||
'result': "<a href=\"foo\" class=\"bar\"></a>\n",
|
||||
'result': "<a class=\"bar\" href=\"foo\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[a=b][b=c=d][e]{foo}*2",
|
||||
'result': "<a a=\"b\" b=\"c=d\" e=\"\" href=\"\">foo</a>\n<a a=\"b\" b=\"c=d\" e=\"\" href=\"\">foo</a>\n",
|
||||
'result': "<a href=\"e\" a=\"b\" b=\"c=d\">foo</a>\n<a href=\"e\" a=\"b\" b=\"c=d\">foo</a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[a=b][b=c=d][e]*2{foo}",
|
||||
'result': "<a a=\"b\" b=\"c=d\" e=\"\" href=\"\"></a>\n<a a=\"b\" b=\"c=d\" e=\"\" href=\"\"></a>\nfoo",
|
||||
'result': "<a href=\"e\" a=\"b\" b=\"c=d\"></a>\n<a href=\"e\" a=\"b\" b=\"c=d\"></a>\nfoo",
|
||||
},
|
||||
{
|
||||
'query': "a*2{foo}a",
|
||||
@@ -315,19 +357,19 @@ finish
|
||||
'result': "<table>\n\t<tr>\n\t\t<td id=\"foo\" class=\"name\"></td>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n</table>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#header + div#footer",
|
||||
'query': "div#header+div#footer",
|
||||
'result': "<div id=\"header\"></div>\n<div id=\"footer\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "#header + div#footer",
|
||||
'query': "#header+div#footer",
|
||||
'result': "<div id=\"header\"></div>\n<div id=\"footer\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "#header > ul > li < p{Footer}",
|
||||
'query': "#header>ul>li<p{Footer}",
|
||||
'result': "<div id=\"header\">\n\t<ul>\n\t\t<li></li>\n\t</ul>\n\t<p>Footer</p>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "#header > ul > li ^ p{Footer}",
|
||||
'query': "#header>ul>li^p{Footer}",
|
||||
'result': "<div id=\"header\">\n\t<ul>\n\t\t<li></li>\n\t</ul>\n\t<p>Footer</p>\n</div>\n",
|
||||
},
|
||||
{
|
||||
@@ -402,13 +444,17 @@ finish
|
||||
'query': "div>div#page>p.title+p|c",
|
||||
'result': "<div>\n\t<!-- #page -->\n\t<div id=\"page\">\n\t\t<!-- .title -->\n\t\t<p class=\"title\"></p>\n\t\t<!-- /.title -->\n\t\t<p></p>\n\t</div>\n\t<!-- /#page -->\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "kbd*2|s",
|
||||
'result': "<kbd></kbd><kbd></kbd>",
|
||||
},
|
||||
{
|
||||
'query': "link:css",
|
||||
'result': "<link media=\"all\" rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" />\n",
|
||||
'result': "<link rel=\"stylesheet\" href=\"style.css\" media=\"all\">\n",
|
||||
},
|
||||
{
|
||||
'query': "a[title=\"Hello', world\" rel]",
|
||||
'result': "<a rel=\"\" href=\"\" title=\"Hello', world\"></a>\n",
|
||||
'result': "<a href=\"\" title=\"Hello', world\" rel=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "div>a#foo{bar}",
|
||||
@@ -460,7 +506,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "(div>(label+input))+div",
|
||||
'result': "<div>\n\t<label for=\"\"></label>\n\t<input type=\"\" />\n</div>\n<div></div>\n",
|
||||
'result': "<div>\n\t<label for=\"\"></label>\n\t<input type=\"\">\n</div>\n<div></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "test1\ntest2\ntest3$$$$\\<esc>ggVG\\<c-y>,ul>li>span*>a\\<cr>$$$$",
|
||||
@@ -468,12 +514,20 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "test1\ntest2\ntest3$$$$\\<esc>ggVG\\<c-y>,input[type=input value=$#]*\\<cr>$$$$",
|
||||
'result': "<input type=\"input\" value=\"test1\" />\n<input type=\"input\" value=\"test2\" />\n<input type=\"input\" value=\"test3\" />",
|
||||
'result': "<input type=\"input\" value=\"test1\">\n<input type=\"input\" value=\"test2\">\n<input type=\"input\" value=\"test3\">",
|
||||
},
|
||||
{
|
||||
'query': "test1\ntest2\ntest3$$$$\\<esc>ggVG\\<c-y>,div[id=$#]*\\<cr>$$$$",
|
||||
'result': "<div id=\"test1\"></div>\n<div id=\"test2\"></div>\n<div id=\"test3\"></div>",
|
||||
},
|
||||
{
|
||||
'query': "div#id-$*5>div#id2-$",
|
||||
'result': "<div id=\"id-1\">\n\t<div id=\"id2-1\"></div>\n</div>\n<div id=\"id-2\">\n\t<div id=\"id2-2\"></div>\n</div>\n<div id=\"id-3\">\n\t<div id=\"id2-3\"></div>\n</div>\n<div id=\"id-4\">\n\t<div id=\"id2-4\"></div>\n</div>\n<div id=\"id-5\">\n\t<div id=\"id2-5\"></div>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': ".foo>[bar=2]>.baz",
|
||||
'result': "<div class=\"foo\">\n\t<div bar=\"2\">\n\t\t<div class=\"baz\"></div>\n\t</div>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "{test case $ }*3",
|
||||
'result': "test case 1 test case 2 test case 3 ",
|
||||
@@ -490,6 +544,30 @@ finish
|
||||
'query': "{test case $$$ }*3",
|
||||
'result': "test case 001 test case 002 test case 003 ",
|
||||
},
|
||||
{
|
||||
'query': "a[title=$#]{foo}",
|
||||
'result': "<a href=\"\" title=\"foo\">foo</a>\n",
|
||||
},
|
||||
{
|
||||
'query': "span.item$*2>{item $}",
|
||||
'result': "<span class=\"item1\">item 1</span>\n<span class=\"item2\">item 2</span>\n",
|
||||
},
|
||||
{
|
||||
'query': "\t<div class=\"footer_nav\">\n\t\t<a href=\"#\">nav link</a>\n\t</div>$$$$\\<esc>ggVG\\<c-y>,div\\<cr>$$$$",
|
||||
'result': "\t<div>\n\t\t<div class=\"footer_nav\">\n\t\t\t<a href=\"#\">nav link</a>\n\t\t</div>\n\t</div>",
|
||||
},
|
||||
{
|
||||
'query': "<small>a$$$$</small>",
|
||||
'result': "<small><a href=\"\"></a></small>",
|
||||
},
|
||||
{
|
||||
'query': "form.search-form._wide>input.-query-string+input:s.-btn_large|bem",
|
||||
'result': "<form class=\"search-form search-form_wide\" action=\"\">\n\t<input class=\"search-form__query-string\" type=\"\">\n\t<input class=\"search-form__btn search-form__btn_large\" type=\"submit\" value=\"\">\n</form>\n",
|
||||
},
|
||||
{
|
||||
'query': "form>fieldset>legend+(label>input[type=\"checkbox\"])*3",
|
||||
'result': "<form action=\"\">\n\t<fieldset>\n\t\t<legend></legend>\n\t\t<label for=\"\"><input type=\"checkbox\"></label>\n\t\t<label for=\"\"><input type=\"checkbox\"></label>\n\t\t<label for=\"\"><input type=\"checkbox\"></label>\n\t</fieldset>\n</form>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -497,12 +575,20 @@ finish
|
||||
'tests': [
|
||||
{
|
||||
'query': "<div>\n\t<span>$$$$\\<c-y>j$$$$</span>\n</div>",
|
||||
'result': "<div>\n\t<span/>\n</div>",
|
||||
'result': "<div>\n\t<span />\n</div>",
|
||||
},
|
||||
{
|
||||
'query': "<div>\n\t<span$$$$\\<c-y>j$$$$/>\n</div>",
|
||||
'result': "<div>\n\t<span></span>\n</div>",
|
||||
},
|
||||
{
|
||||
'query': "<div onclick=\"javascript:console.log(Date.now() % 1000 > 500)\">test$$$$\\<c-y>j$$$$/>\n</div>",
|
||||
'result': "<div onclick=\"javascript:console.log(Date.now() % 1000 > 500)\" />",
|
||||
},
|
||||
{
|
||||
'query': "<div>\n\t<some-tag$$$$\\<c-y>j$$$$/>\n</div>",
|
||||
'result': "<div>\n\t<some-tag></some-tag>\n</div>",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -523,11 +609,15 @@ finish
|
||||
'tests': [
|
||||
{
|
||||
'query': "img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$",
|
||||
'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"96\" height=\"96\" />",
|
||||
'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"113\" height=\"113\">",
|
||||
},
|
||||
{
|
||||
'query': "img[src=/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$",
|
||||
'result': "<img src=\"/logo.png\" alt=\"\" />",
|
||||
'result': "<img src=\"/logo.png\" alt=\"\">",
|
||||
},
|
||||
{
|
||||
'query': "img[src=http://mattn.kaoriya.net/images/logo.png width=foo height=bar]$$$$\\<c-y>,\\<c-y>i$$$$",
|
||||
'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"113\" height=\"113\">",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -540,91 +630,197 @@ finish
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'contains dash in attributes',
|
||||
'tests': [
|
||||
{
|
||||
'query': "div[foo-bar=\"baz\"]",
|
||||
'result': "<div foo-bar=\"baz\"></div>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
},
|
||||
{
|
||||
'name': 'default attributes',
|
||||
'tests': [
|
||||
{
|
||||
'query': "p.title>a[/hoge/]",
|
||||
'result': "<p class=\"title\"><a href=\"/hoge/\"></a></p>\n",
|
||||
},
|
||||
{
|
||||
'query': "script[jquery.js]",
|
||||
'result': "<script src=\"jquery.js\"></script>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'multiple group',
|
||||
'tests': [
|
||||
{
|
||||
'query': ".outer$*3>.inner$*2",
|
||||
'result': "<div class=\"outer1\">\n\t<div class=\"inner1\"></div>\n\t<div class=\"inner2\"></div>\n</div>\n<div class=\"outer2\">\n\t<div class=\"inner1\"></div>\n\t<div class=\"inner2\"></div>\n</div>\n<div class=\"outer3\">\n\t<div class=\"inner1\"></div>\n\t<div class=\"inner2\"></div>\n</div>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'group itemno',
|
||||
'tests': [
|
||||
{
|
||||
'query': "dl>(dt{$}+dd)*3",
|
||||
'result': "<dl>\n\t<dt>1</dt>\n\t<dd></dd>\n\t<dt>2</dt>\n\t<dd></dd>\n\t<dt>3</dt>\n\t<dd></dd>\n</dl>\n",
|
||||
},
|
||||
{
|
||||
'query': "(div[attr=$]*3)*3",
|
||||
'result': "<div attr=\"1\"></div>\n<div attr=\"2\"></div>\n<div attr=\"3\"></div>\n<div attr=\"1\"></div>\n<div attr=\"2\"></div>\n<div attr=\"3\"></div>\n<div attr=\"1\"></div>\n<div attr=\"2\"></div>\n<div attr=\"3\"></div>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'update tag',
|
||||
'tests': [
|
||||
{
|
||||
'query': "<h$$$$\\<c-y>u.global\\<cr>$$$$3></h3>",
|
||||
'result': "<h3 class=\"global\"></h3>",
|
||||
},
|
||||
{
|
||||
'query': "<button$$$$\\<c-y>u.btn\\<cr>$$$$ disabled></button>",
|
||||
'result': "<button class=\"btn\" disabled></button>",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'base value',
|
||||
'tests': [
|
||||
{
|
||||
'query': "ul>li#id$@0*3",
|
||||
'result': "<ul>\n\t<li id=\"id0\"></li>\n\t<li id=\"id1\"></li>\n\t<li id=\"id2\"></li>\n</ul>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'dummy': "}}}"},
|
||||
{ 'test-css': '{{{',
|
||||
'type': 'css',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "@i",
|
||||
'result': "@import url();",
|
||||
'query': "{fs:n$$$$}",
|
||||
'result': "{font-style: normal;}",
|
||||
},
|
||||
{
|
||||
'query': "fs:n",
|
||||
'result': "font-style: normal;",
|
||||
'query': "{fl:l|fc$$$$}",
|
||||
'result': "{float: left;}",
|
||||
},
|
||||
{
|
||||
'query': "fl:l|fc",
|
||||
'result': "float: left;",
|
||||
'query': "{bg+$$$$}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat;}",
|
||||
},
|
||||
{
|
||||
'query': "bg+$$$$",
|
||||
'result': "background: #FFF url($$$$) 0 0 no-repeat;",
|
||||
'query': "{bg+!$$$$}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat !important;}",
|
||||
},
|
||||
{
|
||||
'query': "bg+!$$$$",
|
||||
'result': "background: #FFF url($$$$) 0 0 no-repeat !important;",
|
||||
'query': "{m$$$$}",
|
||||
'result': "{margin: $$$$;}",
|
||||
},
|
||||
{
|
||||
'query': "m$$$$",
|
||||
'result': "margin: $$$$;",
|
||||
'query': "{m0.1p$$$$}",
|
||||
'result': "{margin: 0.1%;}",
|
||||
},
|
||||
{
|
||||
'query': "m0.1p$$$$",
|
||||
'result': "margin: 0.1%;",
|
||||
'query': "{m1.0$$$$}",
|
||||
'result': "{margin: 1.0em;}",
|
||||
},
|
||||
{
|
||||
'query': "m1.0$$$$",
|
||||
'result': "margin: 1.0em;",
|
||||
'query': "{m2$$$$}",
|
||||
'result': "{margin: 2px;}",
|
||||
},
|
||||
{
|
||||
'query': "m2$$$$",
|
||||
'result': "margin: 2px;",
|
||||
'query': "{bdrs10$$$$}",
|
||||
'result': "{border-radius: 10px;}",
|
||||
},
|
||||
{
|
||||
'query': "bdrs10$$$$",
|
||||
'result': "border-radius: 10px;",
|
||||
'query': "{-bdrs20$$$$}",
|
||||
'result': "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}",
|
||||
},
|
||||
{
|
||||
'query': "-bdrs20$$$$",
|
||||
'result': "-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\nborder-radius: 20px;",
|
||||
'query': "{lg(top,#fff,#000)$$$$}",
|
||||
'result': "{background-image: -webkit-gradient(top, 0 0, 0 100, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}",
|
||||
},
|
||||
{
|
||||
'query': "lg(top,#fff,#000)$$$$",
|
||||
'result': "background-image: -webkit-gradient(top, 0 0, 0 100, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n",
|
||||
'query': "{m10-5-0$$$$}",
|
||||
'result': "{margin: 10px 5px 0;}",
|
||||
},
|
||||
{
|
||||
'query': "m10-5-0$$$$",
|
||||
'result': "margin: 10px 5px 0px;",
|
||||
'query': "{m-10--5$$$$}",
|
||||
'result': "{margin: -10px -5px;}",
|
||||
},
|
||||
{
|
||||
'query': "m-10--5$$$$",
|
||||
'result': "margin: -10px -5px;",
|
||||
'query': "{m10-auto$$$$}",
|
||||
'result': "{margin: 10px auto;}",
|
||||
},
|
||||
{
|
||||
'query': "m10-auto$$$$",
|
||||
'result': "margin: 10px auto;",
|
||||
'query': "{w100p$$$$}",
|
||||
'result': "{width: 100%;}",
|
||||
},
|
||||
{
|
||||
'query': "w100p$$$$",
|
||||
'result': "width: 100%;",
|
||||
'query': "{h50e$$$$}",
|
||||
'result': "{height: 50em;}",
|
||||
},
|
||||
{
|
||||
'query': "h50e$$$$",
|
||||
'result': "height: 50em;",
|
||||
'query': "{(bg+)+c$$$$}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}",
|
||||
},
|
||||
{
|
||||
'query': "(bg+)+c$$$$",
|
||||
'result': "background: #FFF url($$$$) 0 0 no-repeat;\ncolor: #000;",
|
||||
'query': "{m0+bgi+bg++p0$$$$}",
|
||||
'result': "{margin: 0;\nbackground-image: url($$$$);\nbackground: #fff url() 0 0 no-repeat;\npadding: 0;}",
|
||||
},
|
||||
{
|
||||
'query': "{borle$$$$}",
|
||||
'result': "{border-left: $$$$;}",
|
||||
},
|
||||
{
|
||||
'query': "{c#dba$$$$}",
|
||||
'result': "{color: rgb(221, 187, 170);}",
|
||||
},
|
||||
{
|
||||
'query': "{c#dba.7$$$$}",
|
||||
'result': "{color: rgb(221, 187, 170, 0.7);}",
|
||||
},
|
||||
{
|
||||
'query': "{dn$$$$}",
|
||||
'result': "{display: none;}",
|
||||
},
|
||||
{
|
||||
'query': "{p10%$$$$}",
|
||||
'result': "{padding: 10%;}",
|
||||
},
|
||||
{
|
||||
'query': "{p10p$$$$}",
|
||||
'result': "{padding: 10%;}",
|
||||
},
|
||||
{
|
||||
'query': "{p10e$$$$}",
|
||||
'result': "{padding: 10em;}",
|
||||
},
|
||||
{
|
||||
'query': "{p10em$$$$}",
|
||||
'result': "{padding: 10em;}",
|
||||
},
|
||||
{
|
||||
'query': "{p10re$$$$}",
|
||||
'result': "{padding: 10rem;}",
|
||||
},
|
||||
{
|
||||
'query': "{p10rem$$$$}",
|
||||
'result': "{padding: 10rem;}",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'dummy': "}}}"},
|
||||
{ 'test-haml': '{{{',
|
||||
'type': 'haml',
|
||||
'categories': [
|
||||
{
|
||||
@@ -646,10 +842,14 @@ finish
|
||||
'query': ".content{Hello!}|haml",
|
||||
'result': "%div.content Hello!\n",
|
||||
},
|
||||
{
|
||||
'query': "a[title=$#]{foo}",
|
||||
'result': "%a{ :href => \"\", :title => \"foo\" } foo\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'name': 'split join',
|
||||
'tests': [
|
||||
{
|
||||
'query': "%a foo\n bar$$$$\\<c-y>j$$$$",
|
||||
@@ -675,8 +875,8 @@ finish
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'dummy': "}}}"},
|
||||
{ 'test-slim': "{{{",
|
||||
'type': 'slim',
|
||||
'categories': [
|
||||
{
|
||||
@@ -684,11 +884,11 @@ finish
|
||||
'tests': [
|
||||
{
|
||||
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}",
|
||||
'result': "div\n p\n ul id=\"foo\"\n li foo=\"bar\" bar=\"baz\" class=\"bar1\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar2\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar3\"\n | baz\n",
|
||||
'result': "div\n p\n ul id=\"foo\"\n li class=\"bar1\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar2\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar3\" foo=\"bar\" bar=\"baz\"\n | baz\n",
|
||||
},
|
||||
{
|
||||
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|slim",
|
||||
'result': "div\n p\n ul id=\"foo\"\n li foo=\"bar\" bar=\"baz\" class=\"bar1\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar2\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar3\"\n | baz\n",
|
||||
'result': "div\n p\n ul id=\"foo\"\n li class=\"bar1\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar2\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar3\" foo=\"bar\" bar=\"baz\"\n | baz\n",
|
||||
},
|
||||
{
|
||||
'query': "a*3|slim",
|
||||
@@ -698,6 +898,10 @@ finish
|
||||
'query': ".content{Hello!}|slim",
|
||||
'result': "div class=\"content\"\n | Hello!\n",
|
||||
},
|
||||
{
|
||||
'query': "a[title=$#]{foo}",
|
||||
'result': "a href=\"\" title=\"foo\"\n | foo\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -727,8 +931,8 @@ finish
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'dummy': "}}}"},
|
||||
{ 'test-xsl': "{{{",
|
||||
'type': 'xsl',
|
||||
'categories': [
|
||||
{
|
||||
@@ -740,13 +944,13 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "ap>wp",
|
||||
'result': "<xsl:apply-templates select=\"\" mode=\"\">\n\t<xsl:with-param select=\"\" name=\"\"></xsl:with-param>\n</xsl:apply-templates>\n",
|
||||
'result': "<xsl:apply-templates select=\"\" mode=\"\">\n\t<xsl:with-param name=\"\" select=\"\"></xsl:with-param>\n</xsl:apply-templates>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'dummy': "}}}"},
|
||||
{ 'test-xsd': "{{{",
|
||||
'type': 'xsd',
|
||||
'categories': [
|
||||
{
|
||||
@@ -754,13 +958,13 @@ finish
|
||||
'tests': [
|
||||
{
|
||||
'query': "xsd:w3c",
|
||||
'result': "<?xml version=\"1.0\"?>\n<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n\t<xsd:element name=\"\" type=\"\"/>\n</xsd:schema>",
|
||||
'result': "<?xml version=\"1.0\"?>\n<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n\t<xsd:element name=\"\" type=\"\"/>\n</xsd:schema>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'dummy': "}}}"},
|
||||
{ 'test-mustache': "{{{",
|
||||
'type': 'mustache',
|
||||
'categories': [
|
||||
{
|
||||
@@ -777,6 +981,150 @@ finish
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
'dummy': "}}}"},
|
||||
{ 'test-sass': "{{{",
|
||||
'type': 'scss',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "@i$$$$",
|
||||
'result': "@import url();",
|
||||
},
|
||||
{
|
||||
'query': "{fs:n$$$$}",
|
||||
'result': "{font-style: normal;}",
|
||||
},
|
||||
{
|
||||
'query': "{fl:l|fc$$$$}",
|
||||
'result': "{float: left;}",
|
||||
},
|
||||
{
|
||||
'query': "{bg+$$$$}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat;}",
|
||||
},
|
||||
{
|
||||
'query': "{bg+!$$$$}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat !important;}",
|
||||
},
|
||||
{
|
||||
'query': "{m$$$$}",
|
||||
'result': "{margin: $$$$;}",
|
||||
},
|
||||
{
|
||||
'query': "{m0.1p$$$$}",
|
||||
'result': "{margin: 0.1%;}",
|
||||
},
|
||||
{
|
||||
'query': "{m1.0$$$$}",
|
||||
'result': "{margin: 1.0em;}",
|
||||
},
|
||||
{
|
||||
'query': "{m2$$$$}",
|
||||
'result': "{margin: 2px;}",
|
||||
},
|
||||
{
|
||||
'query': "{bdrs10$$$$}",
|
||||
'result': "{border-radius: 10px;}",
|
||||
},
|
||||
{
|
||||
'query': "{-bdrs20$$$$}",
|
||||
'result': "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}",
|
||||
},
|
||||
{
|
||||
'query': "{lg(top,#fff,#000)$$$$}",
|
||||
'result': "{background-image: -webkit-gradient(top, 0 0, 0 100, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}",
|
||||
},
|
||||
{
|
||||
'query': "{m10-5-0$$$$}",
|
||||
'result': "{margin: 10px 5px 0;}",
|
||||
},
|
||||
{
|
||||
'query': "{m-10--5$$$$}",
|
||||
'result': "{margin: -10px -5px;}",
|
||||
},
|
||||
{
|
||||
'query': "{m10-auto$$$$}",
|
||||
'result': "{margin: 10px auto;}",
|
||||
},
|
||||
{
|
||||
'query': "{w100p$$$$}",
|
||||
'result': "{width: 100%;}",
|
||||
},
|
||||
{
|
||||
'query': "{h50e$$$$}",
|
||||
'result': "{height: 50em;}",
|
||||
},
|
||||
{
|
||||
'query': "{(bg+)+c$$$$}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'dummy': "}}}"},
|
||||
{ 'test-jade': "{{{",
|
||||
'type': 'jade',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "!!!$$$$\\<c-y>,$$$$",
|
||||
'result': "doctype html\n\n",
|
||||
},
|
||||
{
|
||||
'query': "span.my-span$$$$\\<c-y>,$$$$",
|
||||
'result': "span.my-span",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'dummy': "}}}"},
|
||||
{ 'test-pug': "{{{",
|
||||
'type': 'pug',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "!!!$$$$\\<c-y>,$$$$",
|
||||
'result': "doctype html\n\n",
|
||||
},
|
||||
{
|
||||
'query': "span.my-span$$$$\\<c-y>,$$$$",
|
||||
'result': "span.my-span",
|
||||
},
|
||||
{
|
||||
'query': "input$$$$\\<c-y>,text$$$$",
|
||||
'result': "input(type=\"text\")",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'dummy': "}}}"},
|
||||
{ 'test-jsx': "{{{",
|
||||
'type': 'javascript.jsx',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "img$$$$\\<c-y>,$$$$",
|
||||
'result': "<img src=\"\" alt=\"\" />",
|
||||
},
|
||||
{
|
||||
'query': "span.my-span$$$$\\<c-y>,$$$$",
|
||||
'result': "<span className=\"my-span\"></span>",
|
||||
},
|
||||
{
|
||||
'query': "function() { return span.my-span$$$$\\<c-y>,$$$$; }",
|
||||
'result': "function() { return <span className=\"my-span\"></span>; }",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'dummy': "}}}"},
|
||||
]
|
||||
" vim:set et:
|
||||
" vim:set et fdm=marker:
|
||||
|
||||
Reference in New Issue
Block a user