209 Commits

Author SHA1 Message Date
Yasuhiro Matsumoto
cc8b1a9f22 Fix basevalue access before empty string check in parseIntoTree
l:basevalue[1] was accessed before checking if l:basevalue is empty.
Moved the empty check first so l:basedirect is only computed when
l:basevalue is non-empty.
2026-03-07 16:46:10 +09:00
Yasuhiro Matsumoto
fbb61e7ef2 Use shellescape() for external commands to prevent command injection
File paths passed to system() via xxd and identify were using manual
double-quote wrapping instead of shellescape(), which could allow
command injection with specially crafted filenames.
2026-03-07 16:45:56 +09:00
Yasuhiro Matsumoto
8623326f4c Fix mergeConfig() list merge bug
When merging two lists, l:rhi is a value from iteration (not an index),
so l:rhs[l:rhi] was incorrectly using values as indices. Changed to use
l:rhi directly. Also removed the redundant l:lhs += l:rhs before the
clear-and-rebuild loop.
2026-03-07 16:44:58 +09:00
Yasuhiro Matsumoto
edb1941955 Fix duplicate mergeLines() definition
The second definition without 'range' was overwriting the first one,
causing the visual selection merge to not work properly. Removed the
duplicate and kept the lang-delegating version.
2026-03-07 16:44:38 +09:00
Yasuhiro Matsumoto
7c44caa0e6 Refactoring 2026-03-07 11:08:24 +09:00
mattn
e983971449 Merge pull request #566 from mmppppss/master
fix bug in len() invalid
2025-07-15 11:44:13 +09:00
Pedro Pozo
56199c129a fix bugemmet.vim
in files with double extension type: "hola.txt.md" it generated an error
it is because you were passing a null to len() that detects if the file does not have an extension len(type)==0
2025-07-14 21:12:24 -04:00
mattn
6c511a8d7d Merge pull request #558 from kola-web/master
support treesitter
2024-08-10 11:07:49 +09:00
kola
033476412e Change treesitter judgment method 2024-08-10 09:32:53 +08:00
kola
8f1581550d my_utils.lua -> emmet_utils.lua 2024-08-10 09:29:20 +08:00
kola
c5c5188a0b support treesitter 2024-08-09 18:06:47 +08:00
Yasuhiro Matsumoto
3fb2f63799 support avif for image encode/decode 2024-06-14 23:09:53 +09:00
mattn
def5d57a1a Merge pull request #533 from eight04/dev-update-tag-name
Fix: make updateTag work with tag name
2021-12-05 00:38:44 +09:00
eight04
f4c999bdf2 Fix: updateTag doesn't support hyphen 2021-12-04 22:28:25 +08:00
eight04
f960b9bd59 Fix: make updateTag work with tag name 2021-12-04 00:23:16 +08:00
mattn
1b7e460de0 Merge pull request #523 from snxx-lppxx/master
Update README.mkd
2021-09-30 23:47:58 +09:00
snxx
f0df5fa676 Update README.mkd 2021-09-30 19:26:28 +05:00
mattn
baf5546734 Merge pull request #492 from nhooyr/master
Make mappings silent by default
2021-09-30 00:57:53 +09:00
mattn
58e24035cc Merge pull request #514 from thecodemensch/master
Update README.mkd for responsive snippet
2021-09-30 00:46:54 +09:00
mattn
4ea41b2cba Merge pull request #522 from skylarmb/patch-1
Update README.mkd
2021-09-30 00:44:43 +09:00
snxx
f2a80ddfa2 Update README.mkd 2021-09-29 00:03:02 +05:00
snxx
413fb145fe Update README.mkd 2021-09-29 00:01:22 +05:00
Skylar
8b079dcf6e Update README.mkd
Fixes broken github pages links. github.com urls for github pages sites are deprecated as of earlier this year and should be replaced with github.io
2021-09-08 09:17:29 -07:00
Yasuhiro Matsumoto
46e60676f2 Add note
Closes #148
2021-04-17 21:42:11 +09:00
mattn
1f5daf6810 Merge pull request #515 from ChristianChiarulli/master
Support javascriptreact and typescriptreact filetypes fixes: #505
2021-03-20 21:22:08 +09:00
Chris
15216aa849 Add support for javascriptreact and typescriptreact filetypes fixes: #505 2021-03-19 22:19:26 -04:00
Ibrahim
209220ee02 Updated README.mkd for responsiveness snippet 2021-03-03 12:34:22 +05:30
ibrahim
fc547c48a8 Added meta tag for responsiveness. 2021-03-02 16:31:33 +05:30
Yasuhiro Matsumoto
60930a968d Fix syntax 2020-10-22 08:22:30 +09:00
mattn
8255d7d0b9 Merge pull request #502 from mattn/use-autocmd
Use autocmd to apply syntax styledEmmetAbbreviation
2020-10-20 18:23:42 +09:00
Yasuhiro Matsumoto
9c526a43d6 Use autocmd to apply syntax styledEmmetAbbreviation 2020-10-20 17:36:24 +09:00
mattn
a46a282c5e Merge pull request #501 from gitusp/support-styled-components
Support CSS in JS syntax
2020-10-19 12:20:26 +09:00
gitusp
f8e6431776 Add support for CSS in JS annotations like css` and styled.*` 2020-10-19 10:34:50 +09:00
Anmol Sethi
1533dd03a1 Make mappings silent by default
Closes #361
2020-07-29 12:19:11 -04:00
Yasuhiro Matsumoto
dc6cb4fd07 Remove atttribues with setting v:null in default_attributes 2020-06-21 00:27:03 +09:00
mattn
76285f8ec4 Merge pull request #484 from grohiro/boolean_attr
Fix updateTag() boolean attribute
2020-05-04 11:03:35 +09:00
grohiro
e4d9455d5a Fix updateTag with boolean attr 2020-05-04 01:18:35 +09:00
mattn
c7643e5b61 Merge pull request #477 from zorro/fix445
fix for #445
2020-03-07 20:01:46 +09:00
Arun
e9033d0d88 fix for #445 2020-03-07 15:11:56 +05:30
mattn
5f559fae12 Update FUNDING.yml 2019-10-08 17:37:10 +09:00
mattn
10b3746ecb Merge pull request #468 from r6eve/fix/minor-typo
Fix minor typo
2019-08-27 18:25:18 +09:00
r6eve
61deeebdc9 Fix minor typo 2019-08-27 18:15:14 +09:00
Yasuhiro Matsumoto
37203af2b3 Add LICENSE 2019-08-27 15:06:44 +09:00
mattn
461700696e Merge pull request #462 from baxter2/installation-pathogen
explicit installation instructions for pathogen
2019-07-24 15:34:43 +09:00
baxter2
ef1d557b59 explicit installation instructions for pathogen 2019-07-24 15:55:53 +10:00
Yasuhiro Matsumoto
15ef997d4d Implement imageEncode on CSS 2019-06-24 23:35:52 +09:00
Yasuhiro Matsumoto
f4afd031a3 Fix next item in CSS 2019-06-24 23:20:54 +09:00
Yasuhiro Matsumoto
5a7c7930c6 Fix mergeLines() 2019-06-20 00:32:53 +09:00
Yasuhiro Matsumoto
3f53d7b637 Add mergeLines() 2019-06-20 00:05:36 +09:00
Yasuhiro Matsumoto
9f854c868e Add mergeLines() 2019-06-20 00:02:06 +09:00
Yasuhiro Matsumoto
6ee9d6d417 rename 2019-06-19 23:39:03 +09:00
Yasuhiro Matsumoto
685359e892 Merge branch 'master' of https://github.com/mattn/emmet-vim 2019-06-19 14:56:36 +09:00
Yasuhiro Matsumoto
b9f1ae467b Fix remove tag 2019-06-19 01:39:37 +09:00
Yasuhiro Matsumoto
32dd6d3064 Fix split/join tag 2019-06-19 01:08:51 +09:00
Yasuhiro Matsumoto
50b44d90c9 Fix hang-up while split/join tag 2019-06-19 00:46:33 +09:00
Yasuhiro Matsumoto
7b08b89d7d Implement image encode 2019-06-18 15:44:00 +09:00
Yasuhiro Matsumoto
d02023cd7a Fix unit expanding 2019-06-18 03:56:28 +09:00
Yasuhiro Matsumoto
6039842751 Fix unit expanding 2019-06-18 03:49:40 +09:00
Yasuhiro Matsumoto
dad174f359 auto is not unit name 2019-06-18 03:25:51 +09:00
Yasuhiro Matsumoto
47c28892d9 Fix unit expanding 2019-06-18 03:22:31 +09:00
Yasuhiro Matsumoto
192d22fe69 Handle ex 2019-06-18 03:10:06 +09:00
Yasuhiro Matsumoto
24fbb0aef7 Fix move next/prev 2019-06-07 15:18:29 +09:00
mattn
0414b53a23 Update FUNDING.yml 2019-05-23 23:51:11 +09:00
mattn
369a5420f0 Update FUNDING.yml 2019-05-23 23:49:26 +09:00
mattn
456d094ef3 Create FUNDING.yml 2019-05-23 23:43:41 +09:00
mattn
633320d968 Merge pull request #459 from mattn/fix-dot
Fix unittest
2019-05-23 20:23:08 +09:00
Yasuhiro Matsumoto
5531b23f20 Fix unittest 2019-05-23 20:20:45 +09:00
Yasuhiro Matsumoto
b7cc3a743f Fix emmet#isExpandable()
Fixes #458
2019-05-23 18:52:17 +09:00
mattn
758421535f Merge pull request #456 from mattn/fix-balance
Fix balance tag
2019-05-19 23:28:37 +09:00
Yasuhiro Matsumoto
6a6dc6e093 Fix balance tag 2019-05-19 23:26:36 +09:00
mattn
97b0b6c643 Merge pull request #455 from M4R7iNP/fix-root-filetype-detection
get extends recursively, minor additional fixes for pug and jsx
2019-05-19 22:03:15 +09:00
Martin Pedersen
f8fc806a61 get extends recursively, minor additional fixes for pug and jsx 2019-05-09 01:14:00 +02:00
Yasuhiro Matsumoto
ae7d31f290 Fixes #452, #448 2019-04-16 00:21:28 +09:00
Yasuhiro Matsumoto
d698f16587 Expand lorem with div only when there is multiplier. 2019-02-11 00:04:31 +09:00
mattn
19f2821b7b Merge pull request #447 from mattn/ignore-embeded
Add ignore_embeded_filetype since slim filetype is confusing to html.
2019-01-29 01:03:24 +09:00
Yasuhiro Matsumoto
922784dad6 Fix Makefile 2019-01-29 00:57:37 +09:00
Yasuhiro Matsumoto
eb8a4782ba Fix css 2019-01-29 00:54:17 +09:00
Yasuhiro Matsumoto
b79f9128d3 Fix test 2019-01-29 00:41:06 +09:00
Yasuhiro Matsumoto
5d6870c0af Add ignore_embeded_filetype 2019-01-29 00:15:23 +09:00
Yasuhiro Matsumoto
5fc2cc0fae xenial 2019-01-29 00:09:20 +09:00
Yasuhiro Matsumoto
d99b422a39 Add ignore_embeded_filetype since slim filetype is confusing to html. 2019-01-28 23:59:03 +09:00
mattn
3720be60fb Merge pull request #446 from soywod/master
Add support for TypeScript
2019-01-28 23:50:20 +09:00
Clément DOUIN
313e241932 add support for typescript 2019-01-28 14:21:25 +01:00
Yasuhiro Matsumoto
19e3240bf3 Fix getFileType 2019-01-16 21:57:43 +09:00
mattn
e6fb10d22a Merge pull request #416 from rgalbo/patch-1
fix a broken markdown heading
2018-11-29 15:56:27 +09:00
mattn
d2a7edf1ad Merge pull request #440 from tyru/add-gitlink
[Fix] Add gitlink of 'docs'
2018-11-29 15:55:44 +09:00
tyru
37ac8c3421 fix: add gitlink of 'docs'
.gitmodules has 'docs' entry, but no gitlink is committed in this
repository.
So volt (more specifically, go-git library) results in the error.
https://github.com/vim-volt/volt/issues/260
2018-11-10 13:46:15 +09:00
mattn
7492853a59 Merge pull request #439 from mattn/fix436
add dot into pattern of attributes
2018-11-09 15:44:46 +09:00
Yasuhiro Matsumoto
88ecfac350 add dot into pattern of attributes
Fixes #436
2018-11-09 15:42:39 +09:00
mattn
7a4bf3463e Merge pull request #433 from jpsouzasilva/prioritize-syntax
Prioritizes syntax at the current cursor position for determining the file type
2018-10-06 13:36:39 +09:00
jpsouzasilva
a33b7273a1 Removes extra spaces at line 523 2018-09-07 22:22:44 -03:00
jpsouzasilva
64656d8d4b Fixes the file identification for JSX 2018-08-30 08:11:50 -03:00
jpsouzasilva
0e20db0cb7 Changes from PR review #1 2018-08-29 13:17:06 -03:00
jpsouzasilva
581ba25bf8 Simplify pattern rules for matching single word syntax naming 2018-08-28 23:55:27 -03:00
jpsouzasilva
9cce773acb Case-insensitive type string matching
Fixing the plugin for Vim 7.4 (Travis)
2018-08-28 23:46:27 -03:00
jpsouzasilva
ca2b158737 Deleting the test.log file 2018-08-28 22:06:59 -03:00
jpsouzasilva
03c2309f44 Attempt at fixing the Javascript identifier pattern
Running tests locally seems OK!
2018-08-28 22:05:06 -03:00
jpsouzasilva
3dcdbff913 Remove empty string comparison for xml identification 2018-08-25 15:49:54 -03:00
jpsouzasilva
7843f18e40 Prioritizes syntax at the current cursor position for determining the file type 2018-08-25 15:22:18 -03:00
Yasuhiro Matsumoto
63c98d801b Merge branch 'master' of https://github.com/mattn/emmet-vim 2018-08-07 16:05:04 +09:00
Yasuhiro Matsumoto
645258ddd4 element configuration should be overridable
Fixes #432
2018-08-07 16:03:23 +09:00
Yasuhiro Matsumoto
2ac3648bc8 fix custom expanding
closes #429
2018-08-06 22:31:34 +09:00
Yasuhiro Matsumoto
3fb134b503 fix finding begining of token
closes #428
2018-07-19 01:02:57 +09:00
Yasuhiro Matsumoto
dcf8f6efd8 treat foo. as boolean attributes
closes #426
2018-07-13 12:56:55 +09:00
Yasuhiro Matsumoto
e7dd13a750 fix custom tag 2018-07-13 12:01:46 +09:00
Yasuhiro Matsumoto
f5b185e3a2 fix zero origin base value
closes #420
2018-05-21 10:39:09 +09:00
mattn
acc5ac7a9b Merge pull request #421 from Giorgiosaud/master
get blade syntax
2018-05-21 10:09:01 +09:00
Yasuhiro Matsumoto
fb31b5dbb6 make child node if current node have a name already
related #272
2018-05-02 14:29:53 +09:00
Yasuhiro Matsumoto
1ba2eb67fb fix attribute pattern 2018-04-25 11:15:55 +09:00
Yasuhiro Matsumoto
a0aa79d660 use : prefix for localvar 2018-04-25 10:41:25 +09:00
Yasuhiro Matsumoto
40c89e5415 handle inner []
closes #412
2018-04-25 10:32:16 +09:00
Yasuhiro Matsumoto
c0728a8dac Merge branch 'master' of https://github.com/mattn/emmet-vim 2018-04-25 10:04:27 +09:00
Yasuhiro Matsumoto
06b4cda774 expand local variables in custom snippets.
closes #414
2018-04-25 10:03:38 +09:00
mattn
5cb3b51e47 Merge pull request #410 from ashfinal/master
Adds emmet#anchorizeURL support for reStructuredText
2018-04-25 09:03:40 +09:00
Rick Galbo
927f72b49d fix a broken markdown heading
no space between heading indicator and text
2018-04-22 14:52:18 -05:00
ashfinal
18c0cf55f4 Adds emmet#anchorizeURL support for reStructuredText 2018-03-16 20:47:39 +08:00
mattn
350f0ba10b Merge pull request #398 from taylorzr/master
Fix "More Tutorials" link
2017-12-08 07:47:06 +09:00
Zach Taylor
2a8918a775 Fix "More Tutorials" link 2017-12-07 14:12:48 -06:00
Yasuhiro Matsumoto
abdd9e440d fix .travis.yml and README.mkd 2017-12-07 00:26:00 +09:00
Yasuhiro Matsumoto
e8c905853b fix README.mkd 2017-12-07 00:23:18 +09:00
Yasuhiro Matsumoto
8e06fbd056 remove --clean 2017-12-07 00:20:12 +09:00
Yasuhiro Matsumoto
2364a97f1c fix Makefile 2017-12-07 00:18:25 +09:00
Yasuhiro Matsumoto
1be61f24ba fix Makefile 2017-12-07 00:18:09 +09:00
Yasuhiro Matsumoto
ac8767eb15 fix Makefile 2017-12-07 00:16:02 +09:00
Yasuhiro Matsumoto
5405e9dbf0 add .travis.yml 2017-12-07 00:14:10 +09:00
Yasuhiro Matsumoto
c7923d1ec4 fix #389 2017-12-07 00:13:48 +09:00
Yasuhiro Matsumoto
5181a02a09 add test 2017-12-07 00:13:40 +09:00
mattn
1c6b56f0e0 Merge pull request #395 from pageYe123/patch-2
correct the wrong link address
2017-11-13 14:45:51 +09:00
Ye Shiqing
2196a056b4 correct the wrong link address
missing `/blob/` https://raw.github.com/mattn/emmet-vim/blob/master/TUTORIAL
2017-11-12 01:45:54 -06:00
mattn
a06966cfb2 Merge pull request #393 from vais/patch-2
Fix typo in documentation
2017-11-07 14:18:10 +09:00
mattn
fd4a3f6089 Merge pull request #394 from theRemix/doc/plug-install
README for vim-plug installation
2017-11-01 20:01:42 +09:00
Jon Borgonia
f1fba43944 add instructions for installation with vim-plug 2017-10-31 20:14:05 -07:00
Vais Salikhov
609c66f043 Fix typo in documentation 2017-10-23 22:14:30 +07:00
mattn
bcadf12a03 Merge pull request #392 from vais/patch-1
Fix typo in documentation
2017-10-22 19:51:33 +09:00
Vais Salikhov
d653ee7df0 Fix typo in documentation 2017-10-21 20:14:51 +07:00
mattn
ed79a9264d Merge pull request #384 from hpate-omicron/patch-1
Fix #382 - Multiple class name expansion with Elm
2017-08-21 10:57:21 +09:00
mattn
71c68c2d6c Merge pull request #383 from korneliakobiela/master
Rewrite TUTORIAL to markdown file format
2017-08-21 10:56:42 +09:00
hpate-omicron
4b4e68ae1d Fix #382 - Multiple class name expansion with Elm
This change makes the multiple class name expansion work correctly in Elm.

