mirror of
https://github.com/mattn/emmet-vim.git
synced 2026-04-27 21:11:30 +08:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ff5a094cc8 | |||
| 835b5c7cd9 | |||
| e13abc5f30 | |||
| 52c5ca380f | |||
| d788857b81 | |||
| e6fc11efb2 | |||
| e9c6c86c0f | |||
| 5ec3fbbd47 | |||
| e75b4cef24 | |||
| 7e3c234f8c | |||
| a9e2744a42 | |||
| 1a4c4a5bb8 | |||
| c04cde8752 | |||
| 550feefc06 | |||
| cb731cb965 | |||
| 1b8896f4da | |||
| e28425ce02 | |||
| 62068bb21d | |||
| 8fc38a5dfb | |||
| 01d436b51f | |||
| 9c62c07f1a | |||
| 9b588cbacd | |||
| 434569d388 | |||
| 324c551ba2 | |||
| 320c1ba8d5 |
@@ -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
|
||||
@@ -1,26 +0,0 @@
|
||||
name: Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
vim:
|
||||
- head
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: thinca/action-setup-vim@v2
|
||||
with:
|
||||
vim_version: ${{ matrix.vim }}
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: thinca/vim-themis
|
||||
path: vim-themis
|
||||
- name: Run tests
|
||||
run: ./vim-themis/bin/themis --runtimepath . test/
|
||||
@@ -1 +0,0 @@
|
||||
/doc/tags
|
||||
@@ -1,4 +0,0 @@
|
||||
[submodule "docs"]
|
||||
path = docs
|
||||
url = https://github.com/mattn/emmet-vim
|
||||
branch = gh-pages
|
||||
@@ -1,13 +0,0 @@
|
||||
let &runtimepath .= ',' . fnamemodify(expand('<sfile>'), ':h') . '/test'
|
||||
call themis#helper('command').with(themis#helper('assert'))
|
||||
|
||||
let s:emmet = themis#helper('emmet')
|
||||
call s:emmet.setup()
|
||||
|
||||
function! ExpandWord(query, type) abort
|
||||
return s:emmet.expand_word(a:query, a:type)
|
||||
endfunction
|
||||
|
||||
function! ExpandInBuffer(query, type, result) abort
|
||||
return s:emmet.expand_in_buffer(a:query, a:type, a:result)
|
||||
endfunction
|
||||
-11
@@ -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
|
||||
@@ -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.
|
||||
@@ -1,18 +0,0 @@
|
||||
all : emmet-vim.zip
|
||||
|
||||
remove-zip:
|
||||
-rm doc/tags
|
||||
-rm emmet-vim.zip
|
||||
|
||||
emmet-vim.zip: remove-zip
|
||||
zip -r emmet-vim.zip autoload plugin doc
|
||||
|
||||
release: emmet-vim.zip
|
||||
vimup update-script emmet.vim
|
||||
|
||||
test:
|
||||
@../vim-themis/bin/themis --runtimepath . test/
|
||||
|
||||
test-old:
|
||||
@-rm -f test.log 2> /dev/null
|
||||
@vim -N -c "let &rtp .= ',' . getcwd()" -c "so unittest.vim" -c EmmetUnitTest! || cat test.log || exit 1
|
||||
-200
@@ -1,200 +0,0 @@
|
||||
# Emmet-vim
|
||||
|
||||
|
||||
[](https://travis-ci.org/mattn/emmet-vim)
|
||||
|
||||
[emmet-vim](https://mattn.github.io/emmet-vim/) is a vim plug-in
|
||||
which provides support for expanding abbreviations similar to
|
||||
[emmet](http://emmet.io/).
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
[Download zip file](http://www.vim.org/scripts/script.php?script_id=2981):
|
||||
|
||||
```sh
|
||||
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 [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'
|
||||
```
|
||||
|
||||
To checkout the source from repository:
|
||||
|
||||
```sh
|
||||
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/
|
||||
```
|
||||
|
||||
|
||||
## Quick Tutorial
|
||||
|
||||
Open or create a New File:
|
||||
|
||||
```sh
|
||||
vim index.html
|
||||
```
|
||||
|
||||
Type ("\_" is the cursor position):
|
||||
|
||||
html:5_
|
||||
|
||||
Then type `<c-y>,` (<kbd>Ctrl</kbd><kbd>y</kbd><kbd>,</kbd>), and you should see:
|
||||
|
||||
```html
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
_
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
[More Tutorials](https://raw.githubusercontent.com/mattn/emmet-vim/master/TUTORIAL)
|
||||
|
||||
|
||||
## Enable in different mode
|
||||
|
||||
If you don't want to enable emmet in all modes,
|
||||
you can use set these options in `vimrc`:
|
||||
|
||||
```vim
|
||||
let g:user_emmet_mode='n' "only enable normal mode functions.
|
||||
let g:user_emmet_mode='inv' "enable all functions, which is equal to
|
||||
let g:user_emmet_mode='a' "enable all function in all mode.
|
||||
```
|
||||
|
||||
## Enable just for html/css
|
||||
|
||||
```vim
|
||||
let g:user_emmet_install_global = 0
|
||||
autocmd FileType html,css EmmetInstall
|
||||
```
|
||||
|
||||
## Redefine trigger key
|
||||
To remap the default `<C-Y>` leader:
|
||||
|
||||
```vim
|
||||
let g:user_emmet_leader_key='<C-Z>'
|
||||
```
|
||||
|
||||
Note that the trailing `,` still needs to be entered, so the new keymap would be `<C-Z>,`.
|
||||
|
||||
## Adding custom snippets
|
||||
If you have installed the [web-api](https://github.com/mattn/webapi-vim) for **emmet-vim** you can also add your own snippets using a custom **snippets.json** file.
|
||||
|
||||
Once you have installed the [web-api](https://github.com/mattn/webapi-vim) add this line to your **.vimrc**:
|
||||
```
|
||||
let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/.snippets_custom.json')), "\n"))
|
||||
```
|
||||
You can change the **path** to your **snippets_custom.json** according to your preferences.
|
||||
|
||||
[Here](http://docs.emmet.io/customization/snippets/) you can find instructions about creating your customized **snippets.json** file.
|
||||
|
||||
## Snippet to add meta tag for responsiveness
|
||||
Update this in your .vimrc file.
|
||||
|
||||
|
||||
let g:user_emmet_settings = {
|
||||
\ 'variables': {'lang': 'ja'},
|
||||
\ 'html': {
|
||||
\ 'default_attributes': {
|
||||
\ 'option': {'value': v:null},
|
||||
\ 'textarea': {'id': v:null, 'name': v:null, 'cols': 10, 'rows': 10},
|
||||
\ },
|
||||
\ 'snippets': {
|
||||
\ 'html:5': "<!DOCTYPE html>\n"
|
||||
\ ."<html lang=\"${lang}\">\n"
|
||||
\ ."<head>\n"
|
||||
\ ."\t<meta charset=\"${charset}\">\n"
|
||||
\ ."\t<title></title>\n"
|
||||
\ ."\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
|
||||
\ ."</head>\n"
|
||||
\ ."<body>\n\t${child}|\n</body>\n"
|
||||
\ ."</html>",
|
||||
\ },
|
||||
\ },
|
||||
\}
|
||||
|
||||
|
||||
## Project Authors
|
||||
|
||||
[Yasuhiro Matsumoto](http://mattn.kaoriya.net/)
|
||||
|
||||
## FAQ
|
||||
|
||||
* Pressing ctrl+y+, doesn't work
|
||||
|
||||
Probably you set `timeoutlen=0`. Most of Vim plugins which using key-mappings does not work with `timeoutlen=0`.
|
||||
|
||||
## Links
|
||||
|
||||
### Emmet official site:
|
||||
|
||||
* <http://emmet.io/>
|
||||
|
||||
### zen-coding official site:
|
||||
|
||||
* <http://code.google.com/p/zen-coding/>
|
||||
|
||||
### emmet.vim:
|
||||
|
||||
* <https://mattn.github.io/emmet-vim/>
|
||||
|
||||
### development repository:
|
||||
|
||||
* <https://github.com/mattn/emmet-vim>
|
||||
|
||||
### my blog posts about zencoding-vim:
|
||||
|
||||
* <http://mattn.kaoriya.net/software/vim/20100222103327.htm>
|
||||
|
||||
* <http://mattn.kaoriya.net/software/vim/20100306021632.htm>
|
||||
|
||||
### Japanese blog posts about zencoding-vim:
|
||||
|
||||
* <http://d.hatena.ne.jp/idesaku/20100424/1272092255>
|
||||
|
||||
* <http://d.hatena.ne.jp/griefworker/20110118/vim_zen_coding>
|
||||
|
||||
* <http://d.hatena.ne.jp/sakurako_s/20110126/1295988873>
|
||||
|
||||
* <http://looxu.blogspot.jp/2010/02/zencodingvimhtml.html>
|
||||
|
||||
### A Chinese translation of the tutorial:
|
||||
|
||||
* <http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html>
|
||||
|
||||
@@ -1,212 +0,0 @@
|
||||
Tutorial for Emmet.vim
|
||||
|
||||
mattn <mattn.jp@gmail.com>
|
||||
|
||||
1. Expand an Abbreviation
|
||||
|
||||
Type the abbreviation as 'div>p#foo$*3>a' and type '<c-y>,'.
|
||||
---------------------
|
||||
<div>
|
||||
<p id="foo1">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo2">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo3">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
2. Wrap with an Abbreviation
|
||||
|
||||
Write as below.
|
||||
---------------------
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
---------------------
|
||||
Then do visual select(line wise) and type '<c-y>,'.
|
||||
Once you get to the 'Tag:' prompt, type 'ul>li*'.
|
||||
---------------------
|
||||
<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:
|
||||
---------------------
|
||||
<blockquote>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
</blockquote>
|
||||
---------------------
|
||||
|
||||
3. Balance a Tag Inward
|
||||
|
||||
type '<c-y>d' in insert mode.
|
||||
|
||||
4. Balance a Tag Outward
|
||||
|
||||
type '<c-y>D' in insert mode.
|
||||
|
||||
5. Go to the Next Edit Point
|
||||
|
||||
type '<c-y>n' in insert mode.
|
||||
|
||||
6. Go to the Previous Edit Point
|
||||
|
||||
type '<c-y>N' in insert mode.
|
||||
|
||||
7. Update an <img>’s Size
|
||||
|
||||
Move cursor to the img tag.
|
||||
---------------------
|
||||
<img src="foo.png" />
|
||||
---------------------
|
||||
Type '<c-y>i' on img tag
|
||||
---------------------
|
||||
<img src="foo.png" width="32" height="48" />
|
||||
---------------------
|
||||
|
||||
8. Merge Lines
|
||||
|
||||
select the lines, which include '<li>'
|
||||
---------------------
|
||||
<ul>
|
||||
<li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
---------------------
|
||||
and then type '<c-y>m'
|
||||
---------------------
|
||||
<ul>
|
||||
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
|
||||
</ul>
|
||||
---------------------
|
||||
|
||||
9. Remove a Tag
|
||||
|
||||
Move cursor in block
|
||||
---------------------
|
||||
<div class="foo">
|
||||
<a>cursor is here</a>
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-y>k' in insert mode.
|
||||
---------------------
|
||||
<div class="foo">
|
||||
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
And type '<c-y>k' in there again.
|
||||
---------------------
|
||||
|
||||
---------------------
|
||||
|
||||
10. Split/Join Tag
|
||||
|
||||
Move the cursor inside block
|
||||
---------------------
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-y>j' in insert mode.
|
||||
---------------------
|
||||
<div class="foo"/>
|
||||
---------------------
|
||||
|
||||
And then type '<c-y>j' in there again.
|
||||
---------------------
|
||||
<div class="foo">
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
11. Toggle Comment
|
||||
|
||||
Move cursor inside the block
|
||||
---------------------
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-y>/' in insert mode.
|
||||
---------------------
|
||||
<!-- <div>
|
||||
hello world
|
||||
</div> -->
|
||||
---------------------
|
||||
Type '<c-y>/' in there again.
|
||||
---------------------
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
12. Make an anchor from a URL
|
||||
|
||||
Move cursor to URL
|
||||
---------------------
|
||||
http://www.google.com/
|
||||
---------------------
|
||||
Type '<c-y>a'
|
||||
---------------------
|
||||
<a href="http://www.google.com/">Google</a>
|
||||
---------------------
|
||||
|
||||
13. Make some quoted text from a URL
|
||||
|
||||
Move cursor to the URL
|
||||
---------------------
|
||||
http://github.com/
|
||||
---------------------
|
||||
Type '<c-y>A'
|
||||
---------------------
|
||||
<blockquote class="quote">
|
||||
<a href="http://github.com/">Secure source code hosting and collaborative development - GitHub</a><br />
|
||||
<p>How does it work? Get up and running in seconds by forking a project, pushing an existing repository...</p>
|
||||
<cite>http://github.com/</cite>
|
||||
</blockquote>
|
||||
---------------------
|
||||
|
||||
14. Installing emmet.vim for the language you are using:
|
||||
|
||||
# cd ~/.vim
|
||||
# unzip emmet-vim.zip
|
||||
|
||||
Or if you are using pathogen.vim:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# unzip /path/to/emmet-vim.zip
|
||||
|
||||
Or if you get the sources from the repository:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# git clone http://github.com/mattn/emmet-vim.git
|
||||
|
||||
15. Enable emmet.vim for the language you using.
|
||||
|
||||
You can customize the behavior of the languages you are using.
|
||||
|
||||
---------------------
|
||||
# cat >> ~/.vimrc
|
||||
let g:user_emmet_settings = {
|
||||
\ 'php' : {
|
||||
\ 'extends' : 'html',
|
||||
\ 'filters' : 'c',
|
||||
\ },
|
||||
\ 'xml' : {
|
||||
\ 'extends' : 'html',
|
||||
\ },
|
||||
\ 'haml' : {
|
||||
\ 'extends' : 'html',
|
||||
\ },
|
||||
\}
|
||||
---------------------
|
||||
-247
@@ -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',
|
||||
\ },
|
||||
\}
|
||||
```
|
||||
|
||||
-2136
File diff suppressed because it is too large
Load Diff
@@ -1,52 +0,0 @@
|
||||
let s:exists = {}
|
||||
function! emmet#lang#exists(type) abort
|
||||
if len(a:type) == 0
|
||||
return 0
|
||||
elseif has_key(s:exists, a:type)
|
||||
return s:exists[a:type]
|
||||
endif
|
||||
let s:exists[a:type] = len(globpath(&rtp, 'autoload/emmet/lang/'.a:type.'.vim')) > 0
|
||||
return s:exists[a:type]
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#type(type) abort
|
||||
let l:type = a:type
|
||||
let l:base = l:type
|
||||
let l:settings = emmet#getSettings()
|
||||
while l:base != ''
|
||||
for l:b in split(l:base, '\.')
|
||||
if emmet#lang#exists(l:b)
|
||||
return l:b
|
||||
endif
|
||||
if has_key(l:settings, l:b) && has_key(l:settings[l:b], 'extends')
|
||||
let l:base = l:settings[l:b].extends
|
||||
break
|
||||
else
|
||||
let l:base = ''
|
||||
endif
|
||||
endfor
|
||||
endwhile
|
||||
return 'html'
|
||||
endfunction
|
||||
|
||||
" get all extends for a type recursively
|
||||
function! emmet#lang#getExtends(type) abort
|
||||
let l:settings = emmet#getSettings()
|
||||
|
||||
if !has_key(l:settings[a:type], 'extends')
|
||||
return []
|
||||
endif
|
||||
|
||||
let l:extends = l:settings[a:type].extends
|
||||
if type(l:extends) ==# 1
|
||||
let l:tmp = split(l:extends, '\s*,\s*')
|
||||
unlet! l:extends
|
||||
let l:extends = l:tmp
|
||||
endif
|
||||
|
||||
for l:ext in l:extends
|
||||
let l:extends = l:extends + emmet#lang#getExtends(l:ext)
|
||||
endfor
|
||||
|
||||
return l:extends
|
||||
endfunction
|
||||
@@ -1,385 +0,0 @@
|
||||
function! emmet#lang#css#findTokens(str) abort
|
||||
let l:tmp = substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
|
||||
if l:tmp =~ '/' && l:tmp =~ '^[a-zA-Z0-9/_.]\+$'
|
||||
" maybe path or something
|
||||
return ''
|
||||
endif
|
||||
return substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#parseIntoTree(abbr, type) abort
|
||||
let l:abbr = a:abbr
|
||||
let l:type = a:type
|
||||
let l:prefix = 0
|
||||
let l:value = ''
|
||||
|
||||
let l:indent = emmet#getIndentation(l:type)
|
||||
let l:aliases = emmet#getResource(l:type, 'aliases', {})
|
||||
let l:snippets = emmet#getResource(l:type, 'snippets', {})
|
||||
let l:use_pipe_for_cursor = emmet#getResource(l:type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
let l:root = emmet#newNode()
|
||||
|
||||
" emmet
|
||||
let l:tokens = split(l:abbr, '+\ze[^+)!]')
|
||||
let l:block = emmet#util#searchRegion('{', '}')
|
||||
if l:abbr !~# '^@' && emmet#getBaseType(l:type) ==# 'css' && l:type !=# 'sass' && l:type !=# 'styled' && l:block[0] ==# [0,0] && l:block[1] ==# [0,0]
|
||||
let l:current = emmet#newNode()
|
||||
let l:current.snippet = substitute(l:abbr, '\s\+$', '', '') . " {\n" . l:indent . "${cursor}\n}"
|
||||
let l:current.name = ''
|
||||
call add(l:root.child, deepcopy(l:current))
|
||||
else
|
||||
for l:n in range(len(l:tokens))
|
||||
let l:token = l:tokens[l:n]
|
||||
let l:prop = matchlist(l:token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+\%(p\|e\|em\|x\|vh\|vw\|re\|rem\|%\)\{0,}-\{0,1}\|-auto\)*\)$')
|
||||
if len(l:prop)
|
||||
let l:token = substitute(l:prop[1], '^(\(.*\))', '\1', '')
|
||||
if l:token =~# '^-'
|
||||
let l:prefix = 1
|
||||
let l:token = l:token[1:]
|
||||
endif
|
||||
let l:value = ''
|
||||
for l:vt in split(l:prop[2], '\a\+\zs')
|
||||
let l:ut = matchstr(l:vt, '[a-z]\+$')
|
||||
if l:ut == 'auto'
|
||||
let l:ut = ''
|
||||
endif
|
||||
for l:v in split(l:vt, '\d\zs-')
|
||||
if len(l:value) > 0
|
||||
let l:value .= ' '
|
||||
endif
|
||||
if l:v !~ '[a-z]\+$'
|
||||
let l:v .= l:ut
|
||||
endif
|
||||
if l:token =~# '^[z]'
|
||||
" TODO
|
||||
let l:value .= substitute(l:v, '[^0-9.]*$', '', '')
|
||||
elseif l:v =~# 'em$'
|
||||
let l:value .= l:v
|
||||
elseif l:v =~# 'ex$'
|
||||
let l:value .= l:v
|
||||
elseif l:v =~# 'vh$'
|
||||
let l:value .= l:v
|
||||
elseif l:v =~# 'vw$'
|
||||
let l:value .= l:v
|
||||
elseif l:v =~# 'rem$'
|
||||
let l:value .= l:v
|
||||
elseif l:v ==# 'auto'
|
||||
let l:value .= l:v
|
||||
elseif l:v =~# 'p$'
|
||||
let l:value .= substitute(l:v, 'p$', '%', '')
|
||||
elseif l:v =~# '%$'
|
||||
let l:value .= l:v
|
||||
elseif l:v =~# 'e$'
|
||||
let l:value .= substitute(l:v, 'e$', 'em', '')
|
||||
elseif l:v =~# 'x$'
|
||||
let l:value .= substitute(l:v, 'x$', 'ex', '')
|
||||
elseif l:v =~# 're$'
|
||||
let l:value .= substitute(l:v, 're$', 'rem', '')
|
||||
elseif l:v =~# '\.'
|
||||
let l:value .= l:v . 'em'
|
||||
elseif l:v ==# '0'
|
||||
let l:value .= '0'
|
||||
else
|
||||
let l:value .= l:v . 'px'
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
|
||||
let l:tag_name = l:token
|
||||
if l:tag_name =~# '.!$'
|
||||
let l:tag_name = l:tag_name[:-2]
|
||||
let l:important = 1
|
||||
else
|
||||
let l:important = 0
|
||||
endif
|
||||
" make default node
|
||||
let l:current = emmet#newNode()
|
||||
let l:current.important = l:important
|
||||
let l:current.name = l:tag_name
|
||||
|
||||
" aliases
|
||||
if has_key(l:aliases, l:tag_name)
|
||||
let l:current.name = l:aliases[l:tag_name]
|
||||
endif
|
||||
|
||||
" snippets
|
||||
if !empty(l:snippets)
|
||||
let l:snippet_name = l:tag_name
|
||||
if !has_key(l:snippets, l:snippet_name)
|
||||
let l:pat = '^' . join(split(l:tag_name, '\zs'), '\%(\|[^:-]\+-\)')
|
||||
let l:vv = filter(sort(keys(l:snippets)), 'l:snippets[v:val] =~ l:pat')
|
||||
if len(l:vv) == 0
|
||||
let l:vv = filter(sort(keys(l:snippets)), 'substitute(v:val, ":", "", "g") == l:snippet_name')
|
||||
endif
|
||||
if len(l:vv) > 0
|
||||
let l:snippet_name = l:vv[0]
|
||||
else
|
||||
let l:pat = '^' . join(split(l:tag_name, '\zs'), '\%(\|[^:-]\+-*\)')
|
||||
let l:vv = filter(sort(keys(l:snippets)), 'l:snippets[v:val] =~ l:pat')
|
||||
if len(l:vv) == 0
|
||||
let l:pat = '^' . join(split(l:tag_name, '\zs'), '[^:]\{-}')
|
||||
let l:vv = filter(sort(keys(l:snippets)), 'l:snippets[v:val] =~ l:pat')
|
||||
if len(l:vv) == 0
|
||||
let l:pat = '^' . join(split(l:tag_name, '\zs'), '.\{-}')
|
||||
let l:vv = filter(sort(keys(l:snippets)), 'l:snippets[v:val] =~ l:pat')
|
||||
endif
|
||||
endif
|
||||
let l:minl = -1
|
||||
for l:vk in l:vv
|
||||
let l:vvs = l:snippets[l:vk]
|
||||
if l:minl == -1 || len(l:vvs) < l:minl
|
||||
let l:snippet_name = l:vk
|
||||
let l:minl = len(l:vvs)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
if has_key(l:snippets, l:snippet_name)
|
||||
let l:snippet = l:snippets[l:snippet_name]
|
||||
if l:use_pipe_for_cursor
|
||||
let l:snippet = substitute(l:snippet, '|', '${cursor}', 'g')
|
||||
endif
|
||||
let l:lines = split(l:snippet, "\n")
|
||||
call map(l:lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(l:indent, "\\\\"), "g")')
|
||||
let l:current.snippet = join(l:lines, "\n")
|
||||
let l:current.name = ''
|
||||
let l:current.snippet = substitute(l:current.snippet, ';', l:value . ';', '')
|
||||
if l:use_pipe_for_cursor && len(l:value) > 0
|
||||
let l:current.snippet = substitute(l:current.snippet, '\${cursor}', '', 'g')
|
||||
endif
|
||||
if l:n < len(l:tokens) - 1
|
||||
let l:current.snippet .= "\n"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:current.pos = 0
|
||||
let l:lg = matchlist(l:token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$')
|
||||
if len(l:lg) == 0
|
||||
let l:lg = matchlist(l:token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*)$')
|
||||
if len(l:lg)
|
||||
let [l:lg[1], l:lg[2], l:lg[3]] = ['linear', l:lg[1], l:lg[2]]
|
||||
endif
|
||||
endif
|
||||
if len(l:lg)
|
||||
let l:current.name = ''
|
||||
let l:current.snippet = printf("background-image:-webkit-gradient(%s, 0 0, 0 100%%, from(%s), to(%s));\n", l:lg[1], l:lg[2], l:lg[3])
|
||||
call add(l:root.child, deepcopy(l:current))
|
||||
let l:current.snippet = printf("background-image:-webkit-linear-gradient(%s, %s);\n", l:lg[2], l:lg[3])
|
||||
call add(l:root.child, deepcopy(l:current))
|
||||
let l:current.snippet = printf("background-image:-moz-linear-gradient(%s, %s);\n", l:lg[2], l:lg[3])
|
||||
call add(l:root.child, deepcopy(l:current))
|
||||
let l:current.snippet = printf("background-image:-o-linear-gradient(%s, %s);\n", l:lg[2], l:lg[3])
|
||||
call add(l:root.child, deepcopy(l:current))
|
||||
let l:current.snippet = printf("background-image:linear-gradient(%s, %s);\n", l:lg[2], l:lg[3])
|
||||
call add(l:root.child, deepcopy(l:current))
|
||||
elseif l:prefix
|
||||
let l:snippet = l:current.snippet
|
||||
let l:current.snippet = '-webkit-' . l:snippet . "\n"
|
||||
call add(l:root.child, deepcopy(l:current))
|
||||
let l:current.snippet = '-moz-' . l:snippet . "\n"
|
||||
call add(l:root.child, deepcopy(l:current))
|
||||
let l:current.snippet = '-o-' . l:snippet . "\n"
|
||||
call add(l:root.child, deepcopy(l:current))
|
||||
let l:current.snippet = '-ms-' . l:snippet . "\n"
|
||||
call add(l:root.child, deepcopy(l:current))
|
||||
let l:current.snippet = l:snippet
|
||||
call add(l:root.child, l:current)
|
||||
elseif l:token =~# '^c#\([0-9a-fA-F]\{3}\|[0-9a-fA-F]\{6}\)\(\.[0-9]\+\)\?'
|
||||
let l:cs = split(l:token, '\.')
|
||||
let l:current.name = ''
|
||||
let [l:r,l:g,l:b] = [0,0,0]
|
||||
if len(l:cs[0]) == 5
|
||||
let l:rgb = matchlist(l:cs[0], 'c#\(.\)\(.\)\(.\)')
|
||||
let l:r = eval('0x'.l:rgb[1].l:rgb[1])
|
||||
let l:g = eval('0x'.l:rgb[2].l:rgb[2])
|
||||
let l:b = eval('0x'.l:rgb[3].l:rgb[3])
|
||||
elseif len(l:cs[0]) == 8
|
||||
let l:rgb = matchlist(l:cs[0], 'c#\(..\)\(..\)\(..\)')
|
||||
let l:r = eval('0x'.l:rgb[1])
|
||||
let l:g = eval('0x'.l:rgb[2])
|
||||
let l:b = eval('0x'.l:rgb[3])
|
||||
endif
|
||||
if len(l:cs) == 1
|
||||
let l:current.snippet = printf('color:rgb(%d, %d, %d);', l:r, l:g, l:b)
|
||||
else
|
||||
let l:current.snippet = printf('color:rgb(%d, %d, %d, %s);', l:r, l:g, l:b, string(str2float('0.'.l:cs[1])))
|
||||
endif
|
||||
call add(l:root.child, l:current)
|
||||
elseif l:token =~# '^c#'
|
||||
let l:current.name = ''
|
||||
let l:current.snippet = 'color:\${cursor};'
|
||||
call add(l:root.child, l:current)
|
||||
else
|
||||
call add(l:root.child, l:current)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
return l:root
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let l:current = a:current
|
||||
let l:value = l:current.value[1:-2]
|
||||
let l:tmp = substitute(l:value, '\${cursor}', '', 'g')
|
||||
if l:tmp !~ '.*{[ \t\r\n]*}$'
|
||||
if emmet#useFilter(a:filters, 'fc')
|
||||
let l:value = substitute(l:value, '\([^:]\+\):\([^;]*\)', '\1: \2', 'g')
|
||||
else
|
||||
let l:value = substitute(l:value, '\([^:]\+\):\([^;]*\)', '\1:\2', 'g')
|
||||
endif
|
||||
if l:current.important
|
||||
let l:value = substitute(l:value, ';', ' !important;', '')
|
||||
endif
|
||||
endif
|
||||
return l:value
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#imageSize() abort
|
||||
let l:img_region = emmet#util#searchRegion('{', '}')
|
||||
if !emmet#util#regionIsValid(l:img_region) || !emmet#util#cursorInRegion(l:img_region)
|
||||
return
|
||||
endif
|
||||
let l:content = emmet#util#getContent(l:img_region)
|
||||
let l:fn = matchstr(l:content, '\<url(\zs[^)]\+\ze)')
|
||||
let l:fn = substitute(l:fn, '[''" \t]', '', 'g')
|
||||
if l:fn =~# '^\s*$'
|
||||
return
|
||||
elseif l:fn !~# '^\(/\|http\)'
|
||||
let l:fn = simplify(expand('%:h') . '/' . l:fn)
|
||||
endif
|
||||
let [l:width, l:height] = emmet#util#getImageSize(l:fn)
|
||||
if l:width == -1 && l:height == -1
|
||||
return
|
||||
endif
|
||||
let l:indent = emmet#getIndentation('css')
|
||||
if l:content =~# '.*\<width\s*:[^;]*;.*'
|
||||
let l:content = substitute(l:content, '\<width\s*:[^;]*;', 'width: ' . l:width . 'px;', '')
|
||||
else
|
||||
let l:content = substitute(l:content, '}', l:indent . 'width: ' . l:width . "px;\n}", '')
|
||||
endif
|
||||
if l:content =~# '.*\<height\s*:[^;]*;.*'
|
||||
let l:content = substitute(l:content, '\<height\s*:[^;]*;', 'height: ' . l:height . 'px;', '')
|
||||
else
|
||||
let l:content = substitute(l:content, '}', l:indent . 'height: ' . l:height . "px;\n}", '')
|
||||
endif
|
||||
call emmet#util#setContent(l:img_region, l:content)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#imageEncode() abort
|
||||
let l:img_region = emmet#util#searchRegion('url(', ')')
|
||||
if !emmet#util#regionIsValid(l:img_region) || !emmet#util#cursorInRegion(l:img_region)
|
||||
return
|
||||
endif
|
||||
let l:content = emmet#util#getContent(l:img_region)
|
||||
let l:fn = matchstr(l:content, '\<url(\zs[^)]\+\ze)')
|
||||
let l:fn = substitute(l:fn, '[''" \t]', '', 'g')
|
||||
if l:fn =~# '^\s*$'
|
||||
return
|
||||
elseif l:fn !~# '^\(/\|http\)'
|
||||
let l:fn = simplify(expand('%:h') . '/' . l:fn)
|
||||
endif
|
||||
let l:encoded = emmet#util#imageEncodeDecode(l:fn, 0)
|
||||
call emmet#util#setContent(l:img_region, 'url(' . l:encoded . ')')
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#parseTag(tag) abort
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#toggleComment() abort
|
||||
let l:line = getline('.')
|
||||
let l:mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
|
||||
if l:line =~# '{\s*$'
|
||||
let l:block = emmet#util#searchRegion('/\*', '\*/\zs')
|
||||
if emmet#util#regionIsValid(l:block)
|
||||
let l:content = emmet#util#getContent(l:block)
|
||||
let l:content = substitute(l:content, '/\*\s\(.*\)\s\*/', '\1', '')
|
||||
call emmet#util#setContent(l:block, l:content)
|
||||
else
|
||||
let l:node = expand('<cword>')
|
||||
if len(l:node)
|
||||
exe "normal ciw\<c-r>='/* '.l:node.' */'\<cr>"
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if l:line =~# l:mx
|
||||
let l:space = substitute(matchstr(l:line, l:mx), l:mx, '\1', '')
|
||||
let l:line = substitute(matchstr(l:line, l:mx), l:mx, '\2', '')
|
||||
let l:line = l:space . substitute(l:line, '^\s*\|\s*$', '\1', 'g')
|
||||
else
|
||||
let l:mx = '^\(\s*\)\(''[^'']*''\|[^'']*\|;\)\s*$'
|
||||
" TODO multi-property
|
||||
"let l:mx = '^\(\s*\)\(\%(''[^'']*''\|[^'';]\+\)*;\{0,1}\)'
|
||||
let l:line = substitute(l:line, l:mx, '\1/* \2 */', '')
|
||||
endif
|
||||
call setline('.', l:line)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#balanceTag(flag) range abort
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let l:curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let l:curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let l:block = emmet#util#getVisualBlock()
|
||||
if !emmet#util#regionIsValid(l:block)
|
||||
if a:flag > 0
|
||||
let l:block = emmet#util#searchRegion('^', ';')
|
||||
if emmet#util#regionIsValid(l:block)
|
||||
call emmet#util#selectRegion(l:block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if a:flag > 0
|
||||
let l:content = emmet#util#getContent(l:block)
|
||||
if l:content !~# '^{.*}$'
|
||||
let l:block = emmet#util#searchRegion('{', '}')
|
||||
if emmet#util#regionIsValid(l:block)
|
||||
call emmet#util#selectRegion(l:block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let l:pos = searchpos('.*;', 'nW')
|
||||
if l:pos[0] != 0
|
||||
call setpos('.', [0, l:pos[0], l:pos[1], 0])
|
||||
let l:block = emmet#util#searchRegion('^', ';')
|
||||
if emmet#util#regionIsValid(l:block)
|
||||
call emmet#util#selectRegion(l:block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe 'normal! gv'
|
||||
else
|
||||
call setpos('.', l:curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#css#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#moveNextPrev(flag) abort
|
||||
call search('""\|()\|\(:\s*\zs;\{1,0}$\)', a:flag ? 'Wbp' : 'Wp')
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#splitJoinTag() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#removeTag() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#mergeLines() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
@@ -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 l:tree = emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
if len(l:tree.child) < 2 | return l:tree | endif
|
||||
|
||||
" Add ',' nodes between root elements.
|
||||
let l:new_children = []
|
||||
for l:child in l:tree.child[0:-2]
|
||||
let l:comma = emmet#newNode()
|
||||
let l:comma.name = ','
|
||||
call add(l:new_children, l:child)
|
||||
call add(l:new_children, l:comma)
|
||||
endfor
|
||||
call add(l:new_children, l:tree.child[-1])
|
||||
let l:tree.child = l:new_children
|
||||
return l:tree
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#renderNode(node)
|
||||
let l:elm_nodes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'
|
||||
\, 'div', 'p', 'hr', 'pre', 'blockquote'
|
||||
\, 'span', 'a', 'code', 'em', 'strong', 'i', 'b', 'u', 'sub', 'sup', 'br'
|
||||
\, 'ol', 'ul', 'li', 'dl', 'dt', 'dd'
|
||||
\, 'img', 'iframe', 'canvas', 'math'
|
||||
\, 'form', 'input', 'textarea', 'button', 'select', 'option'
|
||||
\, 'section', 'nav', 'article', 'aside', 'header', 'footer', 'address', 'main_', 'body'
|
||||
\, 'figure', 'figcaption'
|
||||
\, 'table', 'caption', 'colgroup', 'col', 'tbody', 'thead', 'tfoot', 'tr', 'td', 'th'
|
||||
\, 'fieldset', 'legend', 'label', 'datalist', 'optgroup', 'keygen', 'output', 'progress', 'meter'
|
||||
\, 'audio', 'video', 'source', 'track'
|
||||
\, 'embed', 'object', 'param'
|
||||
\, 'ins', 'del'
|
||||
\, 'small', 'cite', 'dfn', 'abbr', 'time', 'var', 'samp', 'kbd', 's', 'q'
|
||||
\, 'mark', 'ruby', 'rt', 'rp', 'bdi', 'bdo', 'wbr'
|
||||
\, 'details', 'summary', 'menuitem', 'menu']
|
||||
|
||||
if index(l:elm_nodes, a:node) >= 0
|
||||
return a:node
|
||||
endif
|
||||
return 'node "' . a:node . '"'
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#renderParam(param)
|
||||
let l:elm_events = ["onClick", "onDoubleClick"
|
||||
\, "onMouseDown", "onMouseUp"
|
||||
\, "onMouseEnter", "onMouseLeave"
|
||||
\, "onMouseOver", "onMouseOut"
|
||||
\, "onInput", "onCheck", "onSubmit"
|
||||
\, "onBlur", "onFocus"
|
||||
\, "on", "onWithOptions", "Options", "defaultOptions"
|
||||
\, "targetValue", "targetChecked", "keyCode"]
|
||||
if index(l:elm_events, a:param) >= 0
|
||||
return a:param
|
||||
endif
|
||||
let l:elm_attributes = ["style", "map" , "class", "id", "title", "hidden"
|
||||
\, "type", "type_", "value", "defaultValue", "checked", "placeholder", "selected"
|
||||
\, "accept", "acceptCharset", "action", "autocomplete", "autofocus"
|
||||
\, "disabled", "enctype", "formaction", "list", "maxlength", "minlength", "method", "multiple"
|
||||
\, "name", "novalidate", "pattern", "readonly", "required", "size", "for", "form"
|
||||
\, "max", "min", "step"
|
||||
\, "cols", "rows", "wrap"
|
||||
\, "href", "target", "download", "downloadAs", "hreflang", "media", "ping", "rel"
|
||||
\, "ismap", "usemap", "shape", "coords"
|
||||
\, "src", "height", "width", "alt"
|
||||
\, "autoplay", "controls", "loop", "preload", "poster", "default", "kind", "srclang"
|
||||
\, "sandbox", "seamless", "srcdoc"
|
||||
\, "reversed", "start"
|
||||
\, "align", "colspan", "rowspan", "headers", "scope"
|
||||
\, "async", "charset", "content", "defer", "httpEquiv", "language", "scoped"
|
||||
\, "accesskey", "contenteditable", "contextmenu", "dir", "draggable", "dropzone"
|
||||
\, "itemprop", "lang", "spellcheck", "tabindex"
|
||||
\, "challenge", "keytype"
|
||||
\, "cite", "datetime", "pubdate", "manifest"]
|
||||
|
||||
if index(l:elm_attributes, a:param) >= 0
|
||||
if a:param == 'type'
|
||||
return 'type_'
|
||||
endif
|
||||
return a:param
|
||||
endif
|
||||
return 'attribute "' . a:param . '"'
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let l:settings = a:settings
|
||||
let l:current = a:current
|
||||
let l:type = a:type
|
||||
let l:inline = a:inline
|
||||
let l:filters = a:filters
|
||||
let l:itemno = a:itemno
|
||||
let l:indent = emmet#getIndentation(l:type)
|
||||
let l:dollar_expr = emmet#getResource(l:type, 'dollar_expr', 1)
|
||||
let l:str = ''
|
||||
|
||||
" comma between items with *, eg. li*3
|
||||
if l:itemno > 0
|
||||
let l:str = ", "
|
||||
endif
|
||||
|
||||
let l:current_name = l:current.name
|
||||
if l:dollar_expr
|
||||
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
|
||||
endif
|
||||
|
||||
if len(l:current.name) > 0
|
||||
" inserted root comma nodes
|
||||
if l:current_name == ','
|
||||
return "\n, "
|
||||
endif
|
||||
let l:str .= emmet#lang#elm#renderNode(l:current_name)
|
||||
let l:tmp = ''
|
||||
for l:attr in emmet#util#unique(l:current.attrs_order + keys(l:current.attr))
|
||||
if !has_key(l:current.attr, l:attr)
|
||||
continue
|
||||
endif
|
||||
let l:Val = l:current.attr[l:attr]
|
||||
|
||||
let l:attr = emmet#lang#elm#renderParam(l:attr)
|
||||
|
||||
if type(l:Val) == 2 && l:Val == function('emmet#types#true')
|
||||
let l:tmp .= ', ' . l:attr . ' True'
|
||||
else
|
||||
if l:dollar_expr
|
||||
while l:Val =~# '\$\([^#{]\|$\)'
|
||||
let l:Val = substitute(l:Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
|
||||
endif
|
||||
let l:valtmp = substitute(l:Val, '\${cursor}', '', '')
|
||||
if l:attr ==# 'id' && len(l:valtmp) > 0
|
||||
let l:tmp .=', id "' . l:Val . '"'
|
||||
elseif l:attr ==# 'class' && len(l:valtmp) > 0
|
||||
let l:tmp .= ', class "' . substitute(l:Val, '\.', ' ', 'g') . '"'
|
||||
else
|
||||
let l:tmp .= ', ' . l:attr . ' "' . l:Val . '"'
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if ! len(l:tmp)
|
||||
let l:str .= ' []'
|
||||
else
|
||||
let l:tmp = strpart(l:tmp, 2)
|
||||
let l:str .= ' [ ' . l:tmp . ' ]'
|
||||
endif
|
||||
|
||||
" No children quit early
|
||||
if len(l:current.child) == 0 && len(l:current.value) == 0
|
||||
"Place cursor in node with no value or children
|
||||
let l:str .= ' [${cursor}]'
|
||||
return l:str
|
||||
endif
|
||||
|
||||
let l:inner = ''
|
||||
|
||||
" Parent contex text
|
||||
if len(l:current.value) > 0
|
||||
let l:text = l:current.value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
|
||||
let l:text = substitute(l:text, '\\\$', '$', 'g')
|
||||
" let l:str = substitute(l:str, '\$#', l:text, 'g')
|
||||
let l:inner .= ', text "' . l:text . '"'
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
" Has children
|
||||
for l:child in l:current.child
|
||||
if len(l:child.name) == 0 && len(l:child.value) > 0
|
||||
" Text node
|
||||
let l:text = l:child.value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
|
||||
let l:text = substitute(l:text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let l:inner .= ', text "' . l:text . '"'
|
||||
else
|
||||
" Other nodes
|
||||
let l:inner .= ', ' . emmet#toString(l:child, l:type, l:inline, l:filters, 0, l:indent)
|
||||
endif
|
||||
endfor
|
||||
|
||||
let l:inner = substitute(l:inner, "\n", "\n" . escape(l:indent, '\'), 'g')
|
||||
let l:inner = substitute(l:inner, "\n" . escape(l:indent, '\') . '$', '', 'g')
|
||||
let l:inner = strpart(l:inner, 2)
|
||||
|
||||
let l:inner = substitute(l:inner, ' ', '', 'g')
|
||||
|
||||
if ! len(l:inner)
|
||||
let l:str .= ' []'
|
||||
else
|
||||
let l:str .= ' [ ' . l:inner . ' ]'
|
||||
endif
|
||||
|
||||
else
|
||||
let l:str = l:current.value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:str = substitute(l:str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:str = substitute(l:str, '\${nr}', "\n", 'g')
|
||||
let l:str = substitute(l:str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:str .= "\n"
|
||||
return l:str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#parseTag(tag) abort
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#toggleComment() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#balanceTag(flag) range abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#elm#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#moveNextPrev(flag) abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#splitJoinTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#removeTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#mergeLines() abort
|
||||
endfunction
|
||||
@@ -1,337 +0,0 @@
|
||||
function! emmet#lang#haml#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let l:settings = a:settings
|
||||
let l:current = a:current
|
||||
let l:type = a:type
|
||||
let l:inline = a:inline
|
||||
let l:filters = a:filters
|
||||
let l:itemno = a:itemno
|
||||
let l:indent = emmet#getIndentation(l:type)
|
||||
let l:dollar_expr = emmet#getResource(l:type, 'dollar_expr', 1)
|
||||
let l:attribute_style = emmet#getResource('haml', 'attribute_style', 'hash')
|
||||
let l:str = ''
|
||||
|
||||
let l:current_name = l:current.name
|
||||
if l:dollar_expr
|
||||
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
|
||||
endif
|
||||
if len(l:current.name) > 0
|
||||
let l:str .= '%' . l:current_name
|
||||
let l:tmp = ''
|
||||
for l:attr in emmet#util#unique(l:current.attrs_order + keys(l:current.attr))
|
||||
if !has_key(l:current.attr, l:attr)
|
||||
continue
|
||||
endif
|
||||
let l:Val = l:current.attr[l:attr]
|
||||
if type(l:Val) == 2 && l:Val == function('emmet#types#true')
|
||||
if l:attribute_style ==# 'hash'
|
||||
let l:tmp .= ' :' . l:attr . ' => true'
|
||||
elseif l:attribute_style ==# 'html'
|
||||
let l:tmp .= l:attr . '=true'
|
||||
end
|
||||
else
|
||||
if l:dollar_expr
|
||||
while l:Val =~# '\$\([^#{]\|$\)'
|
||||
let l:Val = substitute(l:Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
|
||||
endif
|
||||
let l:valtmp = substitute(l:Val, '\${cursor}', '', '')
|
||||
if l:attr ==# 'id' && len(l:valtmp) > 0
|
||||
let l:str .= '#' . l:Val
|
||||
elseif l:attr ==# 'class' && len(l:valtmp) > 0
|
||||
let l:str .= '.' . substitute(l:Val, ' ', '.', 'g')
|
||||
else
|
||||
if len(l:tmp) > 0
|
||||
if l:attribute_style ==# 'hash'
|
||||
let l:tmp .= ','
|
||||
elseif l:attribute_style ==# 'html'
|
||||
let l:tmp .= ' '
|
||||
endif
|
||||
endif
|
||||
if l:attribute_style ==# 'hash'
|
||||
let l:tmp .= ' :' . l:attr . ' => "' . l:Val . '"'
|
||||
elseif l:attribute_style ==# 'html'
|
||||
let l:tmp .= l:attr . '="' . l:Val . '"'
|
||||
end
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(l:tmp)
|
||||
if l:attribute_style ==# 'hash'
|
||||
let l:str .= '{' . l:tmp . ' }'
|
||||
elseif l:attribute_style ==# 'html'
|
||||
let l:str .= '(' . l:tmp . ')'
|
||||
end
|
||||
endif
|
||||
if stridx(','.l:settings.html.empty_elements.',', ','.l:current_name.',') != -1 && len(l:current.value) == 0
|
||||
let l:str .= '/'
|
||||
endif
|
||||
|
||||
let l:inner = ''
|
||||
if len(l:current.value) > 0
|
||||
let l:text = l:current.value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
|
||||
let l:text = substitute(l:text, '\\\$', '$', 'g')
|
||||
let l:str = substitute(l:str, '\$#', l:text, 'g')
|
||||
endif
|
||||
let l:lines = split(l:text, "\n")
|
||||
if len(l:lines) == 1
|
||||
let l:str .= ' ' . l:text
|
||||
else
|
||||
for l:line in l:lines
|
||||
let l:str .= "\n" . l:indent . l:line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(l:current.child) == 0
|
||||
let l:str .= '${cursor}'
|
||||
endif
|
||||
if len(l:current.child) == 1 && len(l:current.child[0].name) == 0
|
||||
let l:text = l:current.child[0].value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
|
||||
let l:text = substitute(l:text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let l:lines = split(l:text, "\n")
|
||||
if len(l:lines) == 1
|
||||
let l:str .= ' ' . l:text
|
||||
else
|
||||
for l:line in l:lines
|
||||
let l:str .= "\n" . l:indent . l:line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(l:current.child) > 0
|
||||
for l:child in l:current.child
|
||||
let l:inner .= emmet#toString(l:child, l:type, l:inline, l:filters, l:itemno, l:indent)
|
||||
endfor
|
||||
let l:inner = substitute(l:inner, "\n", "\n" . escape(l:indent, '\'), 'g')
|
||||
let l:inner = substitute(l:inner, "\n" . escape(l:indent, '\') . '$', '', 'g')
|
||||
let l:str .= "\n" . l:indent . l:inner
|
||||
endif
|
||||
else
|
||||
let l:str = l:current.value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:str = substitute(l:str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:str = substitute(l:str, '\${nr}', "\n", 'g')
|
||||
let l:str = substitute(l:str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
let l:str .= "\n"
|
||||
return l:str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#imageSize() abort
|
||||
let l:line = getline('.')
|
||||
let l:current = emmet#lang#haml#parseTag(l:line)
|
||||
if empty(l:current) || !has_key(l:current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let l:fn = l:current.attr.src
|
||||
if l:fn =~# '^\s*$'
|
||||
return
|
||||
elseif l:fn !~# '^\(/\|http\)'
|
||||
let l:fn = simplify(expand('%:h') . '/' . l:fn)
|
||||
endif
|
||||
|
||||
let [l:width, l:height] = emmet#util#getImageSize(l:fn)
|
||||
if l:width == -1 && l:height == -1
|
||||
return
|
||||
endif
|
||||
let l:current.attr.width = l:width
|
||||
let l:current.attr.height = l:height
|
||||
let l:current.attrs_order += ['width', 'height']
|
||||
let l:haml = emmet#toString(l:current, 'haml', 1)
|
||||
let l:haml = substitute(l:haml, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(l:line, '^\s*') . l:haml, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#parseTag(tag) abort
|
||||
let l:current = emmet#newNode()
|
||||
let l:mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
|
||||
let l:match = matchstr(a:tag, l:mx)
|
||||
let l:current.name = substitute(l:match, l:mx, '\1', '')
|
||||
let l:attrs = substitute(l:match, l:mx, '\2', '')
|
||||
let l:mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(l:attrs) > 0
|
||||
let l:match = matchstr(l:attrs, l:mx)
|
||||
if len(l:match) ==# 0
|
||||
break
|
||||
endif
|
||||
let l:attr_match = matchlist(l:match, l:mx)
|
||||
let l:name = l:attr_match[1]
|
||||
let l:value = len(l:attr_match[2]) ? l:attr_match[2] : l:attr_match[3]
|
||||
let l:current.attr[l:name] = l:value
|
||||
let l:current.attrs_order += [l:name]
|
||||
let l:attrs = l:attrs[stridx(l:attrs, l:match) + len(l:match):]
|
||||
endwhile
|
||||
return l:current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#toggleComment() abort
|
||||
let l:line = getline('.')
|
||||
let l:space = matchstr(l:line, '^\s*')
|
||||
if l:line =~# '^\s*-#'
|
||||
call setline('.', l:space . matchstr(l:line[len(l:space)+2:], '^\s*\zs.*'))
|
||||
elseif l:line =~# '^\s*%[a-z]'
|
||||
call setline('.', l:space . '-# ' . l:line[len(l:space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#balanceTag(flag) range abort
|
||||
let l:block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let l:curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let l:curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let l:n = l:curpos[1]
|
||||
let l:ml = len(matchstr(getline(l:n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(l:block)
|
||||
let l:n = line('.')
|
||||
else
|
||||
while l:n > 0
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*\ze%[a-z]'))
|
||||
if l:l > 0 && l:l < l:ml
|
||||
let l:ml = l:l
|
||||
break
|
||||
endif
|
||||
let l:n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let l:sn = l:n
|
||||
if l:n == 0
|
||||
let l:ml = 0
|
||||
endif
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, l:n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
else
|
||||
while l:n > 0
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
|
||||
if l:l > 0 && l:l > l:ml
|
||||
let l:ml = l:l
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
let l:sn = l:n
|
||||
if l:n == 0
|
||||
let l:ml = 0
|
||||
endif
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, l:n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#haml#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#moveNextPrev(flag) abort
|
||||
let l:pos = search('""', a:flag ? 'Wb' : 'W')
|
||||
if l:pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#splitJoinTag() abort
|
||||
let l:n = line('.')
|
||||
let l:sml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
while l:n > 0
|
||||
if getline(l:n) =~# '^\s*\ze%[a-z]'
|
||||
if len(matchstr(getline(l:n), '^\s*%[a-z]')) < l:sml
|
||||
break
|
||||
endif
|
||||
let l:line = getline(l:n)
|
||||
call setline(l:n, substitute(l:line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
|
||||
let l:sn = l:n
|
||||
let l:n += 1
|
||||
let l:ml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
if len(matchstr(getline(l:n), '^\s*')) > l:ml
|
||||
while l:n <= line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*'))
|
||||
if l:l <= l:ml
|
||||
break
|
||||
endif
|
||||
exe l:n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
else
|
||||
let l:tag = matchstr(getline(l:sn), '^\s*%\zs\(\w\+\)')
|
||||
let l:spaces = matchstr(getline(l:sn), '^\s*')
|
||||
let l:settings = emmet#getSettings()
|
||||
if stridx(','.l:settings.html.inline_elements.',', ','.l:tag.',') == -1
|
||||
call append(l:sn, l:spaces . ' ')
|
||||
call setpos('.', [0, l:sn+1, 1, 0])
|
||||
else
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
endif
|
||||
startinsert!
|
||||
endif
|
||||
break
|
||||
endif
|
||||
let l:n -= 1
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#removeTag() abort
|
||||
let l:n = line('.')
|
||||
let l:ml = 0
|
||||
while l:n > 0
|
||||
if getline(l:n) =~# '^\s*\ze[a-z]'
|
||||
let l:ml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
break
|
||||
endif
|
||||
let l:n -= 1
|
||||
endwhile
|
||||
let l:sn = l:n
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
if l:sn == l:n
|
||||
exe 'delete'
|
||||
else
|
||||
exe l:sn ',' (l:n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#mergeLines() abort
|
||||
endfunction
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,335 +0,0 @@
|
||||
function! emmet#lang#jade#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let l:settings = a:settings
|
||||
let l:current = a:current
|
||||
let l:type = a:type
|
||||
let l:inline = a:inline
|
||||
let l:filters = a:filters
|
||||
let l:itemno = a:itemno
|
||||
let l:indent = emmet#getIndentation(l:type)
|
||||
let l:dollar_expr = emmet#getResource(l:type, 'dollar_expr', 1)
|
||||
let l:attribute_style = emmet#getResource('jade', 'attribute_style', 'hash')
|
||||
let l:str = ''
|
||||
|
||||
let l:current_name = l:current.name
|
||||
if l:dollar_expr
|
||||
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
|
||||
endif
|
||||
if len(l:current.name) > 0
|
||||
let l:str .= '' . l:current_name
|
||||
let l:tmp = ''
|
||||
for l:attr in emmet#util#unique(l:current.attrs_order + keys(l:current.attr))
|
||||
if !has_key(l:current.attr, l:attr)
|
||||
continue
|
||||
endif
|
||||
let l:Val = l:current.attr[l:attr]
|
||||
if type(l:Val) == 2 && l:Val == function('emmet#types#true')
|
||||
if l:attribute_style ==# 'hash'
|
||||
let l:tmp .= ' ' . l:attr . ' = true'
|
||||
elseif l:attribute_style ==# 'html'
|
||||
let l:tmp .= l:attr . '=true'
|
||||
end
|
||||
else
|
||||
if l:dollar_expr
|
||||
while l:Val =~# '\$\([^#{]\|$\)'
|
||||
let l:Val = substitute(l:Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
|
||||
endif
|
||||
let l:valtmp = substitute(l:Val, '\${cursor}', '', '')
|
||||
if l:attr ==# 'id' && len(l:valtmp) > 0
|
||||
let l:str .= '#' . l:Val
|
||||
elseif l:attr ==# 'class' && len(l:valtmp) > 0
|
||||
let l:str .= '.' . substitute(l:Val, ' ', '.', 'g')
|
||||
else
|
||||
if len(l:tmp) > 0
|
||||
if l:attribute_style ==# 'hash'
|
||||
let l:tmp .= ', '
|
||||
elseif l:attribute_style ==# 'html'
|
||||
let l:tmp .= ' '
|
||||
endif
|
||||
endif
|
||||
if l:attribute_style ==# 'hash'
|
||||
let l:tmp .= '' . l:attr . '="' . l:Val . '"'
|
||||
elseif l:attribute_style ==# 'html'
|
||||
let l:tmp .= l:attr . '="' . l:Val . '"'
|
||||
end
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(l:tmp)
|
||||
if l:attribute_style ==# 'hash'
|
||||
let l:str .= '(' . l:tmp . ')'
|
||||
elseif l:attribute_style ==# 'html'
|
||||
let l:str .= '(' . l:tmp . ')'
|
||||
end
|
||||
endif
|
||||
|
||||
let l:inner = ''
|
||||
if len(l:current.value) > 0
|
||||
let l:text = l:current.value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
|
||||
let l:text = substitute(l:text, '\\\$', '$', 'g')
|
||||
let l:str = substitute(l:str, '\$#', l:text, 'g')
|
||||
endif
|
||||
let l:lines = split(l:text, "\n")
|
||||
if len(l:lines) == 1
|
||||
let l:str .= ' ' . l:text
|
||||
else
|
||||
for l:line in l:lines
|
||||
let l:str .= "\n" . l:indent . l:line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(l:current.child) == 0
|
||||
let l:str .= '${cursor}'
|
||||
endif
|
||||
if len(l:current.child) == 1 && len(l:current.child[0].name) == 0
|
||||
let l:text = l:current.child[0].value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
|
||||
let l:text = substitute(l:text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let l:lines = split(l:text, "\n")
|
||||
if len(l:lines) == 1
|
||||
let l:str .= ' ' . l:text
|
||||
else
|
||||
for l:line in l:lines
|
||||
let l:str .= "\n" . l:indent . l:line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(l:current.child) > 0
|
||||
for l:child in l:current.child
|
||||
let l:inner .= emmet#toString(l:child, l:type, l:inline, l:filters, l:itemno, l:indent)
|
||||
endfor
|
||||
let l:inner = substitute(l:inner, "\n", "\n" . escape(l:indent, '\'), 'g')
|
||||
let l:inner = substitute(l:inner, "\n" . escape(l:indent, '\') . '$', '', 'g')
|
||||
let l:str .= "\n" . l:indent . l:inner
|
||||
endif
|
||||
else
|
||||
let l:str = l:current.value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:str = substitute(l:str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:str = substitute(l:str, '\${nr}', "\n", 'g')
|
||||
let l:str = substitute(l:str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
let l:str .= "\n"
|
||||
return l:str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#imageSize() abort
|
||||
let l:line = getline('.')
|
||||
let l:current = emmet#lang#jade#parseTag(l:line)
|
||||
if empty(l:current) || !has_key(l:current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let l:fn = l:current.attr.src
|
||||
if l:fn =~# '^\s*$'
|
||||
return
|
||||
elseif l:fn !~# '^\(/\|http\)'
|
||||
let l:fn = simplify(expand('%:h') . '/' . l:fn)
|
||||
endif
|
||||
|
||||
let [l:width, l:height] = emmet#util#getImageSize(l:fn)
|
||||
if l:width == -1 && l:height == -1
|
||||
return
|
||||
endif
|
||||
let l:current.attr.width = l:width
|
||||
let l:current.attr.height = l:height
|
||||
let l:current.attrs_order += ['width', 'height']
|
||||
let l:jade = emmet#toString(l:current, 'jade', 1)
|
||||
let l:jade = substitute(l:jade, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(l:line, '^\s*') . l:jade, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#parseTag(tag) abort
|
||||
let l:current = emmet#newNode()
|
||||
let l:mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
|
||||
let l:match = matchstr(a:tag, l:mx)
|
||||
let l:current.name = substitute(l:match, l:mx, '\1', '')
|
||||
let l:attrs = substitute(l:match, l:mx, '\2', '')
|
||||
let l:mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(l:attrs) > 0
|
||||
let l:match = matchstr(l:attrs, l:mx)
|
||||
if len(l:match) ==# 0
|
||||
break
|
||||
endif
|
||||
let l:attr_match = matchlist(l:match, l:mx)
|
||||
let l:name = l:attr_match[1]
|
||||
let l:value = len(l:attr_match[2]) ? l:attr_match[2] : l:attr_match[3]
|
||||
let l:current.attr[l:name] = l:value
|
||||
let l:current.attrs_order += [l:name]
|
||||
let l:attrs = l:attrs[stridx(l:attrs, l:match) + len(l:match):]
|
||||
endwhile
|
||||
return l:current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#toggleComment() abort
|
||||
let l:line = getline('.')
|
||||
let l:space = matchstr(l:line, '^\s*')
|
||||
if l:line =~# '^\s*-#'
|
||||
call setline('.', l:space . matchstr(l:line[len(l:space)+2:], '^\s*\zs.*'))
|
||||
elseif l:line =~# '^\s*%[a-z]'
|
||||
call setline('.', l:space . '-# ' . l:line[len(l:space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#balanceTag(flag) range abort
|
||||
let l:block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let l:curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let l:curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let l:n = l:curpos[1]
|
||||
let l:ml = len(matchstr(getline(l:n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(l:block)
|
||||
let l:n = line('.')
|
||||
else
|
||||
while l:n > 0
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*\ze%[a-z]'))
|
||||
if l:l > 0 && l:l < l:ml
|
||||
let l:ml = l:l
|
||||
break
|
||||
endif
|
||||
let l:n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let l:sn = l:n
|
||||
if l:n == 0
|
||||
let l:ml = 0
|
||||
endif
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, l:n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
else
|
||||
while l:n > 0
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
|
||||
if l:l > 0 && l:l > l:ml
|
||||
let l:ml = l:l
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
let l:sn = l:n
|
||||
if l:n == 0
|
||||
let l:ml = 0
|
||||
endif
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, l:n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#jade#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#moveNextPrev(flag) abort
|
||||
let l:pos = search('""', a:flag ? 'Wb' : 'W')
|
||||
if l:pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#splitJoinTag() abort
|
||||
let l:n = line('.')
|
||||
let l:sml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
while l:n > 0
|
||||
if getline(l:n) =~# '^\s*\ze%[a-z]'
|
||||
if len(matchstr(getline(l:n), '^\s*%[a-z]')) < l:sml
|
||||
break
|
||||
endif
|
||||
let l:line = getline(l:n)
|
||||
call setline(l:n, substitute(l:line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
|
||||
let l:sn = l:n
|
||||
let l:n += 1
|
||||
let l:ml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
if len(matchstr(getline(l:n), '^\s*')) > l:ml
|
||||
while l:n <= line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*'))
|
||||
if l:l <= l:ml
|
||||
break
|
||||
endif
|
||||
exe l:n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
else
|
||||
let l:tag = matchstr(getline(l:sn), '^\s*%\zs\(\w\+\)')
|
||||
let l:spaces = matchstr(getline(l:sn), '^\s*')
|
||||
let l:settings = emmet#getSettings()
|
||||
if stridx(','.l:settings.html.inline_elements.',', ','.l:tag.',') == -1
|
||||
call append(l:sn, l:spaces . ' ')
|
||||
call setpos('.', [0, l:sn+1, 1, 0])
|
||||
else
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
endif
|
||||
startinsert!
|
||||
endif
|
||||
break
|
||||
endif
|
||||
let l:n -= 1
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#removeTag() abort
|
||||
let l:n = line('.')
|
||||
let l:ml = 0
|
||||
while l:n > 0
|
||||
if getline(l:n) =~# '^\s*\ze[a-z]'
|
||||
let l:ml = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
break
|
||||
endif
|
||||
let l:n -= 1
|
||||
endwhile
|
||||
let l:sn = l:n
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*%[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
if l:sn == l:n
|
||||
exe 'delete'
|
||||
else
|
||||
exe l:sn ',' (l:n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#mergeLines() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
@@ -1,51 +0,0 @@
|
||||
function! emmet#lang#less#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#scss#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
return emmet#lang#scss#toString(a:settings, a:current, a:type, a:inline, a:filters, a:itemno, a:indent)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#imageSize() abort
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#imageEncode() abort
|
||||
return emmet#lang#css#imageEncode()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#parseTag(tag) abort
|
||||
return emmet#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#toggleComment() abort
|
||||
call emmet#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#balanceTag(flag) range abort
|
||||
call emmet#lang#scss#balanceTag(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#less#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#moveNextPrev(flag) abort
|
||||
call emmet#lang#scss#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#splitJoinTag() abort
|
||||
call emmet#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#removeTag() abort
|
||||
call emmet#lang#css#removeTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#mergeLines() abort
|
||||
call emmet#lang#css#mergeLines()
|
||||
endfunction
|
||||
@@ -1,163 +0,0 @@
|
||||
function! emmet#lang#sass#findTokens(str) abort
|
||||
return emmet#lang#css#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let l:settings = a:settings
|
||||
let l:current = a:current
|
||||
let l:type = a:type
|
||||
let l:inline = a:inline
|
||||
let l:filters = a:filters
|
||||
let l:itemno = a:itemno
|
||||
let l:indent = a:indent
|
||||
let l:str = ''
|
||||
|
||||
let l:current_name = l:current.name
|
||||
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
|
||||
if len(l:current.name) > 0
|
||||
let l:str .= l:current_name
|
||||
let l:tmp = ''
|
||||
for l:attr in keys(l:current.attr)
|
||||
let l:val = l:current.attr[l:attr]
|
||||
while l:val =~# '\$\([^#{]\|$\)'
|
||||
let l:val = substitute(l:val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
|
||||
if l:attr ==# 'id'
|
||||
let l:str .= '#' . l:val
|
||||
elseif l:attr ==# 'class'
|
||||
let l:str .= '.' . l:val
|
||||
else
|
||||
let l:tmp .= l:attr . ': ' . l:val
|
||||
endif
|
||||
endfor
|
||||
if len(l:tmp) > 0
|
||||
let l:str .= "\n"
|
||||
for l:line in split(l:tmp, "\n")
|
||||
let l:str .= l:indent . l:line . "\n"
|
||||
endfor
|
||||
else
|
||||
let l:str .= "\n"
|
||||
endif
|
||||
|
||||
let l:inner = ''
|
||||
for l:child in l:current.child
|
||||
let l:tmp = emmet#toString(l:child, l:type, l:inline, l:filters, l:itemno, l:indent)
|
||||
let l:tmp = substitute(l:tmp, "\n", "\n" . escape(l:indent, '\'), 'g')
|
||||
let l:tmp = substitute(l:tmp, "\n" . escape(l:indent, '\') . '$', '${cursor}\n', 'g')
|
||||
let l:inner .= l:tmp
|
||||
endfor
|
||||
if len(l:inner) > 0
|
||||
let l:str .= l:indent . l:inner
|
||||
endif
|
||||
else
|
||||
let l:text = emmet#lang#css#toString(l:settings, l:current, l:type, l:inline, l:filters, l:itemno, l:indent)
|
||||
let l:text = substitute(l:text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g')
|
||||
return l:text
|
||||
endif
|
||||
return l:str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#imageSize() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#parseTag(tag) abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#toggleComment() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#balanceTag(flag) range abort
|
||||
let l:block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let l:curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let l:curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let l:n = l:curpos[1]
|
||||
let l:ml = len(matchstr(getline(l:n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(l:block)
|
||||
let l:n = line('.')
|
||||
else
|
||||
while l:n > 0
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
|
||||
if l:l > 0 && l:l < l:ml
|
||||
let l:ml = l:l
|
||||
break
|
||||
endif
|
||||
let l:n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let l:sn = l:n
|
||||
if l:n == 0
|
||||
let l:ml = 0
|
||||
endif
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, l:n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
else
|
||||
while l:n > 0
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
|
||||
if l:l > 0 && l:l > l:ml
|
||||
let l:ml = l:l
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
let l:sn = l:n
|
||||
if l:n == 0
|
||||
let l:ml = 0
|
||||
endif
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, l:n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#sass#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#moveNextPrev(flag) abort
|
||||
let l:pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if l:pos == 2
|
||||
startinsert!
|
||||
elseif l:pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#splitJoinTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#removeTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#mergeLines() abort
|
||||
endfunction
|
||||
@@ -1,129 +0,0 @@
|
||||
function! emmet#lang#scss#findTokens(str) abort
|
||||
return emmet#lang#css#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#parseIntoTree(abbr, type) abort
|
||||
if a:abbr =~# '>'
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
else
|
||||
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let l:settings = a:settings
|
||||
let l:current = a:current
|
||||
let l:type = a:type
|
||||
let l:inline = a:inline
|
||||
let l:filters = a:filters
|
||||
let l:itemno = a:itemno
|
||||
let l:indent = a:indent
|
||||
let l:str = ''
|
||||
|
||||
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
|
||||
if len(l:current.name) > 0
|
||||
let l:str .= l:current_name
|
||||
let l:tmp = ''
|
||||
for l:attr in keys(l:current.attr)
|
||||
let l:val = l:current.attr[l:attr]
|
||||
while l:val =~# '\$\([^#{]\|$\)'
|
||||
let l:val = substitute(l:val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
|
||||
if l:attr ==# 'id'
|
||||
let l:str .= '#' . l:val
|
||||
elseif l:attr ==# 'class'
|
||||
let l:str .= '.' . l:val
|
||||
else
|
||||
let l:tmp .= l:attr . ': ' . l:val . ';'
|
||||
endif
|
||||
endfor
|
||||
if len(l:tmp) > 0
|
||||
let l:str .= " {\n"
|
||||
for l:line in split(l:tmp, "\n")
|
||||
let l:str .= l:indent . l:line . "\n"
|
||||
endfor
|
||||
else
|
||||
let l:str .= " {\n"
|
||||
endif
|
||||
|
||||
let l:inner = ''
|
||||
for l:child in l:current.child
|
||||
let l:inner .= emmet#toString(l:child, l:type, l:inline, l:filters, l:itemno)
|
||||
endfor
|
||||
let l:inner = substitute(l:inner, "\n", "\n" . escape(l:indent, '\'), 'g')
|
||||
let l:inner = substitute(l:inner, "\n" . escape(l:indent, '\') . '$', '', 'g')
|
||||
let l:str .= l:indent . l:inner . "${cursor}\n}\n"
|
||||
else
|
||||
return emmet#lang#css#toString(l:settings, l:current, l:type, l:inline, l:filters, l:itemno, l:indent)
|
||||
endif
|
||||
return l:str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#imageSize() abort
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#imageEncode() abort
|
||||
return emmet#lang#css#imageEncode()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#parseTag(tag) abort
|
||||
return emmet#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#toggleComment() abort
|
||||
call emmet#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#balanceTag(flag) range abort
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let l:curpos = [0, line("'<"), col("'<"), 0]
|
||||
call setpos('.', l:curpos)
|
||||
else
|
||||
let l:curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
if a:flag < 0
|
||||
let l:ret = searchpair('}', '', '.\zs{')
|
||||
else
|
||||
let l:ret = searchpair('{', '', '}', 'bW')
|
||||
endif
|
||||
if l:ret > 0
|
||||
let l:pos1 = emmet#util#getcurpos()[1:2]
|
||||
if a:flag < 0
|
||||
let l:pos2 = searchpairpos('{', '', '}')
|
||||
else
|
||||
let l:pos2 = searchpairpos('{', '', '}')
|
||||
endif
|
||||
let l:block = [l:pos1, l:pos2]
|
||||
if emmet#util#regionIsValid(l:block)
|
||||
call emmet#util#selectRegion(l:block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe 'normal! gv'
|
||||
else
|
||||
call setpos('.', l:curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#scss#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#moveNextPrev(flag) abort
|
||||
call emmet#lang#css#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#splitJoinTag() abort
|
||||
call emmet#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#removeTag() abort
|
||||
call emmet#lang#css#removeTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#mergeLines() abort
|
||||
call emmet#lang#css#mergeLines()
|
||||
endfunction
|
||||
@@ -1,284 +0,0 @@
|
||||
function! emmet#lang#slim#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let l:current = a:current
|
||||
let l:type = a:type
|
||||
let l:inline = a:inline
|
||||
let l:filters = a:filters
|
||||
let l:itemno = a:itemno
|
||||
let l:indent = emmet#getIndentation(l:type)
|
||||
let l:dollar_expr = emmet#getResource(l:type, 'dollar_expr', 1)
|
||||
let l:str = ''
|
||||
|
||||
let l:current_name = l:current.name
|
||||
if l:dollar_expr
|
||||
let l:current_name = substitute(l:current.name, '\$$', l:itemno+1, '')
|
||||
endif
|
||||
if len(l:current.name) > 0
|
||||
let l:str .= l:current_name
|
||||
for l:attr in emmet#util#unique(l:current.attrs_order + keys(l:current.attr))
|
||||
if !has_key(l:current.attr, l:attr)
|
||||
continue
|
||||
endif
|
||||
let l:Val = l:current.attr[l:attr]
|
||||
if type(l:Val) == 2 && l:Val == function('emmet#types#true')
|
||||
let l:str .= ' ' . l:attr . '=true'
|
||||
else
|
||||
if l:dollar_expr
|
||||
while l:Val =~# '\$\([^#{]\|$\)'
|
||||
let l:Val = substitute(l:Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
endif
|
||||
let l:attr = substitute(l:attr, '\$$', l:itemno+1, '')
|
||||
let l:str .= ' ' . l:attr . '="' . l:Val . '"'
|
||||
endif
|
||||
endfor
|
||||
|
||||
let l:inner = ''
|
||||
if len(l:current.value) > 0
|
||||
let l:str .= "\n"
|
||||
let l:text = l:current.value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
|
||||
let l:text = substitute(l:text, '\\\$', '$', 'g')
|
||||
let l:str = substitute(l:str, '\$#', l:text, 'g')
|
||||
endif
|
||||
for l:line in split(l:text, "\n")
|
||||
let l:str .= l:indent . '| ' . l:line . "\n"
|
||||
endfor
|
||||
elseif len(l:current.child) == 0
|
||||
let l:str .= '${cursor}'
|
||||
endif
|
||||
if len(l:current.child) == 1 && len(l:current.child[0].name) == 0
|
||||
let l:str .= "\n"
|
||||
let l:text = l:current.child[0].value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:text = substitute(l:text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:text = substitute(l:text, '\${nr}', "\n", 'g')
|
||||
let l:text = substitute(l:text, '\\\$', '$', 'g')
|
||||
endif
|
||||
for l:line in split(l:text, "\n")
|
||||
let l:str .= l:indent . '| ' . l:line . "\n"
|
||||
endfor
|
||||
elseif len(l:current.child) > 0
|
||||
for l:child in l:current.child
|
||||
let l:inner .= emmet#toString(l:child, l:type, l:inline, l:filters, l:itemno, l:indent)
|
||||
endfor
|
||||
let l:inner = substitute(l:inner, "\n", "\n" . escape(l:indent, '\'), 'g')
|
||||
let l:inner = substitute(l:inner, "\n" . escape(l:indent, '\') . '$', '', 'g')
|
||||
let l:str .= "\n" . l:indent . l:inner
|
||||
endif
|
||||
else
|
||||
let l:str = l:current.value[1:-2]
|
||||
if l:dollar_expr
|
||||
let l:str = substitute(l:str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", l:itemno+1).submatch(2)', 'g')
|
||||
let l:str = substitute(l:str, '\${nr}', "\n", 'g')
|
||||
let l:str = substitute(l:str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
if l:str !~# "\n$"
|
||||
let l:str .= "\n"
|
||||
endif
|
||||
return l:str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#imageSize() abort
|
||||
let l:line = getline('.')
|
||||
let l:current = emmet#lang#slim#parseTag(l:line)
|
||||
if empty(l:current) || !has_key(l:current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let l:fn = l:current.attr.src
|
||||
if l:fn =~# '^\s*$'
|
||||
return
|
||||
elseif l:fn !~# '^\(/\|http\)'
|
||||
let l:fn = simplify(expand('%:h') . '/' . l:fn)
|
||||
endif
|
||||
|
||||
let [l:width, l:height] = emmet#util#getImageSize(l:fn)
|
||||
if l:width == -1 && l:height == -1
|
||||
return
|
||||
endif
|
||||
let l:current.attr.width = l:width
|
||||
let l:current.attr.height = l:height
|
||||
let l:current.attrs_order += ['width', 'height']
|
||||
let l:slim = emmet#toString(l:current, 'slim', 1)
|
||||
let l:slim = substitute(l:slim, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(l:line, '^\s*') . l:slim, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#imageEncode() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#parseTag(tag) abort
|
||||
let l:current = emmet#newNode()
|
||||
let l:mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)'
|
||||
let l:match = matchstr(a:tag, l:mx)
|
||||
let l:current.name = substitute(l:match, l:mx, '\1', '')
|
||||
let l:attrs = substitute(l:match, l:mx, '\2', '')
|
||||
let l:mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(l:attrs) > 0
|
||||
let l:match = matchstr(l:attrs, l:mx)
|
||||
if len(l:match) == 0
|
||||
break
|
||||
endif
|
||||
let l:attr_match = matchlist(l:match, l:mx)
|
||||
let l:name = l:attr_match[1]
|
||||
let l:value = len(l:attr_match[2]) ? l:attr_match[2] : l:attr_match[3]
|
||||
let l:current.attr[l:name] = l:value
|
||||
let l:current.attrs_order += [l:name]
|
||||
let l:attrs = l:attrs[stridx(l:attrs, l:match) + len(l:match):]
|
||||
endwhile
|
||||
return l:current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#toggleComment() abort
|
||||
let l:line = getline('.')
|
||||
let l:space = matchstr(l:line, '^\s*')
|
||||
if l:line =~# '^\s*/'
|
||||
call setline('.', l:space . l:line[len(l:space)+1:])
|
||||
elseif l:line =~# '^\s*[a-z]'
|
||||
call setline('.', l:space . '/' . l:line[len(l:space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#balanceTag(flag) range abort
|
||||
let l:block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let l:curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let l:curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let l:n = l:curpos[1]
|
||||
let l:ml = len(matchstr(getline(l:n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(l:block)
|
||||
let l:n = line('.')
|
||||
else
|
||||
while l:n > 0
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
|
||||
if l:l > 0 && l:l < l:ml
|
||||
let l:ml = l:l
|
||||
break
|
||||
endif
|
||||
let l:n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let l:sn = l:n
|
||||
if l:n == 0
|
||||
let l:ml = 0
|
||||
endif
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, l:n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
else
|
||||
while l:n > 0
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*\ze[a-z]'))
|
||||
if l:l > 0 && l:l > l:ml
|
||||
let l:ml = l:l
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
let l:sn = l:n
|
||||
if l:n == 0
|
||||
let l:ml = 0
|
||||
endif
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, l:n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#slim#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#moveNextPrev(flag) abort
|
||||
let l:pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if l:pos == 2
|
||||
startinsert!
|
||||
elseif l:pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#splitJoinTag() abort
|
||||
let l:n = line('.')
|
||||
while l:n > 0
|
||||
if getline(l:n) =~# '^\s*\ze[a-z]'
|
||||
let l:sn = l:n
|
||||
let l:n += 1
|
||||
if getline(l:n) =~# '^\s*|'
|
||||
while l:n <= line('$')
|
||||
if getline(l:n) !~# '^\s*|'
|
||||
break
|
||||
endif
|
||||
exe l:n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, l:sn, 1, 0])
|
||||
else
|
||||
let l:spaces = matchstr(getline(l:sn), '^\s*')
|
||||
call append(l:sn, l:spaces . ' | ')
|
||||
call setpos('.', [0, l:sn+1, 1, 0])
|
||||
startinsert!
|
||||
endif
|
||||
break
|
||||
endif
|
||||
let l:n -= 1
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#removeTag() abort
|
||||
let l:n = line('.')
|
||||
let l:ml = 0
|
||||
while l:n > 0
|
||||
if getline(l:n) =~# '^\s*\ze[a-z]'
|
||||
let l:ml = len(matchstr(getline(l:n), '^\s*[a-z]'))
|
||||
break
|
||||
endif
|
||||
let l:n -= 1
|
||||
endwhile
|
||||
let l:sn = l:n
|
||||
while l:n < line('$')
|
||||
let l:l = len(matchstr(getline(l:n), '^\s*[a-z]'))
|
||||
if l:l > 0 && l:l <= l:ml
|
||||
let l:n -= 1
|
||||
break
|
||||
endif
|
||||
let l:n += 1
|
||||
endwhile
|
||||
if l:sn == l:n
|
||||
exe 'delete'
|
||||
else
|
||||
exe l:sn ',' (l:n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#mergeLines() abort
|
||||
endfunction
|
||||
@@ -1,65 +0,0 @@
|
||||
function! emmet#lorem#en#expand(command) abort
|
||||
let l:wcount = matchstr(a:command, '\(\d*\)$')
|
||||
let l:wcount = l:wcount > 0 ? l:wcount : 30
|
||||
|
||||
let l:common = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit']
|
||||
let l:words = ['exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet',
|
||||
\ 'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi',
|
||||
\ 'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi',
|
||||
\ 'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos',
|
||||
\ 'facilis', 'neque', 'nihil', 'expedita', 'vitae', 'vero', 'ipsum',
|
||||
\ 'nisi', 'animi', 'cumque', 'pariatur', 'velit', 'modi', 'natus',
|
||||
\ 'iusto', 'eaque', 'sequi', 'illo', 'sed', 'ex', 'et', 'voluptatibus',
|
||||
\ 'tempora', 'veritatis', 'ratione', 'assumenda', 'incidunt', 'nostrum',
|
||||
\ 'placeat', 'aliquid', 'fuga', 'provident', 'praesentium', 'rem',
|
||||
\ 'necessitatibus', 'suscipit', 'adipisci', 'quidem', 'possimus',
|
||||
\ 'voluptas', 'debitis', 'sint', 'accusantium', 'unde', 'sapiente',
|
||||
\ 'voluptate', 'qui', 'aspernatur', 'laudantium', 'soluta', 'amet',
|
||||
\ 'quo', 'aliquam', 'saepe', 'culpa', 'libero', 'ipsa', 'dicta',
|
||||
\ 'reiciendis', 'nesciunt', 'doloribus', 'autem', 'impedit', 'minima',
|
||||
\ 'maiores', 'repudiandae', 'ipsam', 'obcaecati', 'ullam', 'enim',
|
||||
\ 'totam', 'delectus', 'ducimus', 'quis', 'voluptates', 'dolores',
|
||||
\ 'molestiae', 'harum', 'dolorem', 'quia', 'voluptatem', 'molestias',
|
||||
\ 'magni', 'distinctio', 'omnis', 'illum', 'dolorum', 'voluptatum', 'ea',
|
||||
\ 'quas', 'quam', 'corporis', 'quae', 'blanditiis', 'atque', 'deserunt',
|
||||
\ 'laboriosam', 'earum', 'consequuntur', 'hic', 'cupiditate',
|
||||
\ 'quibusdam', 'accusamus', 'ut', 'rerum', 'error', 'minus', 'eius',
|
||||
\ 'ab', 'ad', 'nemo', 'fugit', 'officia', 'at', 'in', 'id', 'quos',
|
||||
\ 'reprehenderit', 'numquam', 'iste', 'fugiat', 'sit', 'inventore',
|
||||
\ 'beatae', 'repellendus', 'magnam', 'recusandae', 'quod', 'explicabo',
|
||||
\ 'doloremque', 'aperiam', 'consequatur', 'asperiores', 'commodi',
|
||||
\ 'optio', 'dolor', 'labore', 'temporibus', 'repellat', 'veniam',
|
||||
\ 'architecto', 'est', 'esse', 'mollitia', 'nulla', 'a', 'similique',
|
||||
\ 'eos', 'alias', 'dolore', 'tenetur', 'deleniti', 'porro', 'facere',
|
||||
\ 'maxime', 'corrupti']
|
||||
let l:ret = []
|
||||
let l:sentence = 0
|
||||
for l:i in range(l:wcount)
|
||||
let l:arr = l:common
|
||||
if l:sentence > 0
|
||||
let l:arr += l:words
|
||||
endif
|
||||
let l:r = emmet#util#rand()
|
||||
let l:word = l:arr[l:r % len(l:arr)]
|
||||
if l:sentence == 0
|
||||
let l:word = substitute(l:word, '^.', '\U&', '')
|
||||
endif
|
||||
let l:sentence += 1
|
||||
call add(l:ret, l:word)
|
||||
if (l:sentence > 5 && emmet#util#rand() < 10000) || l:i == l:wcount - 1
|
||||
if l:i == l:wcount - 1
|
||||
let l:endc = '?!...'[emmet#util#rand() % 5]
|
||||
call add(l:ret, l:endc)
|
||||
else
|
||||
let l:endc = '?!,...'[emmet#util#rand() % 6]
|
||||
call add(l:ret, l:endc . ' ')
|
||||
endif
|
||||
if l:endc !=# ','
|
||||
let l:sentence = 0
|
||||
endif
|
||||
else
|
||||
call add(l:ret, ' ')
|
||||
endif
|
||||
endfor
|
||||
return join(l:ret, '')
|
||||
endfunction
|
||||
@@ -1,27 +0,0 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
function! emmet#lorem#ja#expand(command) abort
|
||||
let l:wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '')
|
||||
let l:wcount = l:wcount > 0 ? l:wcount : 30
|
||||
|
||||
let l:url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html"
|
||||
let l:content = emmet#util#cache(l:url)
|
||||
if len(l:content) == 0
|
||||
let l:content = emmet#util#getContentFromURL(l:url)
|
||||
let l:content = matchstr(l:content, '<div[^>]*>\zs.\{-}</div>')
|
||||
let l:content = substitute(l:content, '[ \r]', '', 'g')
|
||||
let l:content = substitute(l:content, '<br[^>]*>', "\n", 'g')
|
||||
let l:content = substitute(l:content, '<[^>]\+>', '', 'g')
|
||||
let l:content = join(filter(split(l:content, "\n"), 'len(v:val)>0'), "\n")
|
||||
call emmet#util#cache(l:url, l:content)
|
||||
endif
|
||||
|
||||
let l:content = substitute(l:content, "、\n", "、", "g")
|
||||
let l:clines = split(l:content, '\n')
|
||||
let l:lines = filter(l:clines, 'len(substitute(v:val,".",".","g"))<=l:wcount')
|
||||
if len(l:lines) == 0
|
||||
let l:lines = l:clines
|
||||
endif
|
||||
let l:r = emmet#util#rand()
|
||||
return l:lines[l:r % len(l:lines)]
|
||||
endfunction
|
||||
@@ -1,376 +0,0 @@
|
||||
"==============================================================================
|
||||
" region utils
|
||||
"==============================================================================
|
||||
" deleteContent : delete content in region
|
||||
" if region make from between '<foo>' and '</foo>'
|
||||
" --------------------
|
||||
" begin:<foo>
|
||||
" </foo>:end
|
||||
" --------------------
|
||||
" this function make the content as following
|
||||
" --------------------
|
||||
" begin::end
|
||||
" --------------------
|
||||
function! emmet#util#deleteContent(region) abort
|
||||
let l:lines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe 'delete '.(a:region[1][0] - a:region[0][0])
|
||||
call setline(line('.'), l:lines[0][:a:region[0][1]-2] . l:lines[-1][a:region[1][1]])
|
||||
endfunction
|
||||
|
||||
" change_content : change content in region
|
||||
" if region make from between '<foo>' and '</foo>'
|
||||
" --------------------
|
||||
" begin:<foo>
|
||||
" </foo>:end
|
||||
" --------------------
|
||||
" and content is
|
||||
" --------------------
|
||||
" foo
|
||||
" bar
|
||||
" baz
|
||||
" --------------------
|
||||
" this function make the content as following
|
||||
" --------------------
|
||||
" begin:foo
|
||||
" bar
|
||||
" baz:end
|
||||
" --------------------
|
||||
function! emmet#util#setContent(region, content) abort
|
||||
let l:newlines = split(a:content, '\n', 1)
|
||||
let l:oldlines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe 'delete '.(a:region[1][0] - a:region[0][0])
|
||||
if len(l:newlines) == 0
|
||||
let l:newlines = ['']
|
||||
endif
|
||||
if a:region[0][1] > 1
|
||||
let l:newlines[0] = l:oldlines[0][:a:region[0][1]-2] . l:newlines[0]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let l:newlines[-1] .= l:oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), l:newlines[0])
|
||||
if len(l:newlines) > 1
|
||||
call append(line('.'), l:newlines[1:])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" select_region : select region
|
||||
" this function make a selection of region
|
||||
function! emmet#util#selectRegion(region) abort
|
||||
call setpos('.', [0, a:region[1][0], a:region[1][1], 0])
|
||||
normal! v
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
endfunction
|
||||
|
||||
" point_in_region : check point is in the region
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#pointInRegion(point, region) abort
|
||||
if !emmet#util#regionIsValid(a:region) | return 0 | endif
|
||||
if a:region[0][0] > a:point[0] | return 0 | endif
|
||||
if a:region[1][0] < a:point[0] | return 0 | endif
|
||||
if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif
|
||||
if a:region[1][0] == a:point[0] && a:region[1][1] < a:point[1] | return 0 | endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" cursor_in_region : check cursor is in the region
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#cursorInRegion(region) abort
|
||||
if !emmet#util#regionIsValid(a:region) | return 0 | endif
|
||||
let l:cur = emmet#util#getcurpos()[1:2]
|
||||
return emmet#util#pointInRegion(l:cur, a:region)
|
||||
endfunction
|
||||
|
||||
" region_is_valid : check region is valid
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#regionIsValid(region) abort
|
||||
if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" search_region : make region from pattern which is composing start/end
|
||||
" this function return array of position
|
||||
function! emmet#util#searchRegion(start, end) abort
|
||||
let l:b = searchpairpos(a:start, '', a:end, 'bcnW')
|
||||
if l:b == [0, 0]
|
||||
return [searchpairpos(a:start, '', a:end, 'bnW'), searchpairpos(a:start, '\%#', a:end, 'nW')]
|
||||
else
|
||||
return [l:b, searchpairpos(a:start, '', a:end. '', 'nW')]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" get_content : get content in region
|
||||
" this function return string in region
|
||||
function! emmet#util#getContent(region) abort
|
||||
if !emmet#util#regionIsValid(a:region)
|
||||
return ''
|
||||
endif
|
||||
let l:lines = getline(a:region[0][0], a:region[1][0])
|
||||
if a:region[0][0] == a:region[1][0]
|
||||
let l:lines[0] = l:lines[0][a:region[0][1]-1:a:region[1][1]-1]
|
||||
else
|
||||
let l:lines[0] = l:lines[0][a:region[0][1]-1:]
|
||||
let l:lines[-1] = l:lines[-1][:a:region[1][1]-1]
|
||||
endif
|
||||
return join(l:lines, "\n")
|
||||
endfunction
|
||||
|
||||
" region_in_region : check region is in the region
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#regionInRegion(outer, inner) abort
|
||||
if !emmet#util#regionIsValid(a:inner) || !emmet#util#regionIsValid(a:outer)
|
||||
return 0
|
||||
endif
|
||||
return emmet#util#pointInRegion(a:inner[0], a:outer) && emmet#util#pointInRegion(a:inner[1], a:outer)
|
||||
endfunction
|
||||
|
||||
" get_visualblock : get region of visual block
|
||||
" this function return region of visual block
|
||||
function! emmet#util#getVisualBlock() abort
|
||||
return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
|
||||
endfunction
|
||||
|
||||
"==============================================================================
|
||||
" html utils
|
||||
"==============================================================================
|
||||
function! s:splitHeaderBody(res) abort
|
||||
let l:pos = stridx(a:res, "\r\n\r\n")
|
||||
if l:pos != -1
|
||||
return [l:pos, strpart(a:res, l:pos+4)]
|
||||
endif
|
||||
let l:pos = stridx(a:res, "\n\n")
|
||||
return [l:pos, strpart(a:res, l:pos+2)]
|
||||
endfunction
|
||||
|
||||
function! emmet#util#getContentFromURL(url) abort
|
||||
let l:res = system(printf('%s -i %s', g:emmet_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
|
||||
while l:res =~# '^HTTP/1.\d 3' || l:res =~# '^HTTP/1\.\d 200 Connection established' || l:res =~# '^HTTP/1\.\d 100 Continue'
|
||||
let [l:pos, l:res] = s:splitHeaderBody(l:res)
|
||||
endwhile
|
||||
let [l:pos, l:content] = s:splitHeaderBody(l:res)
|
||||
let l:header = l:res[:l:pos-1]
|
||||
let l:charset = matchstr(l:content, '<meta[^>]\+content=["''][^;"'']\+;\s*charset=\zs[^;"'']\+\ze["''][^>]*>')
|
||||
if len(l:charset) == 0
|
||||
let l:charset = matchstr(l:content, '<meta\s\+charset=["'']\?\zs[^"'']\+\ze["'']\?[^>]*>')
|
||||
endif
|
||||
if len(l:charset) == 0
|
||||
let l:charset = matchstr(l:header, '\nContent-Type:.* charset=[''"]\?\zs[^''";\n]\+\ze')
|
||||
endif
|
||||
if len(l:charset) == 0
|
||||
let l:s1 = len(split(l:content, '?'))
|
||||
let l:utf8 = iconv(l:content, 'utf-8', &encoding)
|
||||
let l:s2 = len(split(l:utf8, '?'))
|
||||
return (l:s2 == l:s1 || l:s2 >= l:s1 * 2) ? l:utf8 : l:content
|
||||
endif
|
||||
return iconv(l:content, l:charset, &encoding)
|
||||
endfunction
|
||||
|
||||
function! emmet#util#getTextFromHTML(buf) abort
|
||||
let l:threshold_len = 100
|
||||
let l:threshold_per = 0.1
|
||||
let l:buf = a:buf
|
||||
|
||||
let l:buf = strpart(l:buf, stridx(l:buf, '</head>'))
|
||||
let l:buf = substitute(l:buf, '<style[^>]*>.\{-}</style>', '', 'g')
|
||||
let l:buf = substitute(l:buf, '<script[^>]*>.\{-}</script>', '', 'g')
|
||||
let l:res = ''
|
||||
let l:max = 0
|
||||
let l:mx = '\(<td[^>]\{-}>\)\|\(<\/td>\)\|\(<div[^>]\{-}>\)\|\(<\/div>\)'
|
||||
let l:m = split(l:buf, l:mx)
|
||||
for l:str in l:m
|
||||
let l:c = split(l:str, '<[^>]*?>')
|
||||
let l:str = substitute(l:str, '<[^>]\{-}>', ' ', 'g')
|
||||
let l:str = substitute(l:str, '>', '>', 'g')
|
||||
let l:str = substitute(l:str, '<', '<', 'g')
|
||||
let l:str = substitute(l:str, '"', '"', 'g')
|
||||
let l:str = substitute(l:str, ''', '''', 'g')
|
||||
let l:str = substitute(l:str, ' ', ' ', 'g')
|
||||
let l:str = substitute(l:str, '¥', '\¥', 'g')
|
||||
let l:str = substitute(l:str, '&', '\&', 'g')
|
||||
let l:str = substitute(l:str, '^\s*\(.*\)\s*$', '\1', '')
|
||||
let l:str = substitute(l:str, '\s\+', ' ', 'g')
|
||||
let l:l = len(l:str)
|
||||
if l:l > l:threshold_len
|
||||
let l:per = (l:l+0.0) / len(l:c)
|
||||
if l:max < l:l && l:per > l:threshold_per
|
||||
let l:max = l:l
|
||||
let l:res = l:str
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let l:res = substitute(l:res, '^\s*\(.*\)\s*$', '\1', 'g')
|
||||
return l:res
|
||||
endfunction
|
||||
|
||||
function! s:resolveAndReadHex(fn) abort
|
||||
let l:fn = a:fn
|
||||
if filereadable(l:fn)
|
||||
return substitute(system('xxd -p '.shellescape(l:fn)), '\n', '', 'g')
|
||||
endif
|
||||
if l:fn !~# '^\w\+://'
|
||||
let l:path = fnamemodify(expand('%'), ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
let l:path = tolower(l:path)
|
||||
endif
|
||||
for l:k in keys(g:emmet_docroot)
|
||||
let l:root = fnamemodify(l:k, ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
let l:root = tolower(l:root)
|
||||
endif
|
||||
if stridx(l:path, l:root) == 0
|
||||
let l:v = g:emmet_docroot[l:k]
|
||||
let l:fn = (len(l:v) == 0 ? l:k : l:v) . l:fn
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
return substitute(system(g:emmet_curl_command.' '.shellescape(l:fn).' | xxd -p'), '\n', '', 'g')
|
||||
endfunction
|
||||
|
||||
function! emmet#util#getImageSize(fn) abort
|
||||
let l:fn = a:fn
|
||||
|
||||
if emmet#util#isImageMagickInstalled()
|
||||
return emmet#util#imageSizeWithImageMagick(l:fn)
|
||||
endif
|
||||
|
||||
let l:hex = s:resolveAndReadHex(l:fn)
|
||||
|
||||
let [l:width, l:height] = [-1, -1]
|
||||
if l:hex =~# '^89504e470d0a1a0a'
|
||||
let l:width = eval('0x'.l:hex[32:39])
|
||||
let l:height = eval('0x'.l:hex[40:47])
|
||||
endif
|
||||
if l:hex =~# '^ffd8'
|
||||
let l:pos = 4
|
||||
while l:pos < len(l:hex)
|
||||
let l:bs = l:hex[l:pos+0:l:pos+3]
|
||||
let l:pos += 4
|
||||
if l:bs ==# 'ffc0' || l:bs ==# 'ffc2'
|
||||
let l:pos += 6
|
||||
let l:height = eval('0x'.l:hex[l:pos+0:l:pos+1])*256 + eval('0x'.l:hex[l:pos+2:l:pos+3])
|
||||
let l:pos += 4
|
||||
let l:width = eval('0x'.l:hex[l:pos+0:l:pos+1])*256 + eval('0x'.l:hex[l:pos+2:l:pos+3])
|
||||
break
|
||||
elseif l:bs =~# 'ffd[9a]'
|
||||
break
|
||||
elseif l:bs =~# 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)'
|
||||
let l:pos += (eval('0x'.l:hex[l:pos+0:l:pos+1])*256 + eval('0x'.l:hex[l:pos+2:l:pos+3])) * 2
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
if l:hex =~# '^47494638'
|
||||
let l:width = eval('0x'.l:hex[14:15].l:hex[12:13])
|
||||
let l:height = eval('0x'.l:hex[18:19].l:hex[16:17])
|
||||
endif
|
||||
|
||||
return [l:width, l:height]
|
||||
endfunction
|
||||
|
||||
function! emmet#util#imageSizeWithImageMagick(fn) abort
|
||||
let l:img_info = system('identify -format "%wx%h" '.shellescape(a:fn))
|
||||
let l:img_size = split(substitute(l:img_info, '\n', '', ''), 'x')
|
||||
if len(l:img_size) != 2
|
||||
return [-1, -1]
|
||||
endif
|
||||
return l:img_size
|
||||
endfunction
|
||||
|
||||
function! emmet#util#isImageMagickInstalled() abort
|
||||
if !get(g:, 'emmet_use_identify', 1)
|
||||
return 0
|
||||
endif
|
||||
return executable('identify')
|
||||
endfunction
|
||||
|
||||
function! s:b64encode(bytes, table, pad)
|
||||
let l:b64 = []
|
||||
for l:i in range(0, len(a:bytes) - 1, 3)
|
||||
let l:n = a:bytes[l:i] * 0x10000
|
||||
\ + get(a:bytes, l:i + 1, 0) * 0x100
|
||||
\ + get(a:bytes, l:i + 2, 0)
|
||||
call add(l:b64, a:table[l:n / 0x40000])
|
||||
call add(l:b64, a:table[l:n / 0x1000 % 0x40])
|
||||
call add(l:b64, a:table[l:n / 0x40 % 0x40])
|
||||
call add(l:b64, a:table[l:n % 0x40])
|
||||
endfor
|
||||
if len(a:bytes) % 3 == 2
|
||||
let l:b64[-1] = a:pad
|
||||
elseif len(a:bytes) % 3 == 1
|
||||
let l:b64[-1] = a:pad
|
||||
let l:b64[-2] = a:pad
|
||||
endif
|
||||
return l:b64
|
||||
endfunction
|
||||
|
||||
function! emmet#util#imageEncodeDecode(fn, flag) abort
|
||||
let l:hex = s:resolveAndReadHex(a:fn)
|
||||
|
||||
let l:bin = map(split(l:hex, '..\zs'), 'eval("0x" . v:val)')
|
||||
let l:table = split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', '\zs')
|
||||
let l:ret = 'data:image/'
|
||||
if l:hex =~# '^89504e470d0a1a0a'
|
||||
let l:ret .= 'png'
|
||||
elseif l:hex =~# '^ffd8'
|
||||
let l:ret .= 'jpeg'
|
||||
elseif l:hex =~# '^47494638'
|
||||
let l:ret .= 'gif'
|
||||
elseif l:hex =~# '^00000020667479706176696600000000'
|
||||
let l:ret .= 'avif'
|
||||
else
|
||||
let l:ret .= 'unknown'
|
||||
endif
|
||||
return l:ret . ';base64,' . join(s:b64encode(l:bin, l:table, '='), '')
|
||||
endfunction
|
||||
|
||||
function! emmet#util#unique(arr) abort
|
||||
let l:m = {}
|
||||
let l:r = []
|
||||
for l:i in a:arr
|
||||
if !has_key(l:m, l:i)
|
||||
let l:m[l:i] = 1
|
||||
call add(l:r, l:i)
|
||||
endif
|
||||
endfor
|
||||
return l:r
|
||||
endfunction
|
||||
|
||||
let s:seed = localtime()
|
||||
function! emmet#util#srand(seed) abort
|
||||
let s:seed = a:seed
|
||||
endfunction
|
||||
|
||||
function! emmet#util#rand() abort
|
||||
let s:seed = s:seed * 214013 + 2531011
|
||||
return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000
|
||||
endfunction
|
||||
|
||||
function! emmet#util#cache(name, ...) abort
|
||||
let l:content = get(a:000, 0, '')
|
||||
let l:dir = expand('~/.emmet/cache')
|
||||
if !isdirectory(l:dir)
|
||||
call mkdir(l:dir, 'p', 0700)
|
||||
endif
|
||||
let l:file = l:dir . '/' . substitute(a:name, '\W', '_', 'g')
|
||||
if len(l:content) == 0
|
||||
if !filereadable(l:file)
|
||||
return ''
|
||||
endif
|
||||
return join(readfile(l:file), "\n")
|
||||
endif
|
||||
call writefile(split(l:content, "\n"), l:file)
|
||||
endfunction
|
||||
|
||||
function! emmet#util#getcurpos() abort
|
||||
let l:pos = getpos('.')
|
||||
if mode(0) ==# 'i' && l:pos[2] > 0
|
||||
let l:pos[2] -=1
|
||||
endif
|
||||
return l:pos
|
||||
endfunction
|
||||
|
||||
function! emmet#util#closePopup() abort
|
||||
return pumvisible() ? "\<c-e>" : ''
|
||||
endfunction
|
||||
-1771
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
-1
Submodule docs deleted from ff5a094cc8
-277
@@ -1,277 +0,0 @@
|
||||
script_name: Emmet.vim
|
||||
script_id: '2981'
|
||||
script_type: utility
|
||||
script_package: emmet-vim.zip
|
||||
script_version: '0.86'
|
||||
required_vim_version: '7.0'
|
||||
summary: vim plugins for HTML and CSS hi-speed coding.
|
||||
|
||||
detailed_description: |
|
||||
|
||||
This is vim script support expanding abbreviation like emmet.
|
||||
ref: http://emmet.io/
|
||||
|
||||
There is a movie using emmet.vim
|
||||
ref: http://mattn.github.com/emmet-vim
|
||||
|
||||
Source Repository.
|
||||
ref: http://github.com/mattn/emmet-vim
|
||||
|
||||
Type abbreviation
|
||||
+-------------------------------------
|
||||
| html:5_
|
||||
+-------------------------------------
|
||||
"_" is a cursor position. and type "<c-y>," (Ctrl + y and Comma)
|
||||
NOTE: Don't worry about key map. you can change it easily.
|
||||
+-------------------------------------
|
||||
| <!DOCTYPE HTML>
|
||||
| <html lang="en">
|
||||
| <head>
|
||||
| <title></title>
|
||||
| <meta charset="UTF-8">
|
||||
| </head>
|
||||
| <body>
|
||||
| _
|
||||
| </body>
|
||||
| </html>
|
||||
+-------------------------------------
|
||||
Type following
|
||||
+-------------------------------------
|
||||
| div#foo$*2>div.bar
|
||||
+-------------------------------------
|
||||
And type "<c-y>,"
|
||||
+-------------------------------------
|
||||
|<div id="foo1">
|
||||
| <div class="bar">_</div>
|
||||
|</div>
|
||||
|<div id="foo2">
|
||||
| <div class="bar"></div>
|
||||
|</div>
|
||||
| _
|
||||
+-------------------------------------
|
||||
|
||||
Tutorial:
|
||||
|
||||
http://github.com/mattn/emmet-vim/raw/master/TUTORIAL
|
||||
|
||||
How work this:
|
||||
|
||||
http://mattn.github.com/emmet-vim
|
||||
|
||||
Tips:
|
||||
|
||||
You can customize behavior of expanding with overriding config.
|
||||
This configuration will be merged at loading plugin.
|
||||
|
||||
let g:user_emmet_settings = {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'perl' : {
|
||||
\ 'aliases' : {
|
||||
\ 'req' : 'require '
|
||||
\ },
|
||||
\ 'snippets' : {
|
||||
\ 'use' : "use strict\nuse warnings\n\n",
|
||||
\ 'warn' : "warn \"|\";",
|
||||
\ }
|
||||
\ }
|
||||
\}
|
||||
|
||||
let g:user_emmet_expandabbr_key = '<c-e>'
|
||||
|
||||
let g:use_emmet_complete_tag = 1
|
||||
|
||||
You can set language attribute in html using emmet_settings['lang'].
|
||||
|
||||
install_details: |
|
||||
|
||||
# cd ~/.vim
|
||||
# unzip emmet-vim.zip
|
||||
|
||||
or if you install pathogen.vim:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# unzip /path/to/emmet-vim.zip
|
||||
|
||||
if you get sources from repository:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# git clone http://github.com/mattn/emmet-vim.git
|
||||
|
||||
versions:
|
||||
- '0.86': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes.
|
||||
- '0.85': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes.
|
||||
- '0.84': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes. fix bug that interpose insert completion plugins.
|
||||
- '0.83': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes.
|
||||
- '0.82': |
|
||||
This is an upgrade for Emmet.vim: many bug fixes.
|
||||
- '0.81': |
|
||||
Release of Emmet.vim: renamed from ZenCoding.vim.
|
||||
- '0.80': |
|
||||
This is an upgrade for ZenCoding.vim: add emmet features.
|
||||
- '0.74': |
|
||||
This is an upgrade for ZenCoding.vim: many bug fixes.
|
||||
- '0.73': |
|
||||
This is an upgrade for ZenCoding.vim: many bug fixes. and support slim format (experimental).
|
||||
- '0.72': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fix finding tokens.
|
||||
- '0.71': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fix finding begin of tokens.
|
||||
- '0.70': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[mod] Changed behavior of expanding. "div div>a|" should keep first div element.
|
||||
[add] Supported slim formatter.
|
||||
- '0.60': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed expanding {{}}.
|
||||
- '0.59': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed toggleComment and mny bugs.
|
||||
- '0.58': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed 'foo+' style expandos.
|
||||
- '0.57': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed expandos that don't work 'choose' in xsl.
|
||||
- '0.56': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed contents parser.
|
||||
- '0.55': |
|
||||
uploaded again: sorry, files was old.
|
||||
- '0.54': |
|
||||
[add] support sass, xsd.
|
||||
[fix] expanding with html tag.
|
||||
uploaded again: sorry, fileformat was DOS.
|
||||
- '0.53': |
|
||||
[fix] gif width/height was swapped.
|
||||
- '0.52': |
|
||||
[fix] broken wrap expanding.
|
||||
- '0.51': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] wrap expanding with '&'.
|
||||
[fix] expand .content to class="content".
|
||||
[fix] haml expanding.
|
||||
[fix] bg+ snippet
|
||||
- '0.50': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed parsing '#{{foo}}' and '.{{bar}}'.
|
||||
- '0.49': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[doc] add help manual.
|
||||
- '0.48': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] install mappings to global.
|
||||
- '0.47': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[drastic changes] enable autoload. you should whole replace older files.
|
||||
package was empty. upload again.
|
||||
- '0.46': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[drastic changes] enable autoload. you should whole replace older files.
|
||||
- '0.45': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed attribute parsing like: a[href="hello', world" rel].
|
||||
- '0.44': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed checking whether have mapping using maparg() / hasmapto().
|
||||
- '0.43': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed behavior for nested block. like "html:5>#page>(header#globalHeader>(hgroup>h1+h2)+(nav>ul>li*3>a)+(form>p.siteSearch>input+input[type=button]))+(#contents>(#main>(section>h2+p*5)+p.pagetop>a[href=#page])+(#sub>p+(nav>ul>li>a)))+(footer#globalFoooter>(ul>li>a)+(p.copyright>small))"
|
||||
- '0.42': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed select/option indent.
|
||||
- '0.41': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed default filter. when using 'e' filter, output become empty.
|
||||
- '0.40': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
add the pure vimscript code for 'get image size'. you can use it without perl interface just now.
|
||||
change key assign of ZenCodingExpandWord from ',' to ';'. it don't effect to most users.
|
||||
- '0.39': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem about 'selection'. see http://github.com/mattn/zencoding-vim/issues/#issue/2
|
||||
- '0.38': |
|
||||
This is an upgrade for ZenCoding.vim: use v7h"_s instead of v7hs for backspace.
|
||||
- '0.37': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that won't working with some 'backspace' options.
|
||||
- '0.36': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that filter does not work.
|
||||
- '0.35': |
|
||||
This is an upgrade for ZenCoding.vim: enable zencoding for other languages. (meaning php also)
|
||||
- '0.34': |
|
||||
This is an upgrade for ZenCoding.vim: enable zencoding for xsl. (you should add ~/.vim/ftplugin/xslt/zencoding.vim)
|
||||
- '0.33': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem breaking multibyte when cursor is in a part of line. enabled zencoding for javascript in html.
|
||||
- '0.32': |
|
||||
This is an upgrade for ZenCoding.vim: fixed indentation. supported extends so that you can enable zencoding for php/xhtml/haml other's section 14 in http://github.com/mattn/zencoding-vim/raw/master/TUTORIAL
|
||||
- '0.31': |
|
||||
This is an upgrade for ZenCoding.vim: fixed indentation and $$$ problem. fixed about missing support multiple classes.
|
||||
- '0.30': |
|
||||
This is an upgrade for ZenCoding.vim: Fixed key assign.
|
||||
- '0.29': |
|
||||
This is an upgrade for ZenCoding.vim: Changed leading key to '<c-y>' from '<c-z>'.
|
||||
- '0.28': |
|
||||
This is an upgrade for ZenCoding.vim: supported 'Balance Tag Inward/Outward', 'Go to Next/Previous Edit Point', 'Update <img> Size', 'Remove Tag', 'Split/Join Tag', 'Toggle Comment'
|
||||
- '0.27': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that can't work on the part of multibyte characters. fixed inline elements behavior.
|
||||
- '0.26': |
|
||||
This is an upgrade for ZenCoding.vim: The count of '(((a#foo + a#bar)*2)*3)' should be 12.
|
||||
- '0.25': |
|
||||
This is an upgrade for ZenCoding.vim: store undo before working. good luck about 'table>(tr>td*3)*4'.
|
||||
- '0.24': |
|
||||
This is an upgrade for ZenCoding.vim: fixed behavior of parsing area of visual selection.
|
||||
- '0.23': |
|
||||
This is an upgrade for ZenCoding.vim: pre-expand '#header>li<#content' to 'div#header>li<div#content'. support () expression.
|
||||
- '0.22': |
|
||||
This is an upgrade for ZenCoding.vim: expand 'ul+' to 'ul>li'. fix undo ring. support visual selection. when type trigger key on visual select, it request you leader like 'ul>li'. if you give 'ul>li*' as leader, you'll get each separate 'ul>li' tags. and when you give 'blockquote' as leader, you'll get blocked text.
|
||||
- '0.21': |
|
||||
This is an upgrade for ZenCoding.vim: treat xhtml as html.
|
||||
- '0.20': |
|
||||
This is an upgrade for ZenCoding.vim: add option use_zen_complete_tag for complete abbr.
|
||||
- '0.19': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that couldn't expand 'link:css' correctly.
|
||||
- '0.18': |
|
||||
This is an upgrade for ZenCoding.vim: ignore duplicate key map.
|
||||
- '0.17': |
|
||||
This is an upgrade for ZenCoding.vim: fixed key map.
|
||||
- '0.16': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem 'endless loop'.
|
||||
- '0.15': |
|
||||
This is an upgrade for ZenCoding.vim: set default filetype to 'html'.
|
||||
- '0.14': |
|
||||
This is an upgrade for ZenCoding.vim: fixed tag name like 'fs:n' in 'css'.
|
||||
- '0.14': |
|
||||
This is an upgrade for ZenCoding.vim: indentation for each languages.
|
||||
- '0.13': |
|
||||
This is an upgrade for ZenCoding.vim: user key map.
|
||||
- '0.12': |
|
||||
This is an upgrade for ZenCoding.vim: few extensive notation.
|
||||
- '0.11': |
|
||||
This is an upgrade for ZenCoding.vim: fixed indent.
|
||||
- '0.10': |
|
||||
This is an upgrade for ZenCoding.vim: fixed behavior of '+' operator
|
||||
- '0.9': |
|
||||
This is an upgrade for ZenCoding.vim: fixed single line behavior
|
||||
- '0.8': |
|
||||
This is an upgrade for ZenCoding.vim: support 'a[href=http://www.google.com]{Google}'
|
||||
- '0.7': |
|
||||
This is an upgrade for ZenCoding.vim: fixed behavior in 'a+b'.
|
||||
- '0.6': |
|
||||
This is an upgrade for ZenCoding.vim: fixed strange behavior about '<a href="">b_</a>'.
|
||||
- '0.5': |
|
||||
This is an upgrade for ZenCoding.vim: recover rest part in line.
|
||||
- '0.4': |
|
||||
This is an upgrade for ZenCoding.vim: fixed cursor position. fixed ${lang} replacement.
|
||||
- '0.3': |
|
||||
This is an upgrade for ZenCoding.vim: fixed line expanding.
|
||||
- '0.2': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that moving cursor with expanding.
|
||||
- '0.1': |
|
||||
Initial upload
|
||||
|
||||
# __END__
|
||||
# vim: filetype=yaml
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<title>Emmet.vim</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="static/css/style-sites.css" type="text/css" />
|
||||
<!--[if IE]>
|
||||
<script type="text/javascript">
|
||||
document.createElement('header');
|
||||
document.createElement('section');
|
||||
document.createElement('nav');
|
||||
document.createElement('aside');
|
||||
document.createElement('footer');
|
||||
document.createElement('article');
|
||||
</script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<img id="logo" src="static/images/emmet-vim-logo.png" title="禅" alt="禅" />
|
||||
<h2>vim plugins for HTML and CSS hi-speed coding.</h2>
|
||||
<section id="content">
|
||||
<div class="blocked-content">
|
||||
<article id="whats">
|
||||
<h2 class="maintitle">Whats</h2>
|
||||
<p>emmet for vim</p>
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
<div class="blocked-content">
|
||||
<article id="install">
|
||||
<h2 class="maintitle">Install</h2>
|
||||
<p>copy plugin/emmet.vim to plugin directory. and copy autoload/emmet.vim to autoload directory.</p>
|
||||
<pre class="code">
|
||||
# cp -r plugin ~/.vim/.
|
||||
# cp -r autoload ~/.vim/.
|
||||
</pre>
|
||||
<p>if you install <a href="http://www.vim.org/scripts/script.php?script_id=2332">pathogen.vim</a>, you can make it work with only copying emmet-vim directory to bundle directory.</p>
|
||||
<pre class="code">
|
||||
# cp -r emmet-vim ~/.vim/bundle/.
|
||||
</pre>
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
<div class="blocked-content">
|
||||
<article id="howworkthis">
|
||||
<h2 class="maintitle">How This Work</h2>
|
||||
<p>below is a movie when using emmet.vim</p>
|
||||
<script type="text/javascript" src="https://asciinema.org/a/4568.js" id="asciicast-4568" async></script>
|
||||
</div>
|
||||
<!--
|
||||
<embed type="application/x-shockwave-flash" src="http://ttyshare.com/t/a474271fe4eea14f6302286d2bfabd968fb40868" width="480" height="288"/>
|
||||
<embed type="application/x-shockwave-flash" src="http://ttyshare.com/t/8e83a40b6e5d6590b2832fc406114dbe348fc96f" width="480" height="288"/>
|
||||
-->
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
<div class="blocked-content">
|
||||
<article id="repo">
|
||||
<h2 class="maintitle">Repository</h2>
|
||||
<p>
|
||||
<a href="http://github.com/mattn/emmet-vim/">http://github.com/mattn/emmet-vim/</a>
|
||||
</p>
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
<div class="blocked-content">
|
||||
<article id="license">
|
||||
<h2 class="maintitle">License</h2>
|
||||
<p>BSD style license.</p>
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
<div class="blocked-content">
|
||||
<article id="author">
|
||||
<h2 class="maintitle">Author</h2>
|
||||
<p>Project authors:</p>
|
||||
<div>
|
||||
<ul>
|
||||
<li><a href="http://mattn.kaoriya.net/" rel="me">Yasuhiro Matsumoto</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
</section>
|
||||
</body>
|
||||
@@ -1,24 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
M.get_node_at_cursor = function()
|
||||
local node = vim.treesitter.get_node()
|
||||
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
|
||||
@@ -1,192 +0,0 @@
|
||||
"=============================================================================
|
||||
" File: emmet.vim
|
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
" Last Change: 26-Jul-2015.
|
||||
" Version: 0.86
|
||||
" WebPage: http://github.com/mattn/emmet-vim
|
||||
" Description: vim plugins for HTML and CSS hi-speed coding.
|
||||
" SeeAlso: http://emmet.io/
|
||||
" Usage:
|
||||
"
|
||||
" This is vim script support expanding abbreviation like emmet.
|
||||
" ref: http://emmet.io/
|
||||
"
|
||||
" Type abbreviation
|
||||
" +-------------------------------------
|
||||
" | html:5_
|
||||
" +-------------------------------------
|
||||
" "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma)
|
||||
" NOTE: Don't worry about key map. you can change it easily.
|
||||
" +-------------------------------------
|
||||
" | <!DOCTYPE HTML>
|
||||
" | <html lang="en">
|
||||
" | <head>
|
||||
" | <title></title>
|
||||
" | <meta charset="UTF-8">
|
||||
" | <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
" | </head>
|
||||
" | <body>
|
||||
" | _
|
||||
" | </body>
|
||||
" | </html>
|
||||
" +-------------------------------------
|
||||
" Type following
|
||||
" +-------------------------------------
|
||||
" | div#foo$*2>div.bar
|
||||
" +-------------------------------------
|
||||
" And type "<c-y>,"
|
||||
" +-------------------------------------
|
||||
" |<div id="foo1">
|
||||
" | <div class="bar">_</div>
|
||||
" |</div>
|
||||
" |<div id="foo2">
|
||||
" | <div class="bar"></div>
|
||||
" |</div>
|
||||
" +-------------------------------------
|
||||
"
|
||||
" Tips:
|
||||
"
|
||||
" You can customize behavior of expanding with overriding config.
|
||||
" This configuration will be merged at loading plugin.
|
||||
"
|
||||
" let g:user_emmet_settings = {
|
||||
" \ 'indentation' : ' ',
|
||||
" \ 'perl' : {
|
||||
" \ 'aliases' : {
|
||||
" \ 'req' : 'require '
|
||||
" \ },
|
||||
" \ 'snippets' : {
|
||||
" \ 'use' : "use strict\nuse warnings\n\n",
|
||||
" \ 'warn' : "warn \"|\";",
|
||||
" \ }
|
||||
" \ }
|
||||
" \}
|
||||
"
|
||||
" You can set language attribute in html using 'emmet_settings.lang'.
|
||||
"
|
||||
" GetLatestVimScripts: 2981 1 :AutoInstall: emmet.vim
|
||||
" script type: plugin
|
||||
|
||||
if &compatible || v:version < 702 || (exists('g:loaded_emmet_vim') && g:loaded_emmet_vim)
|
||||
finish
|
||||
endif
|
||||
let g:loaded_emmet_vim = 1
|
||||
|
||||
let s:save_cpo = &cpoptions
|
||||
set cpoptions&vim
|
||||
|
||||
if !exists('g:emmet_html5')
|
||||
let g:emmet_html5 = 1
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_docroot')
|
||||
let g:emmet_docroot = {}
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_debug')
|
||||
let g:emmet_debug = 0
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_curl_command')
|
||||
let g:emmet_curl_command = 'curl -s -L -A Mozilla/5.0'
|
||||
endif
|
||||
|
||||
if !exists('g:user_emmet_leader_key')
|
||||
let g:user_emmet_leader_key = '<c-y>'
|
||||
endif
|
||||
|
||||
function! s:install_plugin(mode, buffer)
|
||||
let l:buffer = a:buffer ? '<buffer>' : ''
|
||||
let l:items = [
|
||||
\ {'mode': 'i', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(0,"")<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(3,"")<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(2,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(1,"")<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': ':call emmet#expandAbbr(1,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#updateTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': ':call emmet#updateTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': '<esc>:call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': ':call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': '<esc>:call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': ':call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': ':call emmet#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': ':call emmet#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': '<esc>:call emmet#moveNextPrevItem(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': ':call emmet#moveNextPrevItem(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': '<esc>:call emmet#moveNextPrevItem(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': ':call emmet#moveNextPrevItem(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#imageSize()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': ':call emmet#imageSize()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_imageencode_key', 'key': 'I', 'plug': 'emmet-image-encode', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#imageEncode()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_imageencode_key', 'key': 'I', 'plug': 'emmet-image-encode', 'func': ':call emmet#imageEncode()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#toggleComment()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': ':call emmet#toggleComment()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': '<esc>:call emmet#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': ':call emmet#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#removeTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': ':call emmet#removeTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': ':call emmet#anchorizeURL(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': ':call emmet#anchorizeURL(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#mergeLines()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': ':call emmet#mergeLines()<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_codepretty_key', 'key': 'c', 'plug': 'emmet-code-pretty', 'func': ':call emmet#codePretty()<cr>'},
|
||||
\]
|
||||
|
||||
let l:only_plug = get(g:, 'emmet_install_only_plug', 0)
|
||||
for l:item in l:items
|
||||
if a:mode !=# 'a' && stridx(a:mode, l:item.mode) == -1
|
||||
continue
|
||||
endif
|
||||
exe l:item.mode . 'noremap '. l:buffer .' <plug>(' . l:item.plug . ') ' . l:item.func
|
||||
if l:item.var != '' && !l:only_plug
|
||||
if exists('g:' . l:item.var)
|
||||
let l:key = eval('g:' . l:item.var)
|
||||
else
|
||||
let l:key = g:user_emmet_leader_key . l:item.key
|
||||
endif
|
||||
if !hasmapto('<plug>(' . l:item.plug . ')', l:item.mode) && !len(maparg(l:key, l:item.mode))
|
||||
exe l:item.mode . 'map ' . l:buffer . ' <unique> <silent>' . l:key . ' <plug>(' . l:item.plug . ')'
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if exists('g:user_emmet_complete_tag') && g:user_emmet_complete_tag
|
||||
if get(g:, 'user_emmet_install_global', 1)
|
||||
set omnifunc=emmet#completeTag
|
||||
else
|
||||
setlocal omnifunc=emmet#completeTag
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
command! -nargs=0 -bar EmmetInstall call <SID>install_plugin(get(g:, 'user_emmet_mode', 'a'), 1)
|
||||
|
||||
if get(g:, 'user_emmet_install_global', 1)
|
||||
call s:install_plugin(get(g:, 'user_emmet_mode', 'a'), 0)
|
||||
endif
|
||||
|
||||
if get(g:, 'user_emmet_install_command', 1)
|
||||
command! -nargs=1 Emmet call emmet#expandAbbr(4, <q-args>)
|
||||
endif
|
||||
|
||||
function! s:setup_styledEmmetAbbreviation() abort
|
||||
if index(['javascript', 'javascriptreact', 'typescript', 'typescriptreact'], &filetype) != -1
|
||||
syntax match styledEmmetAbbreviation "[a-z0-9#+!%]\+" containedin=styledDefinition contained
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup ___emmet_setup___
|
||||
au!
|
||||
autocmd Syntax * call s:setup_styledEmmetAbbreviation()
|
||||
augroup END
|
||||
|
||||
let &cpoptions = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:set et:
|
||||
@@ -0,0 +1,99 @@
|
||||
@charset "utf-8"
|
||||
|
||||
section, article, aside, hgroup, header, footer, nav, figure { display: block; }
|
||||
|
||||
body {
|
||||
font-family: "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", Meiryo, "メイリオ", "MS Pゴシック", Verdana, Geneva, Arial, Helvetica;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
section {
|
||||
clear:both;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
article {
|
||||
}
|
||||
|
||||
img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#content {
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: 'Verdana', 'Arial';
|
||||
padding: 0.5em; margin-top: 0; margin-bottom: 0;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
background: transparent url(../images/allow-right-orange.png) no-repeat scroll 0%;
|
||||
padding-left: 26px;
|
||||
line-height: 26px;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.maintitle {
|
||||
background: transparent url(../images/allow-right-green.png) no-repeat scroll 0%;
|
||||
padding-left: 26px;
|
||||
line-height: 26px;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.blocked-content {
|
||||
padding: 1em;
|
||||
border: 1px dotted gray;
|
||||
font-family: 'Verdana', 'Arial';
|
||||
}
|
||||
|
||||
a{
|
||||
color: #006699;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:link {
|
||||
color: #006699;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #006699;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #006699;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
li a, h3 a {
|
||||
padding-left:5px;
|
||||
padding-right:5px;
|
||||
background-color:none;
|
||||
text-decoration:none;
|
||||
color: #333333;
|
||||
text-shadow:1px 1px 1px #ffffff;
|
||||
line-height: 25px;
|
||||
}
|
||||
li a:hover, li a:active, h3 a:hover, li a:active {
|
||||
background-color:#334d55;
|
||||
text-decoration:none;
|
||||
color:#ffffff;
|
||||
text-shadow:1px 1px 1px #000000;
|
||||
}
|
||||
|
||||
pre.code {
|
||||
padding: 1em;
|
||||
border: 1px dotted gray;
|
||||
font-family: 'Verdana', 'Arial';
|
||||
color: white;
|
||||
background: gray;
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
#tty {
|
||||
font-family: monospace;
|
||||
font-size: 10pt;
|
||||
line-height: 0px;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 673 B |
Binary file not shown.
|
After Width: | Height: | Size: 978 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
Vendored
+3549
File diff suppressed because it is too large
Load Diff
@@ -1,36 +0,0 @@
|
||||
let s:helper = {}
|
||||
|
||||
function! s:helper.setup() abort
|
||||
let g:user_emmet_settings = {'variables': {'indentation': "\t", 'use_selection': 1}}
|
||||
exe 'so' getcwd() . '/plugin/emmet.vim'
|
||||
endfunction
|
||||
|
||||
function! s:helper.expand_word(query, type) abort
|
||||
return emmet#expandWord(a:query, a:type, 0)
|
||||
endfunction
|
||||
|
||||
function! s:helper.expand_in_buffer(query, type, result) abort
|
||||
silent! 1new
|
||||
silent! exe 'setlocal ft=' . a:type
|
||||
EmmetInstall
|
||||
let l:key = matchstr(a:query, '.*\$\$\$\$\zs.*\ze\$\$\$\$')
|
||||
if len(l:key) > 0
|
||||
exe printf('let l:key = "%s"', l:key)
|
||||
else
|
||||
let l:key = "\<c-y>,"
|
||||
endif
|
||||
let l:q = substitute(a:query, '\$\$\$\$.*\$\$\$\$', '$$$$', '')
|
||||
call setline(1, split(l:q, "\n"))
|
||||
let l:cmd = "normal gg0/\\$\\$\\$\\$\ri\<del>\<del>\<del>\<del>" . l:key
|
||||
if stridx(a:result, '$$$$') != -1
|
||||
let l:cmd .= '$$$$'
|
||||
endif
|
||||
silent! exe l:cmd
|
||||
let l:res = join(getline(1, line('$')), "\n")
|
||||
silent! bw!
|
||||
return l:res
|
||||
endfunction
|
||||
|
||||
function! themis#helper#emmet#new(runner) abort
|
||||
return deepcopy(s:helper)
|
||||
endfunction
|
||||
@@ -1,144 +0,0 @@
|
||||
Describe css
|
||||
|
||||
Describe expand abbreviation
|
||||
It expands font-style normal
|
||||
let res = ExpandInBuffer('{fs:n$$$$}', 'css', '{font-style: normal;}')
|
||||
Assert Equals(res, '{font-style: normal;}')
|
||||
End
|
||||
|
||||
It expands float left with fc filter
|
||||
let res = ExpandInBuffer('{fl:l|fc$$$$}', 'css', '{float: left;}')
|
||||
Assert Equals(res, '{float: left;}')
|
||||
End
|
||||
|
||||
It expands background+
|
||||
let res = ExpandInBuffer('{bg+$$$$}', 'css', '{background: $$$$#fff url() 0 0 no-repeat;}')
|
||||
Assert Equals(res, '{background: $$$$#fff url() 0 0 no-repeat;}')
|
||||
End
|
||||
|
||||
It expands background+ important
|
||||
let res = ExpandInBuffer('{bg+!$$$$}', 'css', '{background: $$$$#fff url() 0 0 no-repeat !important;}')
|
||||
Assert Equals(res, '{background: $$$$#fff url() 0 0 no-repeat !important;}')
|
||||
End
|
||||
|
||||
It expands margin
|
||||
let res = ExpandInBuffer('{m$$$$}', 'css', '{margin: $$$$;}')
|
||||
Assert Equals(res, '{margin: $$$$;}')
|
||||
End
|
||||
|
||||
It expands margin percent
|
||||
let res = ExpandInBuffer('{m0.1p$$$$}', 'css', '{margin: 0.1%;}')
|
||||
Assert Equals(res, '{margin: 0.1%;}')
|
||||
End
|
||||
|
||||
It expands margin em
|
||||
let res = ExpandInBuffer('{m1.0$$$$}', 'css', '{margin: 1.0em;}')
|
||||
Assert Equals(res, '{margin: 1.0em;}')
|
||||
End
|
||||
|
||||
It expands margin px
|
||||
let res = ExpandInBuffer('{m2$$$$}', 'css', '{margin: 2px;}')
|
||||
Assert Equals(res, '{margin: 2px;}')
|
||||
End
|
||||
|
||||
It expands border-radius
|
||||
let res = ExpandInBuffer('{bdrs10$$$$}', 'css', '{border-radius: 10px;}')
|
||||
Assert Equals(res, '{border-radius: 10px;}')
|
||||
End
|
||||
|
||||
It expands vendor prefix border-radius
|
||||
let res = ExpandInBuffer('{-bdrs20$$$$}', 'css', "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}")
|
||||
Assert Equals(res, "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}")
|
||||
End
|
||||
|
||||
It expands linear-gradient
|
||||
let res = ExpandInBuffer('{lg(top,#fff,#000)$$$$}', 'css', "{background-image: -webkit-gradient(top, 0 0, 0 100%, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}")
|
||||
Assert Equals(res, "{background-image: -webkit-gradient(top, 0 0, 0 100%, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}")
|
||||
End
|
||||
|
||||
It expands margin multi value
|
||||
let res = ExpandInBuffer('{m10-5-0$$$$}', 'css', '{margin: 10px 5px 0;}')
|
||||
Assert Equals(res, '{margin: 10px 5px 0;}')
|
||||
End
|
||||
|
||||
It expands margin negative
|
||||
let res = ExpandInBuffer('{m-10--5$$$$}', 'css', '{margin: -10px -5px;}')
|
||||
Assert Equals(res, '{margin: -10px -5px;}')
|
||||
End
|
||||
|
||||
It expands margin auto
|
||||
let res = ExpandInBuffer('{m10-auto$$$$}', 'css', '{margin: 10px auto;}')
|
||||
Assert Equals(res, '{margin: 10px auto;}')
|
||||
End
|
||||
|
||||
It expands width percent
|
||||
let res = ExpandInBuffer('{w100p$$$$}', 'css', '{width: 100%;}')
|
||||
Assert Equals(res, '{width: 100%;}')
|
||||
End
|
||||
|
||||
It expands height em
|
||||
let res = ExpandInBuffer('{h50e$$$$}', 'css', '{height: 50em;}')
|
||||
Assert Equals(res, '{height: 50em;}')
|
||||
End
|
||||
|
||||
It expands multi property group
|
||||
let res = ExpandInBuffer('{(bg+)+c$$$$}', 'css', "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}")
|
||||
Assert Equals(res, "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}")
|
||||
End
|
||||
|
||||
It expands multi property
|
||||
let res = ExpandInBuffer('{m0+bgi+bg++p0$$$$}', 'css', "{margin: 0;\nbackground-image: url($$$$);\nbackground: #fff url() 0 0 no-repeat;\npadding: 0;}")
|
||||
Assert Equals(res, "{margin: 0;\nbackground-image: url($$$$);\nbackground: #fff url() 0 0 no-repeat;\npadding: 0;}")
|
||||
End
|
||||
|
||||
It expands fuzzy border-left
|
||||
let res = ExpandInBuffer('{borle$$$$}', 'css', '{border-left: $$$$;}')
|
||||
Assert Equals(res, '{border-left: $$$$;}')
|
||||
End
|
||||
|
||||
It expands color shorthand
|
||||
let res = ExpandInBuffer('{c#dba$$$$}', 'css', '{color: rgb(221, 187, 170);}')
|
||||
Assert Equals(res, '{color: rgb(221, 187, 170);}')
|
||||
End
|
||||
|
||||
It expands color shorthand with alpha
|
||||
let res = ExpandInBuffer('{c#dba.7$$$$}', 'css', '{color: rgb(221, 187, 170, 0.7);}')
|
||||
Assert Equals(res, '{color: rgb(221, 187, 170, 0.7);}')
|
||||
End
|
||||
|
||||
It expands display none
|
||||
let res = ExpandInBuffer('{dn$$$$}', 'css', '{display: none;}')
|
||||
Assert Equals(res, '{display: none;}')
|
||||
End
|
||||
|
||||
It expands padding with percent sign
|
||||
let res = ExpandInBuffer('{p10%$$$$}', 'css', '{padding: 10%;}')
|
||||
Assert Equals(res, '{padding: 10%;}')
|
||||
End
|
||||
|
||||
It expands padding with p suffix
|
||||
let res = ExpandInBuffer('{p10p$$$$}', 'css', '{padding: 10%;}')
|
||||
Assert Equals(res, '{padding: 10%;}')
|
||||
End
|
||||
|
||||
It expands padding with e suffix
|
||||
let res = ExpandInBuffer('{p10e$$$$}', 'css', '{padding: 10em;}')
|
||||
Assert Equals(res, '{padding: 10em;}')
|
||||
End
|
||||
|
||||
It expands padding with em suffix
|
||||
let res = ExpandInBuffer('{p10em$$$$}', 'css', '{padding: 10em;}')
|
||||
Assert Equals(res, '{padding: 10em;}')
|
||||
End
|
||||
|
||||
It expands padding with re suffix
|
||||
let res = ExpandInBuffer('{p10re$$$$}', 'css', '{padding: 10rem;}')
|
||||
Assert Equals(res, '{padding: 10rem;}')
|
||||
End
|
||||
|
||||
It expands padding with rem suffix
|
||||
let res = ExpandInBuffer('{p10rem$$$$}', 'css', '{padding: 10rem;}')
|
||||
Assert Equals(res, '{padding: 10rem;}')
|
||||
End
|
||||
End
|
||||
End
|
||||
@@ -1,48 +0,0 @@
|
||||
Describe haml
|
||||
|
||||
Describe expand abbreviation
|
||||
It expands complex
|
||||
Assert Equals(ExpandWord('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}', 'haml'), "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n")
|
||||
End
|
||||
|
||||
It expands with haml filter
|
||||
Assert Equals(ExpandWord('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml', 'haml'), "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n")
|
||||
End
|
||||
|
||||
It expands a multiplier
|
||||
Assert Equals(ExpandWord('a*3|haml', 'haml'), "%a{ :href => \"\" }\n%a{ :href => \"\" }\n%a{ :href => \"\" }\n")
|
||||
End
|
||||
|
||||
It expands class with text
|
||||
Assert Equals(ExpandWord('.content{Hello!}|haml', 'haml'), "%div.content Hello!\n")
|
||||
End
|
||||
|
||||
It expands title dollar hash
|
||||
Assert Equals(ExpandWord('a[title=$#]{foo}', 'haml'), "%a{ :href => \"\", :title => \"foo\" } foo\n")
|
||||
End
|
||||
End
|
||||
|
||||
Describe split join
|
||||
It joins
|
||||
let res = ExpandInBuffer("%a foo\n bar$$$$\\<c-y>j$$$$", 'haml', '%a ')
|
||||
Assert Equals(res, '%a ')
|
||||
End
|
||||
|
||||
It splits
|
||||
let res = ExpandInBuffer("$$$$\\<c-y>j$$$$%a ", 'haml', '%a $$$$')
|
||||
Assert Equals(res, '%a $$$$')
|
||||
End
|
||||
End
|
||||
|
||||
Describe toggle comment
|
||||
It adds comment
|
||||
let res = ExpandInBuffer('%a{ :href => "http://www.google.com"$$$$\<c-y>/$$$$ } hello', 'haml', '-# %a{ :href => "http://www.google.com" } hello')
|
||||
Assert Equals(res, '-# %a{ :href => "http://www.google.com" } hello')
|
||||
End
|
||||
|
||||
It removes comment
|
||||
let res = ExpandInBuffer('-# %a{ :href => "http://www.google.com"$$$$\<c-y>/$$$$ } hello', 'haml', '%a{ :href => "http://www.google.com" } hello')
|
||||
Assert Equals(res, '%a{ :href => "http://www.google.com" } hello')
|
||||
End
|
||||
End
|
||||
End
|
||||
@@ -1,487 +0,0 @@
|
||||
Describe html
|
||||
|
||||
Describe expand abbreviation
|
||||
It expands div
|
||||
Assert Equals(ExpandWord('div', 'html'), "<div></div>\n")
|
||||
End
|
||||
|
||||
It expands div with id
|
||||
Assert Equals(ExpandWord('div#wrapper', 'html'), "<div id=\"wrapper\"></div>\n")
|
||||
End
|
||||
|
||||
It expands div with class
|
||||
Assert Equals(ExpandWord('div.box', 'html'), "<div class=\"box\"></div>\n")
|
||||
End
|
||||
|
||||
It expands a with title attribute
|
||||
Assert Equals(ExpandWord('a[title=TITLE]', 'html'), "<a href=\"\" title=\"TITLE\"></a>\n")
|
||||
End
|
||||
|
||||
It expands div with id and class
|
||||
Assert Equals(ExpandWord('div#wrapper.box', 'html'), "<div id=\"wrapper\" class=\"box\"></div>\n")
|
||||
End
|
||||
|
||||
It expands div with id and multiple classes
|
||||
Assert Equals(ExpandWord('div#wrapper.box.current', 'html'), "<div id=\"wrapper\" class=\"box current\"></div>\n")
|
||||
End
|
||||
|
||||
It expands div with id, classes and attributes
|
||||
Assert Equals(ExpandWord('div#wrapper.box.current[title=TITLE rel]', 'html'), "<div id=\"wrapper\" class=\"box current\" title=\"TITLE\" rel=\"\"></div>\n")
|
||||
End
|
||||
|
||||
It expands sibling divs
|
||||
Assert Equals(ExpandWord('div#main+div#sub', 'html'), "<div id=\"main\"></div>\n<div id=\"sub\"></div>\n")
|
||||
End
|
||||
|
||||
It expands child div
|
||||
Assert Equals(ExpandWord('div#main>div#sub', 'html'), "<div id=\"main\">\n\t<div id=\"sub\"></div>\n</div>\n")
|
||||
End
|
||||
|
||||
It expands html:xt complex
|
||||
Assert Equals(ExpandWord('html:xt>div#header>div#logo+ul#nav>li.item-$*5>a', 'html'), "<!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>")
|
||||
End
|
||||
|
||||
It expands ol with li multiplier
|
||||
Assert Equals(ExpandWord('ol>li*2', 'html'), "<ol>\n\t<li></li>\n\t<li></li>\n</ol>\n")
|
||||
End
|
||||
|
||||
It expands a with default attribute
|
||||
Assert Equals(ExpandWord('a', 'html'), "<a href=\"\"></a>\n")
|
||||
End
|
||||
|
||||
It expands obj alias
|
||||
Assert Equals(ExpandWord('obj', 'html'), "<object data=\"\" type=\"\"></object>\n")
|
||||
End
|
||||
|
||||
It expands cc:ie6 complex
|
||||
Assert Equals(ExpandWord('cc:ie6>p+blockquote#sample$.so.many.classes*2', 'html'), "<!--[if lte IE 6]>\n\t<p></p>\n\t<blockquote id=\"sample1\" class=\"so many classes\"></blockquote>\n\t<blockquote id=\"sample2\" class=\"so many classes\"></blockquote>\n\t\n<![endif]-->")
|
||||
End
|
||||
|
||||
It expands html:4t complex
|
||||
Assert Equals(ExpandWord('html:4t>div#wrapper>div#header+div#contents+div#footer', 'html'), "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html 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=\"wrapper\">\n\t\t<div id=\"header\"></div>\n\t\t<div id=\"contents\"></div>\n\t\t<div id=\"footer\"></div>\n\t</div>\n\t\n</body>\n</html>")
|
||||
End
|
||||
|
||||
It expands a with href, class and id
|
||||
Assert Equals(ExpandWord('a[href=http://www.google.com/].foo#hoge', 'html'), "<a id=\"hoge\" class=\"foo\" href=\"http://www.google.com/\"></a>\n")
|
||||
End
|
||||
|
||||
It expands a with href and text
|
||||
Assert Equals(ExpandWord('a[href=http://www.google.com/]{Google}', 'html'), "<a href=\"http://www.google.com/\">Google</a>\n")
|
||||
End
|
||||
|
||||
It expands text only
|
||||
Assert Equals(ExpandWord('{Emmet}', 'html'), 'Emmet')
|
||||
End
|
||||
|
||||
It expands a+b
|
||||
Assert Equals(ExpandWord('a+b', 'html'), "<a href=\"\"></a>\n<b></b>\n")
|
||||
End
|
||||
|
||||
It climbs up with <
|
||||
Assert Equals(ExpandWord('a>b>i<b', 'html'), "<a href=\"\"><b><i></i></b><b></b></a>\n")
|
||||
End
|
||||
|
||||
It climbs up with ^
|
||||
Assert Equals(ExpandWord('a>b>i^b', 'html'), "<a href=\"\"><b><i></i></b><b></b></a>\n")
|
||||
End
|
||||
|
||||
It climbs up double with <<
|
||||
Assert Equals(ExpandWord('a>b>i<<b', 'html'), "<a href=\"\"><b><i></i></b></a>\n<b></b>\n")
|
||||
End
|
||||
|
||||
It climbs up double with ^^
|
||||
Assert Equals(ExpandWord('a>b>i^^b', 'html'), "<a href=\"\"><b><i></i></b></a>\n<b></b>\n")
|
||||
End
|
||||
|
||||
It climbs up blockquote with <<
|
||||
Assert Equals(ExpandWord('blockquote>b>i<<b', 'html'), "<blockquote>\n\t<b><i></i></b>\n</blockquote>\n<b></b>\n")
|
||||
End
|
||||
|
||||
It climbs up blockquote with ^^
|
||||
Assert Equals(ExpandWord('blockquote>b>i^^b', 'html'), "<blockquote>\n\t<b><i></i></b>\n</blockquote>\n<b></b>\n")
|
||||
End
|
||||
|
||||
It expands multiple attributes
|
||||
Assert Equals(ExpandWord('a[href=foo][class=bar]', 'html'), "<a class=\"bar\" href=\"foo\"></a>\n")
|
||||
End
|
||||
|
||||
It expands complex attrs with multiplier
|
||||
Assert Equals(ExpandWord('a[a=b][b=c=d][e]{foo}*2', 'html'), "<a href=\"e\" a=\"b\" b=\"c=d\">foo</a>\n<a href=\"e\" a=\"b\" b=\"c=d\">foo</a>\n")
|
||||
End
|
||||
|
||||
It expands attrs multiplier text after
|
||||
Assert Equals(ExpandWord('a[a=b][b=c=d][e]*2{foo}', 'html'), "<a href=\"e\" a=\"b\" b=\"c=d\"></a>\n<a href=\"e\" a=\"b\" b=\"c=d\"></a>\nfoo")
|
||||
End
|
||||
|
||||
It expands multiplier text tag
|
||||
Assert Equals(ExpandWord('a*2{foo}a', 'html'), "<a href=\"\"></a>\n<a href=\"\"></a>\nfoo<a href=\"\"></a>\n")
|
||||
End
|
||||
|
||||
It expands text multiplier child
|
||||
Assert Equals(ExpandWord('a{foo}*2>b', 'html'), "<a href=\"\">foo<b></b></a>\n<a href=\"\">foo<b></b></a>\n")
|
||||
End
|
||||
|
||||
It expands multiplier text child
|
||||
Assert Equals(ExpandWord('a*2{foo}>b', 'html'), "<a href=\"\"></a>\n<a href=\"\"></a>\nfoo")
|
||||
End
|
||||
|
||||
It expands table complex
|
||||
Assert Equals(ExpandWord('table>tr>td.name#foo+td*3', 'html'), "<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")
|
||||
End
|
||||
|
||||
It expands sibling ids
|
||||
Assert Equals(ExpandWord('div#header+div#footer', 'html'), "<div id=\"header\"></div>\n<div id=\"footer\"></div>\n")
|
||||
End
|
||||
|
||||
It expands implicit div sibling
|
||||
Assert Equals(ExpandWord('#header+div#footer', 'html'), "<div id=\"header\"></div>\n<div id=\"footer\"></div>\n")
|
||||
End
|
||||
|
||||
It climbs up with text using <
|
||||
Assert Equals(ExpandWord('#header>ul>li<p{Footer}', 'html'), "<div id=\"header\">\n\t<ul>\n\t\t<li></li>\n\t</ul>\n\t<p>Footer</p>\n</div>\n")
|
||||
End
|
||||
|
||||
It climbs up with text using ^
|
||||
Assert Equals(ExpandWord('#header>ul>li^p{Footer}', 'html'), "<div id=\"header\">\n\t<ul>\n\t\t<li></li>\n\t</ul>\n\t<p>Footer</p>\n</div>\n")
|
||||
End
|
||||
|
||||
It expands dollar padding
|
||||
Assert Equals(ExpandWord('a#foo$$$*3', 'html'), "<a id=\"foo001\" href=\"\"></a>\n<a id=\"foo002\" href=\"\"></a>\n<a id=\"foo003\" href=\"\"></a>\n")
|
||||
End
|
||||
|
||||
It expands ul expando
|
||||
Assert Equals(ExpandWord('ul+', 'html'), "<ul>\n\t<li></li>\n</ul>\n")
|
||||
End
|
||||
|
||||
It expands table expando
|
||||
Assert Equals(ExpandWord('table+', 'html'), "<table>\n\t<tr>\n\t\t<td></td>\n\t</tr>\n</table>\n")
|
||||
End
|
||||
|
||||
It climbs header to content with <
|
||||
Assert Equals(ExpandWord('#header>li<#content', 'html'), "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n")
|
||||
End
|
||||
|
||||
It climbs header to content with ^
|
||||
Assert Equals(ExpandWord('#header>li^#content', 'html'), "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n")
|
||||
End
|
||||
|
||||
It climbs group with <
|
||||
Assert Equals(ExpandWord('(#header>li)<#content', 'html'), "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n")
|
||||
End
|
||||
|
||||
It climbs group with ^
|
||||
Assert Equals(ExpandWord('(#header>li)^#content', 'html'), "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n")
|
||||
End
|
||||
|
||||
It climbs double to div with <<
|
||||
Assert Equals(ExpandWord('a>b>i<<div', 'html'), "<a href=\"\"><b><i></i></b></a>\n<div></div>\n")
|
||||
End
|
||||
|
||||
It climbs double to div with ^^
|
||||
Assert Equals(ExpandWord('a>b>i^^div', 'html'), "<a href=\"\"><b><i></i></b></a>\n<div></div>\n")
|
||||
End
|
||||
|
||||
It expands group siblings
|
||||
Assert Equals(ExpandWord('(#header>h1)+#content+#footer', 'html'), "<div id=\"header\">\n\t<h1></h1>\n</div>\n<div id=\"content\"></div>\n<div id=\"footer\"></div>\n")
|
||||
End
|
||||
|
||||
It expands complex nested groups
|
||||
Assert Equals(ExpandWord('(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)', 'html'), "<div id=\"header\">\n\t<h1></h1>\n</div>\n<div id=\"content\">\n\t<div id=\"main\">\n\t\t<h2></h2>\n\t\t<div id=\"entry1\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry2\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry3\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry4\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry5\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t<div id=\"utilities\"></div>\n</div>\n<div id=\"footer\">\n\t<address></address>\n</div>\n")
|
||||
End
|
||||
|
||||
It expands nested multiplier groups
|
||||
Assert Equals(ExpandWord('(div>(ul*2)*2)+(#utilities)', 'html'), "<div>\n\t<ul></ul>\n\t<ul></ul>\n\t<ul></ul>\n\t<ul></ul>\n</div>\n<div id=\"utilities\"></div>\n")
|
||||
End
|
||||
|
||||
It expands table multiplier group
|
||||
Assert Equals(ExpandWord('table>(tr>td*3)*4', 'html'), "<table>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n</table>\n")
|
||||
End
|
||||
|
||||
It expands deep nested multiplier groups
|
||||
Assert Equals(ExpandWord('(((a#foo+a#bar)*2)*3)', 'html'), "<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n")
|
||||
End
|
||||
|
||||
It expands multiplier with child
|
||||
Assert Equals(ExpandWord('div#box$*3>h3+p*2', 'html'), "<div id=\"box1\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n<div id=\"box2\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n<div id=\"box3\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n")
|
||||
End
|
||||
|
||||
It expands dollar multi class
|
||||
Assert Equals(ExpandWord('div#box.foo$$$.bar$$$*3', 'html'), "<div id=\"box\" class=\"foo001 bar001\"></div>\n<div id=\"box\" class=\"foo002 bar002\"></div>\n<div id=\"box\" class=\"foo003 bar003\"></div>\n")
|
||||
End
|
||||
|
||||
It applies escape filter
|
||||
Assert Equals(ExpandWord('div#box$*3>h3+p.bar*2|e', 'html'), "<div id=\"box1\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n<div id=\"box2\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n<div id=\"box3\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n")
|
||||
End
|
||||
|
||||
It applies comment filter
|
||||
Assert Equals(ExpandWord('div>div#page>p.title+p|c', 'html'), "<div>\n\t<!-- #page -->\n\t<div id=\"page\">\n\t\t<!-- .title -->\n\t\t<p class=\"title\"></p>\n\t\t<!-- /.title -->\n\t\t<p></p>\n\t</div>\n\t<!-- /#page -->\n</div>\n")
|
||||
End
|
||||
|
||||
It applies single line filter
|
||||
Assert Equals(ExpandWord('kbd*2|s', 'html'), '<kbd></kbd><kbd></kbd>')
|
||||
End
|
||||
|
||||
It expands link:css
|
||||
Assert Equals(ExpandWord('link:css', 'html'), "<link rel=\"stylesheet\" href=\"style.css\" media=\"all\">\n")
|
||||
End
|
||||
|
||||
It expands attribute with quote
|
||||
Assert Equals(ExpandWord("a[title=\"Hello', world\" rel]", 'html'), "<a href=\"\" title=\"Hello', world\" rel=\"\"></a>\n")
|
||||
End
|
||||
|
||||
It expands child with text
|
||||
Assert Equals(ExpandWord('div>a#foo{bar}', 'html'), "<div><a id=\"foo\" href=\"\">bar</a></div>\n")
|
||||
End
|
||||
|
||||
It expands class with text
|
||||
Assert Equals(ExpandWord('.content{Hello!}', 'html'), "<div class=\"content\">Hello!</div>\n")
|
||||
End
|
||||
|
||||
It expands logo group siblings
|
||||
Assert Equals(ExpandWord('div.logo+(div#navigation)+(div#links)', 'html'), "<div class=\"logo\"></div>\n<div id=\"navigation\"></div>\n<div id=\"links\"></div>\n")
|
||||
End
|
||||
|
||||
It expands mixed text and tags
|
||||
Assert Equals(ExpandWord('h1{header}+{Text}+a[href=http://link.org]{linktext}+{again some text}+a[href=http://anoterlink.org]{click me!}+{some final text}', 'html'), "<h1>header</h1>\nText<a href=\"http://link.org\">linktext</a>\nagain some text<a href=\"http://anoterlink.org\">click me!</a>\nsome final text")
|
||||
End
|
||||
|
||||
It expands ampersand text
|
||||
Assert Equals(ExpandWord('a{&}+div{&&}', 'html'), "<a href=\"\">&</a>\n<div>&&</div>\n")
|
||||
End
|
||||
|
||||
It expands span after tag in buffer
|
||||
let res = ExpandInBuffer('<foo/>span$$$$\<c-y>,$$$$', 'html', '<foo/><span></span>')
|
||||
Assert Equals(res, '<foo/><span></span>')
|
||||
End
|
||||
|
||||
It expands span after text in buffer
|
||||
let res = ExpandInBuffer('foo span$$$$\<c-y>,$$$$', 'html', 'foo <span></span>')
|
||||
Assert Equals(res, 'foo <span></span>')
|
||||
End
|
||||
|
||||
It expands span between text in buffer
|
||||
let res = ExpandInBuffer('foo span$$$$\<c-y>,$$$$ bar', 'html', 'foo <span></span> bar')
|
||||
Assert Equals(res, 'foo <span></span> bar')
|
||||
End
|
||||
|
||||
It wraps visual word (skip: ex mode)
|
||||
if mode() ==# 'c'
|
||||
Skip not supported in ex mode
|
||||
endif
|
||||
let res = ExpandInBuffer("foo $$$$\\<c-o>ve\\<c-y>,p\\<cr>$$$$bar baz", 'html', 'foo <p>bar</p> baz')
|
||||
Assert Equals(res, 'foo <p>bar</p> baz')
|
||||
End
|
||||
|
||||
It wraps visual multi word (skip: ex mode)
|
||||
if mode() ==# 'c'
|
||||
Skip not supported in ex mode
|
||||
endif
|
||||
let res = ExpandInBuffer("foo $$$$\\<c-o>vee\\<c-y>,p\\<cr>$$$$bar baz", 'html', 'foo <p>bar baz</p>')
|
||||
Assert Equals(res, 'foo <p>bar baz</p>')
|
||||
End
|
||||
|
||||
It expands complex nested in buffer
|
||||
let res = ExpandInBuffer("f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$", 'html', "f <div class=\"boxes\">\n\t<article class=\"box2\">\n\t\t<header>\n\t\t\t<hgroup>\n\t\t\t\t<h2>aaa</h2>\n\t\t\t\t<h3>bbb</h3>\n\t\t\t</hgroup>\n\t\t\t<p>ccc</p>\n\t\t</header>\n\t</article>\n</div>")
|
||||
Assert Equals(res, "f <div class=\"boxes\">\n\t<article class=\"box2\">\n\t\t<header>\n\t\t\t<hgroup>\n\t\t\t\t<h2>aaa</h2>\n\t\t\t\t<h3>bbb</h3>\n\t\t\t</hgroup>\n\t\t\t<p>ccc</p>\n\t\t</header>\n\t</article>\n</div>")
|
||||
End
|
||||
|
||||
It expands complex boxes
|
||||
Assert Equals(ExpandWord("div.boxes>(div.box2>section>h2{a}+p{b})+(div.box1>section>h2{c}+p{d}+p{e}+(bq>h2{f}+h3{g})+p{h})", 'html'), "<div class=\"boxes\">\n\t<div class=\"box2\">\n\t\t<section>\n\t\t\t<h2>a</h2>\n\t\t\t<p>b</p>\n\t\t</section>\n\t</div>\n\t<div class=\"box1\">\n\t\t<section>\n\t\t\t<h2>c</h2>\n\t\t\t<p>d</p>\n\t\t\t<p>e</p>\n\t\t\t<blockquote>\n\t\t\t\t<h2>f</h2>\n\t\t\t\t<h3>g</h3>\n\t\t\t</blockquote>\n\t\t\t<p>h</p>\n\t\t</section>\n\t</div>\n</div>\n")
|
||||
End
|
||||
|
||||
It expands label input group
|
||||
Assert Equals(ExpandWord('(div>(label+input))+div', 'html'), "<div>\n\t<label for=\"\"></label>\n\t<input type=\"\">\n</div>\n<div></div>\n")
|
||||
End
|
||||
|
||||
It wraps visual lines with multiplier (skip: ex mode)
|
||||
if mode() ==# 'c'
|
||||
Skip not supported in ex mode
|
||||
endif
|
||||
let res = ExpandInBuffer("test1\ntest2\ntest3$$$$\\<esc>ggVG\\<c-y>,ul>li>span*>a\\<cr>$$$$", 'html', "<ul>\n\t<li>\n\t\t<span><a href=\"\">test1</a></span>\n\t\t<span><a href=\"\">test2</a></span>\n\t\t<span><a href=\"\">test3</a></span>\n\t</li>\n</ul>")
|
||||
Assert Equals(res, "<ul>\n\t<li>\n\t\t<span><a href=\"\">test1</a></span>\n\t\t<span><a href=\"\">test2</a></span>\n\t\t<span><a href=\"\">test3</a></span>\n\t</li>\n</ul>")
|
||||
End
|
||||
|
||||
It wraps visual lines with input (skip: ex mode)
|
||||
if mode() ==# 'c'
|
||||
Skip not supported in ex mode
|
||||
endif
|
||||
let res = ExpandInBuffer("test1\ntest2\ntest3$$$$\\<esc>ggVG\\<c-y>,input[type=input value=$#]*\\<cr>$$$$", 'html', "<input type=\"input\" value=\"test1\">\n<input type=\"input\" value=\"test2\">\n<input type=\"input\" value=\"test3\">")
|
||||
Assert Equals(res, "<input type=\"input\" value=\"test1\">\n<input type=\"input\" value=\"test2\">\n<input type=\"input\" value=\"test3\">")
|
||||
End
|
||||
|
||||
It wraps visual lines with div id (skip: ex mode)
|
||||
if mode() ==# 'c'
|
||||
Skip not supported in ex mode
|
||||
endif
|
||||
let res = ExpandInBuffer("test1\ntest2\ntest3$$$$\\<esc>ggVG\\<c-y>,div[id=$#]*\\<cr>$$$$", 'html', "<div id=\"test1\"></div>\n<div id=\"test2\"></div>\n<div id=\"test3\"></div>")
|
||||
Assert Equals(res, "<div id=\"test1\"></div>\n<div id=\"test2\"></div>\n<div id=\"test3\"></div>")
|
||||
End
|
||||
|
||||
It expands nested id dollar
|
||||
Assert Equals(ExpandWord('div#id-$*5>div#id2-$', 'html'), "<div id=\"id-1\">\n\t<div id=\"id2-1\"></div>\n</div>\n<div id=\"id-2\">\n\t<div id=\"id2-2\"></div>\n</div>\n<div id=\"id-3\">\n\t<div id=\"id2-3\"></div>\n</div>\n<div id=\"id-4\">\n\t<div id=\"id2-4\"></div>\n</div>\n<div id=\"id-5\">\n\t<div id=\"id2-5\"></div>\n</div>\n")
|
||||
End
|
||||
|
||||
It expands implicit child attr
|
||||
Assert Equals(ExpandWord('.foo>[bar=2]>.baz', 'html'), "<div class=\"foo\">\n\t<div bar=\"2\">\n\t\t<div class=\"baz\"></div>\n\t</div>\n</div>\n")
|
||||
End
|
||||
|
||||
It expands text dollar
|
||||
Assert Equals(ExpandWord('{test case $ }*3', 'html'), 'test case 1 test case 2 test case 3 ')
|
||||
End
|
||||
|
||||
It expands text dollar newline
|
||||
Assert Equals(ExpandWord('{test case $${nr}}*3', 'html'), "test case 1\ntest case 2\ntest case 3\n")
|
||||
End
|
||||
|
||||
It expands text escaped dollar
|
||||
Assert Equals(ExpandWord('{test case \$ }*3', 'html'), 'test case $ test case $ test case $ ')
|
||||
End
|
||||
|
||||
It expands text dollar padding
|
||||
Assert Equals(ExpandWord('{test case $$$ }*3', 'html'), 'test case 001 test case 002 test case 003 ')
|
||||
End
|
||||
|
||||
It expands title dollar hash
|
||||
Assert Equals(ExpandWord('a[title=$#]{foo}', 'html'), "<a href=\"\" title=\"foo\">foo</a>\n")
|
||||
End
|
||||
|
||||
It expands span item dollar text
|
||||
Assert Equals(ExpandWord('span.item$*2>{item $}', 'html'), "<span class=\"item1\">item 1</span>\n<span class=\"item2\">item 2</span>\n")
|
||||
End
|
||||
|
||||
It wraps visual indented block (skip: ex mode)
|
||||
if mode() ==# 'c'
|
||||
Skip not supported in ex mode
|
||||
endif
|
||||
let res = ExpandInBuffer("\t<div class=\"footer_nav\">\n\t\t<a href=\"#\">nav link</a>\n\t</div>$$$$\\<esc>ggVG\\<c-y>,div\\<cr>$$$$", 'html', "\t<div>\n\t\t<div class=\"footer_nav\">\n\t\t\t<a href=\"#\">nav link</a>\n\t\t</div>\n\t</div>")
|
||||
Assert Equals(res, "\t<div>\n\t\t<div class=\"footer_nav\">\n\t\t\t<a href=\"#\">nav link</a>\n\t\t</div>\n\t</div>")
|
||||
End
|
||||
|
||||
It expands inside tag
|
||||
let res = ExpandInBuffer('<small>a$$$$</small>', 'html', '<small><a href=""></a></small>')
|
||||
Assert Equals(res, '<small><a href=""></a></small>')
|
||||
End
|
||||
|
||||
It applies BEM filter
|
||||
Assert Equals(ExpandWord('form.search-form._wide>input.-query-string+input:s.-btn_large|bem', 'html'), "<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")
|
||||
End
|
||||
|
||||
It expands fieldset legend label
|
||||
Assert Equals(ExpandWord('form>fieldset>legend+(label>input[type="checkbox"])*3', 'html'), "<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")
|
||||
End
|
||||
End
|
||||
|
||||
Describe split join tag
|
||||
It joins tag
|
||||
let res = ExpandInBuffer("<div>\n\t<span>$$$$\\<c-y>j$$$$</span>\n</div>", 'html', "<div>\n\t<span />\n</div>")
|
||||
Assert Equals(res, "<div>\n\t<span />\n</div>")
|
||||
End
|
||||
|
||||
It splits tag
|
||||
let res = ExpandInBuffer("<div>\n\t<span$$$$\\<c-y>j$$$$/>\n</div>", 'html', "<div>\n\t<span></span>\n</div>")
|
||||
Assert Equals(res, "<div>\n\t<span></span>\n</div>")
|
||||
End
|
||||
|
||||
It joins with complex attribute
|
||||
let res = ExpandInBuffer("<div onclick=\"javascript:console.log(Date.now() % 1000 > 500)\">test$$$$\\<c-y>j$$$$/>\n</div>", 'html', '<div onclick="javascript:console.log(Date.now() % 1000 > 500)" />')
|
||||
Assert Equals(res, '<div onclick="javascript:console.log(Date.now() % 1000 > 500)" />')
|
||||
End
|
||||
|
||||
It splits custom tag
|
||||
let res = ExpandInBuffer("<div>\n\t<some-tag$$$$\\<c-y>j$$$$/>\n</div>", 'html', "<div>\n\t<some-tag></some-tag>\n</div>")
|
||||
Assert Equals(res, "<div>\n\t<some-tag></some-tag>\n</div>")
|
||||
End
|
||||
End
|
||||
|
||||
Describe toggle comment
|
||||
It adds comment
|
||||
let res = ExpandInBuffer("<div>\n\t<span>$$$$\\<c-y>/$$$$</span>\n</div>", 'html', "<div>\n\t<!-- <span></span> -->\n</div>")
|
||||
Assert Equals(res, "<div>\n\t<!-- <span></span> -->\n</div>")
|
||||
End
|
||||
|
||||
It removes comment
|
||||
let res = ExpandInBuffer("<div>\n\t<!-- <span>$$$$\\<c-y>/$$$$</span> -->\n</div>", 'html', "<div>\n\t<span></span>\n</div>")
|
||||
Assert Equals(res, "<div>\n\t<span></span>\n</div>")
|
||||
End
|
||||
End
|
||||
|
||||
Describe image size
|
||||
It gets remote png size
|
||||
let res = ExpandInBuffer("img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$", 'html', '<img src="http://mattn.kaoriya.net/images/logo.png" alt="" width="113" height="113">')
|
||||
Assert Equals(res, '<img src="http://mattn.kaoriya.net/images/logo.png" alt="" width="113" height="113">')
|
||||
End
|
||||
|
||||
It handles missing local image
|
||||
let res = ExpandInBuffer("img[src=/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$", 'html', '<img src="/logo.png" alt="">')
|
||||
Assert Equals(res, '<img src="/logo.png" alt="">')
|
||||
End
|
||||
|
||||
It overwrites existing size
|
||||
let res = ExpandInBuffer("img[src=http://mattn.kaoriya.net/images/logo.png width=foo height=bar]$$$$\\<c-y>,\\<c-y>i$$$$", 'html', '<img src="http://mattn.kaoriya.net/images/logo.png" alt="" width="113" height="113">')
|
||||
Assert Equals(res, '<img src="http://mattn.kaoriya.net/images/logo.png" alt="" width="113" height="113">')
|
||||
End
|
||||
End
|
||||
|
||||
Describe move next prev
|
||||
It moves to third attribute
|
||||
let res = ExpandInBuffer("foo+bar+baz[dankogai=\"\"]$$$$\\<c-y>,\\<esc>gg0\\<c-y>n\\<c-y>n\\<c-y>n\\<esc>Byw:%d _\\<cr>p$$$$", 'html', 'dankogai')
|
||||
Assert Equals(res, 'dankogai')
|
||||
End
|
||||
End
|
||||
|
||||
Describe contains dash in attributes
|
||||
It expands foo-bar attribute
|
||||
Assert Equals(ExpandWord('div[foo-bar="baz"]', 'html'), "<div foo-bar=\"baz\"></div>\n")
|
||||
End
|
||||
End
|
||||
|
||||
Describe default attributes
|
||||
It expands a href shorthand
|
||||
Assert Equals(ExpandWord('p.title>a[/hoge/]', 'html'), "<p class=\"title\"><a href=\"/hoge/\"></a></p>\n")
|
||||
End
|
||||
|
||||
It expands script src
|
||||
Assert Equals(ExpandWord('script[jquery.js]', 'html'), "<script src=\"jquery.js\"></script>\n")
|
||||
End
|
||||
End
|
||||
|
||||
Describe multiple group
|
||||
It expands outer inner
|
||||
Assert Equals(ExpandWord('.outer$*3>.inner$*2', 'html'), "<div class=\"outer1\">\n\t<div class=\"inner1\"></div>\n\t<div class=\"inner2\"></div>\n</div>\n<div class=\"outer2\">\n\t<div class=\"inner1\"></div>\n\t<div class=\"inner2\"></div>\n</div>\n<div class=\"outer3\">\n\t<div class=\"inner1\"></div>\n\t<div class=\"inner2\"></div>\n</div>\n")
|
||||
End
|
||||
End
|
||||
|
||||
Describe group itemno
|
||||
It expands dl dt dd
|
||||
Assert Equals(ExpandWord('dl>(dt{$}+dd)*3', 'html'), "<dl>\n\t<dt>1</dt>\n\t<dd></dd>\n\t<dt>2</dt>\n\t<dd></dd>\n\t<dt>3</dt>\n\t<dd></dd>\n</dl>\n")
|
||||
End
|
||||
|
||||
It expands nested multiplier
|
||||
Assert Equals(ExpandWord('(div[attr=$]*3)*3', 'html'), "<div attr=\"1\"></div>\n<div attr=\"2\"></div>\n<div attr=\"3\"></div>\n<div attr=\"1\"></div>\n<div attr=\"2\"></div>\n<div attr=\"3\"></div>\n<div attr=\"1\"></div>\n<div attr=\"2\"></div>\n<div attr=\"3\"></div>\n")
|
||||
End
|
||||
End
|
||||
|
||||
Describe update tag
|
||||
It adds class (skip: ex mode)
|
||||
if mode() ==# 'c'
|
||||
Skip not supported in ex mode
|
||||
endif
|
||||
let res = ExpandInBuffer("<h$$$$\\<c-y>u.global\\<cr>$$$$3></h3>", 'html', '<h3 class="global"></h3>')
|
||||
Assert Equals(res, '<h3 class="global"></h3>')
|
||||
End
|
||||
|
||||
It adds class preserving attribute (skip: ex mode)
|
||||
if mode() ==# 'c'
|
||||
Skip not supported in ex mode
|
||||
endif
|
||||
let res = ExpandInBuffer("<button$$$$\\<c-y>u.btn\\<cr>$$$$ disabled></button>", 'html', '<button class="btn" disabled></button>')
|
||||
Assert Equals(res, '<button class="btn" disabled></button>')
|
||||
End
|
||||
End
|
||||
|
||||
Describe base value
|
||||
It starts from zero
|
||||
Assert Equals(ExpandWord('ul>li#id$@0*3', 'html'), "<ul>\n\t<li id=\"id0\"></li>\n\t<li id=\"id1\"></li>\n\t<li id=\"id2\"></li>\n</ul>\n")
|
||||
End
|
||||
End
|
||||
End
|
||||
@@ -1,171 +0,0 @@
|
||||
Describe others
|
||||
|
||||
Describe xsl
|
||||
It expands vari
|
||||
Assert Equals(ExpandWord('vari', 'xsl'), "<xsl:variable name=\"\"></xsl:variable>\n")
|
||||
End
|
||||
|
||||
It expands ap>wp
|
||||
Assert Equals(ExpandWord('ap>wp', 'xsl'), "<xsl:apply-templates select=\"\" mode=\"\">\n\t<xsl:with-param name=\"\" select=\"\"></xsl:with-param>\n</xsl:apply-templates>\n")
|
||||
End
|
||||
End
|
||||
|
||||
Describe xsd
|
||||
It expands xsd:w3c
|
||||
Assert Equals(ExpandWord('xsd:w3c', 'xsd'), "<?xml version=\"1.0\"?>\n<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n\t<xsd:element name=\"\" type=\"\"/>\n</xsd:schema>\n")
|
||||
End
|
||||
End
|
||||
|
||||
Describe mustache
|
||||
It expands id with mustache syntax
|
||||
Assert Equals(ExpandWord('div#{{foo}}', 'mustache'), "<div id=\"{{foo}}\"></div>\n")
|
||||
End
|
||||
|
||||
It expands class with mustache syntax
|
||||
Assert Equals(ExpandWord('div.{{foo}}', 'mustache'), "<div class=\"{{foo}}\"></div>\n")
|
||||
End
|
||||
End
|
||||
|
||||
Describe scss
|
||||
It expands import
|
||||
let res = ExpandInBuffer('@i$$$$', 'scss', '@import url();')
|
||||
Assert Equals(res, '@import url();')
|
||||
End
|
||||
|
||||
It expands font-style
|
||||
let res = ExpandInBuffer('{fs:n$$$$}', 'scss', '{font-style: normal;}')
|
||||
Assert Equals(res, '{font-style: normal;}')
|
||||
End
|
||||
|
||||
It expands float left
|
||||
let res = ExpandInBuffer('{fl:l|fc$$$$}', 'scss', '{float: left;}')
|
||||
Assert Equals(res, '{float: left;}')
|
||||
End
|
||||
|
||||
It expands background+
|
||||
let res = ExpandInBuffer('{bg+$$$$}', 'scss', '{background: $$$$#fff url() 0 0 no-repeat;}')
|
||||
Assert Equals(res, '{background: $$$$#fff url() 0 0 no-repeat;}')
|
||||
End
|
||||
|
||||
It expands background+ important
|
||||
let res = ExpandInBuffer('{bg+!$$$$}', 'scss', '{background: $$$$#fff url() 0 0 no-repeat !important;}')
|
||||
Assert Equals(res, '{background: $$$$#fff url() 0 0 no-repeat !important;}')
|
||||
End
|
||||
|
||||
It expands margin
|
||||
let res = ExpandInBuffer('{m$$$$}', 'scss', '{margin: $$$$;}')
|
||||
Assert Equals(res, '{margin: $$$$;}')
|
||||
End
|
||||
|
||||
It expands margin percent
|
||||
let res = ExpandInBuffer('{m0.1p$$$$}', 'scss', '{margin: 0.1%;}')
|
||||
Assert Equals(res, '{margin: 0.1%;}')
|
||||
End
|
||||
|
||||
It expands margin em
|
||||
let res = ExpandInBuffer('{m1.0$$$$}', 'scss', '{margin: 1.0em;}')
|
||||
Assert Equals(res, '{margin: 1.0em;}')
|
||||
End
|
||||
|
||||
It expands margin px
|
||||
let res = ExpandInBuffer('{m2$$$$}', 'scss', '{margin: 2px;}')
|
||||
Assert Equals(res, '{margin: 2px;}')
|
||||
End
|
||||
|
||||
It expands border-radius
|
||||
let res = ExpandInBuffer('{bdrs10$$$$}', 'scss', '{border-radius: 10px;}')
|
||||
Assert Equals(res, '{border-radius: 10px;}')
|
||||
End
|
||||
|
||||
It expands vendor prefix
|
||||
let res = ExpandInBuffer('{-bdrs20$$$$}', 'scss', "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}")
|
||||
Assert Equals(res, "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}")
|
||||
End
|
||||
|
||||
It expands linear-gradient
|
||||
let res = ExpandInBuffer('{lg(top,#fff,#000)$$$$}', 'scss', "{background-image: -webkit-gradient(top, 0 0, 0 100%, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}")
|
||||
Assert Equals(res, "{background-image: -webkit-gradient(top, 0 0, 0 100%, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}")
|
||||
End
|
||||
|
||||
It expands margin multi
|
||||
let res = ExpandInBuffer('{m10-5-0$$$$}', 'scss', '{margin: 10px 5px 0;}')
|
||||
Assert Equals(res, '{margin: 10px 5px 0;}')
|
||||
End
|
||||
|
||||
It expands margin negative
|
||||
let res = ExpandInBuffer('{m-10--5$$$$}', 'scss', '{margin: -10px -5px;}')
|
||||
Assert Equals(res, '{margin: -10px -5px;}')
|
||||
End
|
||||
|
||||
It expands margin auto
|
||||
let res = ExpandInBuffer('{m10-auto$$$$}', 'scss', '{margin: 10px auto;}')
|
||||
Assert Equals(res, '{margin: 10px auto;}')
|
||||
End
|
||||
|
||||
It expands width percent
|
||||
let res = ExpandInBuffer('{w100p$$$$}', 'scss', '{width: 100%;}')
|
||||
Assert Equals(res, '{width: 100%;}')
|
||||
End
|
||||
|
||||
It expands height em
|
||||
let res = ExpandInBuffer('{h50e$$$$}', 'scss', '{height: 50em;}')
|
||||
Assert Equals(res, '{height: 50em;}')
|
||||
End
|
||||
|
||||
It expands multi property group
|
||||
let res = ExpandInBuffer('{(bg+)+c$$$$}', 'scss', "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}")
|
||||
Assert Equals(res, "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}")
|
||||
End
|
||||
End
|
||||
|
||||
Describe jade
|
||||
It expands doctype
|
||||
let res = ExpandInBuffer("!!!$$$$\\<c-y>,$$$$", 'jade', "doctype html\n\n")
|
||||
Assert Equals(res, "doctype html\n\n")
|
||||
End
|
||||
|
||||
It expands span class
|
||||
let res = ExpandInBuffer("span.my-span$$$$\\<c-y>,$$$$", 'jade', 'span.my-span')
|
||||
Assert Equals(res, 'span.my-span')
|
||||
End
|
||||
|
||||
It expands input
|
||||
let res = ExpandInBuffer("input$$$$\\<c-y>,text$$$$", 'jade', 'input(type="text")')
|
||||
Assert Equals(res, 'input(type="text")')
|
||||
End
|
||||
End
|
||||
|
||||
Describe pug
|
||||
It expands doctype
|
||||
let res = ExpandInBuffer("!!!$$$$\\<c-y>,$$$$", 'pug', "doctype html\n\n")
|
||||
Assert Equals(res, "doctype html\n\n")
|
||||
End
|
||||
|
||||
It expands span class
|
||||
let res = ExpandInBuffer("span.my-span$$$$\\<c-y>,$$$$", 'pug', 'span.my-span')
|
||||
Assert Equals(res, 'span.my-span')
|
||||
End
|
||||
|
||||
It expands input
|
||||
let res = ExpandInBuffer("input$$$$\\<c-y>,text$$$$", 'pug', 'input(type="text")')
|
||||
Assert Equals(res, 'input(type="text")')
|
||||
End
|
||||
End
|
||||
|
||||
Describe jsx
|
||||
It expands img
|
||||
let res = ExpandInBuffer("img$$$$\\<c-y>,$$$$", 'javascript.jsx', '<img src="" alt="" />')
|
||||
Assert Equals(res, '<img src="" alt="" />')
|
||||
End
|
||||
|
||||
It expands span class
|
||||
let res = ExpandInBuffer("span.my-span$$$$\\<c-y>,$$$$", 'javascript.jsx', '<span className="my-span"></span>')
|
||||
Assert Equals(res, '<span className="my-span"></span>')
|
||||
End
|
||||
|
||||
It expands in function
|
||||
let res = ExpandInBuffer("function() { return span.my-span$$$$\\<c-y>,$$$$; }", 'javascript.jsx', 'function() { return <span className="my-span"></span>; }')
|
||||
Assert Equals(res, 'function() { return <span className="my-span"></span>; }')
|
||||
End
|
||||
End
|
||||
End
|
||||
@@ -1,48 +0,0 @@
|
||||
Describe slim
|
||||
|
||||
Describe expand abbreviation
|
||||
It expands complex
|
||||
Assert Equals(ExpandWord('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}', 'slim'), "div\n p\n ul id=\"foo\"\n li class=\"bar1\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar2\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar3\" foo=\"bar\" bar=\"baz\"\n | baz\n")
|
||||
End
|
||||
|
||||
It expands with slim filter
|
||||
Assert Equals(ExpandWord('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|slim', 'slim'), "div\n p\n ul id=\"foo\"\n li class=\"bar1\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar2\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar3\" foo=\"bar\" bar=\"baz\"\n | baz\n")
|
||||
End
|
||||
|
||||
It expands a multiplier
|
||||
Assert Equals(ExpandWord('a*3|slim', 'slim'), "a href=\"\"\na href=\"\"\na href=\"\"\n")
|
||||
End
|
||||
|
||||
It expands class with text
|
||||
Assert Equals(ExpandWord('.content{Hello!}|slim', 'slim'), "div class=\"content\"\n | Hello!\n")
|
||||
End
|
||||
|
||||
It expands title dollar hash
|
||||
Assert Equals(ExpandWord('a[title=$#]{foo}', 'slim'), "a href=\"\" title=\"foo\"\n | foo\n")
|
||||
End
|
||||
End
|
||||
|
||||
Describe split join tag
|
||||
It joins
|
||||
let res = ExpandInBuffer("a\n | foo$$$$\\<c-y>j$$$$", 'slim', 'a')
|
||||
Assert Equals(res, 'a')
|
||||
End
|
||||
|
||||
It splits
|
||||
let res = ExpandInBuffer("a$$$$\\<c-y>j$$$$", 'slim', "a\n | $$$$")
|
||||
Assert Equals(res, "a\n | $$$$")
|
||||
End
|
||||
End
|
||||
|
||||
Describe toggle comment
|
||||
It adds comment
|
||||
let res = ExpandInBuffer("a href=\"http://www.google.com\"$$$$\\<c-y>/$$$$\n | hello", 'slim', "/a href=\"http://www.google.com\"\n | hello")
|
||||
Assert Equals(res, "/a href=\"http://www.google.com\"\n | hello")
|
||||
End
|
||||
|
||||
It removes comment
|
||||
let res = ExpandInBuffer("/a href=\"http://www.google.com\"$$$$\\<c-y>/$$$$\n | hello", 'slim', "a href=\"http://www.google.com\"\n | hello")
|
||||
Assert Equals(res, "a href=\"http://www.google.com\"\n | hello")
|
||||
End
|
||||
End
|
||||
End
|
||||
-1130
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user