forked from VimPlug/emmet-vim
Lorem Ipsum
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
" zencoding.vim
|
" zencoding.vim
|
||||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||||
" Last Change: 24-Apr-2013.
|
" Last Change: 03-Jun-2013.
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
@@ -443,6 +443,7 @@ function! zencoding#expandAbbr(mode, abbr) range
|
|||||||
let expand .= '${cursor}'
|
let expand .= '${cursor}'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
let expand = substitute(expand, '\${\%(lorem\|ipsum\)\(\d*\)}', '\=zencoding#util#lorem(submatch(1))', 'g')
|
||||||
let expand = substitute(expand, '${lang}', s:zen_settings.lang, 'g')
|
let expand = substitute(expand, '${lang}', s:zen_settings.lang, 'g')
|
||||||
let expand = substitute(expand, '${charset}', s:zen_settings.charset, 'g')
|
let expand = substitute(expand, '${charset}', s:zen_settings.charset, 'g')
|
||||||
if has_key(s:zen_settings, 'timezone') && len(s:zen_settings.timezone)
|
if has_key(s:zen_settings, 'timezone') && len(s:zen_settings.timezone)
|
||||||
|
|||||||
@@ -118,6 +118,11 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
|
|||||||
let current.name = ''
|
let current.name = ''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if tag_name =~ '^\(lorem\|ipsum\)\d*$'
|
||||||
|
let current.snippet = '${' . tag_name . '}'
|
||||||
|
let current.name = ''
|
||||||
|
endif
|
||||||
|
|
||||||
" default_attributes
|
" default_attributes
|
||||||
let default_attributes = zencoding#getResource(type, 'default_attributes', {})
|
let default_attributes = zencoding#getResource(type, 'default_attributes', {})
|
||||||
if !empty(default_attributes)
|
if !empty(default_attributes)
|
||||||
|
|||||||
@@ -266,3 +266,77 @@ function! zencoding#util#unique(arr)
|
|||||||
endfor
|
endfor
|
||||||
return r
|
return r
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:seed = localtime()
|
||||||
|
function! s:srand(seed)
|
||||||
|
let s:seed = a:seed
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:rand()
|
||||||
|
let s:seed = s:seed * 214013 + 2531011
|
||||||
|
return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! zencoding#util#lorem(count)
|
||||||
|
let common = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit']
|
||||||
|
let words = ['exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet',
|
||||||
|
\ 'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi',
|
||||||
|
\ 'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi',
|
||||||
|
\ 'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos',
|
||||||
|
\ 'facilis', 'neque', 'nihil', 'expedita', 'vitae', 'vero', 'ipsum',
|
||||||
|
\ 'nisi', 'animi', 'cumque', 'pariatur', 'velit', 'modi', 'natus',
|
||||||
|
\ 'iusto', 'eaque', 'sequi', 'illo', 'sed', 'ex', 'et', 'voluptatibus',
|
||||||
|
\ 'tempora', 'veritatis', 'ratione', 'assumenda', 'incidunt', 'nostrum',
|
||||||
|
\ 'placeat', 'aliquid', 'fuga', 'provident', 'praesentium', 'rem',
|
||||||
|
\ 'necessitatibus', 'suscipit', 'adipisci', 'quidem', 'possimus',
|
||||||
|
\ 'voluptas', 'debitis', 'sint', 'accusantium', 'unde', 'sapiente',
|
||||||
|
\ 'voluptate', 'qui', 'aspernatur', 'laudantium', 'soluta', 'amet',
|
||||||
|
\ 'quo', 'aliquam', 'saepe', 'culpa', 'libero', 'ipsa', 'dicta',
|
||||||
|
\ 'reiciendis', 'nesciunt', 'doloribus', 'autem', 'impedit', 'minima',
|
||||||
|
\ 'maiores', 'repudiandae', 'ipsam', 'obcaecati', 'ullam', 'enim',
|
||||||
|
\ 'totam', 'delectus', 'ducimus', 'quis', 'voluptates', 'dolores',
|
||||||
|
\ 'molestiae', 'harum', 'dolorem', 'quia', 'voluptatem', 'molestias',
|
||||||
|
\ 'magni', 'distinctio', 'omnis', 'illum', 'dolorum', 'voluptatum', 'ea',
|
||||||
|
\ 'quas', 'quam', 'corporis', 'quae', 'blanditiis', 'atque', 'deserunt',
|
||||||
|
\ 'laboriosam', 'earum', 'consequuntur', 'hic', 'cupiditate',
|
||||||
|
\ 'quibusdam', 'accusamus', 'ut', 'rerum', 'error', 'minus', 'eius',
|
||||||
|
\ 'ab', 'ad', 'nemo', 'fugit', 'officia', 'at', 'in', 'id', 'quos',
|
||||||
|
\ 'reprehenderit', 'numquam', 'iste', 'fugiat', 'sit', 'inventore',
|
||||||
|
\ 'beatae', 'repellendus', 'magnam', 'recusandae', 'quod', 'explicabo',
|
||||||
|
\ 'doloremque', 'aperiam', 'consequatur', 'asperiores', 'commodi',
|
||||||
|
\ 'optio', 'dolor', 'labore', 'temporibus', 'repellat', 'veniam',
|
||||||
|
\ 'architecto', 'est', 'esse', 'mollitia', 'nulla', 'a', 'similique',
|
||||||
|
\ 'eos', 'alias', 'dolore', 'tenetur', 'deleniti', 'porro', 'facere',
|
||||||
|
\ 'maxime', 'corrupti']
|
||||||
|
let ret = []
|
||||||
|
let sentence = 0
|
||||||
|
let c = a:count > 0 ? a:count : 30
|
||||||
|
for i in range(c)
|
||||||
|
let arr = common
|
||||||
|
if sentence > 0
|
||||||
|
let arr += words
|
||||||
|
endif
|
||||||
|
let r = s:rand()
|
||||||
|
let word = arr[r % len(arr)]
|
||||||
|
if sentence == 0
|
||||||
|
let word = substitute(word, '^.', '\U&', '')
|
||||||
|
endif
|
||||||
|
let sentence += 1
|
||||||
|
call add(ret, word)
|
||||||
|
if (sentence > 5 && s:rand() < 10000) || i == c - 1
|
||||||
|
if i == c - 1
|
||||||
|
let endc = "?!,..."[s:rand() % 6]
|
||||||
|
call add(ret, endc)
|
||||||
|
else
|
||||||
|
let endc = "?!..."[s:rand() % 5]
|
||||||
|
call add(ret, endc . ' ')
|
||||||
|
endif
|
||||||
|
if endc != ','
|
||||||
|
let sentence = 0
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
call add(ret, ' ')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return join(ret, '')
|
||||||
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user