```
div.one.two.three
```

Becomes
```
    div [ class "one two three" ] []
```

Previously you would get
```
    div [ class "one.two.three" ] []
```
https://github.com/mattn/emmet-vim/issues/382
2017-08-16 09:52:32 -04:00
Kornelia Kobiela
abc97ac757 Rewrite TUTORIAL to markdown file format 2017-08-13 21:24:43 +02:00
Yasuhiro Matsumoto
9c6d783636 add test 2017-07-13 01:49:34 +09:00
Yasuhiro Matsumoto
230f41e55b handle attribute in join-tag
close #379
2017-07-13 01:47:17 +09:00
Yasuhiro Matsumoto
94261d6515 handle name={{width: 300px}}
close #377
2017-06-22 22:32:30 +09:00
Yasuhiro Matsumoto
aa801bc9b7 add block_all_childless
close #270
2017-06-13 18:10:16 +09:00
Yasuhiro Matsumoto
3af413c9a3 fix unittest 2017-06-01 22:42:56 +09:00
Yasuhiro Matsumoto
2247b1f457 fix indentation 2017-06-01 22:42:47 +09:00
Yasuhiro Matsumoto
6c38fe86c1 remove debug code 2017-05-16 17:07:20 +09:00
Yasuhiro Matsumoto
956f1b0b43 try to find short name in css snippets
close #371
2017-05-16 17:06:55 +09:00
mattn
4efb1c333e Merge pull request #368 from floscr/fix/add-viewport-units
Add viewport units to expansion
2017-03-30 10:26:09 +09:00
Florian Schroedl Home
d6e093d441 Add viewport units to expansion 2017-03-29 17:35:23 +02:00
mattn
5442207ccb Merge pull request #363 from jankjn/patch-1
fix script tag
2017-01-14 20:01:33 +09:00
Jankin Zhang
f0a0948d2d fix script tag
`script` and `script:src` both was expanded to `<script src=""></script>`
2017-01-14 18:45:49 +08:00
Yasuhiro Matsumoto
e5d28f004c add ! for pug 2017-01-04 12:49:12 +09:00
mattn
20dd275531 Merge pull request #359 from bobbylee/master
Updated CSS snippet section from emmetio/emmet
2017-01-03 22:30:00 +09:00
Bobby Lee
5db2c29f14 Updated CSS snippet section with the latest settings from emmetio/emmet (flexbox) 2016-12-27 12:35:08 +13:00
Michael Bøcker-Larsen
5b217264dd Minimal elm lang support #356 2016-12-07 00:04:49 +09:00
Yasuhiro Matsumoto
1a9c1493ab Fixes #355 2016-11-30 14:05:39 +09:00
Yasuhiro Matsumoto
44906fb16e fix #354 2016-11-23 23:41:57 +09:00
mattn
4eca5f5693 Merge pull request #352 from d8660091/fix351
fix while loop, #351
2016-11-10 10:19:42 +09:00
Xu Deng
dfff6672c6 fix while loop, #351 2016-11-09 20:02:15 -05:00
Yasuhiro Matsumoto
64544b778d fix test 2016-11-07 16:09:13 +09:00
Yasuhiro Matsumoto
ebcf6d2205 fix rtype 2016-11-07 16:09:09 +09:00
Yasuhiro Matsumoto
d7b70c656a handle javascript.jsx
Close #347
2016-10-30 21:10:30 +09:00
Yasuhiro Matsumoto
f12fa6e493 Merge commit '30d58ee' 2016-10-29 22:58:51 +09:00
Yasuhiro Matsumoto
b8bb1e51b8 Merge commit 'b56be29' 2016-10-29 22:58:40 +09:00
Yasuhiro Matsumoto
30d58ee417 lookup base type 2016-10-29 22:57:32 +09:00
Yasuhiro Matsumoto
b56be291c4 empty_element_suffix should be " />" for JSX
Close #313
2016-10-29 20:36:07 +09:00
Yasuhiro Matsumoto
d228a90eb1 Merge branch 'master' of git://github.com/mattn/emmet-vim 2016-10-29 20:34:36 +09:00
Yasuhiro Matsumoto
1fe780000b Self closing tag
Close #346
2016-10-29 20:33:05 +09:00
Yasuhiro Matsumoto
28ff569be3 empty_element_suffix should be " />" for JSX
Close #313
2016-10-27 09:14:09 +09:00
Yasuhiro Matsumoto
f4b097af50 fix #340
add -ms- and -o- for vendor prefixes
2016-07-27 16:53:33 +09:00
mattn
92710ebcd2 Merge pull request #339 from greuben/master
Use htmlFor in jsx
2016-07-18 20:31:29 +09:00
Reuben Gunday
4805d355c1 Use htmlFor in jsx 2016-07-17 01:13:52 +05:30
mattn
3654efd3d1 Merge pull request #338 from abobov/patch-1
Fix typo in documentation
2016-07-07 18:29:06 +09:00
Anton Bobov
3cace3fa08 Fix typo in documentation 2016-07-07 14:00:28 +05:00
Yasuhiro Matsumoto
26899b9981 needless div wrapped for lorem 2016-07-05 10:06:18 +09:00
Yasuhiro Matsumoto
c03599748f fix bem filter 2016-07-05 09:45:13 +09:00
Yasuhiro Matsumoto
52f3af7ca8 select is not inline element 2016-06-10 14:14:11 +09:00
Yasuhiro Matsumoto
6e93371365 fixes about #303 2016-06-07 17:59:41 +09:00
Yasuhiro Matsumoto
7e1aa89fa4 put space after variable like [st :] 2016-06-07 11:10:55 +09:00
Yasuhiro Matsumoto
bcab81cc24 fixes #333 2016-06-05 09:54:14 +09:00
Yasuhiro Matsumoto
02f5a2ec81 fix #332 2016-05-28 00:48:57 +09:00
Yasuhiro Matsumoto
f8bf9dbf69 fix #332 2016-05-28 00:39:18 +09:00
Yasuhiro Matsumoto
7735a778c8 fix #332 2016-05-27 03:48:58 +09:00
Yasuhiro Matsumoto
6a6698a179 fix #332 2016-05-27 01:52:33 +09:00
Yasuhiro Matsumoto
6f4869796c fix #332 2016-05-26 23:45:16 +09:00
Yasuhiro Matsumoto
31d903d390 li>lorem 2016-05-17 02:45:20 +09:00
Yasuhiro Matsumoto
e42c07978e Detect pug as well as jade file types
Close #330
2016-05-12 08:56:28 +09:00
Yasuhiro Matsumoto
e2be3aa391 Custom expands should be expanded in later
Fixes #272
2016-05-10 11:11:41 +09:00
Yasuhiro Matsumoto
05bfff176b Fixes #329 again 2016-05-10 10:00:18 +09:00
Yasuhiro Matsumoto
8239822548 fix test 2016-05-10 09:18:23 +09:00
Yasuhiro Matsumoto
1a0c1288e1 Fixes #329 2016-05-10 09:06:47 +09:00
Yasuhiro Matsumoto
b4b21450f2 fallback for shiftwidth() 2016-04-26 08:49:46 +09:00
mattn
0b4310353a Merge pull request #326 from ryunix/using-shiftwidth-func
Using shiftwidth()
2016-04-17 00:31:10 +09:00
ryunix
d550205295 Using shiftwidth() 2016-04-17 00:13:45 +09:00
Jorge Luis Saud Rosal
1e9df4f015 get blade syntax 2016-03-03 15:39:51 -04:30
Yasuhiro Matsumoto
0ccaa29dbd fix #314 2016-01-11 23:58:22 +09:00
mattn
41f005e740 Merge pull request #312 from jugend/jsx-multi-filetypes
fix jsx type check to support multi file types
2016-01-03 02:12:59 +09:00
Herryanto Siatono
4feadc4062 fix jsx type check to support multi file types 2016-01-03 01:08:04 +08:00
Yasuhiro Matsumoto
dee767c998 check type is JSX strictly 2016-01-01 00:11:00 +09:00
Herryanto Siatono
699689c985 add support for jsx attribute expression 2016-01-01 00:07:23 +09:00
mattn
1ac0fb7011 Merge pull request #310 from jugend/fix-join-space
fix missing space before /> on html tag join
2016-01-01 00:06:53 +09:00
Herryanto Siatono
cbe10f91b4 fix missing space before /> on html tag join 2015-12-31 15:23:29 +08:00
mattn
c790128137 Merge pull request #308 from nkalvi/master
Expand implicit tag names as span inside inline elements
2015-12-20 23:53:00 +09:00
nkalvi
997314f226 Merge pull request #1 from nkalvi/nkalvi-patch-to-307
A possible fix to issue #307
2015-12-19 13:21:30 -05:00
nkalvi
6f676c4a38 A possible fix to issue #307 2015-12-16 14:26:17 -05:00
Yasuhiro Matsumoto
8b8aefd64c more implements for #307 2015-12-14 12:21:17 +09:00
Yasuhiro Matsumoto
ea47fca11e fix implicit tag expansion.
Close #307
2015-12-14 00:39:47 +09:00
Yasuhiro Matsumoto
e24ea1734e add screenshot 2015-11-24 15:04:19 +09:00
Yasuhiro Matsumoto
fb3cac36bb Fixes #306 2015-11-23 23:42:12 +09:00
26 changed files with 3655 additions and 2406 deletions

8
.github/FUNDING.yml vendored Normal file
View 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

11
.travis.yml Normal file
View 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
View 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.

View File

@@ -9,3 +9,7 @@ emmet-vim.zip: remove-zip
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

View File

