mirror of
https://github.com/mattn/emmet-vim.git
synced 2026-04-05 19:11:37 +08:00
Convert tests from custom unittest.vim to vim-themis format
- Add .themisrc to set up runtimepath for test helpers - Add test helper in test/autoload/themis/helper/emmet.vim - Add test files: html, css, haml, slim, others (xsl/xsd/mustache/scss/jade/pug/jsx) - Update Makefile to use vim-themis (old target preserved as test-old) - All 181 test cases from unittest.vim are covered
This commit is contained in:
42
test/autoload/themis/helper/emmet.vim
Normal file
42
test/autoload/themis/helper/emmet.vim
Normal file
@@ -0,0 +1,42 @@
|
||||
let s:helper = {}
|
||||
|
||||
function! s:helper.setup() abort
|
||||
let g:user_emmet_settings = {'variables': {'indentation': "\t", 'use_selection': 1}}
|
||||
for f in split(globpath(getcwd(), 'autoload/**/*.vim'), "\n")
|
||||
if f =~# 'themis'
|
||||
continue
|
||||
endif
|
||||
silent! exe 'so' f
|
||||
endfor
|
||||
silent! 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
|
||||
Reference in New Issue
Block a user