mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-06 10:44:24 +08:00
Compare commits
1 Commits
74d582b66e
...
fix-abbr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fe726da47 |
8
.github/FUNDING.yml
vendored
8
.github/FUNDING.yml
vendored
@@ -1,8 +0,0 @@
|
||||
# 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
11
.travis.yml
@@ -1,11 +0,0 @@
|
||||
language: generic
|
||||
sudo: false
|
||||
dist: xenial
|
||||
git:
|
||||
depth: 10
|
||||
|
||||
script:
|
||||
- uname -a
|
||||
- which -a vim
|
||||
- vim --cmd version --cmd quit
|
||||
- make test
|
||||
21
LICENSE
21
LICENSE
@@ -1,21 +0,0 @@
|
||||
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.
|
||||
4
Makefile
4
Makefile
@@ -9,7 +9,3 @@ 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
|
||||
|
||||
93
README.mkd
93
README.mkd
@@ -1,68 +1,47 @@
|
||||
# Emmet-vim
|
||||
|
||||
|
||||
[](https://travis-ci.org/mattn/emmet-vim)
|
||||
|
||||
[emmet-vim](https://mattn.github.io/emmet-vim/) is a vim plug-in
|
||||
[emmet-vim](http://mattn.github.com/emmet-vim) is a vim plug-in
|
||||
which provides support for expanding abbreviations similar to
|
||||
[emmet](http://emmet.io/).
|
||||
|
||||

|
||||
[](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
||||
## Installation
|
||||
|
||||
[Download zip file](http://www.vim.org/scripts/script.php?script_id=2981):
|
||||
|
||||
```sh
|
||||
cd ~/.vim
|
||||
unzip emmet-vim.zip
|
||||
```
|
||||
cd ~/.vim
|
||||
unzip emmet-vim.zip
|
||||
|
||||
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
|
||||
```
|
||||
To install using pathogen.vim:
|
||||
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/mattn/emmet-vim.git
|
||||
|
||||
To install using [Vundle](https://github.com/gmarik/vundle):
|
||||
|
||||
```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'
|
||||
```
|
||||
" add this line to your .vimrc file
|
||||
Plugin 'mattn/emmet-vim'
|
||||
|
||||
To checkout the source from repository:
|
||||
|
||||
```sh
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/mattn/emmet-vim.git
|
||||
```
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/mattn/emmet-vim.git
|
||||
|
||||
or:
|
||||
|
||||
```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/
|
||||
```
|
||||
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:
|
||||
|
||||
```sh
|
||||
vim index.html
|
||||
```
|
||||
vim index.html
|
||||
|
||||
Type ("\_" is the cursor position):
|
||||
|
||||
@@ -83,7 +62,7 @@ Then type `<c-y>,` (<kbd>Ctrl</kbd><kbd>y</kbd><kbd>,</kbd>), and you should see
|
||||
</html>
|
||||
```
|
||||
|
||||
[More Tutorials](https://raw.githubusercontent.com/mattn/emmet-vim/master/TUTORIAL)
|
||||
[More Tutorials](https://raw.github.com/mattn/emmet-vim/master/TUTORIAL)
|
||||
|
||||
|
||||
## Enable in different mode
|
||||
@@ -124,42 +103,10 @@ 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:
|
||||
@@ -172,7 +119,7 @@ Update this in your .vimrc file.
|
||||
|
||||
### emmet.vim:
|
||||
|
||||
* <https://mattn.github.io/emmet-vim/>
|
||||
* <http://mattn.github.com/emmet-vim>
|
||||
|
||||
### development repository:
|
||||
|
||||
|
||||
247
TUTORIAL.mkd
247
TUTORIAL.mkd
@@ -1,247 +0,0 @@
|
||||
# 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',
|
||||
\ },
|
||||
\}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
let s:save_cpo = &cpoptions
|
||||
set cpoptions&vim
|
||||
|
||||
let s:filtermx = '|\(\%(bem\|html\|blade\|haml\|slim\|e\|c\|s\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$'
|
||||
let s:filtermx = '|\(\%(bem\|html\|haml\|slim\|e\|c\|s\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$'
|
||||
|
||||
function! emmet#getExpandos(type, key) abort
|
||||
let expandos = emmet#getResource(a:type, 'expandos', {})
|
||||
@@ -49,8 +49,7 @@ function! emmet#getIndentation(...) abort
|
||||
elseif has_key(s:emmet_settings.variables, 'indentation')
|
||||
let indent = s:emmet_settings.variables.indentation
|
||||
else
|
||||
let sw = exists('*shiftwidth') ? shiftwidth() : &l:shiftwidth
|
||||
let indent = (&l:expandtab || &l:tabstop !=# sw) ? repeat(' ', sw) : "\t"
|
||||
let indent = (&l:expandtab || &l:tabstop !=# &l:shiftwidth) ? repeat(' ', &l:shiftwidth) : "\t"
|
||||
endif
|
||||
return indent
|
||||
endfunction
|
||||
@@ -85,7 +84,12 @@ function! emmet#isExtends(type, extend) abort
|
||||
if !has_key(s:emmet_settings[a:type], 'extends')
|
||||
return 0
|
||||
endif
|
||||
let extends = emmet#lang#getExtends(a:type)
|
||||
let extends = s:emmet_settings[a:type].extends
|
||||
if type(extends) ==# 1
|
||||
let tmp = split(extends, '\s*,\s*')
|
||||
unlet! extends
|
||||
let extends = tmp
|
||||
endif
|
||||
for ext in extends
|
||||
if a:extend ==# ext
|
||||
return 1
|
||||
@@ -97,7 +101,8 @@ endfunction
|
||||
function! emmet#parseIntoTree(abbr, type) abort
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
return emmet#lang#{emmet#lang#type(type)}#parseIntoTree(abbr, type)
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#parseIntoTree(abbr, type)
|
||||
endfunction
|
||||
|
||||
function! emmet#expandAbbrIntelligent(feedkey) abort
|
||||
@@ -114,8 +119,8 @@ function! emmet#isExpandable() abort
|
||||
endif
|
||||
let part = matchstr(line, '\(\S.*\)$')
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#lang#type(type)
|
||||
let part = emmet#lang#{rtype}#findTokens(part)
|
||||
let ftype = emmet#lang#exists(type) ? type : 'html'
|
||||
let part = emmet#lang#{ftype}#findTokens(part)
|
||||
return len(part) > 0
|
||||
endfunction
|
||||
|
||||
@@ -171,28 +176,24 @@ function! emmet#mergeConfig(lhs, rhs) abort
|
||||
endfunction
|
||||
|
||||
function! emmet#newNode() abort
|
||||
return { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'basevalue': 0, 'basedirect': 1, 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0, 'attrs_order': ['id', 'class'], 'block': 0, 'empty': 0 }
|
||||
return { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'basevalue': 0, 'basedirect': 1, 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0, 'attrs_order': ['id', 'class'] }
|
||||
endfunction
|
||||
|
||||
function! s:itemno(itemno, current) abort
|
||||
let current = a:current
|
||||
if current.basedirect > 0
|
||||
return current.basevalue - 1 + a:itemno
|
||||
else
|
||||
return current.multiplier + current.basevalue - 2 - a:itemno
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:localvar(current, key) abort
|
||||
let val = ''
|
||||
let cur = a:current
|
||||
while !empty(cur)
|
||||
if has_key(cur, 'variables') && has_key(cur.variables, a:key)
|
||||
return cur.variables[a:key]
|
||||
if current.basevalue ==# 0
|
||||
return a:itemno
|
||||
else
|
||||
return current.basevalue - 1 + a:itemno
|
||||
endif
|
||||
let cur = cur.parent
|
||||
endwhile
|
||||
return ''
|
||||
else
|
||||
if current.basevalue ==# 0
|
||||
return current.multiplier - 1 - a:itemno
|
||||
else
|
||||
return current.multiplier + current.basevalue - 2 - a:itemno
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#toString(...) abort
|
||||
@@ -231,7 +232,7 @@ function! emmet#toString(...) abort
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let itemno = 0
|
||||
let str = ''
|
||||
let rtype = emmet#lang#type(type)
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
while itemno < current.multiplier
|
||||
if len(current.name)
|
||||
if current.multiplier ==# 1
|
||||
@@ -289,8 +290,8 @@ function! emmet#toString(...) abort
|
||||
else
|
||||
let inner = current.value[1:-2]
|
||||
endif
|
||||
let inner = substitute(inner, '\${child}', '', '')
|
||||
let inner = substitute(inner, "\n", "\n" . indent, 'g')
|
||||
let str = substitute(str, '\${:\(\w\+\)}', '\=s:localvar(current, submatch(1))', '')
|
||||
let str = substitute(str, '\${child}', inner, '')
|
||||
endif
|
||||
let itemno = itemno + 1
|
||||
@@ -329,14 +330,14 @@ function! emmet#getResource(type, name, default) abort
|
||||
let ret = a:default
|
||||
|
||||
if has_key(s:emmet_settings[type], 'extends')
|
||||
let extends = emmet#lang#getExtends(a:type)
|
||||
call reverse(extends) " reverse to overwrite the correct way
|
||||
let extends = s:emmet_settings[type].extends
|
||||
if type(extends) ==# 1
|
||||
let tmp = split(extends, '\s*,\s*')
|
||||
unlet! extends
|
||||
let extends = tmp
|
||||
endif
|
||||
for ext in extends
|
||||
if !has_key(s:emmet_settings, ext)
|
||||
continue
|
||||
endif
|
||||
|
||||
if has_key(s:emmet_settings[ext], a:name)
|
||||
if has_key(s:emmet_settings, ext) && has_key(s:emmet_settings[ext], a:name)
|
||||
if type(ret) ==# 3 || type(ret) ==# 4
|
||||
call emmet#mergeConfig(ret, s:emmet_settings[ext][a:name])
|
||||
else
|
||||
@@ -371,66 +372,47 @@ endfunction
|
||||
|
||||
function! emmet#getFileType(...) abort
|
||||
let flg = get(a:000, 0, 0)
|
||||
|
||||
let type = ''
|
||||
|
||||
if has_key(s:emmet_settings, &filetype)
|
||||
let type = &filetype
|
||||
if emmet#getResource(type, 'ignore_embeded_filetype', 0)
|
||||
return type
|
||||
endif
|
||||
endif
|
||||
|
||||
if get(g:, 'loaded_nvim_treesitter', 0)
|
||||
let type = luaeval('require"emmet_utils".get_node_at_cursor()')
|
||||
else
|
||||
let pos = emmet#util#getcurpos()
|
||||
let type = synIDattr(synID(max([pos[1], 1]), max([pos[2], 1]), 1), 'name')
|
||||
endif
|
||||
|
||||
" ignore htmlTagName as it seems to occur too often
|
||||
if type == 'htmlTagName'
|
||||
let type = ''
|
||||
endif
|
||||
if type =~ '^mkdSnippet'
|
||||
let type = tolower(type[10:])
|
||||
endif
|
||||
|
||||
if type =~? '^css'
|
||||
let type = 'css'
|
||||
elseif type =~? '^html'
|
||||
let type = 'html'
|
||||
elseif type =~? '^jsx'
|
||||
let type = 'jsx'
|
||||
elseif (type =~? '^js\w' || type =~? '^javascript') && !(&filetype =~? 'jsx')
|
||||
let type = 'javascript'
|
||||
elseif type =~? '^tsx'
|
||||
let type = 'tsx'
|
||||
elseif type =~? '^ts\w' || type =~? '^typescript'
|
||||
let type = 'typescript'
|
||||
elseif type =~? '^xml'
|
||||
let type = 'xml'
|
||||
elseif type == 'styledEmmetAbbreviation'
|
||||
let type = 'styled'
|
||||
let types = [&filetype]
|
||||
else
|
||||
let types = split(&filetype, '\.')
|
||||
for part in types
|
||||
if has_key(s:emmet_settings, part)
|
||||
let type = part
|
||||
break
|
||||
endif
|
||||
let base = emmet#getBaseType(part)
|
||||
if base !=# ''
|
||||
if flg
|
||||
let type = &filetype
|
||||
else
|
||||
let type = base
|
||||
endif
|
||||
unlet base
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
return len(type) == 0 ? 'html' : type
|
||||
for part in types
|
||||
if emmet#lang#exists(part)
|
||||
let type = part
|
||||
break
|
||||
endif
|
||||
let base = emmet#getBaseType(part)
|
||||
if base !=# ''
|
||||
if flg
|
||||
let type = &filetype
|
||||
else
|
||||
let type = base
|
||||
endif
|
||||
unlet base
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if type ==# 'html'
|
||||
let pos = emmet#util#getcurpos()
|
||||
let type = synIDattr(synID(pos[1], pos[2], 1), 'name')
|
||||
if type =~# '^css\w'
|
||||
let type = 'css'
|
||||
endif
|
||||
if type =~# '^html\w'
|
||||
let type = 'html'
|
||||
endif
|
||||
if type =~# '^javaScript'
|
||||
let type = 'javascript'
|
||||
endif
|
||||
if len(type) ==# 0 && type =~# '^xml'
|
||||
let type = 'xml'
|
||||
endif
|
||||
endif
|
||||
if len(type) ==# 0 | let type = 'html' | endif
|
||||
return type
|
||||
endfunction
|
||||
|
||||
function! emmet#getDollarExprs(expand) abort
|
||||
@@ -525,7 +507,8 @@ function! emmet#unescapeDollarExpr(expand) abort
|
||||
endfunction
|
||||
|
||||
function! emmet#expandAbbr(mode, abbr) range abort
|
||||
let type = emmet#getFileType(1)
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#getFileType(1)
|
||||
let indent = emmet#getIndentation(type)
|
||||
let expand = ''
|
||||
let line = ''
|
||||
@@ -561,7 +544,7 @@ function! emmet#expandAbbr(mode, abbr) range abort
|
||||
let items = emmet#parseIntoTree(query, type).child
|
||||
let itemno = 0
|
||||
for item in items
|
||||
let inner = emmet#toString(item, type, 0, filters, 0, indent)
|
||||
let inner = emmet#toString(item, rtype, 0, filters, 0, indent)
|
||||
let inner = substitute(inner, '\$#', '$line'.(itemno*(a:lastline - a:firstline + 1)/len(items)+1).'$', 'g')
|
||||
let expand .= inner
|
||||
let itemno = itemno + 1
|
||||
@@ -631,7 +614,7 @@ function! emmet#expandAbbr(mode, abbr) range abort
|
||||
let items = emmet#parseIntoTree(leader, type).child
|
||||
endif
|
||||
for item in items
|
||||
let expand .= emmet#toString(item, type, 0, filters, 0, '')
|
||||
let expand .= emmet#toString(item, rtype, 0, filters, 0, '')
|
||||
endfor
|
||||
if emmet#useFilter(filters, 'e')
|
||||
let expand = substitute(expand, '&', '\&', 'g')
|
||||
@@ -662,8 +645,8 @@ function! emmet#expandAbbr(mode, abbr) range abort
|
||||
let part = matchstr(line, '\([a-zA-Z0-9:_\-\@|]\+\)$')
|
||||
else
|
||||
let part = matchstr(line, '\(\S.*\)$')
|
||||
let rtype = emmet#lang#type(type)
|
||||
let part = emmet#lang#{rtype}#findTokens(part)
|
||||
let ftype = emmet#lang#exists(type) ? type : 'html'
|
||||
let part = emmet#lang#{ftype}#findTokens(part)
|
||||
let line = line[0: strridx(line, part) + len(part) - 1]
|
||||
endif
|
||||
if col('.') ==# col('$')
|
||||
@@ -676,9 +659,9 @@ function! emmet#expandAbbr(mode, abbr) range abort
|
||||
let filters = split(matchstr(str, s:filtermx)[1:], '\s*,\s*')
|
||||
let str = substitute(str, s:filtermx, '', '')
|
||||
endif
|
||||
let items = emmet#parseIntoTree(str, type).child
|
||||
let items = emmet#parseIntoTree(str, rtype).child
|
||||
for item in items
|
||||
let expand .= emmet#toString(item, type, 0, filters, 0, indent)
|
||||
let expand .= emmet#toString(item, rtype, 0, filters, 0, indent)
|
||||
endfor
|
||||
if emmet#useFilter(filters, 'e')
|
||||
let expand = substitute(expand, '&', '\&', 'g')
|
||||
@@ -789,69 +772,63 @@ function! emmet#updateTag() abort
|
||||
if empty(current)
|
||||
return ''
|
||||
endif
|
||||
let old_tag_name = current.name
|
||||
|
||||
let str = substitute(input('Enter Abbreviation: ', ''), '^\s*\(.*\)\s*$', '\1', 'g')
|
||||
let tag_changed = str =~# '^\s*\w'
|
||||
let item = emmet#parseIntoTree(str, type).child[0]
|
||||
for k in keys(item.attr)
|
||||
let current.attr[k] = item.attr[k]
|
||||
endfor
|
||||
if tag_changed
|
||||
let current.name = item.name
|
||||
endif
|
||||
let html = substitute(emmet#toString(current, 'html', 1), '\n', '', '')
|
||||
let html = substitute(html, '\${cursor}', '', '')
|
||||
let html = matchstr(html, '^<[^><]\+>')
|
||||
if tag_changed
|
||||
let pos2 = searchpairpos('<' . old_tag_name . '\>[^>]*>', '', '</' . old_tag_name . '>', 'W')
|
||||
if pos2 != [0, 0]
|
||||
let html .= emmet#util#getContent([region[1], pos2])[1:-2]
|
||||
let html .= '</' . current.name . '>'
|
||||
let region = [region[0], [pos2[0], pos2[1] + len(old_tag_name) + 3]]
|
||||
endif
|
||||
endif
|
||||
call emmet#util#setContent(region, html)
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! emmet#moveNextPrevItem(flag) abort
|
||||
let type = emmet#getFileType()
|
||||
return emmet#lang#{emmet#lang#type(type)}#moveNextPrevItem(a:flag)
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#moveNextPrevItem(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#moveNextPrev(flag) abort
|
||||
let type = emmet#getFileType()
|
||||
return emmet#lang#{emmet#lang#type(type)}#moveNextPrev(a:flag)
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#imageSize() abort
|
||||
let orgpos = emmet#util#getcurpos()
|
||||
let type = emmet#getFileType()
|
||||
call emmet#lang#{emmet#lang#type(type)}#imageSize()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
call emmet#lang#{rtype}#imageSize()
|
||||
silent! call setpos('.', orgpos)
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! emmet#imageEncode() abort
|
||||
function! emmet#encodeImage() abort
|
||||
let type = emmet#getFileType()
|
||||
return emmet#lang#{emmet#lang#type(type)}#imageEncode()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! emmet#toggleComment() abort
|
||||
let type = emmet#getFileType()
|
||||
call emmet#lang#{emmet#lang#type(type)}#toggleComment()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
call emmet#lang#{rtype}#toggleComment()
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! emmet#balanceTag(flag) range abort
|
||||
let type = emmet#getFileType()
|
||||
return emmet#lang#{emmet#lang#type(type)}#balanceTag(a:flag)
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#balanceTag(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#splitJoinTag() abort
|
||||
let type = emmet#getFileType()
|
||||
return emmet#lang#{emmet#lang#type(type)}#splitJoinTag()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
return emmet#lang#{rtype}#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#mergeLines() range abort
|
||||
@@ -863,13 +840,8 @@ endfunction
|
||||
|
||||
function! emmet#removeTag() abort
|
||||
let type = emmet#getFileType()
|
||||
call emmet#lang#{emmet#lang#type(type)}#removeTag()
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! emmet#mergeLines() abort
|
||||
let type = emmet#getFileType()
|
||||
call emmet#lang#{emmet#lang#type(type)}#mergeLines()
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
call emmet#lang#{rtype}#removeTag()
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
@@ -890,11 +862,9 @@ function! emmet#anchorizeURL(flag) abort
|
||||
let title = matchstr(content, mx)
|
||||
|
||||
let type = emmet#getFileType()
|
||||
let rtype = emmet#lang#type(type)
|
||||
let rtype = emmet#lang#exists(type) ? type : 'html'
|
||||
if &filetype ==# 'markdown'
|
||||
let expand = printf('[%s](%s)', substitute(title, '[\[\]]', '\\&', 'g'), url)
|
||||
elseif &filetype ==# 'rst'
|
||||
let expand = printf('`%s <%s>`_', substitute(title, '[\[\]]', '\\&', 'g'), url)
|
||||
elseif a:flag ==# 0
|
||||
let a = emmet#lang#html#parseTag('<a>')
|
||||
let a.attr.href = url
|
||||
@@ -1107,7 +1077,6 @@ let s:emmet_settings = {
|
||||
\ "d:n": "display:none;",
|
||||
\ "d:b": "display:block;",
|
||||
\ "d:f": "display:flex;",
|
||||
\ "d:if": "display:inline-flex;",
|
||||
\ "d:i": "display:inline;",
|
||||
\ "d:ib": "display:inline-block;",
|
||||
\ "d:ib+": "display: inline-block;\n*display: inline;\n*zoom: 1;",
|
||||
@@ -1612,47 +1581,6 @@ let s:emmet_settings = {
|
||||
\ "cur:m": "cursor:move;",
|
||||
\ "cur:p": "cursor:pointer;",
|
||||
\ "cur:t": "cursor:text;",
|
||||
\ "fxd": "flex-direction:|;",
|
||||
\ "fxd:r": "flex-direction:row;",
|
||||
\ "fxd:rr": "flex-direction:row-reverse;",
|
||||
\ "fxd:c": "flex-direction:column;",
|
||||
\ "fxd:cr": "flex-direction:column-reverse;",
|
||||
\ "fxw": "flex-wrap: |;",
|
||||
\ "fxw:n": "flex-wrap:nowrap;",
|
||||
\ "fxw:w": "flex-wrap:wrap;",
|
||||
\ "fxw:wr": "flex-wrap:wrap-reverse;",
|
||||
\ "fxf": "flex-flow:|;",
|
||||
\ "jc": "justify-content:|;",
|
||||
\ "jc:fs": "justify-content:flex-start;",
|
||||
\ "jc:fe": "justify-content:flex-end;",
|
||||
\ "jc:c": "justify-content:center;",
|
||||
\ "jc:sb": "justify-content:space-between;",
|
||||
\ "jc:sa": "justify-content:space-around;",
|
||||
\ "ai": "align-items:|;",
|
||||
\ "ai:fs": "align-items:flex-start;",
|
||||
\ "ai:fe": "align-items:flex-end;",
|
||||
\ "ai:c": "align-items:center;",
|
||||
\ "ai:b": "align-items:baseline;",
|
||||
\ "ai:s": "align-items:stretch;",
|
||||
\ "ac": "align-content:|;",
|
||||
\ "ac:fs": "align-content:flex-start;",
|
||||
\ "ac:fe": "align-content:flex-end;",
|
||||
\ "ac:c": "align-content:center;",
|
||||
\ "ac:sb": "align-content:space-between;",
|
||||
\ "ac:sa": "align-content:space-around;",
|
||||
\ "ac:s": "align-content:stretch;",
|
||||
\ "ord": "order:|;",
|
||||
\ "fxg": "flex-grow:|;",
|
||||
\ "fxsh": "flex-shrink:|;",
|
||||
\ "fxb": "flex-basis:|;",
|
||||
\ "fx": "flex:|;",
|
||||
\ "as": "align-self:|;",
|
||||
\ "as:a": "align-self:auto;",
|
||||
\ "as:fs": "align-self:flex-start;",
|
||||
\ "as:fe": "align-self:flex-end;",
|
||||
\ "as:c": "align-self:center;",
|
||||
\ "as:b": "align-self:baseline;",
|
||||
\ "as:s": "align-self:stretch;",
|
||||
\ "pgbb": "page-break-before:|;",
|
||||
\ "pgbb:au": "page-break-before:auto;",
|
||||
\ "pgbb:al": "page-break-before:always;",
|
||||
@@ -1676,7 +1604,6 @@ let s:emmet_settings = {
|
||||
\ "wfsm:n": "-webkit-font-smoothing:none;"
|
||||
\ },
|
||||
\ 'filters': 'fc',
|
||||
\ 'ignore_embeded_filetype': 1,
|
||||
\ },
|
||||
\ 'sass': {
|
||||
\ 'extends': 'css',
|
||||
@@ -1699,12 +1626,8 @@ let s:emmet_settings = {
|
||||
\ 'css.drupal': {
|
||||
\ 'extends': 'css',
|
||||
\ },
|
||||
\ 'styled': {
|
||||
\ 'extends': 'css',
|
||||
\ },
|
||||
\ 'html': {
|
||||
\ 'snippets': {
|
||||
\ '!': "html:5",
|
||||
\ 'abbreviations': {
|
||||
\ '!!!': "<!DOCTYPE html>\n",
|
||||
\ '!!!4t': "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n",
|
||||
\ '!!!4s': "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n",
|
||||
@@ -1715,82 +1638,31 @@ let s:emmet_settings = {
|
||||
\ 'cc:ie6': "<!--[if lte IE 6]>\n\t${child}|\n<![endif]-->",
|
||||
\ 'cc:ie': "<!--[if IE]>\n\t${child}|\n<![endif]-->",
|
||||
\ 'cc:noie': "<!--[if !IE]><!-->\n\t${child}|\n<!--<![endif]-->",
|
||||
\ 'html:4t': "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"
|
||||
\ ."<html lang=\"${lang}\">\n"
|
||||
\ ."<head>\n"
|
||||
\ ."\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\">\n"
|
||||
\ ."\t<title></title>\n"
|
||||
\ ."</head>\n"
|
||||
\ ."<body>\n\t${child}|\n</body>\n"
|
||||
\ ."</html>",
|
||||
\ 'html:4s': "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
|
||||
\ ."<html lang=\"${lang}\">\n"
|
||||
\ ."<head>\n"
|
||||
\ ."\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\">\n"
|
||||
\ ."\t<title></title>\n"
|
||||
\ ."</head>\n"
|
||||
\ ."<body>\n\t${child}|\n</body>\n"
|
||||
\ ."</html>",
|
||||
\ 'html:xt': "<!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=\"${lang}\">\n"
|
||||
\ ."<head>\n"
|
||||
\ ."\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\" />\n"
|
||||
\ ."\t<title></title>\n"
|
||||
\ ."</head>\n"
|
||||
\ ."<body>\n\t${child}|\n</body>\n"
|
||||
\ ."</html>",
|
||||
\ 'html:xs': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
|
||||
\ ."<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"${lang}\">\n"
|
||||
\ ."<head>\n"
|
||||
\ ."\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\" />\n"
|
||||
\ ."\t<title></title>\n"
|
||||
\ ."</head>\n"
|
||||
\ ."<body>\n\t${child}|\n</body>\n"
|
||||
\ ."</html>",
|
||||
\ 'html:xxs': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
|
||||
\ ."<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"${lang}\">\n"
|
||||
\ ."<head>\n"
|
||||
\ ."\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\" />\n"
|
||||
\ ."\t<title></title>\n"
|
||||
\ ."</head>\n"
|
||||
\ ."<body>\n\t${child}|\n</body>\n"
|
||||
\ ."</html>",
|
||||
\ 'html:5': "<!DOCTYPE html>\n"
|
||||
\ ."<html lang=\"${lang}\">\n"
|
||||
\ ."<head>\n"
|
||||
\ ."\t<meta charset=\"${charset}\">\n"
|
||||
\ ."\t<title></title>\n"
|
||||
\ ."</head>\n"
|
||||
\ ."<body>\n\t${child}|\n</body>\n"
|
||||
\ ."</html>",
|
||||
\ },
|
||||
\ 'snippets': {
|
||||
\ '!': "html:5",
|
||||
\ 'doc': "html>(head>meta[charset=${charset}]+title{${1:Document}})+body>${child}",
|
||||
\ 'doc4': "html>(head>meta[http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\"]+title{${1:Document}})+body>${child}",
|
||||
\ 'html:4t': "!!!4t+doc4[lang=${lang}]",
|
||||
\ 'html:4s': "!!!4s+doc4[lang=${lang}]",
|
||||
\ 'html:xt': "!!!xt+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]",
|
||||
\ 'html:xs': "!!!xs+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]",
|
||||
\ 'html:xxs': "!!!xxs+doc4[xmlns=http://www.w3.org/1999/xhtml xml:lang=${lang}]",
|
||||
\ 'html:5': "!!!+doc[lang=${lang}]",
|
||||
\ },
|
||||
\ 'default_attributes': {
|
||||
\ 'a': [{'href': ''}],
|
||||
\ 'a:blank': [{'href': 'http://|'},{'target': '_blank'},{'rel': 'noopener noreferrer'}],
|
||||
\ 'a:link': [{'href': 'http://|'}],
|
||||
\ 'a:mail': [{'href': 'mailto:|'}],
|
||||
\ 'a:tel': [{'href': 'tel:+|'}],
|
||||
\ 'abbr': [{'title': ''}],
|
||||
\ 'acronym': [{'title': ''}],
|
||||
\ 'acr': [{'title': ''}],
|
||||
\ 'base': [{'href': ''}],
|
||||
\ 'bdo': [{'dir': ''}],
|
||||
\ 'bdo:r': [{'dir': 'rtl'}],
|
||||
\ 'bdo:l': [{'dir': 'ltr'}],
|
||||
\ 'button:disabled': [{'disabled': 'disabled'}],
|
||||
\ 'button:d': [{'disabled': 'disabled'}],
|
||||
\ 'btn:d': [{'disabled': 'disabled'}],
|
||||
\ 'button:submit': [{'type': 'submit'}],
|
||||
\ 'button:s': [{'type': 'submit'}],
|
||||
\ 'btn:s': [{'type': 'submit'}],
|
||||
\ 'button:reset': [{'type': 'reset'}],
|
||||
\ 'button:r': [{'type': 'reset'}],
|
||||
\ 'btn:r': [{'type': 'reset'}],
|
||||
\ 'del': [{'datetime': '${datetime}'}],
|
||||
\ 'ins': [{'datetime': '${datetime}'}],
|
||||
\ 'link:css': [{'rel': 'stylesheet'}, g:emmet_html5 ? {} : {'type': 'text/css'}, {'href': '|style.css'}, {'media': 'all'}],
|
||||
\ 'link:manifest': [{'rel': 'manifest'},{'href': '|manifest.json'}],
|
||||
\ 'link:mf': [{'rel': 'manifest'},{'href': '|manifest.json'}],
|
||||
\ 'link:print': [{'rel': 'stylesheet'}, g:emmet_html5 ? {} : {'type': 'text/css'}, {'href': '|print.css'}, {'media': 'print'}],
|
||||
\ 'link:import': [{'rel': 'import'}, {'href': '|.html'}],
|
||||
\ 'link:im': [{'rel': 'import'}, {'href': '|.html'}],
|
||||
@@ -1798,23 +1670,14 @@ let s:emmet_settings = {
|
||||
\ 'link:touch': [{'rel': 'apple-touch-icon'}, {'href': '|favicon.png'}],
|
||||
\ 'link:rss': [{'rel': 'alternate'}, {'type': 'application/rss+xml'}, {'title': 'RSS'}, {'href': '|rss.xml'}],
|
||||
\ 'link:atom': [{'rel': 'alternate'}, {'type': 'application/atom+xml'}, {'title': 'Atom'}, {'href': 'atom.xml'}],
|
||||
\ 'marquee': [{'behavior': ''},{'direction': ''}],
|
||||
\ 'meta:utf': [{'http-equiv': 'Content-Type'}, {'content': 'text/html;charset=UTF-8'}],
|
||||
\ 'meta:vp': [{'name': 'viewport'}, {'content': 'width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0'}],
|
||||
\ 'meta:win': [{'http-equiv': 'Content-Type'}, {'content': 'text/html;charset=Win-1251'}],
|
||||
\ 'meta:compat': [{'http-equiv': 'X-UA-Compatible'}, {'content': 'IE=7'}],
|
||||
\ 'meta:desc': [{'name': 'description'},{'content': ''}],
|
||||
\ 'meta:edge': [{'http-equiv': 'X-UA-Compatible'}, {'content': 'ie=edge'}],
|
||||
\ 'meta:kw': [{'name': 'keywords'},{'content': ''}],
|
||||
\ 'meta:redirect': [{'http-equiv': 'Content-Type'}, {'content': '0; url=http://example.com'}],
|
||||
\ 'style': g:emmet_html5 ? [] : [{'type': 'text/css'}],
|
||||
\ 'script': g:emmet_html5 ? [] : [{'type': 'text/javascript'}],
|
||||
\ 'script:src': (g:emmet_html5 ? [] : [{'type': 'text/javascript'}]) + [{'src': ''}],
|
||||
\ 'script': [{'src': ''}] + (g:emmet_html5 ? [] : [{'type': 'text/javascript'}]),
|
||||
\ 'script:src': [{'src': ''}] + (g:emmet_html5 ? [] : [{'type': 'text/javascript'}, {'src': ''}]),
|
||||
\ 'img': [{'src': ''}, {'alt': ''}],
|
||||
\ 'img:srcset': [{'srcset': ''},{'src': ''}, {'alt': ''}],
|
||||
\ 'img:s': [{'srcset': ''},{'src': ''}, {'alt': ''}],
|
||||
\ 'img:sizes': [{'sizes': ''},{'srcset': ''},{'src': ''}, {'alt': ''}],
|
||||
\ 'img:z': [{'sizes': ''},{'srcset': ''},{'src': ''}, {'alt': ''}],
|
||||
\ 'iframe': [{'src': ''}, {'frameborder': '0'}],
|
||||
\ 'embed': [{'src': ''}, {'type': ''}],
|
||||
\ 'object': [{'data': ''}, {'type': ''}],
|
||||
@@ -1826,10 +1689,6 @@ let s:emmet_settings = {
|
||||
\ 'area:r': [{'shape': 'rect'}, {'coords': ''}, {'href': ''}, {'alt': ''}],
|
||||
\ 'area:p': [{'shape': 'poly'}, {'coords': ''}, {'href': ''}, {'alt': ''}],
|
||||
\ 'link': [{'rel': 'stylesheet'}, {'href': ''}],
|
||||
\ 'fieldset:disabled': [{'disabled': 'disabled'}],
|
||||
\ 'fieldset:d': [{'disabled': 'disabled'}],
|
||||
\ 'fset:d': [{'disabled': 'disabled'}],
|
||||
\ 'fst:disabled': [{'disabled': 'disabled'}],
|
||||
\ 'form': [{'action': ''}],
|
||||
\ 'form:get': [{'action': ''}, {'method': 'get'}],
|
||||
\ 'form:post': [{'action': ''}, {'method': 'post'}],
|
||||
@@ -1842,7 +1701,6 @@ let s:emmet_settings = {
|
||||
\ 'input:t': [{'type': 'text'}, {'name': ''}, {'id': ''}],
|
||||
\ 'input:search': [{'type': 'search'}, {'name': ''}, {'id': ''}],
|
||||
\ 'input:email': [{'type': 'email'}, {'name': ''}, {'id': ''}],
|
||||
\ 'input:tel': [{'type': 'tel'}, {'name': ''}, {'id': ''}],
|
||||
\ 'input:url': [{'type': 'url'}, {'name': ''}, {'id': ''}],
|
||||
\ 'input:password': [{'type': 'password'}, {'name': ''}, {'id': ''}],
|
||||
\ 'input:p': [{'type': 'password'}, {'name': ''}, {'id': ''}],
|
||||
@@ -1869,20 +1727,6 @@ let s:emmet_settings = {
|
||||
\ 'input:button': [{'type': 'button'}, {'value': ''}],
|
||||
\ 'input:b': [{'type': 'button'}, {'value': ''}],
|
||||
\ 'select': [{'name': ''}, {'id': ''}],
|
||||
\ 'select:disabled': [{'name': ''}, {'id': ''}, {'disabled': 'disabled'}],
|
||||
\ 'source:media': [{'media': '(minwidth: )'},{'srcset': ''}],
|
||||
\ 'source:m': [{'media': '(minwidth: )'},{'srcset': ''}],
|
||||
\ 'source:media:type': [{'media': '(minwidth: )'},{'srcset': ''},{'type': 'image/'}],
|
||||
\ 'source:media:sizes': [{'media': '(minwidth: )'},{'srcset': ''},{'sizes': ''}],
|
||||
\ 'source:sizes:type': [{'sizes': ''},{'srcset': ''},{'type': 'image/'}],
|
||||
\ 'source:src': [{'src': ''},{'type': ''}],
|
||||
\ 'source:sc': [{'src': ''},{'type': ''}],
|
||||
\ 'source:srcset': [{'srcset': ''}],
|
||||
\ 'source:s': [{'srcset': ''}],
|
||||
\ 'source:type': [{'srcset': ''},{'type': 'image/'}],
|
||||
\ 'source:t': [{'srcset': ''},{'type': 'image/'}],
|
||||
\ 'source:sizes': [{'sizes': ''},{'srcset': ''}],
|
||||
\ 'source:z': [{'sizes': ''},{'srcset': ''}],
|
||||
\ 'option': [{'value': ''}],
|
||||
\ 'textarea': [{'name': ''}, {'id': ''}, {'cols': '30'}, {'rows': '10'}],
|
||||
\ 'menu:context': [{'type': 'context'}],
|
||||
@@ -1904,23 +1748,19 @@ let s:emmet_settings = {
|
||||
\ 'html:*': 'html',
|
||||
\ 'a:*': 'a',
|
||||
\ 'menu:*': 'menu',
|
||||
\ 'mn': 'main',
|
||||
\ 'tem': 'template',
|
||||
\ 'bq': 'blockquote',
|
||||
\ 'acr': 'acronym',
|
||||
\ 'fig': 'figure',
|
||||
\ 'figc': 'figcaption',
|
||||
\ 'ifr': 'iframe',
|
||||
\ 'emb': 'embed',
|
||||
\ 'obj': 'object',
|
||||
\ 'src:*': 'source',
|
||||
\ 'src': 'source',
|
||||
\ 'cap': 'caption',
|
||||
\ 'colg': 'colgroup',
|
||||
\ 'fst': 'fieldset',
|
||||
\ 'btn:': 'button',
|
||||
\ 'btn': 'button',
|
||||
\ 'optg': 'optgroup',
|
||||
\ 'opt': 'option',
|
||||
\ 'pic': 'picture',
|
||||
\ 'tarea': 'textarea',
|
||||
\ 'leg': 'legend',
|
||||
\ 'sect': 'section',
|
||||
@@ -1939,7 +1779,6 @@ let s:emmet_settings = {
|
||||
\ 'out': 'output',
|
||||
\ 'det': 'details',
|
||||
\ 'cmd': 'command',
|
||||
\ 'sum': 'summary',
|
||||
\ },
|
||||
\ 'expandos': {
|
||||
\ 'ol': 'ol>li',
|
||||
@@ -1953,31 +1792,12 @@ let s:emmet_settings = {
|
||||
\ 'select': 'select>option',
|
||||
\ 'optgroup': 'optgroup>option',
|
||||
\ 'optg': 'optgroup>option',
|
||||
\ 'ri:dpr': 'img:s',
|
||||
\ 'ri:d': 'img:s',
|
||||
\ 'ri:viewport': 'img:z',
|
||||
\ 'ri:vp': 'img:z',
|
||||
\ 'ri:art': 'pic>source:m+img',
|
||||
\ 'ri:a': 'pic>source:m+img',
|
||||
\ 'ri:type': 'pic>source:t+img',
|
||||
\ 'ri:t': 'pic>source:t+img',
|
||||
\ },
|
||||
\ 'empty_elements': 'area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed,keygen,command',
|
||||
\ 'block_elements': 'address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,link,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul,h1,h2,h3,h4,h5,h6',
|
||||
\ 'inline_elements': 'a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,small,span,strike,strong,sub,sup,textarea,tt,u,var',
|
||||
\ 'inline_elements': 'a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var',
|
||||
\ 'empty_element_suffix': g:emmet_html5 ? '>' : ' />',
|
||||
\ 'indent_blockelement': 0,
|
||||
\ 'block_all_childless': 0,
|
||||
\ },
|
||||
\ 'elm': {
|
||||
\ 'indentation': ' ',
|
||||
\ 'extends': 'html',
|
||||
\ },
|
||||
\ 'xml': {
|
||||
\ 'extends': 'html',
|
||||
\ 'empty_elements': '',
|
||||
\ 'block_elements': '',
|
||||
\ 'inline_elements': '',
|
||||
\ },
|
||||
\ 'htmldjango': {
|
||||
\ 'extends': 'html',
|
||||
@@ -1988,55 +1808,6 @@ let s:emmet_settings = {
|
||||
\ 'jade': {
|
||||
\ 'indentation': ' ',
|
||||
\ 'extends': 'html',
|
||||
\ 'snippets': {
|
||||
\ '!': "html:5",
|
||||
\ '!!!': "doctype html\n",
|
||||
\ '!!!4t': "doctype HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"\n",
|
||||
\ '!!!4s': "doctype HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"\n",
|
||||
\ '!!!xt': "doctype transitional\n",
|
||||
\ '!!!xs': "doctype strict\n",
|
||||
\ '!!!xxs': "doctype 1.1\n",
|
||||
\ 'c': "\/\/ |${child}",
|
||||
\ 'html:4t': "doctype HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"\n"
|
||||
\ ."html(lang=\"${lang}\")\n"
|
||||
\ ."\thead\n"
|
||||
\ ."\t\tmeta(http-equiv=\"Content-Type\", content=\"text/html;charset=${charset}\")\n"
|
||||
\ ."\t\ttitle\n"
|
||||
\ ."\tbody\n\t\t${child}|",
|
||||
\ 'html:4s': "doctype HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"\n"
|
||||
\ ."html(lang=\"${lang}\")\n"
|
||||
\ ."\thead\n"
|
||||
\ ."\t\tmeta(http-equiv=\"Content-Type\", content=\"text/html;charset=${charset}\")\n"
|
||||
\ ."\t\ttitle\n"
|
||||
\ ."\tbody\n\t\t${child}|",
|
||||
\ 'html:xt': "doctype transitional\n"
|
||||
\ ."html(xmlns=\"http://www.w3.org/1999/xhtml\", xml:lang=\"${lang}\")\n"
|
||||
\ ."\thead\n"
|
||||
\ ."\t\tmeta(http-equiv=\"Content-Type\", content=\"text/html;charset=${charset}\")\n"
|
||||
\ ."\t\ttitle\n"
|
||||
\ ."\tbody\n\t\t${child}|",
|
||||
\ 'html:xs': "doctype strict\n"
|
||||
\ ."html(xmlns=\"http://www.w3.org/1999/xhtml\", xml:lang=\"${lang}\")\n"
|
||||
\ ."\thead\n"
|
||||
\ ."\t\tmeta(http-equiv=\"Content-Type\", content=\"text/html;charset=${charset}\")\n"
|
||||
\ ."\t\ttitle\n"
|
||||
\ ."\tbody\n\t\t${child}|",
|
||||
\ 'html:xxs': "doctype 1.1\n"
|
||||
\ ."html(xmlns=\"http://www.w3.org/1999/xhtml\", xml:lang=\"${lang}\")\n"
|
||||
\ ."\thead\n"
|
||||
\ ."\t\tmeta(http-equiv=\"Content-Type\", content=\"text/html;charset=${charset}\")\n"
|
||||
\ ."\t\ttitle\n"
|
||||
\ ."\tbody\n\t\t${child}|",
|
||||
\ 'html:5': "doctype html\n"
|
||||
\ ."html(lang=\"${lang}\")\n"
|
||||
\ ."\thead\n"
|
||||
\ ."\t\tmeta(charset=\"${charset}\")\n"
|
||||
\ ."\t\ttitle\n"
|
||||
\ ."\tbody\n\t\t${child}|",
|
||||
\ },
|
||||
\ },
|
||||
\ 'pug': {
|
||||
\ 'extends': 'jade',
|
||||
\ },
|
||||
\ 'xsl': {
|
||||
\ 'extends': 'html',
|
||||
@@ -2056,6 +1827,47 @@ let s:emmet_settings = {
|
||||
\ 'each': {'select': ''},
|
||||
\ 'ap': [{'select': ''}, {'mode': ''}]
|
||||
\ },
|
||||
\ "abbreviations": {
|
||||
\ 'tm|tmatch': "<xsl:template match=\"\" mode=\"\">",
|
||||
\ 'tn|tname': "<xsl:template name=\"\">",
|
||||
\ 'call': "<xsl:call-template name=\"\"/>",
|
||||
\ 'ap': "<xsl:apply-templates select=\"\" mode=\"\"/>",
|
||||
\ 'api': "<xsl:apply-imports/>",
|
||||
\ 'imp': "<xsl:import href=\"\"/>",
|
||||
\ 'inc': "<xsl:include href=\"\"/>",
|
||||
\ 'ch': "<xsl:choose>",
|
||||
\ 'wh|xsl:when': "<xsl:when test=\"\">",
|
||||
\ 'ot': "<xsl:otherwise>",
|
||||
\ 'if': "<xsl:if test=\"\">",
|
||||
\ 'par': "<xsl:param name=\"\">",
|
||||
\ 'pare': "<xsl:param name=\"\" select=\"\"/>",
|
||||
\ 'var': "<xsl:variable name=\"\">",
|
||||
\ 'vare': "<xsl:variable name=\"\" select=\"\"/>",
|
||||
\ 'wp': "<xsl:with-param name=\"\" select=\"\"/>",
|
||||
\ 'key': "<xsl:key name=\"\" match=\"\" use=\"\"/>",
|
||||
\ 'elem': "<xsl:element name=\"\">",
|
||||
\ 'attr': "<xsl:attribute name=\"\">",
|
||||
\ 'attrs': "<xsl:attribute-set name=\"\">",
|
||||
\ 'cp': "<xsl:copy select=\"\"/>",
|
||||
\ 'co': "<xsl:copy-of select=\"\"/>",
|
||||
\ 'val': "<xsl:value-of select=\"\"/>",
|
||||
\ 'for|each': "<xsl:for-each select=\"\">",
|
||||
\ 'tex': "<xsl:text></xsl:text>",
|
||||
\ 'com': "<xsl:comment>",
|
||||
\ 'msg': "<xsl:message terminate=\"no\">",
|
||||
\ 'fall': "<xsl:fallback>",
|
||||
\ 'num': "<xsl:number value=\"\"/>",
|
||||
\ 'nam': "<namespace-alias stylesheet-prefix=\"\" result-prefix=\"\"/>",
|
||||
\ 'pres': "<xsl:preserve-space elements=\"\"/>",
|
||||
\ 'strip': "<xsl:strip-space elements=\"\"/>",
|
||||
\ 'proc': "<xsl:processing-instruction name=\"\">",
|
||||
\ 'sort': "<xsl:sort select=\"\" order=\"\"/>",
|
||||
\ 'choose+': "xsl:choose>xsl:when+xsl:otherwise",
|
||||
\ 'xsl': "!!!+xsl:stylesheet[version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform]>{\n|}"
|
||||
\ },
|
||||
\ "snippets": {
|
||||
\ "!!!": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
\ },
|
||||
\ 'aliases': {
|
||||
\ 'tmatch': 'xsl:template',
|
||||
\ 'tname': 'xsl:template',
|
||||
@@ -2078,21 +1890,7 @@ let s:emmet_settings = {
|
||||
\ },
|
||||
\ 'jsx': {
|
||||
\ 'extends': 'html',
|
||||
\ 'attribute_name': {'class': 'className', 'for': 'htmlFor'},
|
||||
\ 'empty_element_suffix': ' />',
|
||||
\ },
|
||||
\ 'javascriptreact': {
|
||||
\ 'extends': 'html',
|
||||
\ 'attribute_name': {'class': 'className', 'for': 'htmlFor'},
|
||||
\ 'empty_element_suffix': ' />',
|
||||
\ },
|
||||
\ 'tsx': {
|
||||
\ 'extends': 'jsx',
|
||||
\ },
|
||||
\ 'typescriptreact': {
|
||||
\ 'extends': 'html',
|
||||
\ 'attribute_name': {'class': 'className', 'for': 'htmlFor'},
|
||||
\ 'empty_element_suffix': ' />',
|
||||
\ 'attribute_name': {'class': 'className'},
|
||||
\ },
|
||||
\ 'xslt': {
|
||||
\ 'extends': 'xsl',
|
||||
@@ -2100,30 +1898,16 @@ let s:emmet_settings = {
|
||||
\ 'haml': {
|
||||
\ 'indentation': ' ',
|
||||
\ 'extends': 'html',
|
||||
\ 'snippets': {
|
||||
\ 'html:5': "!!! 5\n"
|
||||
\ ."%html{:lang => \"${lang}\"}\n"
|
||||
\ ."\t%head\n"
|
||||
\ ."\t\t%meta{:charset => \"${charset}\"}\n"
|
||||
\ ."\t\t%title\n"
|
||||
\ ."\t%body\n"
|
||||
\ ."\t\t${child}|\n",
|
||||
\ 'abbreviations': {
|
||||
\ '!!!': "!!! 5",
|
||||
\ },
|
||||
\ 'attribute_style': 'hash',
|
||||
\ },
|
||||
\ 'slim': {
|
||||
\ 'indentation': ' ',
|
||||
\ 'extends': 'html',
|
||||
\ 'snippets': {
|
||||
\ 'html:5': "doctype 5\n"
|
||||
\ ."html lang=\"${lang}\"\n"
|
||||
\ ."\thead\n"
|
||||
\ ."\t\tmeta charset=\"${charset}\"\n"
|
||||
\ ."\t\ttitle\n"
|
||||
\ ."\tbody\n"
|
||||
\ ."\t\t${child}|\n",
|
||||
\ 'abbreviations': {
|
||||
\ },
|
||||
\ 'ignore_embeded_filetype': 1,
|
||||
\ },
|
||||
\ 'xhtml': {
|
||||
\ 'extends': 'html'
|
||||
|
||||
@@ -9,44 +9,3 @@ function! emmet#lang#exists(type) abort
|
||||
return s:exists[a:type]
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#type(type) abort
|
||||
let type = a:type
|
||||
let base = type
|
||||
let settings = emmet#getSettings()
|
||||
while base != ''
|
||||
for b in split(base, '\.')
|
||||
if emmet#lang#exists(b)
|
||||
return b
|
||||
endif
|
||||
if has_key(settings, b) && has_key(settings[b], 'extends')
|
||||
let base = settings[b].extends
|
||||
break
|
||||
else
|
||||
let base = ''
|
||||
endif
|
||||
endfor
|
||||
endwhile
|
||||
return 'html'
|
||||
endfunction
|
||||
|
||||
" get all extends for a type recursively
|
||||
function! emmet#lang#getExtends(type) abort
|
||||
let settings = emmet#getSettings()
|
||||
|
||||
if !has_key(settings[a:type], 'extends')
|
||||
return []
|
||||
endif
|
||||
|
||||
let extends = settings[a:type].extends
|
||||
if type(extends) ==# 1
|
||||
let tmp = split(extends, '\s*,\s*')
|
||||
unlet! extends
|
||||
let extends = tmp
|
||||
endif
|
||||
|
||||
for ext in extends
|
||||
let extends = extends + emmet#lang#getExtends(ext)
|
||||
endfor
|
||||
|
||||
return extends
|
||||
endfunction
|
||||
|
||||
@@ -23,7 +23,7 @@ function! emmet#lang#css#parseIntoTree(abbr, type) abort
|
||||
" emmet
|
||||
let tokens = split(abbr, '+\ze[^+)!]')
|
||||
let block = emmet#util#searchRegion('{', '}')
|
||||
if abbr !~# '^@' && emmet#getBaseType(type) ==# 'css' && type !=# 'sass' && type !=# 'styled' && block[0] ==# [0,0] && block[1] ==# [0,0]
|
||||
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 = ''
|
||||
@@ -31,7 +31,7 @@ function! emmet#lang#css#parseIntoTree(abbr, type) abort
|
||||
else
|
||||
for n in range(len(tokens))
|
||||
let token = tokens[n]
|
||||
let prop = matchlist(token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+\%(p\|e\|em\|x\|vh\|vw\|re\|rem\|%\)\{0,}-\{0,1}\|-auto\)*\)$')
|
||||
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 =~# '^-'
|
||||
@@ -39,51 +39,34 @@ function! emmet#lang#css#parseIntoTree(abbr, type) abort
|
||||
let token = token[1:]
|
||||
endif
|
||||
let value = ''
|
||||
for vt in split(prop[2], '\a\+\zs')
|
||||
let ut = matchstr(vt, '[a-z]\+$')
|
||||
if ut == 'auto'
|
||||
let ut = ''
|
||||
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'
|
||||
endif
|
||||
for v in split(vt, '\d\zs-')
|
||||
if len(value) > 0
|
||||
let value .= ' '
|
||||
endif
|
||||
if v !~ '[a-z]\+$'
|
||||
let v .= ut
|
||||
endif
|
||||
if token =~# '^[z]'
|
||||
" TODO
|
||||
let value .= substitute(v, '[^0-9.]*$', '', '')
|
||||
elseif v =~# 'em$'
|
||||
let value .= v
|
||||
elseif v =~# 'ex$'
|
||||
let value .= v
|
||||
elseif v =~# 'vh$'
|
||||
let value .= v
|
||||
elseif v =~# 'vw$'
|
||||
let value .= v
|
||||
elseif v =~# 'rem$'
|
||||
let value .= v
|
||||
elseif v ==# 'auto'
|
||||
let value .= v
|
||||
elseif v =~# 'p$'
|
||||
let value .= substitute(v, 'p$', '%', '')
|
||||
elseif v =~# '%$'
|
||||
let value .= v
|
||||
elseif v =~# 'e$'
|
||||
let value .= substitute(v, 'e$', 'em', '')
|
||||
elseif v =~# 'x$'
|
||||
let value .= substitute(v, 'x$', 'ex', '')
|
||||
elseif v =~# 're$'
|
||||
let value .= substitute(v, 're$', 'rem', '')
|
||||
elseif v =~# '\.'
|
||||
let value .= v . 'em'
|
||||
elseif v ==# '0'
|
||||
let value .= '0'
|
||||
else
|
||||
let value .= v . 'px'
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
|
||||
@@ -110,9 +93,6 @@ function! emmet#lang#css#parseIntoTree(abbr, type) abort
|
||||
if !has_key(snippets, snippet_name)
|
||||
let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-\)')
|
||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
||||
if len(vv) == 0
|
||||
let vv = filter(sort(keys(snippets)), 'substitute(v:val, ":", "", "g") == snippet_name')
|
||||
endif
|
||||
if len(vv) > 0
|
||||
let snippet_name = vv[0]
|
||||
else
|
||||
@@ -181,10 +161,6 @@ function! emmet#lang#css#parseIntoTree(abbr, type) abort
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-moz-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-o-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-ms-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = snippet
|
||||
call add(root.child, current)
|
||||
elseif token =~# '^c#\([0-9a-fA-F]\{3}\|[0-9a-fA-F]\{6}\)\(\.[0-9]\+\)\?'
|
||||
@@ -268,21 +244,7 @@ function! emmet#lang#css#imageSize() abort
|
||||
call emmet#util#setContent(img_region, content)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#imageEncode() abort
|
||||
let img_region = emmet#util#searchRegion('url(', ')')
|
||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = emmet#util#getContent(img_region)
|
||||
let fn = matchstr(content, '\<url(\zs[^)]\+\ze)')
|
||||
let fn = substitute(fn, '[''" \t]', '', 'g')
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
let encoded = emmet#util#imageEncodeDecode(fn, 0)
|
||||
call emmet#util#setContent(img_region, 'url(' . encoded . ')')
|
||||
function! emmet#lang#css#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#parseTag(tag) abort
|
||||
@@ -310,9 +272,7 @@ function! emmet#lang#css#toggleComment() abort
|
||||
let line = substitute(matchstr(line, mx), mx, '\2', '')
|
||||
let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g')
|
||||
else
|
||||
let mx = '^\(\s*\)\(''[^'']*''\|[^'']*\|;\)\s*$'
|
||||
" TODO multi-property
|
||||
"let mx = '^\(\s*\)\(\%(''[^'']*''\|[^'';]\+\)*;\{0,1}\)'
|
||||
let mx = '^\(\s*\)\(.*\)\s*$'
|
||||
let line = substitute(line, mx, '\1/* \2 */', '')
|
||||
endif
|
||||
call setline('.', line)
|
||||
@@ -368,8 +328,13 @@ function! emmet#lang#css#moveNextPrevItem(flag) abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#moveNextPrev(flag) abort
|
||||
call search('""\|()\|\(:\s*\zs;\{1,0}$\)', a:flag ? 'Wbp' : 'Wp')
|
||||
return ''
|
||||
let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
else
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#splitJoinTag() abort
|
||||
@@ -379,7 +344,3 @@ endfunction
|
||||
function! emmet#lang#css#removeTag() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#mergeLines() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
@@ -1,241 +0,0 @@
|
||||
function! emmet#lang#elm#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#parseIntoTree(abbr, type) abort
|
||||
let tree = emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
if len(tree.child) < 2 | return tree | endif
|
||||
|
||||
" Add ',' nodes between root elements.
|
||||
let new_children = []
|
||||
for child in tree.child[0:-2]
|
||||
let comma = emmet#newNode()
|
||||
let comma.name = ','
|
||||
call add(new_children, child)
|
||||
call add(new_children, comma)
|
||||
endfor
|
||||
call add(new_children, tree.child[-1])
|
||||
let tree.child = new_children
|
||||
return tree
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#renderNode(node)
|
||||
let elm_nodes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'
|
||||
\, 'div', 'p', 'hr', 'pre', 'blockquote'
|
||||
\, 'span', 'a', 'code', 'em', 'strong', 'i', 'b', 'u', 'sub', 'sup', 'br'
|
||||
\, 'ol', 'ul', 'li', 'dl', 'dt', 'dd'
|
||||
\, 'img', 'iframe', 'canvas', 'math'
|
||||
\, 'form', 'input', 'textarea', 'button', 'select', 'option'
|
||||
\, 'section', 'nav', 'article', 'aside', 'header', 'footer', 'address', 'main_', 'body'
|
||||
\, 'figure', 'figcaption'
|
||||
\, 'table', 'caption', 'colgroup', 'col', 'tbody', 'thead', 'tfoot', 'tr', 'td', 'th'
|
||||
\, 'fieldset', 'legend', 'label', 'datalist', 'optgroup', 'keygen', 'output', 'progress', 'meter'
|
||||
\, 'audio', 'video', 'source', 'track'
|
||||
\, 'embed', 'object', 'param'
|
||||
\, 'ins', 'del'
|
||||
\, 'small', 'cite', 'dfn', 'abbr', 'time', 'var', 'samp', 'kbd', 's', 'q'
|
||||
\, 'mark', 'ruby', 'rt', 'rp', 'bdi', 'bdo', 'wbr'
|
||||
\, 'details', 'summary', 'menuitem', 'menu']
|
||||
|
||||
if index(elm_nodes, a:node) >= 0
|
||||
return a:node
|
||||
endif
|
||||
return 'node "' . a:node . '"'
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#renderParam(param)
|
||||
let elm_events = ["onClick", "onDoubleClick"
|
||||
\, "onMouseDown", "onMouseUp"
|
||||
\, "onMouseEnter", "onMouseLeave"
|
||||
\, "onMouseOver", "onMouseOut"
|
||||
\, "onInput", "onCheck", "onSubmit"
|
||||
\, "onBlur", "onFocus"
|
||||
\, "on", "onWithOptions", "Options", "defaultOptions"
|
||||
\, "targetValue", "targetChecked", "keyCode"]
|
||||
if index(elm_events, a:param) >= 0
|
||||
return a:param
|
||||
endif
|
||||
let elm_attributes = ["style", "map" , "class", "id", "title", "hidden"
|
||||
\, "type", "type_", "value", "defaultValue", "checked", "placeholder", "selected"
|
||||
\, "accept", "acceptCharset", "action", "autocomplete", "autofocus"
|
||||
\, "disabled", "enctype", "formaction", "list", "maxlength", "minlength", "method", "multiple"
|
||||
\, "name", "novalidate", "pattern", "readonly", "required", "size", "for", "form"
|
||||
\, "max", "min", "step"
|
||||
\, "cols", "rows", "wrap"
|
||||
\, "href", "target", "download", "downloadAs", "hreflang", "media", "ping", "rel"
|
||||
\, "ismap", "usemap", "shape", "coords"
|
||||
\, "src", "height", "width", "alt"
|
||||
\, "autoplay", "controls", "loop", "preload", "poster", "default", "kind", "srclang"
|
||||
\, "sandbox", "seamless", "srcdoc"
|
||||
\, "reversed", "start"
|
||||
\, "align", "colspan", "rowspan", "headers", "scope"
|
||||
\, "async", "charset", "content", "defer", "httpEquiv", "language", "scoped"
|
||||
\, "accesskey", "contenteditable", "contextmenu", "dir", "draggable", "dropzone"
|
||||
\, "itemprop", "lang", "spellcheck", "tabindex"
|
||||
\, "challenge", "keytype"
|
||||
\, "cite", "datetime", "pubdate", "manifest"]
|
||||
|
||||
if index(elm_attributes, a:param) >= 0
|
||||
if a:param == 'type'
|
||||
return 'type_'
|
||||
endif
|
||||
return a:param
|
||||
endif
|
||||
return 'attribute "' . a:param . '"'
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let str = ''
|
||||
|
||||
" comma between items with *, eg. li*3
|
||||
if itemno > 0
|
||||
let str = ", "
|
||||
endif
|
||||
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
endif
|
||||
|
||||
if len(current.name) > 0
|
||||
" inserted root comma nodes
|
||||
if current_name == ','
|
||||
return "\n, "
|
||||
endif
|
||||
let str .= emmet#lang#elm#renderNode(current_name)
|
||||
let tmp = ''
|
||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
|
||||
let attr = emmet#lang#elm#renderParam(attr)
|
||||
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
let tmp .= ', ' . attr . ' True'
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let valtmp = substitute(Val, '\${cursor}', '', '')
|
||||
if attr ==# 'id' && len(valtmp) > 0
|
||||
let tmp .=', id "' . Val . '"'
|
||||
elseif attr ==# 'class' && len(valtmp) > 0
|
||||
let tmp .= ', class "' . substitute(Val, '\.', ' ', 'g') . '"'
|
||||
else
|
||||
let tmp .= ', ' . attr . ' "' . Val . '"'
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if ! len(tmp)
|
||||
let str .= ' []'
|
||||
else
|
||||
let tmp = strpart(tmp, 2)
|
||||
let str .= ' [ ' . tmp . ' ]'
|
||||
endif
|
||||
|
||||
" No children quit early
|
||||
if len(current.child) == 0 && len(current.value) == 0
|
||||
"Place cursor in node with no value or children
|
||||
let str .= ' [${cursor}]'
|
||||
return str
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
|
||||
" Parent contex text
|
||||
if len(current.value) > 0
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
" let str = substitute(str, '\$#', text, 'g')
|
||||
let inner .= ', text "' . text . '"'
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
" Has children
|
||||
for child in current.child
|
||||
if len(child.name) == 0 && len(child.value) > 0
|
||||
" Text node
|
||||
let text = child.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let inner .= ', text "' . text . '"'
|
||||
else
|
||||
" Other nodes
|
||||
let inner .= ', ' . emmet#toString(child, type, inline, filters, 0, indent)
|
||||
endif
|
||||
endfor
|
||||
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let inner = strpart(inner, 2)
|
||||
|
||||
let inner = substitute(inner, ' ', '', 'g')
|
||||
|
||||
if ! len(inner)
|
||||
let str .= ' []'
|
||||
else
|
||||
let str .= ' [ ' . inner . ' ]'
|
||||
endif
|
||||
|
||||
else
|
||||
let str = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
|
||||
let str .= "\n"
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#parseTag(tag) abort
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#toggleComment() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#balanceTag(flag) range abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#elm#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#moveNextPrev(flag) abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#splitJoinTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#removeTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#mergeLines() abort
|
||||
endfunction
|
||||
@@ -155,7 +155,7 @@ function! emmet#lang#haml#imageSize() abort
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#imageEncode() abort
|
||||
function! emmet#lang#haml#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#parseTag(tag) abort
|
||||
@@ -332,6 +332,3 @@ function! emmet#lang#haml#removeTag() abort
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#mergeLines() abort
|
||||
endfunction
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
let s:bx = '{\%("[^"]*"\|''[^'']*''\|\$#\|\${\w\+}\|\$\+\|{[^{]\+\|[^{}]\)\{-}}'
|
||||
let s:mx = '\([+>]\|[<^]\+\)\{-}'
|
||||
\ .'\((*\)\{-}'
|
||||
\ .'\([@#.]\{-}[a-zA-Z_\!][a-zA-Z0-9:_\!\-$]*\|' . s:bx . '\|\[[^\]]\+\]\)'
|
||||
let s:mx = '\([+>]\|[<^]\+\)\{-}\s*'
|
||||
\ .'\((*\)\{-}\s*'
|
||||
\ .'\([@#.]\{-}[a-zA-Z_\!][a-zA-Z0-9:_\!\-$]*\|\${[^}]\+}\|{\%([^%$}]\+\|\$#\|\${\w\+}\|\$\+\)*}*[ \t\r\n}]*\|\[[^\]]\+\]\)'
|
||||
\ .'\('
|
||||
\ .'\%('
|
||||
\ .'\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)'
|
||||
\ .'\|\%(\[\%(\[[^\]]*\]\|"[^"]*"\|[^"\[\]]*\)\+\]\)'
|
||||
\ .'\|\%(\.{[{}a-zA-Z0-9_\-\$\.]\+\|\.[a-zA-Z0-9_\-\$]\+\)'
|
||||
\ .'\|\%(\[\%("[^"]*"\|[^"\]]*\)\+\]\)'
|
||||
\ .'\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)'
|
||||
\ .'\)*'
|
||||
\ .'\)'
|
||||
\ .'\%(\(' . s:bx . '\+\)\)\{0,1}'
|
||||
\ .'\%(\({\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}\+\)\)\{0,1}'
|
||||
\ .'\%(\(@-\{0,1}[0-9]*\)\{0,1}\*\([0-9]\+\)\)\{0,1}'
|
||||
\ .'\(\%()\%(\(@-\{0,1}[0-9]*\)\{0,1}\*[0-9]\+\)\{0,1}\)*\)'
|
||||
|
||||
@@ -32,15 +31,14 @@ function! emmet#lang#html#findTokens(str) abort
|
||||
endwhile
|
||||
let last_pos = pos
|
||||
while len(str) > 0
|
||||
let white = matchstr(str, '^\s\+', pos)
|
||||
if white != ''
|
||||
let last_pos = pos + len(white)
|
||||
let pos = last_pos
|
||||
endif
|
||||
let token = matchstr(str, s:mx, pos)
|
||||
if token ==# ''
|
||||
break
|
||||
endif
|
||||
if token =~# '^\s'
|
||||
let token = matchstr(token, '^\s*\zs.*')
|
||||
let last_pos = stridx(str, token, pos)
|
||||
endif
|
||||
let pos = stridx(str, token, pos) + len(token)
|
||||
endwhile
|
||||
let str = a:str[last_pos :-1]
|
||||
@@ -60,31 +58,8 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
endif
|
||||
if len(type) == 0 | let type = 'html' | endif
|
||||
|
||||
let settings = emmet#getSettings()
|
||||
let indent = emmet#getIndentation(type)
|
||||
let pmap = {
|
||||
\'p': 'span',
|
||||
\'ul': 'li',
|
||||
\'ol': 'li',
|
||||
\'table': 'tr',
|
||||
\'tr': 'td',
|
||||
\'tbody': 'tr',
|
||||
\'thead': 'tr',
|
||||
\'tfoot': 'tr',
|
||||
\'colgroup': 'col',
|
||||
\'select': 'option',
|
||||
\'optgroup': 'option',
|
||||
\'audio': 'source',
|
||||
\'video': 'source',
|
||||
\'object': 'param',
|
||||
\'map': 'area'
|
||||
\}
|
||||
|
||||
let inlineLevel = split('a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var',',')
|
||||
|
||||
let custom_expands = emmet#getResource(type, 'custom_expands', {})
|
||||
if empty(custom_expands) && has_key(settings, 'custom_expands')
|
||||
let custom_expands = settings['custom_expands']
|
||||
endif
|
||||
|
||||
" try 'foo' to (foo-x)
|
||||
let rabbr = emmet#getExpandos(type, abbr)
|
||||
@@ -95,7 +70,6 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
let abbr = rabbr
|
||||
|
||||
let root = emmet#newNode()
|
||||
let root['variables'] = {}
|
||||
let parent = root
|
||||
let last = root
|
||||
let pos = []
|
||||
@@ -111,14 +85,13 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
let basevalue = substitute(match, s:mx, '\6', 'ig')
|
||||
let multiplier = 0 + substitute(match, s:mx, '\7', 'ig')
|
||||
let block_end = substitute(match, s:mx, '\8', 'ig')
|
||||
let custom = ''
|
||||
let important = 0
|
||||
if len(str) == 0
|
||||
break
|
||||
endif
|
||||
if tag_name =~# '^#'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = ''
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
if tag_name =~# '[^!]!$'
|
||||
let tag_name = tag_name[:-2]
|
||||
@@ -126,48 +99,20 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
endif
|
||||
if tag_name =~# '^\.'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = ''
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
if tag_name =~# '^\[.*\]$'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = ''
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
|
||||
for k in keys(custom_expands)
|
||||
if tag_name =~ k
|
||||
let custom = tag_name
|
||||
let tag_name = ''
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
if empty(tag_name)
|
||||
let pname = len(parent.child) > 0 ? parent.child[0].name : ''
|
||||
if !empty(pname) && has_key(pmap, pname) && custom == ''
|
||||
let tag_name = pmap[pname]
|
||||
elseif !empty(pname) && index(inlineLevel, pname) > -1
|
||||
let tag_name = 'span'
|
||||
elseif len(custom) == 0
|
||||
let tag_name = 'div'
|
||||
elseif len(custom) != 0 && multiplier > 1
|
||||
let tag_name = 'div'
|
||||
else
|
||||
let tag_name = custom
|
||||
endif
|
||||
endif
|
||||
|
||||
let basedirect = basevalue[1] ==# '-' ? -1 : 1
|
||||
if basevalue != ''
|
||||
let basevalue = 0 + abs(basevalue[1:])
|
||||
else
|
||||
let basevalue = 1
|
||||
endif
|
||||
let basevalue = 0 + abs(basevalue[1:])
|
||||
if multiplier <= 0 | let multiplier = 1 | endif
|
||||
|
||||
" make default node
|
||||
let current = emmet#newNode()
|
||||
|
||||
let current.name = tag_name
|
||||
|
||||
let current.important = important
|
||||
|
||||
" aliases
|
||||
@@ -178,46 +123,62 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
|
||||
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
" snippets
|
||||
let snippets = emmet#getResource(type, 'snippets', {})
|
||||
if !empty(snippets)
|
||||
let snippet_name = tag_name
|
||||
if has_key(snippets, snippet_name)
|
||||
let snippet = snippet_name
|
||||
while has_key(snippets, snippet)
|
||||
let snippet = snippets[snippet]
|
||||
let abbreviations = emmet#getResource(type, 'abbreviations', {})
|
||||
if !empty(abbreviations)
|
||||
let abbreviation_name = tag_name
|
||||
if has_key(abbreviations, abbreviation_name)
|
||||
let abbreviation = abbreviation_name
|
||||
while has_key(abbreviations, abbreviation)
|
||||
let abbreviation = abbreviations[abbreviation]
|
||||
endwhile
|
||||
if use_pipe_for_cursor
|
||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
||||
let abbreviation = substitute(abbreviation, '|', '${cursor}', 'g')
|
||||
endif
|
||||
" just redirect to expanding
|
||||
if type == 'html' && snippet !~ '^\s*[{\[<]'
|
||||
return emmet#lang#html#parseIntoTree(snippet, a:type)
|
||||
endif
|
||||
let lines = split(snippet, "\n", 1)
|
||||
let lines = split(abbreviation, "\n", 1)
|
||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
||||
let current.snippet = join(lines, "\n")
|
||||
let current.name = ''
|
||||
endif
|
||||
endif
|
||||
|
||||
" snippets
|
||||
let snippets = emmet#getResource(type, 'snippets', {})
|
||||
if empty(current.snippet)
|
||||
let snippets = emmet#getResource(type, 'snippets', {})
|
||||
if !empty(snippets)
|
||||
let snippet_name = tag_name
|
||||
if has_key(snippets, snippet_name)
|
||||
let snippet = snippet_name
|
||||
while has_key(snippets, snippet)
|
||||
let snippet = snippets[snippet]
|
||||
endwhile
|
||||
if use_pipe_for_cursor
|
||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
||||
endif
|
||||
if emmet#isExtends(type, 'html') && snippet !~ '^\s*[{\[<]'
|
||||
let current = emmet#lang#html#parseIntoTree(snippet, a:type)
|
||||
if current.name == '' && current.value == '' && current.snippet == '' && len(current.child) > 0
|
||||
let parent.child += current.child[:-2]
|
||||
let current = current.child[-1]
|
||||
endif
|
||||
else
|
||||
let lines = split(snippet, "\n", 1)
|
||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
||||
let current.snippet = join(lines, "\n")
|
||||
let current.name = ''
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let custom_expands = emmet#getResource(type, 'custom_expands', {})
|
||||
if empty(custom_expands) && has_key(settings, 'custom_expands')
|
||||
let custom_expands = settings['custom_expands']
|
||||
endif
|
||||
for k in keys(custom_expands)
|
||||
if tag_name =~# k
|
||||
let snippet = '${' . (empty(custom) ? tag_name : custom) . '}'
|
||||
let current.snippet = '${' . tag_name . '}'
|
||||
let current.name = ''
|
||||
let current.snippet = snippet
|
||||
break
|
||||
elseif custom =~# k
|
||||
let snippet = '${' . custom . '}'
|
||||
let current.snippet = '${' . custom . '}'
|
||||
if current.name != ''
|
||||
let snode = emmet#newNode()
|
||||
let snode.snippet = snippet
|
||||
let snode.parent = current
|
||||
call add(current.child, snode)
|
||||
else
|
||||
let current.snippet = snippet
|
||||
endif
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
@@ -232,18 +193,10 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
let current.attrs_order += keys(a)
|
||||
if use_pipe_for_cursor
|
||||
for k in keys(a)
|
||||
if type(a[k]) == 7
|
||||
call remove(current.attr, k)
|
||||
continue
|
||||
endif
|
||||
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
|
||||
endfor
|
||||
else
|
||||
for k in keys(a)
|
||||
if type(a[k]) == 7
|
||||
call remove(current.attr, k)
|
||||
continue
|
||||
endif
|
||||
let current.attr[k] = a[k]
|
||||
endfor
|
||||
endif
|
||||
@@ -252,24 +205,16 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
let current.attrs_order += keys(a)
|
||||
if use_pipe_for_cursor
|
||||
for k in keys(a)
|
||||
if type(a[k]) == 7
|
||||
call remove(current.attr, k)
|
||||
continue
|
||||
endif
|
||||
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
|
||||
endfor
|
||||
else
|
||||
for k in keys(a)
|
||||
if type(a[k]) == 7
|
||||
call remove(current.attr, k)
|
||||
continue
|
||||
endif
|
||||
let current.attr[k] = a[k]
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
if has_key(default_attributes, current.name)
|
||||
if has_key(settings.html.default_attributes, current.name)
|
||||
let current.name = substitute(current.name, ':.*$', '', '')
|
||||
endif
|
||||
break
|
||||
@@ -281,7 +226,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
if len(attributes)
|
||||
let attr = attributes
|
||||
while len(attr)
|
||||
let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[\%(\[[^\]]*\]\|"[^"]*"\|[^"\[\]]*\)\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)')
|
||||
let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[\%("[^"]*"\|[^"\]]*\)\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)')
|
||||
if g:emmet_debug > 1
|
||||
echomsg 'attr=' . item
|
||||
endif
|
||||
@@ -290,34 +235,29 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
endif
|
||||
if item[0] ==# '#'
|
||||
let current.attr.id = item[1:]
|
||||
let root['variables']['id'] = current.attr.id
|
||||
endif
|
||||
if item[0] ==# '.'
|
||||
let current.attr.class = substitute(item[1:], '\.', ' ', 'g')
|
||||
let root['variables']['class'] = current.attr.class
|
||||
endif
|
||||
if item[0] ==# '['
|
||||
let atts = item[1:-2]
|
||||
if matchstr(atts, '^\s*\zs[0-9a-zA-Z_\-:]\+\(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\)') ==# ''
|
||||
if matchstr(atts, '^\s*\zs[0-9a-zA-Z-:]\+\(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\)') ==# ''
|
||||
let ks = []
|
||||
if has_key(default_attributes, current.name)
|
||||
if has_key(default_attributes, current.name)
|
||||
let dfa = default_attributes[current.name]
|
||||
let ks = type(dfa) == 3 ? len(dfa) > 0 ? keys(dfa[0]) : [] : keys(dfa)
|
||||
let ks = type(dfa) == 3 ? keys(dfa[0]) : keys(dfa)
|
||||
endif
|
||||
if len(ks) == 0 && has_key(default_attributes, current.name . ':src')
|
||||
let dfa = default_attributes[current.name . ':src']
|
||||
let ks = type(dfa) == 3 ? len(dfa) > 0 ? keys(dfa[0]) : [] : keys(dfa)
|
||||
let ks = keys(default_attributes[current.name . ':src'])
|
||||
endif
|
||||
if len(ks) > 0
|
||||
let current.attr[ks[0]] = atts
|
||||
elseif atts =~# '\.$'
|
||||
let current.attr[atts[:-2]] = function('emmet#types#true')
|
||||
else
|
||||
let current.attr[atts] = ''
|
||||
endif
|
||||
else
|
||||
while len(atts)
|
||||
let amat = matchstr(atts, '^\s*\zs\([0-9a-zA-Z-:]\+\%(={{.\{-}}}\|="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\|[^ ''"\]]*\)\{0,1}\)')
|
||||
let amat = matchstr(atts, '^\s*\zs\([0-9a-zA-Z-:]\+\%(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\|[^ ''"\]]*\)\{0,1}\)')
|
||||
if len(amat) == 0
|
||||
break
|
||||
endif
|
||||
@@ -347,6 +287,9 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
if tag_name =~# '^{.*}$'
|
||||
let current.name = ''
|
||||
let current.value = tag_name
|
||||
elseif tag_name =~# '^\$\?{.*}$'
|
||||
let current.name = ''
|
||||
let current.value = '{' . tag_name . '}'
|
||||
else
|
||||
let current.value = value
|
||||
endif
|
||||
@@ -388,7 +331,6 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
if operator =~# '>'
|
||||
let last.pos += 1
|
||||
endif
|
||||
let last.block = 1
|
||||
for n in range(len(block_start))
|
||||
let pos += [last.pos]
|
||||
endfor
|
||||
@@ -411,14 +353,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
let last.pos += 1
|
||||
endif
|
||||
elseif len(n)
|
||||
let st = 0
|
||||
for nc in range(len(last.child))
|
||||
if last.child[nc].block
|
||||
let st = nc
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
let cl = last.child[st :]
|
||||
let cl = last.child
|
||||
let cls = []
|
||||
for c in range(n[1:])
|
||||
for cc in cl
|
||||
@@ -430,18 +365,11 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
endfor
|
||||
let cls += deepcopy(cl)
|
||||
endfor
|
||||
if st > 0
|
||||
let last.child = last.child[:st-1] + cls
|
||||
else
|
||||
let last.child = cls
|
||||
endif
|
||||
let last.child = cls
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
let abbr = abbr[stridx(abbr, match) + len(match):]
|
||||
if abbr == '/'
|
||||
let current.empty = 1
|
||||
endif
|
||||
|
||||
if g:emmet_debug > 1
|
||||
echomsg 'str='.str
|
||||
@@ -483,12 +411,6 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
let q = emmet#getResource(type, 'quote_char', '"')
|
||||
let ct = emmet#getResource(type, 'comment_type', 'both')
|
||||
let an = emmet#getResource(type, 'attribute_name', {})
|
||||
let empty_elements = emmet#getResource(type, 'empty_elements', '')
|
||||
let empty_element_suffix = emmet#getResource(type, 'empty_element_suffix', '')
|
||||
let inline_elements = emmet#getResource(type, 'inline_elements', '')
|
||||
let block_elements = emmet#getResource(type, 'block_elements', '')
|
||||
let indent_blockelement = emmet#getResource(type, 'indent_blockelement', '')
|
||||
let block_all_childless = emmet#getResource(type, 'block_all_childless', 0)
|
||||
|
||||
if emmet#useFilter(filters, 'haml')
|
||||
return emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
@@ -560,32 +482,16 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
let Val .= ' '
|
||||
endif
|
||||
if _val =~# '^_'
|
||||
if has_key(current.parent.attr, 'class')
|
||||
let lead = current.parent.attr["class"]
|
||||
if _val =~# '^__'
|
||||
let Val .= lead . _val
|
||||
else
|
||||
let Val .= lead . ' ' . lead . _val
|
||||
endif
|
||||
else
|
||||
let lead = split(vals[0], '_')[0]
|
||||
let Val .= lead . _val
|
||||
endif
|
||||
let lead = vals[0]
|
||||
let Val .= lead . _val
|
||||
elseif _val =~# '^-'
|
||||
for l in split(_val, '_')
|
||||
if len(Val) > 0
|
||||
let Val .= ' '
|
||||
if len(lead) == 0
|
||||
let pattr = current.parent.attr
|
||||
if has_key(pattr, 'class')
|
||||
let lead = split(pattr['class'], '\s\+')[0]
|
||||
endif
|
||||
let l = substitute(l, '^-', '__', '')
|
||||
if len(lead) == 0
|
||||
let pattr = current.parent.attr
|
||||
if has_key(pattr, 'class')
|
||||
let lead = split(pattr['class'], '\s\+')[0]
|
||||
endif
|
||||
endif
|
||||
let Val .= lead . l
|
||||
let lead .= l . '_'
|
||||
endfor
|
||||
endif
|
||||
let Val .= lead . _val
|
||||
else
|
||||
let Val .= _val
|
||||
endif
|
||||
@@ -594,11 +500,7 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
if has_key(an, attr)
|
||||
let attr = an[attr]
|
||||
endif
|
||||
if emmet#isExtends(type, 'jsx') && Val =~ '^{.*}$'
|
||||
let str .= ' ' . attr . '=' . Val
|
||||
else
|
||||
let str .= ' ' . attr . '=' . q . Val . q
|
||||
endif
|
||||
let str .= ' ' . attr . '=' . q . Val . q
|
||||
if emmet#useFilter(filters, 'c')
|
||||
if attr ==# 'id' | let comment .= '#' . Val | endif
|
||||
if attr ==# 'class' | let comment .= '.' . Val | endif
|
||||
@@ -609,10 +511,8 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
if len(comment) > 0 && ct ==# 'both'
|
||||
let str = '<!-- ' . comment . " -->\n" . str
|
||||
endif
|
||||
if current.empty
|
||||
let str .= ' />'
|
||||
elseif stridx(','.empty_elements.',', ','.current_name.',') != -1
|
||||
let str .= empty_element_suffix
|
||||
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1
|
||||
let str .= settings.html.empty_element_suffix
|
||||
else
|
||||
let str .= '>'
|
||||
let text = current.value[1:-2]
|
||||
@@ -636,11 +536,11 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
if nc > 0
|
||||
for n in range(nc)
|
||||
let child = current.child[n]
|
||||
if child.multiplier > 1 || (child.multiplier == 1 && len(child.child) > 0 && stridx(','.inline_elements.',', ','.current_name.',') == -1) || block_all_childless
|
||||
if child.multiplier > 1
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
elseif len(current_name) > 0 && stridx(','.inline_elements.',', ','.current_name.',') == -1
|
||||
if nc > 1 || (len(child.name) > 0 && stridx(','.inline_elements.',', ','.child.name.',') == -1)
|
||||
elseif len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
||||
if nc > 1 || (len(child.name) > 0 && stridx(','.settings.html.inline_elements.',', ','.child.name.',') == -1)
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
elseif current.multiplier == 1 && nc == 1 && len(child.name) == 0
|
||||
@@ -655,7 +555,7 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
let str .= inner
|
||||
endfor
|
||||
else
|
||||
if indent_blockelement && len(current_name) > 0 && stridx(','.inline_elements.',', ','.current_name.',') == -1 || block_all_childless
|
||||
if settings.html.indent_blockelement && len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
||||
let str .= "\n" . indent . '${cursor}' . "\n"
|
||||
else
|
||||
let str .= '${cursor}'
|
||||
@@ -673,7 +573,7 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
let str .= "\n<!-- /" . comment . ' -->'
|
||||
endif
|
||||
endif
|
||||
if len(current_name) > 0 && current.multiplier > 0 || stridx(','.block_elements.',', ','.current_name.',') != -1
|
||||
if len(current_name) > 0 && current.multiplier > 0 || stridx(','.settings.html.block_elements.',', ','.current_name.',') != -1
|
||||
let str .= "\n"
|
||||
endif
|
||||
return str
|
||||
@@ -711,7 +611,7 @@ function! emmet#lang#html#imageSize() abort
|
||||
call emmet#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#imageEncode() abort
|
||||
function! emmet#lang#html#encodeImage() abort
|
||||
let img_region = emmet#util#searchRegion('<img\s', '>')
|
||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
||||
return
|
||||
@@ -725,26 +625,27 @@ function! emmet#lang#html#imageEncode() abort
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
if fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let encoded = emmet#util#imageEncodeDecode(fn, 0)
|
||||
let current.attr.src = encoded
|
||||
let content = substitute(emmet#toString(current, 'html', 1), '\n', '', '')
|
||||
let content = substitute(content, '\${cursor}', '', '')
|
||||
call emmet#util#setContent(img_region, content)
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let html = emmet#toString(current, 'html', 1)
|
||||
call emmet#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#parseTag(tag) abort
|
||||
let current = emmet#newNode()
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9-]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9-]\+=\?\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>'
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', 'i')
|
||||
let attrs = substitute(match, mx, '\2', 'i')
|
||||
let mx = '\([a-zA-Z0-9-]\+\)\(\(=[^"'' \t]\+\)\|="\([^"]\{-}\)"\|=''\([^'']\{-}\)''\)\?'
|
||||
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) == 0
|
||||
@@ -752,12 +653,8 @@ function! emmet#lang#html#parseTag(tag) abort
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
if len(attr_match[2])
|
||||
let Val = len(attr_match[3]) ? attr_match[3] : attr_match[4]
|
||||
else
|
||||
let Val = function('emmet#types#true')
|
||||
endif
|
||||
let current.attr[name] = Val
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let current.attrs_order += [name]
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
@@ -793,7 +690,7 @@ function! emmet#lang#html#toggleComment() abort
|
||||
let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+')
|
||||
if tag_name[0] ==# '/'
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpairpos('<'. tag_name[1:] . '\>[^/>]*>', '', '</' . tag_name[1:] . '>', 'bnW')
|
||||
let pos2 = searchpairpos('<'. tag_name[1:] . '\>[^>]*>', '', '</' . tag_name[1:] . '>', 'bnW')
|
||||
let pos1 = searchpos('>', 'cneW')
|
||||
let block = [pos2, pos1]
|
||||
elseif tag_name =~# '/$'
|
||||
@@ -808,7 +705,7 @@ function! emmet#lang#html#toggleComment() abort
|
||||
endif
|
||||
else
|
||||
call setpos('.', [0, pos2[0], pos2[1], 0])
|
||||
let pos3 = searchpairpos('<'. tag_name . '\>[^/>]*>', '', '</' . tag_name . '>', 'nW')
|
||||
let pos3 = searchpairpos('<'. tag_name . '\>[^>]*>', '', '</' . tag_name . '>', 'nW')
|
||||
if pos3 == [0, 0]
|
||||
let block = [pos1, pos2]
|
||||
else
|
||||
@@ -832,7 +729,11 @@ endfunction
|
||||
|
||||
function! emmet#lang#html#balanceTag(flag) range abort
|
||||
let vblock = emmet#util#getVisualBlock()
|
||||
let curpos = emmet#util#getcurpos()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let settings = emmet#getSettings()
|
||||
|
||||
if a:flag > 0
|
||||
@@ -842,13 +743,13 @@ function! emmet#lang#html#balanceTag(flag) range abort
|
||||
let pos1 = searchpos(mx, 'bW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
||||
if stridx(','.empty_elements.',', ','.tag_name.',') != -1
|
||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
||||
let pos2 = searchpos('>', 'nW')
|
||||
else
|
||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if pos1 == [0, 0]
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
break
|
||||
endif
|
||||
if emmet#util#pointInRegion(last, block) && emmet#util#regionIsValid(block)
|
||||
@@ -864,8 +765,8 @@ function! emmet#lang#html#balanceTag(flag) range abort
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
while 1
|
||||
let pos1 = searchpos(mx, 'W')
|
||||
if pos1 == [0, 0] || pos1 == curpos[1:2]
|
||||
let pos1 = searchpos('>\zs', 'W')
|
||||
if pos1 == curpos[1:2]
|
||||
let pos1 = searchpos(mx . '\zs', 'W')
|
||||
let pos2 = searchpos('.\ze<', 'W')
|
||||
let block = [pos1, pos2]
|
||||
if emmet#util#regionIsValid(block)
|
||||
@@ -875,13 +776,13 @@ function! emmet#lang#html#balanceTag(flag) range abort
|
||||
endif
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
||||
if stridx(','.empty_elements.',', ','.tag_name.',') != -1
|
||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
||||
let pos2 = searchpos('>', 'nW')
|
||||
else
|
||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if pos1 == [0, 0]
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
break
|
||||
endif
|
||||
if emmet#util#regionIsValid(block)
|
||||
@@ -890,7 +791,11 @@ function! emmet#lang#html#balanceTag(flag) range abort
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
call setpos('.', curpos)
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe 'normal! gv'
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#moveNextPrevItem(flag) abort
|
||||
@@ -900,7 +805,6 @@ function! emmet#lang#html#moveNextPrevItem(flag) abort
|
||||
if pos != [0,0]
|
||||
call feedkeys('v?\s\zs'.mx."\<cr>", '')
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#moveNextPrev(flag) abort
|
||||
@@ -911,130 +815,82 @@ function! emmet#lang#html#moveNextPrev(flag) abort
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#splitJoinTag() abort
|
||||
let curpos = emmet#util#getcurpos()
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][-a-zA-Z0-9:_\-]*\)\%(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\s*\%(/\{0,1}\)>'
|
||||
while 1
|
||||
let old = getpos('.')[1:2]
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let pos1 = searchpos(mx, 'bcnW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block)
|
||||
let content = substitute(content[:-3], '\s*$', '', '') . '></' . tag_name . '>'
|
||||
let content = content[:-3] . '></' . tag_name . '>'
|
||||
call emmet#util#setContent(block, content)
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
endif
|
||||
if tag_name[0] ==# '/'
|
||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpairpos('<'. tag_name[1:] . '\>[^/>]*>', '', '</' . tag_name[1:] . '>', 'W')
|
||||
else
|
||||
let pos2 = searchpairpos('<'. tag_name . '[^/>]*>', '', '</' . tag_name . '>', 'W')
|
||||
endif
|
||||
if pos2 == [0, 0]
|
||||
return
|
||||
endif
|
||||
let pos2 = searchpos('>', 'neW')
|
||||
let block = [pos1, pos2]
|
||||
if emmet#util#pointInRegion(curpos[1:2], block)
|
||||
let content = matchstr(content, mx)[:-2] . ' />'
|
||||
call emmet#util#setContent(block, content)
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
endif
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
if pos1 == old
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
if tag_name[0] ==# '/'
|
||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
||||
else
|
||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
let content = emmet#util#getContent(block)
|
||||
if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~# '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||
let content = matchstr(content, mx)[:-2] . '/>'
|
||||
call emmet#util#setContent(block, content)
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#removeTag() abort
|
||||
let curpos = emmet#util#getcurpos()
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][-a-zA-Z0-9:_\-]*\)\%(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\s*\%(/\{0,1}\)>'
|
||||
|
||||
let pos1 = searchpos(mx, 'bcnW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block)
|
||||
call emmet#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
endif
|
||||
if tag_name[0] ==# '/'
|
||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpairpos('<'. tag_name[1:] . '\>[^/>]*>', '', '</' . tag_name[1:] . '>', 'W')
|
||||
else
|
||||
let pos2 = searchpairpos('<'. tag_name . '[^/>]*>', '', '</' . tag_name . '>', 'W')
|
||||
endif
|
||||
if pos2 == [0, 0]
|
||||
return
|
||||
endif
|
||||
let pos2 = searchpos('>', 'neW')
|
||||
let block = [pos1, pos2]
|
||||
if emmet#util#pointInRegion(curpos[1:2], block)
|
||||
call emmet#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
endif
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#mergeLines() abort
|
||||
let curpos = emmet#util#getcurpos()
|
||||
let settings = emmet#getSettings()
|
||||
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let last = curpos[1:2]
|
||||
while 1
|
||||
let pos1 = searchpos(mx, 'bcW')
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*'
|
||||
let pos1 = searchpos(mx, 'bcnW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
echomsg string(content)
|
||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
||||
let pos2 = searchpos('>', 'nW')
|
||||
let tag_name = matchstr(content, '^<\zs/\{0,1}[a-zA-Z0-9:_\-]*')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block)
|
||||
call emmet#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
||||
if tag_name[0] ==# '/'
|
||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
||||
else
|
||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
let content = emmet#util#getContent(block)
|
||||
if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~# '^<' . tag_name . '[^a-zA-Z0-9]'
|
||||
call emmet#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if pos1 == [0, 0] || pos2 == [0, 0]
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if emmet#util#pointInRegion(last, block) && emmet#util#regionIsValid(block)
|
||||
break
|
||||
endif
|
||||
if pos1 == last
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
let last = pos1
|
||||
endwhile
|
||||
|
||||
let content = emmet#util#getContent(block)
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][-a-zA-Z0-9:_\-]*\)\%(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\s*\%(/\{0,1}\)>'
|
||||
let content = join(map(split(content, mx . '\zs\s*'), 'trim(v:val)'), '')
|
||||
call emmet#util#setContent(block, content)
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@@ -152,7 +152,7 @@ function! emmet#lang#jade#imageSize() abort
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . jade, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#imageEncode() abort
|
||||
function! emmet#lang#jade#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#parseTag(tag) abort
|
||||
@@ -329,7 +329,3 @@ function! emmet#lang#jade#removeTag() abort
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#mergeLines() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
@@ -14,8 +14,8 @@ function! emmet#lang#less#imageSize() abort
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#imageEncode() abort
|
||||
return emmet#lang#css#imageEncode()
|
||||
function! emmet#lang#less#encodeImage() abort
|
||||
return emmet#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#parseTag(tag) abort
|
||||
@@ -45,7 +45,3 @@ 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
|
||||
|
||||
@@ -3,7 +3,7 @@ function! emmet#lang#sass#findTokens(str) abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
@@ -65,7 +65,7 @@ endfunction
|
||||
function! emmet#lang#sass#imageSize() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#imageEncode() abort
|
||||
function! emmet#lang#sass#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#parseTag(tag) abort
|
||||
@@ -158,6 +158,3 @@ endfunction
|
||||
|
||||
function! emmet#lang#sass#removeTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#mergeLines() abort
|
||||
endfunction
|
||||
|
||||
@@ -53,7 +53,7 @@ function! emmet#lang#scss#toString(settings, current, type, inline, filters, ite
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= indent . inner . "${cursor}\n}\n"
|
||||
let str .= indent . inner . "\n}\n"
|
||||
else
|
||||
return emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
@@ -64,8 +64,8 @@ function! emmet#lang#scss#imageSize() abort
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#imageEncode() abort
|
||||
return emmet#lang#css#imageEncode()
|
||||
function! emmet#lang#scss#encodeImage() abort
|
||||
return emmet#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#parseTag(tag) abort
|
||||
@@ -123,7 +123,3 @@ 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
|
||||
|
||||
@@ -114,7 +114,7 @@ function! emmet#lang#slim#imageSize() abort
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#imageEncode() abort
|
||||
function! emmet#lang#slim#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#parseTag(tag) abort
|
||||
@@ -279,6 +279,3 @@ function! emmet#lang#slim#removeTag() abort
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#mergeLines() abort
|
||||
endfunction
|
||||
|
||||
@@ -233,12 +233,12 @@ function! emmet#util#getImageSize(fn) abort
|
||||
else
|
||||
if fn !~# '^\w\+://'
|
||||
let path = fnamemodify(expand('%'), ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
if has('win32') || has('win64') |
|
||||
let path = tolower(path)
|
||||
endif
|
||||
for k in keys(g:emmet_docroot)
|
||||
let root = fnamemodify(k, ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
if has('win32') || has('win64') |
|
||||
let root = tolower(root)
|
||||
endif
|
||||
if stridx(path, root) == 0
|
||||
@@ -298,69 +298,6 @@ function! emmet#util#isImageMagickInstalled() abort
|
||||
return executable('identify')
|
||||
endfunction
|
||||
|
||||
function! s:b64encode(bytes, table, pad)
|
||||
let b64 = []
|
||||
for i in range(0, len(a:bytes) - 1, 3)
|
||||
let n = a:bytes[i] * 0x10000
|
||||
\ + get(a:bytes, i + 1, 0) * 0x100
|
||||
\ + get(a:bytes, i + 2, 0)
|
||||
call add(b64, a:table[n / 0x40000])
|
||||
call add(b64, a:table[n / 0x1000 % 0x40])
|
||||
call add(b64, a:table[n / 0x40 % 0x40])
|
||||
call add(b64, a:table[n % 0x40])
|
||||
endfor
|
||||
if len(a:bytes) % 3 == 2
|
||||
let b64[-1] = a:pad
|
||||
elseif len(a:bytes) % 3 == 1
|
||||
let b64[-1] = a:pad
|
||||
let b64[-2] = a:pad
|
||||
endif
|
||||
return b64
|
||||
endfunction
|
||||
|
||||
function! emmet#util#imageEncodeDecode(fn, flag) abort
|
||||
let fn = a:fn
|
||||
|
||||
if filereadable(fn)
|
||||
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
|
||||
else
|
||||
if fn !~# '^\w\+://'
|
||||
let path = fnamemodify(expand('%'), ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
let path = tolower(path)
|
||||
endif
|
||||
for k in keys(g:emmet_docroot)
|
||||
let root = fnamemodify(k, ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
let root = tolower(root)
|
||||
endif
|
||||
if stridx(path, root) == 0
|
||||
let v = g:emmet_docroot[k]
|
||||
let fn = (len(v) == 0 ? k : v) . fn
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
let hex = substitute(system(g:emmet_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g')
|
||||
endif
|
||||
|
||||
let bin = map(split(hex, '..\zs'), 'eval("0x" . v:val)')
|
||||
let table = split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', '\zs')
|
||||
let ret = 'data:image/'
|
||||
if hex =~# '^89504e470d0a1a0a'
|
||||
let ret .= 'png'
|
||||
elseif hex =~# '^ffd8'
|
||||
let ret .= 'jpeg'
|
||||
elseif hex =~# '^47494638'
|
||||
let ret .= 'gif'
|
||||
elseif hex =~# '^00000020667479706176696600000000'
|
||||
let ret .= 'avif'
|
||||
else
|
||||
let ret .= 'unknown'
|
||||
endif
|
||||
return ret . ';base64,' . join(s:b64encode(bin, table, '='), '')
|
||||
endfunction
|
||||
|
||||
function! emmet#util#unique(arr) abort
|
||||
let m = {}
|
||||
let r = []
|
||||
|
||||
@@ -148,19 +148,21 @@ You should copy this section and create new buffer, paste and write as
|
||||
</p>
|
||||
</div>
|
||||
<
|
||||
2. Expand word *emmet-expand-word* *<C-y>;*
|
||||
2. Expand abbreviation *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 beginning of tags '<div>' on below
|
||||
The begining of tags '<div>' on below
|
||||
>
|
||||
<div>foo</div>
|
||||
<
|
||||
@@ -170,7 +172,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>,*
|
||||
|
||||
@@ -1264,14 +1266,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 action separately, use following variables:
|
||||
If you prefer to map for each actions separately, use following valuables:
|
||||
>
|
||||
let g:user_emmet_expandabbr_key = '<C-y>,'
|
||||
let g:user_emmet_expandword_key = '<C-y>;'
|
||||
@@ -1332,7 +1334,7 @@ CUSTOMIZE *emmet-customize*
|
||||
|
||||
3. Define tag's behavior *emmet-define-tags-behavior*
|
||||
|
||||
User can create abbreviations and snippets for each filetype
|
||||
User can create abbreviations and snippets for each filetypes
|
||||
using |g:user_emmet_settings|. For details, see official site of Emmet.
|
||||
For example, user can add following:
|
||||
>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
1
docs
1
docs
Submodule docs deleted from ff5a094cc8
@@ -1,25 +0,0 @@
|
||||
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
|
||||
@@ -23,7 +23,6 @@
|
||||
" | <head>
|
||||
" | <title></title>
|
||||
" | <meta charset="UTF-8">
|
||||
" | <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
" | </head>
|
||||
" | <body>
|
||||
" | _
|
||||
@@ -47,7 +46,7 @@
|
||||
" Tips:
|
||||
"
|
||||
" You can customize behavior of expanding with overriding config.
|
||||
" This configuration will be merged at loading plugin.
|
||||
" This configuration will be marged at loading plugin.
|
||||
"
|
||||
" let g:user_emmet_settings = {
|
||||
" \ 'indentation' : ' ',
|
||||
@@ -107,13 +106,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': '<esc>: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': 'i', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': ':call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': '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': 'n', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': ':call emmet#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': '<esc>:call 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>'},
|
||||
@@ -121,8 +120,6 @@ 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>'},
|
||||
@@ -133,8 +130,7 @@ 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': '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_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>'},
|
||||
\]
|
||||
|
||||
@@ -151,7 +147,7 @@ function! s:install_plugin(mode, buffer)
|
||||
let key = g:user_emmet_leader_key . item.key
|
||||
endif
|
||||
if !hasmapto('<plug>(' . item.plug . ')', item.mode) && !len(maparg(key, item.mode))
|
||||
exe item.mode . 'map ' . buffer . ' <unique> <silent>' . key . ' <plug>(' . item.plug . ')'
|
||||
exe item.mode . 'map ' . buffer . ' <unique> ' . key . ' <plug>(' . item.plug . ')'
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
@@ -175,17 +171,6 @@ 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
|
||||
|
||||
|
||||
172
unittest.vim
172
unittest.vim
@@ -1,6 +1,5 @@
|
||||
" {{{
|
||||
let s:sfile = expand('<sfile>')
|
||||
let s:logging = 0
|
||||
|
||||
function! s:reload(d)
|
||||
exe 'so' a:d.'/plugin/emmet.vim'
|
||||
@@ -9,32 +8,22 @@ 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 | call s:log('['.a:type.']') | echohl None
|
||||
echohl Search | echon '[' a:type "]\n" | echohl None
|
||||
echo "\r"
|
||||
endfunction
|
||||
|
||||
function! s:show_category(category)
|
||||
echohl MatchParen | call s:log('['.a:category.']') | echohl None
|
||||
echohl MatchParen | echon '[' a:category "]\n" | echohl None
|
||||
echo "\r"
|
||||
endfunction
|
||||
|
||||
function! s:show_pass(pass)
|
||||
echohl Title | call s:log('pass '.substitute(a:pass, '\s', '', 'g')) | echohl None
|
||||
echohl Title | echo 'pass'.a:pass."\n" | echohl None
|
||||
endfunction
|
||||
|
||||
function! s:show_done()
|
||||
echohl IncSearch | call s:log('done') | echohl None
|
||||
echohl IncSearch | echo 'done' | echohl None
|
||||
endfunction
|
||||
|
||||
function! s:escape(str)
|
||||
@@ -47,39 +36,37 @@ endfunction
|
||||
function! s:show_title(no, title)
|
||||
let title = s:escape(a:title)
|
||||
let width = &columns - 23
|
||||
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)).'... ')
|
||||
echohl MoreMsg | echon "\rtesting #".printf('%03d', a:no)
|
||||
echohl None | echon ': ' . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
|
||||
endfunction
|
||||
|
||||
function! s:show_skip(no, title)
|
||||
let title = s:escape(a:title)
|
||||
let width = &columns - 23
|
||||
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)).'... ')
|
||||
echohl WarningMsg | echon "\rskipped #".printf('%03d', a:no)
|
||||
echohl None | echon ': ' . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
|
||||
echo ''
|
||||
endfunction
|
||||
|
||||
function! s:show_ok()
|
||||
echohl Title | call s:logn('ok') | echohl None
|
||||
echohl Title | echon "ok\n" | echohl None
|
||||
echo ''
|
||||
endfunction
|
||||
|
||||
function! s:show_ng(no, expect, got)
|
||||
echohl WarningMsg | call s:logn('ng') | echohl None
|
||||
echohl ErrorMsg | call s:log('failed test #'.a:no) | echohl None
|
||||
echohl WarningMsg | echon "ng\n" | echohl None
|
||||
echohl ErrorMsg | echo 'failed test #'.a:no | echohl None
|
||||
set more
|
||||
echohl WarningMsg | call s:log(printf('expect(%d):', len(a:expect))) | echohl None
|
||||
echohl WarningMsg | echo printf('expect(%d):', len(a:expect)) | echohl None
|
||||
echo join(split(a:expect, "\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"))
|
||||
echohl WarningMsg | echo printf('got(%d):', len(a:got)) | echohl None
|
||||
echo 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 | call s:log('differ at:') | echohl None
|
||||
call s:log(a:expect[c :-1])
|
||||
echohl WarningMsg | echo 'differ at:' | echohl None
|
||||
echo a:expect[c :-1]
|
||||
break
|
||||
endif
|
||||
endif
|
||||
@@ -104,7 +91,6 @@ 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
|
||||
@@ -122,7 +108,6 @@ 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)
|
||||
@@ -169,9 +154,8 @@ function! s:test(...)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:do_tests(bang, ...)
|
||||
function! s:do_tests(...)
|
||||
try
|
||||
let s:logging = a:bang
|
||||
if exists('g:user_emmet_settings')
|
||||
let s:old_user_emmet_settings = g:user_emmet_settings
|
||||
endif
|
||||
@@ -181,22 +165,13 @@ function! s:do_tests(bang, ...)
|
||||
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
|
||||
|
||||
@@ -214,7 +189,7 @@ function! s:emmet_unittest_complete(arglead, cmdline, cmdpos)
|
||||
return []
|
||||
endfunction
|
||||
|
||||
command! -bang -nargs=* -complete=customlist,<SID>emmet_unittest_complete EmmetUnitTest call s:do_tests("<bang>", <f-args>)
|
||||
command! -nargs=* -complete=customlist,<SID>emmet_unittest_complete EmmetUnitTest call s:do_tests(<f-args>)
|
||||
if s:sfile == expand('%:p')
|
||||
EmmetUnitTest
|
||||
endif
|
||||
@@ -266,7 +241,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<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>",
|
||||
'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>",
|
||||
},
|
||||
{
|
||||
'query': "ol>li*2",
|
||||
@@ -322,11 +297,11 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "blockquote>b>i<<b",
|
||||
'result': "<blockquote>\n\t<b><i></i></b>\n</blockquote>\n<b></b>\n",
|
||||
'result': "<blockquote><b><i></i></b></blockquote>\n<b></b>\n",
|
||||
},
|
||||
{
|
||||
'query': "blockquote>b>i^^b",
|
||||
'result': "<blockquote>\n\t<b><i></i></b>\n</blockquote>\n<b></b>\n",
|
||||
'result': "<blockquote><b><i></i></b></blockquote>\n<b></b>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[href=foo][class=bar]",
|
||||
@@ -357,19 +332,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",
|
||||
},
|
||||
{
|
||||
@@ -562,11 +537,7 @@ 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 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",
|
||||
'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",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -575,20 +546,12 @@ 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>",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -681,19 +644,6 @@ 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",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -742,7 +692,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "{-bdrs20$$$$}",
|
||||
'result': "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}",
|
||||
'result': "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\nborder-radius: 20px;}",
|
||||
},
|
||||
{
|
||||
'query': "{lg(top,#fff,#000)$$$$}",
|
||||
@@ -849,7 +799,7 @@ finish
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'split join',
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "%a foo\n bar$$$$\\<c-y>j$$$$",
|
||||
@@ -1030,7 +980,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "{-bdrs20$$$$}",
|
||||
'result': "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}",
|
||||
'result': "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\nborder-radius: 20px;}",
|
||||
},
|
||||
{
|
||||
'query': "{lg(top,#fff,#000)$$$$}",
|
||||
@@ -1064,67 +1014,5 @@ 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:
|
||||
|
||||
Reference in New Issue
Block a user