@@ -1,47 +1,68 @@
# Emmet-vim
[emmet-vim](http://mattn.github.com/emmet-vim) is a vim plug-in
[![Build Status](https://travis-ci.org/mattn/emmet-vim.svg?branch=master)](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/).
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mattn/emmet-vim/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
![screenshot](https://raw.githubusercontent.com/mattn/emmet-vim/master/doc/screenshot.gif)
## Installation
[Download zip file](http://www.vim.org/scripts/script.php?script_id=2981):
cd ~/.vim
unzip emmet-vim.zip
```sh
cd ~/.vim
unzip emmet-vim.zip
```
To install using pathogen.vim:
To install using [pathogen.vim](https://github.com/tpope/vim-pathogen):
```sh
git clone https://github.com/mattn/emmet-vim.git ~/.vim/bundle/emmet-vim
```
cd ~/.vim/bundle
git clone https://github.com/mattn/emmet-vim.git
To install using [Vundle](https://github.com/gmarik/vundle):
" add this line to your .vimrc file
Plugin 'mattn/emmet-vim'
```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:
cd ~/.vim/bundle
git clone https://github.com/mattn/emmet-vim.git
```sh
cd ~/.vim/bundle
git clone https://github.com/mattn/emmet-vim.git
```
or:
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/
```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 a New File:
vim index.html
```sh
vim index.html
```
Type ("\_" is the cursor position):
@@ -62,7 +83,7 @@ Then type `<c-y>,` (<kbd>Ctrl</kbd><kbd>y</kbd><kbd>,</kbd>), and you should see
</html>
```
[More Tutorials](https://raw.github.com/mattn/emmet-vim/master/TUTORIAL)
[More Tutorials](https://raw.githubusercontent.com/mattn/emmet-vim/master/TUTORIAL)
## Enable in different mode
@@ -103,10 +124,42 @@ You can change the **path** to your **snippets_custom.json** according to your p
[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:
@@ -119,7 +172,7 @@ You can change the **path** to your **snippets_custom.json** according to your p
### emmet.vim:
* <http://mattn.github.com/emmet-vim>
* <https://mattn.github.io/emmet-vim/>
### development repository:

247
TUTORIAL.mkd Normal file
View 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',
\ },
\}
```

File diff suppressed because it is too large Load Diff

View File

@@ -9,3 +9,44 @@ function! emmet#lang#exists(type) abort
return s:exists[a:type]
endfunction
function! emmet#lang#type(type) abort
let l:type = a:type
let l:base = l:type
let l:settings = emmet#getSettings()
while l:base != ''
for l:b in split(l:base, '\.')
if emmet#lang#exists(l:b)
return l:b
endif
if has_key(l:settings, l:b) && has_key(l:settings[l:b], 'extends')
let l:base = l:settings[l:b].extends
break
else
let l:base = ''
endif
endfor
endwhile
return 'html'
endfunction
" get all extends for a type recursively
function! emmet#lang#getExtends(type) abort
let l:settings = emmet#getSettings()
if !has_key(l:settings[a:type], 'extends')
return []
endif
let l:extends = l:settings[a:type].extends
if type(l:extends) ==# 1
let l:tmp = split(l:extends, '\s*,\s*')
unlet! l:extends
let l:extends = l:tmp
endif
for l:ext in l:extends
let l:extends = l:extends + emmet#lang#getExtends(l:ext)
endfor
return l:extends
endfunction

View File

@@ -1,6 +1,6 @@
function! emmet#lang#css#findTokens(str) abort
let tmp = substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
if tmp =~ '/' && tmp =~ '^[a-zA-Z0-9/_.]\+$'
let l:tmp = substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
if l:tmp =~ '/' && l:tmp =~ '^[a-zA-Z0-9/_.]\+$'
" maybe path or something
return ''
endif
@@ -8,243 +8,281 @@ function! emmet#lang#css#findTokens(str) abort
endfunction
function! emmet#lang#css#parseIntoTree(abbr, type) abort
let abbr = a:abbr
let type = a:type
let prefix = 0
let value = ''
let l:abbr = a:abbr
let l:type = a:type
let l:prefix = 0
let l: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 l:indent = emmet#getIndentation(l:type)
let l:aliases = emmet#getResource(l:type, 'aliases', {})
let l:snippets = emmet#getResource(l:type, 'snippets', {})
let l:use_pipe_for_cursor = emmet#getResource(l:type, 'use_pipe_for_cursor', 1)
let root = emmet#newNode()
let l:root = emmet#newNode()
" emmet
let tokens = split(abbr, '+\ze[^+)!]')
let block = emmet#util#searchRegion('{', '}')
if abbr !~# '^@' && emmet#getBaseType(type) ==# 'css' && type !=# 'sass' && 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))
let l:tokens = split(l:abbr, '+\ze[^+)!]')
let l:block = emmet#util#searchRegion('{', '}')
if l:abbr !~# '^@' && emmet#getBaseType(l:type) ==# 'css' && l:type !=# 'sass' && l:type !=# 'styled' && l:block[0] ==# [0,0] && l:block[1] ==# [0,0]
let l:current = emmet#newNode()
let l:current.snippet = substitute(l:abbr, '\s\+$', '', '') . " {\n" . l:indent . "${cursor}\n}"
let l:current.name = ''
call add(l:root.child, deepcopy(l: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\|re\|rem\|%\)\{0,1}-\{0,1}\|-auto\)*\)$')
if len(prop)
let token = substitute(prop[1], '^(\(.*\))', '\1', '')
if token =~# '^-'
let prefix = 1
let token = token[1:]
for l:n in range(len(l:tokens))
let l:token = l:tokens[l:n]
let l:prop = matchlist(l: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(l:prop)
let l:token = substitute(l:prop[1], '^(\(.*\))', '\1', '')
if l:token =~# '^-'
let l:prefix = 1
let l:token = l: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 =~# '%$'
let value .= v
elseif v =~# 'e$'
let value .= substitute(v, 'e$', 'em', '')
elseif v =~# 'em$'
let value .= v
elseif v =~# 're$'
let value .= substitute(v, 're$', 'rem', '')
elseif v =~# 'rem$'
let value .= v
elseif v =~# '\.'
let value .= v . 'em'
elseif v ==# 'auto'
let value .= v
elseif v ==# '0'
let value .= '0'
else
let value .= v . 'px'
let l:value = ''
for l:vt in split(l:prop[2], '\a\+\zs')
let l:ut = matchstr(l:vt, '[a-z]\+$')
if l:ut == 'auto'
let l:ut = ''
endif
for l:v in split(l:vt, '\d\zs-')
if len(l:value) > 0
let l:value .= ' '
endif
if l:v !~ '[a-z]\+$'
let l:v .= l:ut
endif
if l:token =~# '^[z]'
" TODO
let l:value .= substitute(l:v, '[^0-9.]*$', '', '')
elseif l:v =~# 'em$'
let l:value .= l:v
elseif l:v =~# 'ex$'
let l:value .= l:v
elseif l:v =~# 'vh$'
let l:value .= l:v
elseif l:v =~# 'vw$'
let l:value .= l:v
elseif l:v =~# 'rem$'
let l:value .= l:v
elseif l:v ==# 'auto'
let l:value .= l:v
elseif l:v =~# 'p$'
let l:value .= substitute(l:v, 'p$', '%', '')
elseif l:v =~# '%$'
let l:value .= l:v
elseif l:v =~# 'e$'
let l:value .= substitute(l:v, 'e$', 'em', '')
elseif l:v =~# 'x$'
let l:value .= substitute(l:v, 'x$', 'ex', '')
elseif l:v =~# 're$'
let l:value .= substitute(l:v, 're$', 'rem', '')
elseif l:v =~# '\.'
let l:value .= l:v . 'em'
elseif l:v ==# '0'
let l:value .= '0'
else
let l:value .= l:v . 'px'
endif
endfor
endfor
endif
let tag_name = token
if tag_name =~# '.!$'
let tag_name = tag_name[:-2]
let important = 1
let l:tag_name = l:token
if l:tag_name =~# '.!$'
let l:tag_name = l:tag_name[:-2]
let l:important = 1
else
let important = 0
let l:important = 0
endif
" make default node
let current = emmet#newNode()
let current.important = important
let current.name = tag_name
let l:current = emmet#newNode()
let l:current.important = l:important
let l:current.name = l:tag_name
" aliases
if has_key(aliases, tag_name)
let current.name = aliases[tag_name]
if has_key(l:aliases, l:tag_name)
let l:current.name = l:aliases[l: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 snippet_name = vv[0]
if !empty(l:snippets)
let l:snippet_name = l:tag_name
if !has_key(l:snippets, l:snippet_name)
let l:pat = '^' . join(split(l:tag_name, '\zs'), '\%(\|[^:-]\+-\)')
let l:vv = filter(sort(keys(l:snippets)), 'l:snippets[v:val] =~ l:pat')
if len(l:vv) == 0
let l:vv = filter(sort(keys(l:snippets)), 'substitute(v:val, ":", "", "g") == l:snippet_name')
endif
if len(l:vv) > 0
let l:snippet_name = l: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')
let l:pat = '^' . join(split(l:tag_name, '\zs'), '\%(\|[^:-]\+-*\)')
let l:vv = filter(sort(keys(l:snippets)), 'l:snippets[v:val] =~ l:pat')
if len(l:vv) == 0
let l:pat = '^' . join(split(l:tag_name, '\zs'), '[^:]\{-}')
let l:vv = filter(sort(keys(l:snippets)), 'l:snippets[v:val] =~ l:pat')
if len(l:vv) == 0
let l:pat = '^' . join(split(l:tag_name, '\zs'), '.\{-}')
let l:vv = filter(sort(keys(l:snippets)), 'l:snippets[v:val] =~ l: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)
let l:minl = -1
for l:vk in l:vv
let l:vvs = l:snippets[l:vk]
if l:minl == -1 || len(l:vvs) < l:minl
let l:snippet_name = l:vk
let l:minl = len(l: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')
if has_key(l:snippets, l:snippet_name)
let l:snippet = l:snippets[l:snippet_name]
if l:use_pipe_for_cursor
let l:snippet = substitute(l: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')
let l:lines = split(l:snippet, "\n")
call map(l:lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(l:indent, "\\\\"), "g")')
let l:current.snippet = join(l:lines, "\n")
let l:current.name = ''
let l:current.snippet = substitute(l:current.snippet, ';', l:value . ';', '')
if l:use_pipe_for_cursor && len(l:value) > 0
let l:current.snippet = substitute(l:current.snippet, '\${cursor}', '', 'g')
endif
if n < len(tokens) - 1
let current.snippet .= "\n"
if l:n < len(l:tokens) - 1
let l: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]]
let l:current.pos = 0
let l:lg = matchlist(l:token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$')
if len(l:lg) == 0
let l:lg = matchlist(l:token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*)$')
if len(l:lg)
let [l:lg[1], l:lg[2], l:lg[3]] = ['linear', l:lg[1], l: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 = 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])
if len(l:lg)
let l:current.name = ''
let l:current.snippet = printf("background-image:-webkit-gradient(%s, 0 0, 0 100%%, from(%s), to(%s));\n", l:lg[1], l:lg[2], l:lg[3])
call add(l:root.child, deepcopy(l:current))
let l:current.snippet = printf("background-image:-webkit-linear-gradient(%s, %s);\n", l:lg[2], l:lg[3])
call add(l:root.child, deepcopy(l:current))
let l:current.snippet = printf("background-image:-moz-linear-gradient(%s, %s);\n", l:lg[2], l:lg[3])
call add(l:root.child, deepcopy(l:current))
let l:current.snippet = printf("background-image:-o-linear-gradient(%s, %s);\n", l:lg[2], l:lg[3])
call add(l:root.child, deepcopy(l:current))
let l:current.snippet = printf("background-image:linear-gradient(%s, %s);\n", l:lg[2], l:lg[3])
call add(l:root.child, deepcopy(l:current))
elseif l:prefix
let l:snippet = l:current.snippet
let l:current.snippet = '-webkit-' . l:snippet . "\n"
call add(l:root.child, deepcopy(l:current))
let l:current.snippet = '-moz-' . l:snippet . "\n"
call add(l:root.child, deepcopy(l:current))
let l:current.snippet = '-o-' . l:snippet . "\n"
call add(l:root.child, deepcopy(l:current))
let l:current.snippet = '-ms-' . l:snippet . "\n"
call add(l:root.child, deepcopy(l:current))
let l:current.snippet = l:snippet
call add(l:root.child, l:current)
elseif l:token =~# '^c#\([0-9a-fA-F]\{3}\|[0-9a-fA-F]\{6}\)\(\.[0-9]\+\)\?'
let l:cs = split(l:token, '\.')
let l:current.name = ''
let [l:r,l:g,l:b] = [0,0,0]
if len(l:cs[0]) == 5
let l:rgb = matchlist(l:cs[0], 'c#\(.\)\(.\)\(.\)')
let l:r = eval('0x'.l:rgb[1].l:rgb[1])
let l:g = eval('0x'.l:rgb[2].l:rgb[2])
let l:b = eval('0x'.l:rgb[3].l:rgb[3])
elseif len(l:cs[0]) == 8
let l:rgb = matchlist(l:cs[0], 'c#\(..\)\(..\)\(..\)')
let l:r = eval('0x'.l:rgb[1])
let l:g = eval('0x'.l:rgb[2])
let l:b = eval('0x'.l:rgb[3])
endif
if len(cs) == 1
let current.snippet = printf('color:rgb(%d, %d, %d);', r, g, b)
if len(l:cs) == 1
let l:current.snippet = printf('color:rgb(%d, %d, %d);', l:r, l:g, l:b)
else
let current.snippet = printf('color:rgb(%d, %d, %d, %s);', r, g, b, string(str2float('0.'.cs[1])))
let l:current.snippet = printf('color:rgb(%d, %d, %d, %s);', l:r, l:g, l:b, string(str2float('0.'.l:cs[1])))
endif
call add(root.child, current)
elseif token =~# '^c#'
let current.name = ''
let current.snippet = 'color:\${cursor};'
call add(root.child, current)
call add(l:root.child, l:current)
elseif l:token =~# '^c#'
let l:current.name = ''
let l:current.snippet = 'color:\${cursor};'
call add(l:root.child, l:current)
else
call add(root.child, current)
call add(l:root.child, l:current)
endif
endfor
endif
return root
return l: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]*}$'
let l:current = a:current
let l:value = l:current.value[1:-2]
let l:tmp = substitute(l:value, '\${cursor}', '', 'g')
if l:tmp !~ '.*{[ \t\r\n]*}$'
if emmet#useFilter(a:filters, 'fc')
let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1: \2', 'g')
let l:value = substitute(l:value, '\([^:]\+\):\([^;]*\)', '\1: \2', 'g')
else
let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1:\2', 'g')
let l:value = substitute(l:value, '\([^:]\+\):\([^;]*\)', '\1:\2', 'g')
endif
if current.important
let value = substitute(value, ';', ' !important;', '')
if l:current.important
let l:value = substitute(l:value, ';', ' !important;', '')
endif
endif
return value
return l: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)
let l:img_region = emmet#util#searchRegion('{', '}')
if !emmet#util#regionIsValid(l:img_region) || !emmet#util#cursorInRegion(l: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*$'
let l:content = emmet#util#getContent(l:img_region)
let l:fn = matchstr(l:content, '\<url(\zs[^)]\+\ze)')
let l:fn = substitute(l:fn, '[''" \t]', '', 'g')
if l:fn =~# '^\s*$'
return
elseif fn !~# '^\(/\|http\)'
let fn = simplify(expand('%:h') . '/' . fn)
elseif l:fn !~# '^\(/\|http\)'
let l:fn = simplify(expand('%:h') . '/' . l:fn)
endif
let [width, height] = emmet#util#getImageSize(fn)
if width == -1 && height == -1
let [l:width, l:height] = emmet#util#getImageSize(l:fn)
if l:width == -1 && l:height == -1
return
endif
let indent = emmet#getIndentation('css')
if content =~# '.*\<width\s*:[^;]*;.*'
let content = substitute(content, '\<width\s*:[^;]*;', 'width: ' . width . 'px;', '')
let l:indent = emmet#getIndentation('css')
if l:content =~# '.*\<width\s*:[^;]*;.*'
let l:content = substitute(l:content, '\<width\s*:[^;]*;', 'width: ' . l:width . 'px;', '')
else
let content = substitute(content, '}', indent . 'width: ' . width . "px;\n}", '')
let l:content = substitute(l:content, '}', l:indent . 'width: ' . l:width . "px;\n}", '')
endif
if content =~# '.*\<height\s*:[^;]*;.*'
let content = substitute(content, '\<height\s*:[^;]*;', 'height: ' . height . 'px;', '')
if l:content =~# '.*\<height\s*:[^;]*;.*'
let l:content = substitute(l:content, '\<height\s*:[^;]*;', 'height: ' . l:height . 'px;', '')
else
let content = substitute(content, '}', indent . 'height: ' . height . "px;\n}", '')
let l:content = substitute(l:content, '}', l:indent . 'height: ' . l:height . "px;\n}", '')
endif
call emmet#util#setContent(img_region, content)
call emmet#util#setContent(l:img_region, l:content)
endfunction
function! emmet#lang#css#encodeImage() abort
function! emmet#lang#css#imageEncode() abort
let l:img_region = emmet#util#searchRegion('url(', ')')
if !emmet#util#regionIsValid(l:img_region) || !emmet#util#cursorInRegion(l:img_region)
return
endif
let l:content = emmet#util#getContent(l:img_region)
let l:fn = matchstr(l:content, '\<url(\zs[^)]\+\ze)')
let l:fn = substitute(l:fn, '[''" \t]', '', 'g')
if l:fn =~# '^\s*$'
return
elseif l:fn !~# '^\(/\|http\)'
let l:fn = simplify(expand('%:h') . '/' . l:fn)
endif
let l:encoded = emmet#util#imageEncodeDecode(l:fn, 0)
call emmet#util#setContent(l:img_region, 'url(' . l:encoded . ')')
endfunction
function! emmet#lang#css#parseTag(tag) abort
@@ -252,65 +290,67 @@ function! emmet#lang#css#parseTag(tag) abort
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)
let l:line = getline('.')
let l:mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
if l:line =~# '{\s*$'
let l:block = emmet#util#searchRegion('/\*', '\*/\zs')
if emmet#util#regionIsValid(l:block)
let l:content = emmet#util#getContent(l:block)
let l:content = substitute(l:content, '/\*\s\(.*\)\s\*/', '\1', '')
call emmet#util#setContent(l:block, l:content)
else
let node = expand('<cword>')
if len(node)
exe "normal ciw\<c-r>='/* '.node.' */'\<cr>"
let l:node = expand('<cword>')
if len(l:node)
exe "normal ciw\<c-r>='/* '.l: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')
if l:line =~# l:mx
let l:space = substitute(matchstr(l:line, l:mx), l:mx, '\1', '')
let l:line = substitute(matchstr(l:line, l:mx), l:mx, '\2', '')
let l:line = l:space . substitute(l:line, '^\s*\|\s*$', '\1', 'g')
else
let mx = '^\(\s*\)\(.*\)\s*$'
let line = substitute(line, mx, '\1/* \2 */', '')
let l:mx = '^\(\s*\)\(''[^'']*''\|[^'']*\|;\)\s*$'
" TODO multi-property
"let l:mx = '^\(\s*\)\(\%(''[^'']*''\|[^'';]\+\)*;\{0,1}\)'
let l:line = substitute(l:line, l:mx, '\1/* \2 */', '')
endif
call setline('.', line)
call setline('.', l:line)
endif
endfunction
function! emmet#lang#css#balanceTag(flag) range abort
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
let l:curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = emmet#util#getcurpos()
let l:curpos = emmet#util#getcurpos()
endif
let block = emmet#util#getVisualBlock()
if !emmet#util#regionIsValid(block)
let l:block = emmet#util#getVisualBlock()
if !emmet#util#regionIsValid(l:block)
if a:flag > 0
let block = emmet#util#searchRegion('^', ';')
if emmet#util#regionIsValid(block)
call emmet#util#selectRegion(block)
let l:block = emmet#util#searchRegion('^', ';')
if emmet#util#regionIsValid(l:block)
call emmet#util#selectRegion(l: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)
let l:content = emmet#util#getContent(l:block)
if l:content !~# '^{.*}$'
let l:block = emmet#util#searchRegion('{', '}')
if emmet#util#regionIsValid(l:block)
call emmet#util#selectRegion(l: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)
let l:pos = searchpos('.*;', 'nW')
if l:pos[0] != 0
call setpos('.', [0, l:pos[0], l:pos[1], 0])
let l:block = emmet#util#searchRegion('^', ';')
if emmet#util#regionIsValid(l:block)
call emmet#util#selectRegion(l:block)
return
endif
endif
@@ -319,7 +359,7 @@ function! emmet#lang#css#balanceTag(flag) range abort
if a:flag == -2 || a:flag == 2
silent! exe 'normal! gv'
else
call setpos('.', curpos)
call setpos('.', l:curpos)
endif
endfunction
@@ -328,13 +368,8 @@ function! emmet#lang#css#moveNextPrevItem(flag) abort
endfunction
function! emmet#lang#css#moveNextPrev(flag) abort
let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
if pos == 2
startinsert!
else
silent! normal! l
startinsert
endif
call search('""\|()\|\(:\s*\zs;\{1,0}$\)', a:flag ? 'Wbp' : 'Wp')
return ''
endfunction
function! emmet#lang#css#splitJoinTag() abort
@@ -344,3 +379,7 @@ 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
View 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 l:tree = emmet#lang#html#parseIntoTree(a:abbr, a:type)
if len(l:tree.child) < 2 | return l:tree | endif
" Add ',' nodes between root elements.
let l:new_children = []
for l:child in l:tree.child[0:-2]
let l:comma = emmet#newNode()
let l:comma.name = ','
call add(l:new_children, l:child)
call add(l:new_children, l:comma)
endfor
call add(l:new_children, l:tree.child[-1])
let l:tree.child = l:new_children
return l:tree
endfunction
function! emmet#lang#elm#renderNode(node)
let l: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(l:elm_nodes, a:node) >= 0
return a:node
endif
return 'node "' . a:node . '"'
endfunction
function! emmet#lang#elm#renderParam(param)
let l:elm_events = ["onClick", "onDoubleClick"
\, "onMouseDown", "onMouseUp"
\, "onMouseEnter", "onMouseLeave"
\, "onMouseOver", "onMouseOut"
\, "onInput", "onCheck", "onSubmit"
\, "onBlur", "onFocus"
\, "on", "onWithOptions", "Options", "defaultOptions"
\, "targetValue", "targetChecked", "keyCode"]
if index(l:elm_events, a:param) >= 0
return a:param
endif
let l: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(l: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 l:settings = a:settings
let l:current = a:current
let l:type = a:type
let l:inline = a:inline
let l:filters = a:filters
let l:itemno = a:itemno
let l:indent = emmet#getIndentation(l:type)
let l:dollar_expr = emmet#getResource(l:type, 'dollar_expr', 1)
let l:str = ''
" comma between items with *, eg. li*3
if l:itemno > 0
let l:str = ", "
endif
let l:current_name = l:current.name
if l:dollar_expr
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
endif
if len(l:current.name) > 0
" inserted root comma nodes
if l:current_name == ','
return "\n, "
endif
let l:str .= emmet#lang#elm#renderNode(l:current_name)
let l:tmp = ''
for l:attr in emmet#util#unique(l:current.attrs_order + keys(l:current.attr))
if !has_key(l:current.attr, l:attr)
continue
endif
let l:Val = l:current.attr[l:attr]
let l:attr = emmet#lang#elm#renderParam(l:attr)
if type(l:Val) == 2 && l:Val == function('emmet#types#true')
let l:tmp .= ', ' . l:attr . ' True'
else
if l:dollar_expr
while l:Val =~# '\$\([^#{]\|$\)'
let l:Val = substitute(l:Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
endwhile
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
endif
let l:valtmp = substitute(l:Val, '\${cursor}', '', '')
if l:attr ==# 'id' && len(l:valtmp) > 0
let l:tmp .=', id "' . l:Val . '"'
elseif l:attr ==# 'class' && len(l:valtmp) > 0
let l:tmp .= ', class "' . substitute(l:Val, '\.', ' ', 'g') . '"'
else
let l:tmp .= ', ' . l:attr . ' "' . l:Val . '"'
endif
endif
endfor
if ! len(l:tmp)
let l:str .= ' []'
else
let l:tmp = strpart(l:tmp, 2)
let l:str .= ' [ ' . l:tmp . ' ]'
endif
" No children quit early
if len(l:current.child) == 0 && len(l:current.value) == 0
"Place cursor in node with no value or children
let l:str .= ' [${cursor}]'
return l:str
endif
let l:inner = ''
" Parent contex text
if len(l:current.value) > 0
let l:text = l:current.value[1:-2]
if l:dollar_expr
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
let l:text = substitute(l:text, '\\\$', '$', 'g')
" let l:str = substitute(l:str, '\$#', l:text, 'g')
let l:inner .= ', text "' . l:text . '"'
endif
endif
" Has children
for l:child in l:current.child
if len(l:child.name) == 0 && len(l:child.value) > 0
" Text node
let l:text = l:child.value[1:-2]
if l:dollar_expr
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
let l:text = substitute(l:text, '\\\$', '$', 'g')
endif
let l:inner .= ', text "' . l:text . '"'
else
" Other nodes
let l:inner .= ', ' . emmet#toString(l:child, l:type, l:inline, l:filters, 0, l:indent)
endif
endfor
let l:inner = substitute(l:inner, "\n", "\n" . escape(l:indent, '\'), 'g')
let l:inner = substitute(l:inner, "\n" . escape(l:indent, '\') . '$', '', 'g')
let l:inner = strpart(l:inner, 2)
let l:inner = substitute(l:inner, ' ', '', 'g')
if ! len(l:inner)
let l:str .= ' []'
else
let l:str .= ' [ ' . l:inner . ' ]'
endif
else
let l:str = l:current.value[1:-2]
if l:dollar_expr
let l:str = substitute(l:str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:str = substitute(l:str, '\${nr}', "\n", 'g')
let l:str = substitute(l:str, '\\\$', '$', 'g')
endif
endif
let l:str .= "\n"
return l: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

View File

@@ -7,251 +7,251 @@ function! emmet#lang#haml#parseIntoTree(abbr, type) abort
endfunction
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 = emmet#getIndentation(type)
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
let attribute_style = emmet#getResource('haml', 'attribute_style', 'hash')
let str = ''
let l:settings = a:settings
let l:current = a:current
let l:type = a:type
let l:inline = a:inline
let l:filters = a:filters
let l:itemno = a:itemno
let l:indent = emmet#getIndentation(l:type)
let l:dollar_expr = emmet#getResource(l:type, 'dollar_expr', 1)
let l:attribute_style = emmet#getResource('haml', 'attribute_style', 'hash')
let l:str = ''
let current_name = current.name
if dollar_expr
let current_name = substitute(current.name, '\$$', itemno+1, '')
let l:current_name = l:current.name
if l:dollar_expr
let l:current_name = substitute(l:current.name, '\$$', l: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)
if len(l:current.name) > 0
let l:str .= '%' . l:current_name
let l:tmp = ''
for l:attr in emmet#util#unique(l:current.attrs_order + keys(l:current.attr))
if !has_key(l:current.attr, l: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'
let l:Val = l:current.attr[l:attr]
if type(l:Val) == 2 && l:Val == function('emmet#types#true')
if l:attribute_style ==# 'hash'
let l:tmp .= ' :' . l:attr . ' => true'
elseif l:attribute_style ==# 'html'
let l:tmp .= l:attr . '=true'
end
else
if dollar_expr
while Val =~# '\$\([^#{]\|$\)'
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
if l:dollar_expr
while l:Val =~# '\$\([^#{]\|$\)'
let l:Val = substitute(l:Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
let l:attr = substitute(l:attr, '\$$', l: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 l:valtmp = substitute(l:Val, '\${cursor}', '', '')
if l:attr ==# 'id' && len(l:valtmp) > 0
let l:str .= '#' . l:Val
elseif l:attr ==# 'class' && len(l:valtmp) > 0
let l:str .= '.' . substitute(l:Val, ' ', '.', 'g')
else
if len(tmp) > 0
if attribute_style ==# 'hash'
let tmp .= ','
elseif attribute_style ==# 'html'
let tmp .= ' '
if len(l:tmp) > 0
if l:attribute_style ==# 'hash'
let l:tmp .= ','
elseif l:attribute_style ==# 'html'
let l:tmp .= ' '
endif
endif
if attribute_style ==# 'hash'
let tmp .= ' :' . attr . ' => "' . Val . '"'
elseif attribute_style ==# 'html'
let tmp .= attr . '="' . Val . '"'
if l:attribute_style ==# 'hash'
let l:tmp .= ' :' . l:attr . ' => "' . l:Val . '"'
elseif l:attribute_style ==# 'html'
let l:tmp .= l:attr . '="' . l:Val . '"'
end
endif
endif
endfor
if len(tmp)
if attribute_style ==# 'hash'
let str .= '{' . tmp . ' }'
elseif attribute_style ==# 'html'
let str .= '(' . tmp . ')'
if len(l:tmp)
if l:attribute_style ==# 'hash'
let l:str .= '{' . l:tmp . ' }'
elseif l:attribute_style ==# 'html'
let l:str .= '(' . l:tmp . ')'
end
endif
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0
let str .= '/'
if stridx(','.l:settings.html.empty_elements.',', ','.l:current_name.',') != -1 && len(l:current.value) == 0
let l:str .= '/'
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')
let l:inner = ''
if len(l:current.value) > 0
let l:text = l:current.value[1:-2]
if l:dollar_expr
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
let l:text = substitute(l:text, '\\\$', '$', 'g')
let l:str = substitute(l:str, '\$#', l:text, 'g')
endif
let lines = split(text, "\n")
if len(lines) == 1
let str .= ' ' . text
let l:lines = split(l:text, "\n")
if len(l:lines) == 1
let l:str .= ' ' . l:text
else
for line in lines
let str .= "\n" . indent . line . ' |'
for l:line in l:lines
let l:str .= "\n" . l:indent . l:line . ' |'
endfor
endif
elseif len(current.child) == 0
let str .= '${cursor}'
elseif len(l:current.child) == 0
let l: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')
if len(l:current.child) == 1 && len(l:current.child[0].name) == 0
let l:text = l:current.child[0].value[1:-2]
if l:dollar_expr
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
let l:text = substitute(l:text, '\\\$', '$', 'g')
endif
let lines = split(text, "\n")
if len(lines) == 1
let str .= ' ' . text
let l:lines = split(l:text, "\n")
if len(l:lines) == 1
let l:str .= ' ' . l:text
else
for line in lines
let str .= "\n" . indent . line . ' |'
for l:line in l:lines
let l:str .= "\n" . l:indent . l:line . ' |'
endfor
endif
elseif len(current.child) > 0
for child in current.child
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
elseif len(l:current.child) > 0
for l:child in l:current.child
let l:inner .= emmet#toString(l:child, l:type, l:inline, l:filters, l:itemno, l:indent)
endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
let str .= "\n" . indent . inner
let l:inner = substitute(l:inner, "\n", "\n" . escape(l:indent, '\'), 'g')
let l:inner = substitute(l:inner, "\n" . escape(l:indent, '\') . '$', '', 'g')
let l:str .= "\n" . l:indent . l: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')
let l:str = l:current.value[1:-2]
if l:dollar_expr
let l:str = substitute(l:str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:str = substitute(l:str, '\${nr}', "\n", 'g')
let l:str = substitute(l:str, '\\\$', '$', 'g')
endif
endif
let str .= "\n"
return str
let l:str .= "\n"
return l:str
endfunction
function! emmet#lang#haml#imageSize() abort
let line = getline('.')
let current = emmet#lang#haml#parseTag(line)
if empty(current) || !has_key(current.attr, 'src')
let l:line = getline('.')
let l:current = emmet#lang#haml#parseTag(l:line)
if empty(l:current) || !has_key(l:current.attr, 'src')
return
endif
let fn = current.attr.src
if fn =~# '^\s*$'
let l:fn = l:current.attr.src
if l:fn =~# '^\s*$'
return
elseif fn !~# '^\(/\|http\)'
let fn = simplify(expand('%:h') . '/' . fn)
elseif l:fn !~# '^\(/\|http\)'
let l:fn = simplify(expand('%:h') . '/' . l:fn)
endif
let [width, height] = emmet#util#getImageSize(fn)
if width == -1 && height == -1
let [l:width, l:height] = emmet#util#getImageSize(l:fn)
if l:width == -1 && l:height == -1
return
endif
let current.attr.width = width
let current.attr.height = height
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'))
let l:current.attr.width = l:width
let l:current.attr.height = l:height
let l:current.attrs_order += ['width', 'height']
let l:haml = emmet#toString(l:current, 'haml', 1)
let l:haml = substitute(l:haml, '\${cursor}', '', '')
call setline('.', substitute(matchstr(l:line, '^\s*') . l:haml, "\n", '', 'g'))
endfunction
function! emmet#lang#haml#encodeImage() abort
function! emmet#lang#haml#imageEncode() abort
endfunction
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', '')
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
let l:current = emmet#newNode()
let l:mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
let l:match = matchstr(a:tag, l:mx)
let l:current.name = substitute(l:match, l:mx, '\1', '')
let l:attrs = substitute(l:match, l:mx, '\2', '')
let l:mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
while len(l:attrs) > 0
let l:match = matchstr(l:attrs, l:mx)
if len(l: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):]
let l:attr_match = matchlist(l:match, l:mx)
let l:name = l:attr_match[1]
let l:value = len(l:attr_match[2]) ? l:attr_match[2] : l:attr_match[3]
let l:current.attr[l:name] = l:value
let l:current.attrs_order += [l:name]
let l:attrs = l:attrs[stridx(l:attrs, l:match) + len(l:match):]
endwhile
return current
return l:current
endfunction
function! emmet#lang#haml#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):])
let l:line = getline('.')
let l:space = matchstr(l:line, '^\s*')
if l:line =~# '^\s*-#'
call setline('.', l:space . matchstr(l:line[len(l:space)+2:], '^\s*\zs.*'))
elseif l:line =~# '^\s*%[a-z]'
call setline('.', l:space . '-# ' . l:line[len(l:space):])
endif
endfunction
function! emmet#lang#haml#balanceTag(flag) range abort
let block = emmet#util#getVisualBlock()
let l:block = emmet#util#getVisualBlock()
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
let l:curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = emmet#util#getcurpos()
let l:curpos = emmet#util#getcurpos()
endif
let n = curpos[1]
let ml = len(matchstr(getline(n), '^\s*'))
let l:n = l:curpos[1]
let l:ml = len(matchstr(getline(l:n), '^\s*'))
if a:flag > 0
if a:flag == 1 || !emmet#util#regionIsValid(block)
let n = line('.')
if a:flag == 1 || !emmet#util#regionIsValid(l:block)
let l:n = line('.')
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
if l > 0 && l < ml
let ml = l
while l:n > 0
let l:l = len(matchstr(getline(l:n), '^\s*\ze%[a-z]'))
if l:l > 0 && l:l < l:ml
let l:ml = l:l
break
endif
let n -= 1
let l:n -= 1
endwhile
endif
let sn = n
if n == 0
let ml = 0
let l:sn = l:n
if l:n == 0
let l:ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
if l > 0 && l <= ml
let n -= 1
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
call setpos('.', [0, n, 1, 0])
call setpos('.', [0, l:n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l: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
while l:n > 0
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
if l:l > 0 && l:l > l:ml
let l:ml = l:l
break
endif
let n += 1
let l:n += 1
endwhile
let sn = n
if n == 0
let ml = 0
let l:sn = l:n
if l:n == 0
let l:ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
if l > 0 && l <= ml
let n -= 1
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
call setpos('.', [0, n, 1, 0])
call setpos('.', [0, l:n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l:sn, 1, 0])
endif
endfunction
@@ -260,75 +260,78 @@ function! emmet#lang#haml#moveNextPrevItem(flag) abort
endfunction
function! emmet#lang#haml#moveNextPrev(flag) abort
let pos = search('""', a:flag ? 'Wb' : 'W')
if pos != 0
let l:pos = search('""', a:flag ? 'Wb' : 'W')
if l:pos != 0
silent! normal! l
startinsert
endif
endfunction
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 len(matchstr(getline(n), '^\s*%[a-z]')) < sml
let l:n = line('.')
let l:sml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
while l:n > 0
if getline(l:n) =~# '^\s*\ze%[a-z]'
if len(matchstr(getline(l:n), '^\s*%[a-z]')) < l: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
let l:line = getline(l:n)
call setline(l:n, substitute(l:line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
let l:sn = l:n
let l:n += 1
let l:ml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
if len(matchstr(getline(l:n), '^\s*')) > l:ml
while l:n <= line('$')
let l:l = len(matchstr(getline(l:n), '^\s*'))
if l:l <= l:ml
break
endif
exe n 'delete'
exe l:n 'delete'
endwhile
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l: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])
let l:tag = matchstr(getline(l:sn), '^\s*%\zs\(\w\+\)')
let l:spaces = matchstr(getline(l:sn), '^\s*')
let l:settings = emmet#getSettings()
if stridx(','.l:settings.html.inline_elements.',', ','.l:tag.',') == -1
call append(l:sn, l:spaces . ' ')
call setpos('.', [0, l:sn+1, 1, 0])
else
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l:sn, 1, 0])
endif
startinsert!
endif
break
endif
let n -= 1
let l:n -= 1
endwhile
endfunction
function! emmet#lang#haml#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]'))
let l:n = line('.')
let l:ml = 0
while l:n > 0
if getline(l:n) =~# '^\s*\ze[a-z]'
let l:ml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
break
endif
let n -= 1
let l: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
let l:sn = l:n
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
if sn == n
if l:sn == l:n
exe 'delete'
else
exe sn ',' (n-1) 'delete'
exe l:sn ',' (l:n-1) 'delete'
endif
endfunction
function! emmet#lang#haml#mergeLines() abort
endfunction

File diff suppressed because it is too large Load Diff

View File

@@ -7,248 +7,248 @@ function! emmet#lang#jade#parseIntoTree(abbr, type) abort
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 l:settings = a:settings
let l:current = a:current
let l:type = a:type
let l:inline = a:inline
let l:filters = a:filters
let l:itemno = a:itemno
let l:indent = emmet#getIndentation(l:type)
let l:dollar_expr = emmet#getResource(l:type, 'dollar_expr', 1)
let l:attribute_style = emmet#getResource('jade', 'attribute_style', 'hash')
let l:str = ''
let current_name = current.name
if dollar_expr
let current_name = substitute(current.name, '\$$', itemno+1, '')
let l:current_name = l:current.name
if l:dollar_expr
let l:current_name = substitute(l:current.name, '\$$', l: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)
if len(l:current.name) > 0
let l:str .= '' . l:current_name
let l:tmp = ''
for l:attr in emmet#util#unique(l:current.attrs_order + keys(l:current.attr))
if !has_key(l:current.attr, l: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'
let l:Val = l:current.attr[l:attr]
if type(l:Val) == 2 && l:Val == function('emmet#types#true')
if l:attribute_style ==# 'hash'
let l:tmp .= ' ' . l:attr . ' = true'
elseif l:attribute_style ==# 'html'
let l:tmp .= l:attr . '=true'
end
else
if dollar_expr
while Val =~# '\$\([^#{]\|$\)'
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
if l:dollar_expr
while l:Val =~# '\$\([^#{]\|$\)'
let l:Val = substitute(l:Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
let l:attr = substitute(l:attr, '\$$', l: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 l:valtmp = substitute(l:Val, '\${cursor}', '', '')
if l:attr ==# 'id' && len(l:valtmp) > 0
let l:str .= '#' . l:Val
elseif l:attr ==# 'class' && len(l:valtmp) > 0
let l:str .= '.' . substitute(l:Val, ' ', '.', 'g')
else
if len(tmp) > 0
if attribute_style ==# 'hash'
let tmp .= ', '
elseif attribute_style ==# 'html'
let tmp .= ' '
if len(l:tmp) > 0
if l:attribute_style ==# 'hash'
let l:tmp .= ', '
elseif l:attribute_style ==# 'html'
let l:tmp .= ' '
endif
endif
if attribute_style ==# 'hash'
let tmp .= '' . attr . '="' . Val . '"'
elseif attribute_style ==# 'html'
let tmp .= attr . '="' . Val . '"'
if l:attribute_style ==# 'hash'
let l:tmp .= '' . l:attr . '="' . l:Val . '"'
elseif l:attribute_style ==# 'html'
let l:tmp .= l:attr . '="' . l:Val . '"'
end
endif
endif
endfor
if len(tmp)
if attribute_style ==# 'hash'
let str .= '(' . tmp . ')'
elseif attribute_style ==# 'html'
let str .= '(' . tmp . ')'
if len(l:tmp)
if l:attribute_style ==# 'hash'
let l:str .= '(' . l:tmp . ')'
elseif l:attribute_style ==# 'html'
let l:str .= '(' . l: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')
let l:inner = ''
if len(l:current.value) > 0
let l:text = l:current.value[1:-2]
if l:dollar_expr
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
let l:text = substitute(l:text, '\\\$', '$', 'g')
let l:str = substitute(l:str, '\$#', l:text, 'g')
endif
let lines = split(text, "\n")
if len(lines) == 1
let str .= ' ' . text
let l:lines = split(l:text, "\n")
if len(l:lines) == 1
let l:str .= ' ' . l:text
else
for line in lines
let str .= "\n" . indent . line . ' |'
for l:line in l:lines
let l:str .= "\n" . l:indent . l:line . ' |'
endfor
endif
elseif len(current.child) == 0
let str .= '${cursor}'
elseif len(l:current.child) == 0
let l: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')
if len(l:current.child) == 1 && len(l:current.child[0].name) == 0
let l:text = l:current.child[0].value[1:-2]
if l:dollar_expr
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
let l:text = substitute(l:text, '\\\$', '$', 'g')
endif
let lines = split(text, "\n")
if len(lines) == 1
let str .= ' ' . text
let l:lines = split(l:text, "\n")
if len(l:lines) == 1
let l:str .= ' ' . l:text
else
for line in lines
let str .= "\n" . indent . line . ' |'
for l:line in l:lines
let l:str .= "\n" . l:indent . l:line . ' |'
endfor
endif
elseif len(current.child) > 0
for child in current.child
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
elseif len(l:current.child) > 0
for l:child in l:current.child
let l:inner .= emmet#toString(l:child, l:type, l:inline, l:filters, l:itemno, l:indent)
endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
let str .= "\n" . indent . inner
let l:inner = substitute(l:inner, "\n", "\n" . escape(l:indent, '\'), 'g')
let l:inner = substitute(l:inner, "\n" . escape(l:indent, '\') . '$', '', 'g')
let l:str .= "\n" . l:indent . l: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')
let l:str = l:current.value[1:-2]
if l:dollar_expr
let l:str = substitute(l:str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:str = substitute(l:str, '\${nr}', "\n", 'g')
let l:str = substitute(l:str, '\\\$', '$', 'g')
endif
endif
let str .= "\n"
return str
let l:str .= "\n"
return l: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')
let l:line = getline('.')
let l:current = emmet#lang#jade#parseTag(l:line)
if empty(l:current) || !has_key(l:current.attr, 'src')
return
endif
let fn = current.attr.src
if fn =~# '^\s*$'
let l:fn = l:current.attr.src
if l:fn =~# '^\s*$'
return
elseif fn !~# '^\(/\|http\)'
let fn = simplify(expand('%:h') . '/' . fn)
elseif l:fn !~# '^\(/\|http\)'
let l:fn = simplify(expand('%:h') . '/' . l:fn)
endif
let [width, height] = emmet#util#getImageSize(fn)
if width == -1 && height == -1
let [l:width, l:height] = emmet#util#getImageSize(l:fn)
if l:width == -1 && l: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'))
let l:current.attr.width = l:width
let l:current.attr.height = l:height
let l:current.attrs_order += ['width', 'height']
let l:jade = emmet#toString(l:current, 'jade', 1)
let l:jade = substitute(l:jade, '\${cursor}', '', '')
call setline('.', substitute(matchstr(l:line, '^\s*') . l:jade, "\n", '', 'g'))
endfunction
function! emmet#lang#jade#encodeImage() abort
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
let l:current = emmet#newNode()
let l:mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
let l:match = matchstr(a:tag, l:mx)
let l:current.name = substitute(l:match, l:mx, '\1', '')
let l:attrs = substitute(l:match, l:mx, '\2', '')
let l:mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
while len(l:attrs) > 0
let l:match = matchstr(l:attrs, l:mx)
if len(l: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):]
let l:attr_match = matchlist(l:match, l:mx)
let l:name = l:attr_match[1]
let l:value = len(l:attr_match[2]) ? l:attr_match[2] : l:attr_match[3]
let l:current.attr[l:name] = l:value
let l:current.attrs_order += [l:name]
let l:attrs = l:attrs[stridx(l:attrs, l:match) + len(l:match):]
endwhile
return current
return l: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):])
let l:line = getline('.')
let l:space = matchstr(l:line, '^\s*')
if l:line =~# '^\s*-#'
call setline('.', l:space . matchstr(l:line[len(l:space)+2:], '^\s*\zs.*'))
elseif l:line =~# '^\s*%[a-z]'
call setline('.', l:space . '-# ' . l:line[len(l:space):])
endif
endfunction
function! emmet#lang#jade#balanceTag(flag) range abort
let block = emmet#util#getVisualBlock()
let l:block = emmet#util#getVisualBlock()
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
let l:curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = emmet#util#getcurpos()
let l:curpos = emmet#util#getcurpos()
endif
let n = curpos[1]
let ml = len(matchstr(getline(n), '^\s*'))
let l:n = l:curpos[1]
let l:ml = len(matchstr(getline(l:n), '^\s*'))
if a:flag > 0
if a:flag == 1 || !emmet#util#regionIsValid(block)
let n = line('.')
if a:flag == 1 || !emmet#util#regionIsValid(l:block)
let l:n = line('.')
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
if l > 0 && l < ml
let ml = l
while l:n > 0
let l:l = len(matchstr(getline(l:n), '^\s*\ze%[a-z]'))
if l:l > 0 && l:l < l:ml
let l:ml = l:l
break
endif
let n -= 1
let l:n -= 1
endwhile
endif
let sn = n
if n == 0
let ml = 0
let l:sn = l:n
if l:n == 0
let l:ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
if l > 0 && l <= ml
let n -= 1
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
call setpos('.', [0, n, 1, 0])
call setpos('.', [0, l:n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l: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
while l:n > 0
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
if l:l > 0 && l:l > l:ml
let l:ml = l:l
break
endif
let n += 1
let l:n += 1
endwhile
let sn = n
if n == 0
let ml = 0
let l:sn = l:n
if l:n == 0
let l:ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
if l > 0 && l <= ml
let n -= 1
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
call setpos('.', [0, n, 1, 0])
call setpos('.', [0, l:n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l:sn, 1, 0])
endif
endfunction
@@ -257,75 +257,79 @@ function! emmet#lang#jade#moveNextPrevItem(flag) abort
endfunction
function! emmet#lang#jade#moveNextPrev(flag) abort
let pos = search('""', a:flag ? 'Wb' : 'W')
if pos != 0
let l:pos = search('""', a:flag ? 'Wb' : 'W')
if l: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
let l:n = line('.')
let l:sml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
while l:n > 0
if getline(l:n) =~# '^\s*\ze%[a-z]'
if len(matchstr(getline(l:n), '^\s*%[a-z]')) < l: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
let l:line = getline(l:n)
call setline(l:n, substitute(l:line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
let l:sn = l:n
let l:n += 1
let l:ml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
if len(matchstr(getline(l:n), '^\s*')) > l:ml
while l:n <= line('$')
let l:l = len(matchstr(getline(l:n), '^\s*'))
if l:l <= l:ml
break
endif
exe n 'delete'
exe l:n 'delete'
endwhile
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l: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])
let l:tag = matchstr(getline(l:sn), '^\s*%\zs\(\w\+\)')
let l:spaces = matchstr(getline(l:sn), '^\s*')
let l:settings = emmet#getSettings()
if stridx(','.l:settings.html.inline_elements.',', ','.l:tag.',') == -1
call append(l:sn, l:spaces . ' ')
call setpos('.', [0, l:sn+1, 1, 0])
else
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l:sn, 1, 0])
endif
startinsert!
endif
break
endif
let n -= 1
let l: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]'))
let l:n = line('.')
let l:ml = 0
while l:n > 0
if getline(l:n) =~# '^\s*\ze[a-z]'
let l:ml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
break
endif
let n -= 1
let l: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
let l:sn = l:n
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
if sn == n
if l:sn == l:n
exe 'delete'
else
exe sn ',' (n-1) 'delete'
exe l:sn ',' (l:n-1) 'delete'
endif
endfunction
function! emmet#lang#jade#mergeLines() abort
" nothing to do
endfunction

View File

@@ -14,8 +14,8 @@ function! emmet#lang#less#imageSize() abort
call emmet#lang#css#imageSize()
endfunction
function! emmet#lang#less#encodeImage() abort
return emmet#lang#css#encodeImage()
function! emmet#lang#less#imageEncode() abort
return emmet#lang#css#imageEncode()
endfunction
function! emmet#lang#less#parseTag(tag) abort
@@ -45,3 +45,7 @@ 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

View File

@@ -3,69 +3,69 @@ function! emmet#lang#sass#findTokens(str) abort
endfunction
function! emmet#lang#sass#parseIntoTree(abbr, type) abort
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
endfunction
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
let inline = a:inline
let filters = a:filters
let itemno = a:itemno
let indent = a:indent
let str = ''
let l:settings = a:settings
let l:current = a:current
let l:type = a:type
let l:inline = a:inline
let l:filters = a:filters
let l:itemno = a:itemno
let l:indent = a:indent
let l: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')
let l:current_name = l:current.name
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
if len(l:current.name) > 0
let l:str .= l:current_name
let l:tmp = ''
for l:attr in keys(l:current.attr)
let l:val = l:current.attr[l:attr]
while l:val =~# '\$\([^#{]\|$\)'
let l:val = substitute(l:val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
if attr ==# 'id'
let str .= '#' . val
elseif attr ==# 'class'
let str .= '.' . val
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
if l:attr ==# 'id'
let l:str .= '#' . l:val
elseif l:attr ==# 'class'
let l:str .= '.' . l:val
else
let tmp .= attr . ': ' . val
let l:tmp .= l:attr . ': ' . l:val
endif
endfor
if len(tmp) > 0
let str .= "\n"
for line in split(tmp, "\n")
let str .= indent . line . "\n"
if len(l:tmp) > 0
let l:str .= "\n"
for l:line in split(l:tmp, "\n")
let l:str .= l:indent . l:line . "\n"
endfor
else
let str .= "\n"
let l:str .= "\n"
endif
let inner = ''
for child in current.child
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
let l:inner = ''
for l:child in l:current.child
let l:tmp = emmet#toString(l:child, l:type, l:inline, l:filters, l:itemno, l:indent)
let l:tmp = substitute(l:tmp, "\n", "\n" . escape(l:indent, '\'), 'g')
let l:tmp = substitute(l:tmp, "\n" . escape(l:indent, '\') . '$', '${cursor}\n', 'g')
let l:inner .= l:tmp
endfor
if len(inner) > 0
let str .= indent . inner
if len(l:inner) > 0
let l:str .= l:indent . l:inner
endif
else
let text = emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
let text = substitute(text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g')
return text
let l:text = emmet#lang#css#toString(l:settings, l:current, l:type, l:inline, l:filters, l:itemno, l:indent)
let l:text = substitute(l:text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g')
return l:text
endif
return str
return l:str
endfunction
function! emmet#lang#sass#imageSize() abort
endfunction
function! emmet#lang#sass#encodeImage() abort
function! emmet#lang#sass#imageEncode() abort
endfunction
function! emmet#lang#sass#parseTag(tag) abort
@@ -75,67 +75,67 @@ function! emmet#lang#sass#toggleComment() abort
endfunction
function! emmet#lang#sass#balanceTag(flag) range abort
let block = emmet#util#getVisualBlock()
let l:block = emmet#util#getVisualBlock()
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
let l:curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = emmet#util#getcurpos()
let l:curpos = emmet#util#getcurpos()
endif
let n = curpos[1]
let ml = len(matchstr(getline(n), '^\s*'))
let l:n = l:curpos[1]
let l:ml = len(matchstr(getline(l:n), '^\s*'))
if a:flag > 0
if a:flag == 1 || !emmet#util#regionIsValid(block)
let n = line('.')
if a:flag == 1 || !emmet#util#regionIsValid(l:block)
let l:n = line('.')
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
if l > 0 && l < ml
let ml = l
while l:n > 0
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
if l:l > 0 && l:l < l:ml
let l:ml = l:l
break
endif
let n -= 1
let l:n -= 1
endwhile
endif
let sn = n
if n == 0
let ml = 0
let l:sn = l:n
if l:n == 0
let l:ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
call setpos('.', [0, n, 1, 0])
call setpos('.', [0, l:n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l: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
while l:n > 0
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
if l:l > 0 && l:l > l:ml
let l:ml = l:l
break
endif
let n += 1
let l:n += 1
endwhile
let sn = n
if n == 0
let ml = 0
let l:sn = l:n
if l:n == 0
let l:ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
call setpos('.', [0, n, 1, 0])
call setpos('.', [0, l:n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l:sn, 1, 0])
endif
endfunction
@@ -144,10 +144,10 @@ function! emmet#lang#sass#moveNextPrevItem(flag) abort
endfunction
function! emmet#lang#sass#moveNextPrev(flag) abort
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if pos == 2
let l:pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if l:pos == 2
startinsert!
elseif pos != 0
elseif l:pos != 0
silent! normal! l
startinsert
endif
@@ -158,3 +158,6 @@ endfunction
function! emmet#lang#sass#removeTag() abort
endfunction
function! emmet#lang#sass#mergeLines() abort
endfunction

View File

@@ -11,61 +11,61 @@ function! emmet#lang#scss#parseIntoTree(abbr, type) abort
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 l:settings = a:settings
let l:current = a:current
let l:type = a:type
let l:inline = a:inline
let l:filters = a:filters
let l:itemno = a:itemno
let l:indent = a:indent
let l: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')
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
if len(l:current.name) > 0
let l:str .= l:current_name
let l:tmp = ''
for l:attr in keys(l:current.attr)
let l:val = l:current.attr[l:attr]
while l:val =~# '\$\([^#{]\|$\)'
let l:val = substitute(l:val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
if attr ==# 'id'
let str .= '#' . val
elseif attr ==# 'class'
let str .= '.' . val
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
if l:attr ==# 'id'
let l:str .= '#' . l:val
elseif l:attr ==# 'class'
let l:str .= '.' . l:val
else
let tmp .= attr . ': ' . val . ';'
let l:tmp .= l:attr . ': ' . l:val . ';'
endif
endfor
if len(tmp) > 0
let str .= " {\n"
for line in split(tmp, "\n")
let str .= indent . line . "\n"
if len(l:tmp) > 0
let l:str .= " {\n"
for l:line in split(l:tmp, "\n")
let l:str .= l:indent . l:line . "\n"
endfor
else
let str .= " {\n"
let l:str .= " {\n"
endif
let inner = ''
for child in current.child
let inner .= emmet#toString(child, type, inline, filters, itemno)
let l:inner = ''
for l:child in l:current.child
let l:inner .= emmet#toString(l:child, l:type, l:inline, l:filters, l: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"
let l:inner = substitute(l:inner, "\n", "\n" . escape(l:indent, '\'), 'g')
let l:inner = substitute(l:inner, "\n" . escape(l:indent, '\') . '$', '', 'g')
let l:str .= l:indent . l:inner . "${cursor}\n}\n"
else
return emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
return emmet#lang#css#toString(l:settings, l:current, l:type, l:inline, l:filters, l:itemno, l:indent)
endif
return str
return l:str
endfunction
function! emmet#lang#scss#imageSize() abort
call emmet#lang#css#imageSize()
endfunction
function! emmet#lang#scss#encodeImage() abort
return emmet#lang#css#encodeImage()
function! emmet#lang#scss#imageEncode() abort
return emmet#lang#css#imageEncode()
endfunction
function! emmet#lang#scss#parseTag(tag) abort
@@ -78,33 +78,33 @@ 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)
let l:curpos = [0, line("'<"), col("'<"), 0]
call setpos('.', l:curpos)
else
let curpos = emmet#util#getcurpos()
let l:curpos = emmet#util#getcurpos()
endif
if a:flag < 0
let ret = searchpair('}', '', '.\zs{')
let l:ret = searchpair('}', '', '.\zs{')
else
let ret = searchpair('{', '', '}', 'bW')
let l:ret = searchpair('{', '', '}', 'bW')
endif
if ret > 0
let pos1 = emmet#util#getcurpos()[1:2]
if l:ret > 0
let l:pos1 = emmet#util#getcurpos()[1:2]
if a:flag < 0
let pos2 = searchpairpos('{', '', '}')
let l:pos2 = searchpairpos('{', '', '}')
else
let pos2 = searchpairpos('{', '', '}')
let l:pos2 = searchpairpos('{', '', '}')
endif
let block = [pos1, pos2]
if emmet#util#regionIsValid(block)
call emmet#util#selectRegion(block)
let l:block = [l:pos1, l:pos2]
if emmet#util#regionIsValid(l:block)
call emmet#util#selectRegion(l:block)
return
endif
endif
if a:flag == -2 || a:flag == 2
silent! exe 'normal! gv'
else
call setpos('.', curpos)
call setpos('.', l:curpos)
endif
endfunction
@@ -123,3 +123,7 @@ 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

View File

@@ -7,210 +7,210 @@ function! emmet#lang#slim#parseIntoTree(abbr, type) abort
endfunction
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 = emmet#getIndentation(type)
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
let str = ''
let l:current = a:current
let l:type = a:type
let l:inline = a:inline
let l:filters = a:filters
let l:itemno = a:itemno
let l:indent = emmet#getIndentation(l:type)
let l:dollar_expr = emmet#getResource(l:type, 'dollar_expr', 1)
let l:str = ''
let current_name = current.name
if dollar_expr
let current_name = substitute(current.name, '\$$', itemno+1, '')
let l:current_name = l:current.name
if l:dollar_expr
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
endif
if len(current.name) > 0
let str .= current_name
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
if !has_key(current.attr, attr)
if len(l:current.name) > 0
let l:str .= l:current_name
for l:attr in emmet#util#unique(l:current.attrs_order + keys(l:current.attr))
if !has_key(l:current.attr, l:attr)
continue
endif
let Val = current.attr[attr]
if type(Val) == 2 && Val == function('emmet#types#true')
let str .= ' ' . attr . '=true'
let l:Val = l:current.attr[l:attr]
if type(l:Val) == 2 && l:Val == function('emmet#types#true')
let l:str .= ' ' . l:attr . '=true'
else
if dollar_expr
while Val =~# '\$\([^#{]\|$\)'
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
if l:dollar_expr
while l:Val =~# '\$\([^#{]\|$\)'
let l:Val = substitute(l:Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
endwhile
endif
let attr = substitute(attr, '\$$', itemno+1, '')
let str .= ' ' . attr . '="' . Val . '"'
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
let l:str .= ' ' . l:attr . '="' . l:Val . '"'
endif
endfor
let inner = ''
if len(current.value) > 0
let str .= "\n"
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 l:inner = ''
if len(l:current.value) > 0
let l:str .= "\n"
let l:text = l:current.value[1:-2]
if l:dollar_expr
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
let l:text = substitute(l:text, '\\\$', '$', 'g')
let l:str = substitute(l:str, '\$#', l:text, 'g')
endif
for line in split(text, "\n")
let str .= indent . '| ' . line . "\n"
for l:line in split(l:text, "\n")
let l:str .= l:indent . '| ' . l:line . "\n"
endfor
elseif len(current.child) == 0
let str .= '${cursor}'
elseif len(l:current.child) == 0
let l:str .= '${cursor}'
endif
if len(current.child) == 1 && len(current.child[0].name) == 0
let str .= "\n"
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')
if len(l:current.child) == 1 && len(l:current.child[0].name) == 0
let l:str .= "\n"
let l:text = l:current.child[0].value[1:-2]
if l:dollar_expr
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
let l:text = substitute(l:text, '\\\$', '$', 'g')
endif
for line in split(text, "\n")
let str .= indent . '| ' . line . "\n"
for l:line in split(l:text, "\n")
let l:str .= l:indent . '| ' . l:line . "\n"
endfor
elseif len(current.child) > 0
for child in current.child
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
elseif len(l:current.child) > 0
for l:child in l:current.child
let l:inner .= emmet#toString(l:child, l:type, l:inline, l:filters, l:itemno, l:indent)
endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
let str .= "\n" . indent . inner
let l:inner = substitute(l:inner, "\n", "\n" . escape(l:indent, '\'), 'g')
let l:inner = substitute(l:inner, "\n" . escape(l:indent, '\') . '$', '', 'g')
let l:str .= "\n" . l:indent . l: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')
let l:str = l:current.value[1:-2]
if l:dollar_expr
let l:str = substitute(l:str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
let l:str = substitute(l:str, '\${nr}', "\n", 'g')
let l:str = substitute(l:str, '\\\$', '$', 'g')
endif
endif
if str !~# "\n$"
let str .= "\n"
if l:str !~# "\n$"
let l:str .= "\n"
endif
return str
return l:str
endfunction
function! emmet#lang#slim#imageSize() abort
let line = getline('.')
let current = emmet#lang#slim#parseTag(line)
if empty(current) || !has_key(current.attr, 'src')
let l:line = getline('.')
let l:current = emmet#lang#slim#parseTag(l:line)
if empty(l:current) || !has_key(l:current.attr, 'src')
return
endif
let fn = current.attr.src
if fn =~# '^\s*$'
let l:fn = l:current.attr.src
if l:fn =~# '^\s*$'
return
elseif fn !~# '^\(/\|http\)'
let fn = simplify(expand('%:h') . '/' . fn)
elseif l:fn !~# '^\(/\|http\)'
let l:fn = simplify(expand('%:h') . '/' . l:fn)
endif
let [width, height] = emmet#util#getImageSize(fn)
if width == -1 && height == -1
let [l:width, l:height] = emmet#util#getImageSize(l:fn)
if l:width == -1 && l:height == -1
return
endif
let current.attr.width = width
let current.attr.height = height
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'))
let l:current.attr.width = l:width
let l:current.attr.height = l:height
let l:current.attrs_order += ['width', 'height']
let l:slim = emmet#toString(l:current, 'slim', 1)
let l:slim = substitute(l:slim, '\${cursor}', '', '')
call setline('.', substitute(matchstr(l:line, '^\s*') . l:slim, "\n", '', 'g'))
endfunction
function! emmet#lang#slim#encodeImage() abort
function! emmet#lang#slim#imageEncode() abort
endfunction
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', '')
let attrs = substitute(match, mx, '\2', '')
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
while len(attrs) > 0
let match = matchstr(attrs, mx)
if len(match) == 0
let l:current = emmet#newNode()
let l:mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)'
let l:match = matchstr(a:tag, l:mx)
let l:current.name = substitute(l:match, l:mx, '\1', '')
let l:attrs = substitute(l:match, l:mx, '\2', '')
let l:mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
while len(l:attrs) > 0
let l:match = matchstr(l:attrs, l:mx)
if len(l: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):]
let l:attr_match = matchlist(l:match, l:mx)
let l:name = l:attr_match[1]
let l:value = len(l:attr_match[2]) ? l:attr_match[2] : l:attr_match[3]
let l:current.attr[l:name] = l:value
let l:current.attrs_order += [l:name]
let l:attrs = l:attrs[stridx(l:attrs, l:match) + len(l:match):]
endwhile
return current
return l:current
endfunction
function! emmet#lang#slim#toggleComment() abort
let line = getline('.')
let space = matchstr(line, '^\s*')
if line =~# '^\s*/'
call setline('.', space . line[len(space)+1:])
elseif line =~# '^\s*[a-z]'
call setline('.', space . '/' . line[len(space):])
let l:line = getline('.')
let l:space = matchstr(l:line, '^\s*')
if l:line =~# '^\s*/'
call setline('.', l:space . l:line[len(l:space)+1:])
elseif l:line =~# '^\s*[a-z]'
call setline('.', l:space . '/' . l:line[len(l:space):])
endif
endfunction
function! emmet#lang#slim#balanceTag(flag) range abort
let block = emmet#util#getVisualBlock()
let l:block = emmet#util#getVisualBlock()
if a:flag == -2 || a:flag == 2
let curpos = [0, line("'<"), col("'<"), 0]
let l:curpos = [0, line("'<"), col("'<"), 0]
else
let curpos = emmet#util#getcurpos()
let l:curpos = emmet#util#getcurpos()
endif
let n = curpos[1]
let ml = len(matchstr(getline(n), '^\s*'))
let l:n = l:curpos[1]
let l:ml = len(matchstr(getline(l:n), '^\s*'))
if a:flag > 0
if a:flag == 1 || !emmet#util#regionIsValid(block)
let n = line('.')
if a:flag == 1 || !emmet#util#regionIsValid(l:block)
let l:n = line('.')
else
while n > 0
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
if l > 0 && l < ml
let ml = l
while l:n > 0
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
if l:l > 0 && l:l < l:ml
let l:ml = l:l
break
endif
let n -= 1
let l:n -= 1
endwhile
endif
let sn = n
if n == 0
let ml = 0
let l:sn = l:n
if l:n == 0
let l:ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
call setpos('.', [0, n, 1, 0])
call setpos('.', [0, l:n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l: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
while l:n > 0
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
if l:l > 0 && l:l > l:ml
let l:ml = l:l
break
endif
let n += 1
let l:n += 1
endwhile
let sn = n
if n == 0
let ml = 0
let l:sn = l:n
if l:n == 0
let l:ml = 0
endif
while n < line('$')
let l = len(matchstr(getline(n), '^\s*[a-z]'))
if l > 0 && l <= ml
let n -= 1
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
call setpos('.', [0, n, 1, 0])
call setpos('.', [0, l:n, 1, 0])
normal! V
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l:sn, 1, 0])
endif
endfunction
@@ -219,63 +219,66 @@ function! emmet#lang#slim#moveNextPrevItem(flag) abort
endfunction
function! emmet#lang#slim#moveNextPrev(flag) abort
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if pos == 2
let l:pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
if l:pos == 2
startinsert!
elseif pos != 0
elseif l:pos != 0
silent! normal! l
startinsert
endif
endfunction
function! emmet#lang#slim#splitJoinTag() abort
let n = line('.')
while n > 0
if getline(n) =~# '^\s*\ze[a-z]'
let sn = n
let n += 1
if getline(n) =~# '^\s*|'
while n <= line('$')
if getline(n) !~# '^\s*|'
let l:n = line('.')
while l:n > 0
if getline(l:n) =~# '^\s*\ze[a-z]'
let l:sn = l:n
let l:n += 1
if getline(l:n) =~# '^\s*|'
while l:n <= line('$')
if getline(l:n) !~# '^\s*|'
break
endif
exe n 'delete'
exe l:n 'delete'
endwhile
call setpos('.', [0, sn, 1, 0])
call setpos('.', [0, l:sn, 1, 0])
else
let spaces = matchstr(getline(sn), '^\s*')
call append(sn, spaces . ' | ')
call setpos('.', [0, sn+1, 1, 0])
let l:spaces = matchstr(getline(l:sn), '^\s*')
call append(l:sn, l:spaces . ' | ')
call setpos('.', [0, l:sn+1, 1, 0])
startinsert!
endif
break
endif
let n -= 1
let l:n -= 1
endwhile
endfunction
function! emmet#lang#slim#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]'))
let l:n = line('.')
let l:ml = 0
while l:n > 0
if getline(l:n) =~# '^\s*\ze[a-z]'
let l:ml = len(matchstr(getline(l:n), '^\s*[a-z]'))
break
endif
let n -= 1
let l: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
let l:sn = l:n
while l:n < line('$')
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
if l:l > 0 && l:l <= l:ml
let l:n -= 1
break
endif
let n += 1
let l:n += 1
endwhile
if sn == n
if l:sn == l:n
exe 'delete'
else
exe sn ',' (n-1) 'delete'
exe l:sn ',' (l:n-1) 'delete'
endif
endfunction
function! emmet#lang#slim#mergeLines() abort
endfunction

View File

@@ -1,9 +1,9 @@
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',
let l:wcount = matchstr(a:command, '\(\d*\)$')
let l:wcount = l:wcount > 0 ? l:wcount : 30
let l:common = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit']
let l: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',
@@ -32,34 +32,34 @@ function! emmet#lorem#en#expand(command) abort
\ '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
let l:ret = []
let l:sentence = 0
for l:i in range(l:wcount)
let l:arr = l:common
if l:sentence > 0
let l:arr += l:words
endif
let r = emmet#util#rand()
let word = arr[r % len(arr)]
if sentence == 0
let word = substitute(word, '^.', '\U&', '')
let l:r = emmet#util#rand()
let l:word = l:arr[l:r % len(l:arr)]
if l:sentence == 0
let l:word = substitute(l: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)
let l:sentence += 1
call add(l:ret, l:word)
if (l:sentence > 5 && emmet#util#rand() < 10000) || l:i == l:wcount - 1
if l:i == l:wcount - 1
let l:endc = '?!...'[emmet#util#rand() % 5]
call add(l:ret, l:endc)
else
let endc = '?!,...'[emmet#util#rand() % 6]
call add(ret, endc . ' ')
let l:endc = '?!,...'[emmet#util#rand() % 6]
call add(l:ret, l:endc . ' ')
endif
if endc !=# ','
let sentence = 0
if l:endc !=# ','
let l:sentence = 0
endif
else
call add(ret, ' ')
call add(l:ret, ' ')
endif
endfor
return join(ret, '')
return join(l:ret, '')
endfunction

View File

@@ -1,27 +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 l:wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '')
let l:wcount = l:wcount > 0 ? l: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)
let l:url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html"
let l:content = emmet#util#cache(l:url)
if len(l:content) == 0
let l:content = emmet#util#getContentFromURL(l:url)
let l:content = matchstr(l:content, '<div[^>]*>\zs.\{-}</div>')
let l:content = substitute(l:content, '[ \r]', '', 'g')
let l:content = substitute(l:content, '<br[^>]*>', "\n", 'g')
let l:content = substitute(l:content, '<[^>]\+>', '', 'g')
let l:content = join(filter(split(l:content, "\n"), 'len(v:val)>0'), "\n")
call emmet#util#cache(l:url, l: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
let l:content = substitute(l:content, "、\n", "、", "g")
let l:clines = split(l:content, '\n')
let l:lines = filter(l:clines, 'len(substitute(v:val,".",".","g"))<=l:wcount')
if len(l:lines) == 0
let l:lines = l:clines
endif
let r = emmet#util#rand()
return lines[r % len(lines)]
let l:r = emmet#util#rand()
return l:lines[l:r % len(l:lines)]
endfunction

View File

@@ -12,10 +12,10 @@
" begin::end
" --------------------
function! emmet#util#deleteContent(region) abort
let lines = getline(a:region[0][0], a:region[1][0])
let l: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]])
call setline(line('.'), l:lines[0][:a:region[0][1]-2] . l:lines[-1][a:region[1][1]])
endfunction
" change_content : change content in region
@@ -37,36 +37,36 @@ endfunction
" 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])
let l:newlines = split(a:content, '\n', 1)
let l: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 len(l:newlines) == 0
let l:tmp = ''
if a:region[0][1] > 1
let tmp = oldlines[0][:a:region[0][1]-2]
let l:tmp = l:oldlines[0][:a:region[0][1]-2]
endif
if a:region[1][1] >= 1
let tmp .= oldlines[-1][a:region[1][1]:]
let l:tmp .= l:oldlines[-1][a:region[1][1]:]
endif
call setline(line('.'), tmp)
elseif len(newlines) == 1
call setline(line('.'), l:tmp)
elseif len(l:newlines) == 1
if a:region[0][1] > 1
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
let l:newlines[0] = l:oldlines[0][:a:region[0][1]-2] . l:newlines[0]
endif
if a:region[1][1] >= 1
let newlines[0] .= oldlines[-1][a:region[1][1]:]
let l:newlines[0] .= l:oldlines[-1][a:region[1][1]:]
endif
call setline(line('.'), newlines[0])
call setline(line('.'), l:newlines[0])
else
if a:region[0][1] > 1
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
let l:newlines[0] = l:oldlines[0][:a:region[0][1]-2] . l:newlines[0]
endif
if a:region[1][1] >= 1
let newlines[-1] .= oldlines[-1][a:region[1][1]:]
let l:newlines[-1] .= l:oldlines[-1][a:region[1][1]:]
endif
call setline(line('.'), newlines[0])
call append(line('.'), newlines[1:])
call setline(line('.'), l:newlines[0])
call append(line('.'), l:newlines[1:])
endif
endfunction
@@ -93,8 +93,8 @@ endfunction
" 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)
let l:cur = emmet#util#getcurpos()[1:2]
return emmet#util#pointInRegion(l:cur, a:region)
endfunction
" region_is_valid : check region is valid
@@ -107,11 +107,11 @@ 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]
let l:b = searchpairpos(a:start, '', a:end, 'bcnW')
if l: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')]
return [l:b, searchpairpos(a:start, '', a:end. '', 'nW')]
endif
endfunction
@@ -121,14 +121,14 @@ 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])
let l: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]
let l:lines[0] = l: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]
let l:lines[0] = l:lines[0][a:region[0][1]-1:]
let l:lines[-1] = l:lines[-1][:a:region[1][1]-1]
endif
return join(lines, "\n")
return join(l:lines, "\n")
endfunction
" region_in_region : check region is in the region
@@ -150,145 +150,145 @@ 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)
let l:res = system(printf('%s -i %s', g:emmet_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
while l:res =~# '^HTTP/1.\d 3' || l:res =~# '^HTTP/1\.\d 200 Connection established' || l:res =~# '^HTTP/1\.\d 100 Continue'
let l:pos = stridx(l:res, "\r\n\r\n")
if l:pos != -1
let l:res = strpart(l:res, l:pos+4)
else
let pos = stridx(res, "\n\n")
let res = strpart(res, pos+2)
let l:pos = stridx(l:res, "\n\n")
let l:res = strpart(l:res, l:pos+2)
endif
endwhile
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let content = strpart(res, pos+4)
let l:pos = stridx(l:res, "\r\n\r\n")
if l:pos != -1
let l:content = strpart(l:res, l:pos+4)
else
let pos = stridx(res, "\n\n")
let content = strpart(res, pos+2)
let l:pos = stridx(l:res, "\n\n")
let l:content = strpart(l:res, l: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["'']\?[^>]*>')
let l:header = l:res[:l:pos-1]
let l:charset = matchstr(l:content, '<meta[^>]\+content=["''][^;"'']\+;\s*charset=\zs[^;"'']\+\ze["''][^>]*>')
if len(l:charset) == 0
let l:charset = matchstr(l:content, '<meta\s\+charset=["'']\?\zs[^"'']\+\ze["'']\?[^>]*>')
endif
if len(charset) == 0
let charset = matchstr(header, '\nContent-Type:.* charset=[''"]\?\zs[^''";\n]\+\ze')
if len(l:charset) == 0
let l:charset = matchstr(l: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
if len(l:charset) == 0
let l:s1 = len(split(l:content, '?'))
let l:utf8 = iconv(l:content, 'utf-8', &encoding)
let l:s2 = len(split(l:utf8, '?'))
return (l:s2 == l:s1 || l:s2 >= l:s1 * 2) ? l:utf8 : l:content
endif
return iconv(content, charset, &encoding)
return iconv(l:content, l:charset, &encoding)
endfunction
function! emmet#util#getTextFromHTML(buf) abort
let threshold_len = 100
let threshold_per = 0.1
let buf = a:buf
let l:threshold_len = 100
let l:threshold_per = 0.1
let l: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, '&gt;', '>', 'g')
let str = substitute(str, '&lt;', '<', 'g')
let str = substitute(str, '&quot;', '"', 'g')
let str = substitute(str, '&apos;', '''', 'g')
let str = substitute(str, '&nbsp;', ' ', 'g')
let str = substitute(str, '&yen;', '\&#65509;', 'g')
let str = substitute(str, '&amp;', '\&', '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
let l:buf = strpart(l:buf, stridx(l:buf, '</head>'))
let l:buf = substitute(l:buf, '<style[^>]*>.\{-}</style>', '', 'g')
let l:buf = substitute(l:buf, '<script[^>]*>.\{-}</script>', '', 'g')
let l:res = ''
let l:max = 0
let l:mx = '\(<td[^>]\{-}>\)\|\(<\/td>\)\|\(<div[^>]\{-}>\)\|\(<\/div>\)'
let l:m = split(l:buf, l:mx)
for l:str in l:m
let l:c = split(l:str, '<[^>]*?>')
let l:str = substitute(l:str, '<[^>]\{-}>', ' ', 'g')
let l:str = substitute(l:str, '&gt;', '>', 'g')
let l:str = substitute(l:str, '&lt;', '<', 'g')
let l:str = substitute(l:str, '&quot;', '"', 'g')
let l:str = substitute(l:str, '&apos;', '''', 'g')
let l:str = substitute(l:str, '&nbsp;', ' ', 'g')
let l:str = substitute(l:str, '&yen;', '\&#65509;', 'g')
let l:str = substitute(l:str, '&amp;', '\&', 'g')
let l:str = substitute(l:str, '^\s*\(.*\)\s*$', '\1', '')
let l:str = substitute(l:str, '\s\+', ' ', 'g')
let l:l = len(l:str)
if l:l > l:threshold_len
let l:per = (l:l+0.0) / len(l:c)
if l:max < l:l && l:per > l:threshold_per
let l:max = l:l
let l:res = l:str
endif
endif
endfor
let res = substitute(res, '^\s*\(.*\)\s*$', '\1', 'g')
return res
let l:res = substitute(l:res, '^\s*\(.*\)\s*$', '\1', 'g')
return l:res
endfunction
function! emmet#util#getImageSize(fn) abort
let fn = a:fn
let l:fn = a:fn
if emmet#util#isImageMagickInstalled()
return emmet#util#imageSizeWithImageMagick(fn)
return emmet#util#imageSizeWithImageMagick(l:fn)
endif
if filereadable(fn)
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
if filereadable(l:fn)
let l:hex = substitute(system('xxd -p '.shellescape(l:fn)), '\n', '', 'g')
else
if fn !~# '^\w\+://'
let path = fnamemodify(expand('%'), ':p:gs?\\?/?')
if has('win32') || has('win64') |
let path = tolower(path)
if l:fn !~# '^\w\+://'
let l:path = fnamemodify(expand('%'), ':p:gs?\\?/?')
if has('win32') || has('win64') |
let l:path = tolower(l:path)
endif
for k in keys(g:emmet_docroot)
let root = fnamemodify(k, ':p:gs?\\?/?')
if has('win32') || has('win64') |
let root = tolower(root)
for l:k in keys(g:emmet_docroot)
let l:root = fnamemodify(l:k, ':p:gs?\\?/?')
if has('win32') || has('win64') |
let l:root = tolower(l:root)
endif
if stridx(path, root) == 0
let v = g:emmet_docroot[k]
let fn = (len(v) == 0 ? k : v) . fn
if stridx(l:path, l:root) == 0
let l:v = g:emmet_docroot[l:k]
let l:fn = (len(l:v) == 0 ? l:k : l:v) . l:fn
break
endif
endfor
endif
let hex = substitute(system(g:emmet_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g')
let l:hex = substitute(system(g:emmet_curl_command.' '.shellescape(l: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])
let [l:width, l:height] = [-1, -1]
if l:hex =~# '^89504e470d0a1a0a'
let l:width = eval('0x'.l:hex[32:39])
let l:height = eval('0x'.l: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])
if l:hex =~# '^ffd8'
let l:pos = 4
while l:pos < len(l:hex)
let l:bs = l:hex[l:pos+0:l:pos+3]
let l:pos += 4
if l:bs ==# 'ffc0' || l:bs ==# 'ffc2'
let l:pos += 6
let l:height = eval('0x'.l:hex[l:pos+0:l:pos+1])*256 + eval('0x'.l:hex[l:pos+2:l:pos+3])
let l:pos += 4
let l:width = eval('0x'.l:hex[l:pos+0:l:pos+1])*256 + eval('0x'.l:hex[l:pos+2:l:pos+3])
break
elseif bs =~# 'ffd[9a]'
elseif l: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
elseif l:bs =~# 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)'
let l:pos += (eval('0x'.l:hex[l:pos+0:l:pos+1])*256 + eval('0x'.l:hex[l:pos+2:l: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])
if l:hex =~# '^47494638'
let l:width = eval('0x'.l:hex[14:15].l:hex[12:13])
let l:height = eval('0x'.l:hex[18:19].l:hex[16:17])
endif
return [width, height]
return [l:width, l: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
let l:img_info = system('identify -format "%wx%h" '.shellescape(a:fn))
let l:img_size = split(substitute(l:img_info, '\n', '', ''), 'x')
if len(l:img_size) != 2
return [-1, -1]
endif
return img_size
return l:img_size
endfunction
function! emmet#util#isImageMagickInstalled() abort
@@ -298,16 +298,79 @@ function! emmet#util#isImageMagickInstalled() abort
return executable('identify')
endfunction
function! s:b64encode(bytes, table, pad)
let l:b64 = []
for l:i in range(0, len(a:bytes) - 1, 3)
let l:n = a:bytes[l:i] * 0x10000
\ + get(a:bytes, l:i + 1, 0) * 0x100
\ + get(a:bytes, l:i + 2, 0)
call add(l:b64, a:table[l:n / 0x40000])
call add(l:b64, a:table[l:n / 0x1000 % 0x40])
call add(l:b64, a:table[l:n / 0x40 % 0x40])
call add(l:b64, a:table[l:n % 0x40])
endfor
if len(a:bytes) % 3 == 2
let l:b64[-1] = a:pad
elseif len(a:bytes) % 3 == 1
let l:b64[-1] = a:pad
let l:b64[-2] = a:pad
endif
return l:b64
endfunction
function! emmet#util#imageEncodeDecode(fn, flag) abort
let l:fn = a:fn
if filereadable(l:fn)
let l:hex = substitute(system('xxd -p '.shellescape(l:fn)), '\n', '', 'g')
else
if l:fn !~# '^\w\+://'
let l:path = fnamemodify(expand('%'), ':p:gs?\\?/?')
if has('win32') || has('win64') |
let l:path = tolower(l:path)
endif
for l:k in keys(g:emmet_docroot)
let l:root = fnamemodify(l:k, ':p:gs?\\?/?')
if has('win32') || has('win64') |
let l:root = tolower(l:root)
endif
if stridx(l:path, l:root) == 0
let l:v = g:emmet_docroot[l:k]
let l:fn = (len(l:v) == 0 ? l:k : l:v) . l:fn
break
endif
endfor
endif
let l:hex = substitute(system(g:emmet_curl_command.' '.shellescape(l:fn).' | xxd -p'), '\n', '', 'g')
endif
let l:bin = map(split(l:hex, '..\zs'), 'eval("0x" . v:val)')
let l:table = split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', '\zs')
let l:ret = 'data:image/'
if l:hex =~# '^89504e470d0a1a0a'
let l:ret .= 'png'
elseif l:hex =~# '^ffd8'
let l:ret .= 'jpeg'
elseif l:hex =~# '^47494638'
let l:ret .= 'gif'
elseif l:hex =~# '^00000020667479706176696600000000'
let l:ret .= 'avif'
else
let l:ret .= 'unknown'
endif
return l:ret . ';base64,' . join(s:b64encode(l:bin, l: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)
let l:m = {}
let l:r = []
for l:i in a:arr
if !has_key(l:m, l:i)
let l:m[l:i] = 1
call add(l:r, l:i)
endif
endfor
return r
return l:r
endfunction
let s:seed = localtime()
@@ -321,27 +384,27 @@ function! emmet#util#rand() abort
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)
let l:content = get(a:000, 0, '')
let l:dir = expand('~/.emmet/cache')
if !isdirectory(l:dir)
call mkdir(l:dir, 'p', 0700)
endif
let file = dir . '/' . substitute(a:name, '\W', '_', 'g')
if len(content) == 0
if !filereadable(file)
let l:file = l:dir . '/' . substitute(a:name, '\W', '_', 'g')
if len(l:content) == 0
if !filereadable(l:file)
return ''
endif
return join(readfile(file), "\n")
return join(readfile(l:file), "\n")
endif
call writefile(split(content, "\n"), file)
call writefile(split(l:content, "\n"), l:file)
endfunction
function! emmet#util#getcurpos() abort
let pos = getpos('.')
if mode(0) ==# 'i' && pos[2] > 0
let pos[2] -=1
let l:pos = getpos('.')
if mode(0) ==# 'i' && l:pos[2] > 0
let l:pos[2] -=1
endif
return pos
return l:pos
endfunction
function! emmet#util#closePopup() abort

View File

@@ -148,21 +148,19 @@ You should copy this section and create new buffer, paste and write as
</p>
</div>
<
2. Expand abbreviation *emmet-expand-word* *<C-y>;*
2. Expand word *emmet-expand-word* *<C-y>;*
When you want to expand word except html tokens like below, use this.
>
<html
>foo
<html>foo
<
This will be expanded like:
>
<html
><foo></foo>
<html><foo></foo>
<
3. Update tag *emmet-update-tag* *<C-y>u*
The begining of tags '<div>' on below
The beginning of tags '<div>' on below
>
<div>foo</div>
<
@@ -172,7 +170,7 @@ You should copy this section and create new buffer, paste and write as
<
This will be expanded like:
>
<div class=".global">foo</div>
<div class="global">foo</div>
<
4. Wrap with abbreviation *emmet-wrap-with-abbreviation* *v_<C-y>,*
@@ -1266,14 +1264,14 @@ CUSTOMIZE *emmet-customize*
1. Key mapping *emmet-customize-key-mappings*
To specify leading key for expanding or balance tag, or for all,
Add this line in your 'vimrc': >
Add this line in your 'vimrc':
>
let g:user_emmet_leader_key = '<C-y>'
<
Note that to expand abbreviation a trailing ',' must be typed, so
the resultant keymap is '<C-y>,'.
If you prefer to map for each actions separately, use following valuables:
If you prefer to map for each action separately, use following variables:
>
let g:user_emmet_expandabbr_key = '<C-y>,'
let g:user_emmet_expandword_key = '<C-y>;'
@@ -1334,7 +1332,7 @@ CUSTOMIZE *emmet-customize*
3. Define tag's behavior *emmet-define-tags-behavior*
User can create abbreviations and snippets for each filetypes
User can create abbreviations and snippets for each filetype
using |g:user_emmet_settings|. For details, see official site of Emmet.
For example, user can add following:
>

BIN
doc/screenshot.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

1
docs Submodule

Submodule docs added at ff5a094cc8

25
lua/emmet_utils.lua Normal file
View File

@@ -0,0 +1,25 @@
local M = {}
M.get_node_at_cursor = function()
local ts_utils = require("nvim-treesitter.ts_utils")
local node = ts_utils.get_node_at_cursor()
if not node then
return nil
end
while node do
local node_type = node:type()
if node_type == "element" then
return "html"
elseif node_type == "stylesheet" then
return "css"
end
node = node:parent()
end
return ""
end
return M

View File

@@ -23,6 +23,7 @@
" | <head>
" | <title></title>
" | <meta charset="UTF-8">
" | <meta name="viewport" content="width=device-width, initial-scale=1.0">
" | </head>
" | <body>
" | _
@@ -46,7 +47,7 @@
" 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_emmet_settings = {
" \ 'indentation' : ' ',
@@ -95,8 +96,8 @@ if !exists('g:user_emmet_leader_key')
endif
function! s:install_plugin(mode, buffer)
let buffer = a:buffer ? '<buffer>' : ''
let items = [
let l:buffer = a:buffer ? '<buffer>' : ''
let l: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>'},
@@ -106,13 +107,13 @@ function! s:install_plugin(mode, buffer)
\ {'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': ':call emmet#balanceTag(2)<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': ':call emmet#balanceTag(-2)<cr>'},
\ {'mode': 'i', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': '<esc>:call emmet#moveNextPrev(0)<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': '<esc>:call emmet#moveNextPrev(1)<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>'},
@@ -120,6 +121,8 @@ function! s:install_plugin(mode, buffer)
\ {'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>'},
@@ -130,24 +133,25 @@ function! s:install_plugin(mode, buffer)
\ {'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': 'v', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': ':call emmet#mergeLines()<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
let l:only_plug = get(g:, 'emmet_install_only_plug', 0)
for l:item in l:items
if a:mode !=# 'a' && stridx(a:mode, l: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)
exe l:item.mode . 'noremap '. l:buffer .' <plug>(' . l:item.plug . ') ' . l:item.func
if l:item.var != '' && !l:only_plug
if exists('g:' . l:item.var)
let l:key = eval('g:' . l:item.var)
else
let key = g:user_emmet_leader_key . item.key
let l:key = g:user_emmet_leader_key . l:item.key
endif
if !hasmapto('<plug>(' . item.plug . ')', item.mode) && !len(maparg(key, item.mode))
exe item.mode . 'map ' . buffer . ' <unique> ' . key . ' <plug>(' . item.plug . ')'
if !hasmapto('<plug>(' . l:item.plug . ')', l:item.mode) && !len(maparg(l:key, l:item.mode))
exe l:item.mode . 'map ' . l:buffer . ' <unique> <silent>' . l:key . ' <plug>(' . l:item.plug . ')'
endif
endif
endfor
@@ -171,6 +175,17 @@ 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

View File

@@ -1,5 +1,6 @@
" {{{
let s:sfile = expand('<sfile>')
let s:logging = 0
function! s:reload(d)
exe 'so' a:d.'/plugin/emmet.vim'
@@ -8,22 +9,32 @@ function! s:reload(d)
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)
@@ -36,37 +47,39 @@ 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)) . ' ... '
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
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
@@ -91,6 +104,7 @@ 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
@@ -108,6 +122,7 @@ function! s:test(...)
if stridx(query, '$$$$') != -1
silent! 1new
silent! exe 'setlocal ft='.testgroup.type
EmmetInstall
silent! let key = matchstr(query, '.*\$\$\$\$\zs.*\ze\$\$\$\$')
if len(key) > 0
exe printf('let key = "%s"', key)
@@ -154,8 +169,9 @@ function! s:test(...)
endfor
endfunction
function! s:do_tests(...)
function! s:do_tests(bang, ...)
try
let s:logging = a:bang
if exists('g:user_emmet_settings')
let s:old_user_emmet_settings = g:user_emmet_settings
endif
@@ -165,13 +181,22 @@ function! s:do_tests(...)
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('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
@@ -189,7 +214,7 @@ function! s:emmet_unittest_complete(arglead, cmdline, cmdpos)
return []
endfunction
command! -nargs=* -complete=customlist,<SID>emmet_unittest_complete EmmetUnitTest 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')
EmmetUnitTest
endif
@@ -241,7 +266,7 @@ finish
},
{
'query': "html:xt>div#header>div#logo+ul#nav>li.item-$*5>a",
'result': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n\t<head>\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\n\t\t<title>${1:Document}</title>\n\t</head>\n\t<body>\n\t<div id=\"header\">\n\t\t<div id=\"logo\"></div>\n\t\t<ul id=\"nav\">\n\t\t\t<li class=\"item-1\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-2\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-3\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-4\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-5\"><a href=\"\"></a></li>\n\t\t</ul>\n\t</div>\n\t\n</body>\n</html>",
'result': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\" />\n\t<title></title>\n</head>\n<body>\n\t<div id=\"header\">\n\t\t<div id=\"logo\"></div>\n\t\t<ul id=\"nav\">\n\t\t\t<li class=\"item-1\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-2\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-3\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-4\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-5\"><a href=\"\"></a></li>\n\t\t</ul>\n\t</div>\n\t\n</body>\n</html>",
},
{
'query': "ol>li*2",
@@ -297,11 +322,11 @@ 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]",
@@ -332,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",
},
{
@@ -537,7 +562,11 @@ finish
},
{
'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_large\" type=\"submit\" value=\"\">\n</form>\n",
'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",
},
],
},
@@ -546,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>",
},
],
},
{
@@ -644,6 +681,19 @@ finish
'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",
},
],
},
],
@@ -692,7 +742,7 @@ finish
},
{
'query': "{-bdrs20$$$$}",
'result': "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\nborder-radius: 20px;}",
'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)$$$$}",
@@ -799,7 +849,7 @@ finish
],
},
{
'name': 'expand abbreviation',
'name': 'split join',
'tests': [
{
'query': "%a foo\n bar$$$$\\<c-y>j$$$$",
@@ -980,7 +1030,7 @@ finish
},
{
'query': "{-bdrs20$$$$}",
'result': "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\nborder-radius: 20px;}",
'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)$$$$}",
@@ -1014,5 +1064,67 @@ finish
},
],
'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 fdm=marker: